forked from medic/cht-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(medic#9732): address review feedback
- Loading branch information
1 parent
c73bd10
commit 2afbb8d
Showing
4 changed files
with
90 additions
and
1 deletion.
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
56 changes: 56 additions & 0 deletions
56
tests/e2e/default/privacy-policy/login-privacy-policy.wdio-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,56 @@ | ||
const utils = require('@utils'); | ||
const commonPage = require('@page-objects/default/common/common.wdio.page.js'); | ||
const loginPage = require('@page-objects/default/login/login.wdio.page'); | ||
const privacyPolicyFactory = require('@factories/cht/settings/privacy-policy'); | ||
const loginPrivacyPolicyPage = require('@page-objects/default/privacy-policy/login-privacy-policy.wdio.page'); | ||
|
||
describe('Privacy Policy Navigation for Unauthenticated Users', () => { | ||
const privacyPolicy = privacyPolicyFactory.privacyPolicy().build(); | ||
|
||
afterEach(async () => { | ||
await utils.deleteAllDocs(); | ||
}); | ||
|
||
it('should not display privacy policy page when the privacy policy is not enabled', async () => { | ||
await commonPage.reloadSession(); | ||
|
||
// Assert: privacy policy link is not available on the login page | ||
const privacyPolicyLink = await loginPage.privacyPolicyPageLink(); | ||
expect(await privacyPolicyLink.isDisplayed()).to.equal(false); | ||
}); | ||
|
||
it('should navigate back to the login page when using either back button', async () => { | ||
await utils.saveDocs([privacyPolicy]); | ||
await commonPage.reloadSession(); | ||
|
||
// Navigate to privacy policy page | ||
await loginPage.goToPrivacyPolicyPage(); | ||
const privacyContent = await loginPrivacyPolicyPage.privacyContent(); | ||
expect(await privacyContent.isDisplayed()).to.equal(true); | ||
|
||
// Test navigation using both back buttons | ||
const testBackButton = async (backButtonType) => { | ||
let backButton; | ||
|
||
if (backButtonType === 'top') { | ||
backButton = await loginPrivacyPolicyPage.topBackButton(); | ||
} else if (backButtonType === 'bottom') { | ||
await loginPrivacyPolicyPage.scrollToBottom(); | ||
backButton = await loginPrivacyPolicyPage.bottomBackButton(); | ||
} | ||
|
||
// Click the back button | ||
await loginPrivacyPolicyPage.goBackToLoginPage(backButton); | ||
|
||
// Assert: back button redirects to the login page | ||
expect((await browser.getUrl()).includes('/medic/login')).to.be.true; | ||
|
||
// Navigate back to the privacy policy page for the next iteration | ||
await loginPage.goToPrivacyPolicyPage(); | ||
}; | ||
|
||
// Run tests for both buttons | ||
await testBackButton('top'); | ||
await testBackButton('bottom'); | ||
}); | ||
}); |
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
26 changes: 26 additions & 0 deletions
26
tests/page-objects/default/privacy-policy/login-privacy-policy.wdio.page.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,26 @@ | ||
const privacyContent = () => $('#privacy-policy-content'); | ||
const backButtons = () => $$('a.back-button'); | ||
|
||
const topBackButton = async () => { | ||
return (await backButtons())[0]; | ||
}; | ||
|
||
const bottomBackButton = async () => { | ||
return (await backButtons())[1]; | ||
}; | ||
|
||
const scrollToBottom = async () => { | ||
await (await bottomBackButton()).scrollIntoView(); | ||
}; | ||
|
||
const goBackToLoginPage = async (backButton) => { | ||
await (backButton).click(); | ||
}; | ||
|
||
module.exports = { | ||
privacyContent, | ||
topBackButton, | ||
bottomBackButton, | ||
scrollToBottom, | ||
goBackToLoginPage | ||
}; |