-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mhv 61207 contact list navigate away (#31756)
* added guards for browser navigation with unsaved changes * added unit tests * MHV-61207 recycling beforeunload in sm nav guard * add navigation away tests --------- Co-authored-by: Alex Morgun <oleksii.morgun@va.gov> Co-authored-by: fazilqa <fazil.mammadov@bylight.com>
- Loading branch information
1 parent
d3b5c0c
commit e3d9239
Showing
7 changed files
with
304 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 8 additions & 8 deletions
16
...ng-contact-list-interface.cypress.spec.js → ...ng-contact-list-interface.cypress.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 8 additions & 8 deletions
16
...ist-multi-facility-errors.cypress.spec.js → ...ist-multi-facility-errors.cypress.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
...t-tests/secure-messaging-contact-list-multi-facility-navigate-away-errors.cypress.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import SecureMessagingSite from '../sm_site/SecureMessagingSite'; | ||
import PatientInboxPage from '../pages/PatientInboxPage'; | ||
import ContactListPage from '../pages/ContactListPage'; | ||
import { AXE_CONTEXT, Paths } from '../utils/constants'; | ||
import mockEhrData from '../fixtures/userResponse/vamc-ehr-cerner-mixed.json'; | ||
import mockMixedCernerFacilitiesUser from '../fixtures/userResponse/user-cerner-mixed.json'; | ||
import mockFacilities from '../fixtures/facilityResponse/cerner-facility-mock-data.json'; | ||
import mockMixRecipients from '../fixtures/multi-facilities-recipients-response.json'; | ||
|
||
describe('SM Single Facility Contact list', () => { | ||
beforeEach(() => { | ||
SecureMessagingSite.login( | ||
mockEhrData, | ||
true, | ||
mockMixedCernerFacilitiesUser, | ||
mockFacilities, | ||
); | ||
PatientInboxPage.loadInboxMessages(); | ||
ContactListPage.loadContactList(mockMixRecipients); | ||
ContactListPage.selectAllCheckBox(); | ||
}); | ||
|
||
it('navigate away using secondary navigation', () => { | ||
cy.injectAxe(); | ||
cy.axeCheck(AXE_CONTEXT); | ||
|
||
cy.window().then(win => { | ||
const beforeUnloadStub = cy.stub(); | ||
|
||
win.addEventListener('beforeunload', beforeUnloadStub); | ||
|
||
cy.visit(`${Paths.UI_MAIN}/medications/about`); | ||
|
||
cy.then(() => { | ||
expect(beforeUnloadStub).to.have.been.called; | ||
expect(win.location.href).to.eq( | ||
`http://localhost:3001${Paths.UI_MAIN}/medications/about`, | ||
); | ||
}); | ||
}); | ||
}); | ||
|
||
it(`navigate away using navbar`, () => { | ||
cy.injectAxe(); | ||
cy.axeCheck(AXE_CONTEXT); | ||
|
||
cy.window().then(win => { | ||
const beforeUnloadStub = cy.stub(); | ||
|
||
win.addEventListener('beforeunload', beforeUnloadStub); | ||
|
||
cy.visit(`${Paths.UI_MAIN}/find-locations`); | ||
|
||
cy.then(() => { | ||
expect(beforeUnloadStub).to.have.been.called; | ||
expect(win.location.href).to.eq( | ||
`http://localhost:3001${Paths.UI_MAIN}/find-locations`, | ||
); | ||
}); | ||
}); | ||
}); | ||
|
||
it(`navigate away using browser back button`, () => { | ||
cy.injectAxe(); | ||
cy.axeCheck(AXE_CONTEXT); | ||
|
||
cy.window().then(win => { | ||
const beforeUnloadStub = cy.stub(); | ||
|
||
win.addEventListener('beforeunload', beforeUnloadStub); | ||
|
||
cy.go(`back`); | ||
|
||
cy.then(() => { | ||
expect(beforeUnloadStub).to.have.been.called; | ||
expect(win.location.href).to.eq( | ||
`http://localhost:3001${Paths.UI_MAIN}/inbox/`, | ||
); | ||
}); | ||
}); | ||
}); | ||
|
||
it(`navigate away using browser reload`, () => { | ||
cy.injectAxe(); | ||
cy.axeCheck(AXE_CONTEXT); | ||
|
||
cy.window().then(win => { | ||
const beforeUnloadStub = cy.stub(); | ||
|
||
win.addEventListener('beforeunload', beforeUnloadStub); | ||
|
||
cy.reload(); | ||
|
||
cy.then(() => { | ||
expect(beforeUnloadStub).to.have.been.called; | ||
expect(win.location.href).to.eq( | ||
`http://localhost:3001${Paths.UI_MAIN}/contact-list`, | ||
); | ||
}); | ||
}); | ||
}); | ||
}); |
8 changes: 4 additions & 4 deletions
8
...st-single-facility-errors.cypress.spec.js → ...st-single-facility-errors.cypress.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
...-tests/secure-messaging-contact-list-single-facility-navigate-away-errors.cypress.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import SecureMessagingSite from '../sm_site/SecureMessagingSite'; | ||
import PatientInboxPage from '../pages/PatientInboxPage'; | ||
import ContactListPage from '../pages/ContactListPage'; | ||
import { AXE_CONTEXT, Paths } from '../utils/constants'; | ||
|
||
describe('SM Single Facility Contact list', () => { | ||
beforeEach(() => { | ||
SecureMessagingSite.login(); | ||
PatientInboxPage.loadInboxMessages(); | ||
ContactListPage.loadContactList(); | ||
ContactListPage.selectAllCheckBox(); | ||
}); | ||
|
||
it('navigate away using secondary navigation', () => { | ||
cy.injectAxe(); | ||
cy.axeCheck(AXE_CONTEXT); | ||
|
||
cy.window().then(win => { | ||
const beforeUnloadStub = cy.stub(); | ||
|
||
win.addEventListener('beforeunload', beforeUnloadStub); | ||
|
||
cy.visit(`${Paths.UI_MAIN}/medications/about`); | ||
|
||
cy.then(() => { | ||
expect(beforeUnloadStub).to.have.been.called; | ||
expect(win.location.href).to.eq( | ||
`http://localhost:3001${Paths.UI_MAIN}/medications/about`, | ||
); | ||
}); | ||
}); | ||
}); | ||
|
||
it(`navigate away using navbar`, () => { | ||
cy.injectAxe(); | ||
cy.axeCheck(AXE_CONTEXT); | ||
|
||
cy.window().then(win => { | ||
const beforeUnloadStub = cy.stub(); | ||
|
||
win.addEventListener('beforeunload', beforeUnloadStub); | ||
|
||
cy.visit(`${Paths.UI_MAIN}/find-locations`); | ||
|
||
cy.then(() => { | ||
expect(beforeUnloadStub).to.have.been.called; | ||
expect(win.location.href).to.eq( | ||
`http://localhost:3001${Paths.UI_MAIN}/find-locations`, | ||
); | ||
}); | ||
}); | ||
}); | ||
|
||
it(`navigate away using browser back button`, () => { | ||
cy.injectAxe(); | ||
cy.axeCheck(AXE_CONTEXT); | ||
|
||
cy.window().then(win => { | ||
const beforeUnloadStub = cy.stub(); | ||
|
||
win.addEventListener('beforeunload', beforeUnloadStub); | ||
|
||
cy.go(`back`); | ||
|
||
cy.then(() => { | ||
expect(beforeUnloadStub).to.have.been.called; | ||
expect(win.location.href).to.eq( | ||
`http://localhost:3001${Paths.UI_MAIN}/inbox/`, | ||
); | ||
}); | ||
}); | ||
}); | ||
|
||
it(`navigate away using browser reload`, () => { | ||
cy.injectAxe(); | ||
cy.axeCheck(AXE_CONTEXT); | ||
|
||
cy.window().then(win => { | ||
const beforeUnloadStub = cy.stub(); | ||
|
||
win.addEventListener('beforeunload', beforeUnloadStub); | ||
|
||
cy.reload(); | ||
|
||
cy.then(() => { | ||
expect(beforeUnloadStub).to.have.been.called; | ||
expect(win.location.href).to.eq( | ||
`http://localhost:3001${Paths.UI_MAIN}/contact-list`, | ||
); | ||
}); | ||
}); | ||
}); | ||
}); |