From 1c3c9b25b90321bbbb52d330ccf77f2454107892 Mon Sep 17 00:00:00 2001 From: Dan Good Date: Mon, 21 Aug 2023 12:07:39 +0100 Subject: [PATCH 1/7] Adding inviteAndRemoveContributor.ts spec file --- .../e2e/inviteAndRemoveContributor.cy.ts | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Dfe.Academies.External.Web/CypressTests/cypress/e2e/inviteAndRemoveContributor.cy.ts diff --git a/Dfe.Academies.External.Web/CypressTests/cypress/e2e/inviteAndRemoveContributor.cy.ts b/Dfe.Academies.External.Web/CypressTests/cypress/e2e/inviteAndRemoveContributor.cy.ts new file mode 100644 index 000000000..72e1888f4 --- /dev/null +++ b/Dfe.Academies.External.Web/CypressTests/cypress/e2e/inviteAndRemoveContributor.cy.ts @@ -0,0 +1,47 @@ + +import Header from "../page-objects/components/Header"; +import CookieHeaderModal from "../page-objects/components/CookieHeaderModal"; +import A2BHome from "../page-objects/pages/A2BHome"; +import A2BLogin from "../page-objects/pages/A2BLogin"; +import A2BYourApplications from "../page-objects/pages/A2BYourApplications"; +import A2BYourApplication from "../page-objects/pages/A2BYourApplication"; +import A2BInviteContributor from "../page-objects/pages/A2BInviteContributor"; +import A2BConfirmInviteContributorDelete from "../page-objects/pages/A2BConfirmInviteContributorDelete"; +import Footer from "../page-objects/components/Footer"; + +describe("Invite / Remove Contributor", () => { + beforeEach(function () { + cy.visit(Cypress.env('URL')); + + Header.govUkHeaderVisible(); + Header.applyToBecomeAnAcademyHeaderLinkVisible(); + + A2BHome.homePageElementsVisible(); + + Footer.checkFooterLinksVisible(); + + CookieHeaderModal.clickAcceptAnalyticsCookies(); + A2BHome.clickStartNow(); + }); + + it("should add and remove a contributor to a JAM application", () => { + + A2BLogin.login(Cypress.env('LOGIN_USERNAME'), Cypress.env('LOGIN_PASSWORD')); + + A2BYourApplications.selectApplicationForInviteContributor() + + A2BYourApplication.selectInviteContributorLink() + + A2BInviteContributor.fillDetailsAndSubmit() + + A2BInviteContributor.verifySuccessBannerAndContributorList() + + A2BInviteContributor.selectRemoveContributorLink() + + A2BConfirmInviteContributorDelete.confirmRemoveContributor() + + A2BInviteContributor.verifyContributorRemovedAndSuccessRemoved() + }) +}) + + From 7fa23d8ff33908c66a1cd22611a9d1f2d0b9f30f Mon Sep 17 00:00:00 2001 From: Dan Good Date: Mon, 21 Aug 2023 12:09:29 +0100 Subject: [PATCH 2/7] Adding A2BInviteContributor.ts page object --- .../pages/A2BInviteContributor.ts | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Dfe.Academies.External.Web/CypressTests/cypress/page-objects/pages/A2BInviteContributor.ts diff --git a/Dfe.Academies.External.Web/CypressTests/cypress/page-objects/pages/A2BInviteContributor.ts b/Dfe.Academies.External.Web/CypressTests/cypress/page-objects/pages/A2BInviteContributor.ts new file mode 100644 index 000000000..55e2a90d7 --- /dev/null +++ b/Dfe.Academies.External.Web/CypressTests/cypress/page-objects/pages/A2BInviteContributor.ts @@ -0,0 +1,25 @@ +import BasePage from "../BasePage" + +export default class A2BInviteContributor extends BasePage { + static fillDetailsAndSubmit() + { + cy.fillDetailsAndSubmit() + } + + static verifySuccessBannerAndContributorList() + { + cy.verifySuccessBannerAndContributorList() + } + + static selectRemoveContributorLink() + { + cy.contains('Remove contributor').click() + } + + static verifyContributorRemovedAndSuccessRemoved() + { + cy.verifyContributorRemovedAndSuccessRemoved() + } +} + + From fdec850e48c220bfcea1288cf9bc8a07061fb2e4 Mon Sep 17 00:00:00 2001 From: Dan Good Date: Mon, 21 Aug 2023 12:12:04 +0100 Subject: [PATCH 3/7] Adding A2BConfirmInviteConributorDelete.ts page object --- .../pages/A2BConfirmInviteContributorDelete.ts | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 Dfe.Academies.External.Web/CypressTests/cypress/page-objects/pages/A2BConfirmInviteContributorDelete.ts diff --git a/Dfe.Academies.External.Web/CypressTests/cypress/page-objects/pages/A2BConfirmInviteContributorDelete.ts b/Dfe.Academies.External.Web/CypressTests/cypress/page-objects/pages/A2BConfirmInviteContributorDelete.ts new file mode 100644 index 000000000..0922e2fef --- /dev/null +++ b/Dfe.Academies.External.Web/CypressTests/cypress/page-objects/pages/A2BConfirmInviteContributorDelete.ts @@ -0,0 +1,9 @@ +import BasePage from "../BasePage" +export default class A2BConfirmInviteContributorDelete extends BasePage { + + static confirmRemoveContributor() + { + cy.get('.govuk-button').eq(0).click() + } + +} \ No newline at end of file From 7a92ae4fb09e7131e628bf511a4b87fc65fe0e62 Mon Sep 17 00:00:00 2001 From: Dan Good Date: Mon, 21 Aug 2023 12:20:53 +0100 Subject: [PATCH 4/7] Added selectApplicationForInviteContributor() function to A2BYourApplications.ts page object --- .../cypress/page-objects/pages/A2BYourApplications.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Dfe.Academies.External.Web/CypressTests/cypress/page-objects/pages/A2BYourApplications.ts b/Dfe.Academies.External.Web/CypressTests/cypress/page-objects/pages/A2BYourApplications.ts index 91a279e75..281622aa8 100644 --- a/Dfe.Academies.External.Web/CypressTests/cypress/page-objects/pages/A2BYourApplications.ts +++ b/Dfe.Academies.External.Web/CypressTests/cypress/page-objects/pages/A2BYourApplications.ts @@ -21,4 +21,9 @@ export default class A2BYourApplications extends BasePage { { cy.verifyApplicationDeleted() } + + static selectApplicationForInviteContributor() + { + cy.contains('10280').click() + } } \ No newline at end of file From b2d401b8629424b9e12efeea0b646ee3c3c301ad Mon Sep 17 00:00:00 2001 From: Dan Good Date: Mon, 21 Aug 2023 12:24:28 +0100 Subject: [PATCH 5/7] Added selectInviteContributorLink() function to A2BYourApplication.ts page object --- .../cypress/page-objects/pages/A2BYourApplication.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Dfe.Academies.External.Web/CypressTests/cypress/page-objects/pages/A2BYourApplication.ts b/Dfe.Academies.External.Web/CypressTests/cypress/page-objects/pages/A2BYourApplication.ts index dd5ee8556..4317086be 100644 --- a/Dfe.Academies.External.Web/CypressTests/cypress/page-objects/pages/A2BYourApplication.ts +++ b/Dfe.Academies.External.Web/CypressTests/cypress/page-objects/pages/A2BYourApplication.ts @@ -131,4 +131,9 @@ export default class A2BYourApplication extends BasePage { cy.contains('Cancel application').click() } + static selectInviteContributorLink() + { + cy.contains('invite or remove').click() + } + } \ No newline at end of file From 4bed1f1dbb3127d2244c9377b2208c1c25513ee6 Mon Sep 17 00:00:00 2001 From: Dan Good Date: Mon, 21 Aug 2023 12:29:19 +0100 Subject: [PATCH 6/7] Added necessary functions for inviteAndRemoveContributor test in commands.ts --- .../CypressTests/cypress/support/commands.ts | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/Dfe.Academies.External.Web/CypressTests/cypress/support/commands.ts b/Dfe.Academies.External.Web/CypressTests/cypress/support/commands.ts index f8a8121a1..bb7fdfbba 100644 --- a/Dfe.Academies.External.Web/CypressTests/cypress/support/commands.ts +++ b/Dfe.Academies.External.Web/CypressTests/cypress/support/commands.ts @@ -29,6 +29,64 @@ Cypress.Commands.add("excuteAccessibilityTests", () => { continueOnFail ); }); + + Cypress.Commands.add('fillDetailsAndSubmit', ():void => { + cy.get('#EmailAddress').click() + cy.get('#EmailAddress').type('dangood84@me.com') + + cy.get('#Name').click() + cy.get('#Name').type('Daniel') + + cy.get('#role-2').click() + + cy.get('#role-description').click() + cy.get('#role-description').type('Headmaster') + + cy.get('input[type="submit"]').click() + }) + + Cypress.Commands.add('verifySuccessBannerAndContributorList', ():void => { + cy.get('div[role="alert"]').contains('Success') + cy.get('div[role="alert"]').contains('Contributor added') + cy.get('div[role="alert"]').contains('Daniel has been sent an invitation to help with this application.') + + cy.get('.govuk-form-group').contains('Daniel') + cy.get('.govuk-form-group').contains('Headmaster') + cy.get('.govuk-form-group').contains('Remove contributor') + + }) + + Cypress.Commands.add('verifyContributorRemovedAndSuccessRemoved', ():void => { + cy.get('div[role="alert"]').contains('Success') + cy.get('div[role="alert"]').contains('Contributor removed') + cy.get('div[role="alert"]').contains('Daniel can no longer contribute to this application.') + + cy.get('.govuk-form-group').contains('Daniel').should('not.exist') + }) + + Cypress.Commands.add('checkAppIDIsCorrectAndselectConfirmDelete', ():void => { + cy.log(`Global Application ID = ${globalApplicationId}`) + + + cy.get('.govuk-caption-xl').contains(`Application reference: A2B_${globalApplicationId}`) + + + cy.get('#deleteButton').should('be.visible').contains('Yes, delete') + cy.get('a[class="govuk-button govuk-button--secondary"]').should('be.visible').contains('No, take me back') + + cy.get('#deleteButton').should('be.visible').contains('Yes, delete').click() + + }) + + Cypress.Commands.add('verifyApplicationDeleted', ():void => { + cy.log(`Global Application ID = ${globalApplicationId}`) + + cy.get('.govuk-body').eq(0).contains(`trust A2B_${globalApplicationId} has been successfully removed.`) + + cy.get('.govuk-table').contains(`${globalApplicationId}`).should('not.exist') + + + }) Cypress.Commands.add('checkAppIDIsCorrectAndselectConfirmDelete', ():void => { From d7f7bec52c32448c475512adc8fe0f740c341cba Mon Sep 17 00:00:00 2001 From: Dan Good Date: Mon, 21 Aug 2023 12:35:43 +0100 Subject: [PATCH 7/7] Removing redundant JS version of the page object A2BInviteContributor.JS --- .../cypress/page-objects/pages/A2BInviteContributor.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 Dfe.Academies.External.Web/CypressTests/cypress/page-objects/pages/A2BInviteContributor.js diff --git a/Dfe.Academies.External.Web/CypressTests/cypress/page-objects/pages/A2BInviteContributor.js b/Dfe.Academies.External.Web/CypressTests/cypress/page-objects/pages/A2BInviteContributor.js deleted file mode 100644 index e69de29bb..000000000