Skip to content

Commit

Permalink
Merge pull request #1490 from ministryofjustice/MLPAB-2358-back-cypress
Browse files Browse the repository at this point in the history
MLPAB-2358 Use go(-2) instead of clicking back, add back link e2e test
  • Loading branch information
acsauk authored Sep 17, 2024
2 parents 4fedf67 + 70dbb97 commit d9a9dd8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 16 deletions.
15 changes: 7 additions & 8 deletions cypress/e2e/donor/choose-attorneys.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,12 @@ describe('Choose attorneys', () => {
cy.contains('button', 'Save and continue').click();
cy.url().should('contain', '/choose-attorneys-address');

// TODO workout why cypress with later versions of node breaks when using back links
// cy.contains('a', 'Back').click()
// cy.url().should('contain', '/choose-attorneys');
//
// cy.get('#f-date-of-birth-year').clear().type(new Date().getFullYear() - 20);
// cy.contains('button', 'Save and continue').click();
//
// cy.url().should('contain', '/choose-attorneys-address');
cy.go(-2);
cy.url().should('contain', '/choose-attorneys');

cy.get('#f-date-of-birth-year').clear().type(new Date().getFullYear() - 20);
cy.contains('button', 'Save and continue').click();

cy.url().should('contain', '/choose-attorneys-address');
});
});
15 changes: 7 additions & 8 deletions cypress/e2e/donor/choose-replacement-attorneys.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,12 @@ describe('Choose replacement attorneys', () => {
cy.contains('button', 'Save and continue').click();
cy.url().should('contain', '/choose-replacement-attorneys-address');

// TODO workout why cypress with later versions of node breaks when using back links
// cy.contains('a', 'Back').click()
// cy.url().should('contain', '/choose-replacement-attorneys');
//
// cy.get('#f-date-of-birth-year').clear().type(new Date().getFullYear() - 20);
// cy.contains('button', 'Save and continue').click();
//
// cy.url().should('contain', '/choose-replacement-attorneys-address');
cy.go(-2);
cy.url().should('contain', '/choose-replacement-attorneys');

cy.get('#f-date-of-birth-year').clear().type(new Date().getFullYear() - 20);
cy.contains('button', 'Save and continue').click();

cy.url().should('contain', '/choose-replacement-attorneys-address');
});
});
16 changes: 16 additions & 0 deletions cypress/e2e/navigation.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
describe('High level navigation', () => {
describe('back link', () => {
it('navigates to the previous page', () => {
cy.visit('/fixtures?redirect=/task-list&progress=provideYourDetails')
cy.contains('a', 'Choose your attorneys').click()

cy.url().should('contain', '/choose-attorneys-guidance')
cy.contains('button', 'Continue').click()

cy.url().should('contain', '/choose-attorneys')
cy.contains('a', 'Back').click()

cy.url().should('contain', '/choose-attorneys-guidance')
})
})
})

0 comments on commit d9a9dd8

Please sign in to comment.