Skip to content

Commit

Permalink
Merge pull request #487 from DFE-Digital/AddInviteAndRemoveContributo…
Browse files Browse the repository at this point in the history
…rCypressTest

Add invite and remove contributor cypress test
  • Loading branch information
dangood84 authored Aug 21, 2023
2 parents 6403b9c + d7f7bec commit 4f1ed44
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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()
})
})


Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import BasePage from "../BasePage"
export default class A2BConfirmInviteContributorDelete extends BasePage {

static confirmRemoveContributor()
{
cy.get('.govuk-button').eq(0).click()
}

}
Empty file.
Original file line number Diff line number Diff line change
@@ -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()
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,9 @@ export default class A2BYourApplication extends BasePage {
cy.contains('Cancel application').click()
}

static selectInviteContributorLink()
{
cy.contains('invite or remove').click()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,9 @@ export default class A2BYourApplications extends BasePage {
{
cy.verifyApplicationDeleted()
}

static selectApplicationForInviteContributor()
{
cy.contains('10280').click()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,64 @@ Cypress.Commands.add("excuteAccessibilityTests", () => {
continueOnFail
);
});

Cypress.Commands.add('fillDetailsAndSubmit', ():void => {
cy.get('#EmailAddress').click()
cy.get('#EmailAddress').type('[email protected]')

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 => {
Expand Down

0 comments on commit 4f1ed44

Please sign in to comment.