diff --git a/src/server/licence/receiveMethod/index.njk b/src/server/licence/receiveMethod/index.njk index 275ddba8..7d32ca5b 100644 --- a/src/server/licence/receiveMethod/index.njk +++ b/src/server/licence/receiveMethod/index.njk @@ -11,7 +11,7 @@ value: value, items: [ { - id: "email", + id: "receiveMethod", value: "email", text: "Email" }, diff --git a/user-journey-tests/helpers/testHelpers/checkAnswers.js b/user-journey-tests/helpers/testHelpers/checkAnswers.js index cc4e61cf..ce815b3e 100644 --- a/user-journey-tests/helpers/testHelpers/checkAnswers.js +++ b/user-journey-tests/helpers/testHelpers/checkAnswers.js @@ -12,6 +12,7 @@ import { import taskListIncompletePage from '../../page-objects/taskListIncompletePage.js' import finalAnswersPage from '../../page-objects/finalAnswersPage.js' import originTypePage from '../../page-objects/origin/originTypePage.js' +import receiveMethodPage from '../../page-objects/receiving-the-licence/receiveMethodPage.js' export const validateOnOffFarm = async (changeLink, valueElement) => { await selectElement(changeLink) @@ -104,6 +105,15 @@ export const validateAndAdjustEmail = async ( await validateElementVisibleAndText(valueElement, inputEmail) } +export const validateReceiveMethod = async (changeLink, valueElement) => { + await selectElement(changeLink) + + await expect(receiveMethodPage.emailRadio).toBeSelected() + await receiveMethodPage.selectEmailAndContinue() + + await validateElementVisibleAndText(valueElement, 'email') +} + export const validateOnFarmErrorHandling = async ( changeElement, final = false diff --git a/user-journey-tests/helpers/testHelpers/receivingLicence.js b/user-journey-tests/helpers/testHelpers/receivingLicence.js index 1180c0b8..584bd3ce 100644 --- a/user-journey-tests/helpers/testHelpers/receivingLicence.js +++ b/user-journey-tests/helpers/testHelpers/receivingLicence.js @@ -1,6 +1,7 @@ import landingPage from '../../page-objects/landingPage.js' import emailPage from '../../page-objects/receiving-the-licence/emailPage.js' import licenceAnswersPage from '../../page-objects/receiving-the-licence/licenceAnswersPage.js' +import receiveMethodPage from '../../page-objects/receiving-the-licence/receiveMethodPage.js' import taskListPage from '../../page-objects/taskListPage.js' import { validateElementVisibleAndText } from '../page.js' @@ -13,6 +14,7 @@ const completeLicenceTask = async ({ email = defaultEmail } = {}) => { await landingPage.navigateToPageAndVerifyTitle() await landingPage.verifyStartNowButton('Start now', true) await taskListPage.selectReceiveTheLicence() + await receiveMethodPage.selectEmailAndContinue() await emailPage.inputEmailAndContinue(email) await validateElementVisibleAndText(licenceAnswersPage.emailValue, email) } diff --git a/user-journey-tests/page-objects/finalAnswersPage.js b/user-journey-tests/page-objects/finalAnswersPage.js index b806d3b6..4c305832 100644 --- a/user-journey-tests/page-objects/finalAnswersPage.js +++ b/user-journey-tests/page-objects/finalAnswersPage.js @@ -40,7 +40,7 @@ class FinalAnswersPage extends Page { return $$(valueIdentifier)[4] } - get receivingMethodValue() { + get receiveMethodValue() { return $$(valueIdentifier)[5] } @@ -68,7 +68,7 @@ class FinalAnswersPage extends Page { return $('[data-testid="destinationType-change-link"]') } - get receivingMethodChange() { + get receiveMethodChange() { return $('[data-testid="licence-choice-change-link"]') } diff --git a/user-journey-tests/page-objects/receiving-the-licence/licenceAnswersPage.js b/user-journey-tests/page-objects/receiving-the-licence/licenceAnswersPage.js index f07e1b79..c190d48a 100644 --- a/user-journey-tests/page-objects/receiving-the-licence/licenceAnswersPage.js +++ b/user-journey-tests/page-objects/receiving-the-licence/licenceAnswersPage.js @@ -14,9 +14,14 @@ class LicenceAnswersPage extends Page { } // Answer values - get emailValue() { + + get receiveMethodValue() { return $$('.govuk-summary-list__value')[0] } + + get emailValue() { + return $$('.govuk-summary-list__value')[1] + } } export default new LicenceAnswersPage() diff --git a/user-journey-tests/page-objects/receiving-the-licence/receiveMethodPage.js b/user-journey-tests/page-objects/receiving-the-licence/receiveMethodPage.js new file mode 100644 index 00000000..f3104387 --- /dev/null +++ b/user-journey-tests/page-objects/receiving-the-licence/receiveMethodPage.js @@ -0,0 +1,50 @@ +import { Page } from '../page.js' + +const emailId = 'receiveMethod' +const postId = 'post' +const pageHeadingAndTitle = 'How would you like this licence sent to you?' + +class ReceiveMethodPage extends Page { + pagePath = '/receiving-the-licence/licence-email-or-post' + pageHeading = pageHeadingAndTitle + pageTitle = pageHeadingAndTitle + noSelectionError = 'Select how you would like this licence sent to you' + + get emailRadio() { + return super.getInputField(emailId) + } + + get postRadio() { + return super.getInputField(postId) + } + + get receiveMethodRadioError() { + return super.getErrorElement(emailId) + } + + get receiveMethodSummaryErrorLink() { + return super.getErrorLink(emailId) + } + + async selectEmailAndContinue() { + await super.selectRadioAndContinue(this.emailRadio) + } + + async selectPostAndContinue() { + await super.selectRadioAndContinue(this.postRadio) + } + + async receiveMethodErrorTest() { + await super.selectContinue() + await super.verifyErrorsOnPage( + this.receiveMethodRadioError, + this.noSelectionError + ) + await super.verifySummaryErrorLink( + this.receiveMethodSummaryErrorLink, + this.emailRadio + ) + } +} + +export default new ReceiveMethodPage() diff --git a/user-journey-tests/specs/finalAnswers.spec.js b/user-journey-tests/specs/finalAnswers.spec.js index be9d1692..1d5d5ca5 100644 --- a/user-journey-tests/specs/finalAnswers.spec.js +++ b/user-journey-tests/specs/finalAnswers.spec.js @@ -6,7 +6,8 @@ import { validateAndAdjustParishNumber, validateOnFarmErrorHandling, validateOnOffFarm, - validateOriginType + validateOriginType, + validateReceiveMethod } from '../helpers/testHelpers/checkAnswers.js' import { completeOriginTaskAnswersCustom } from '../helpers/testHelpers/movementLicence.js' import { completeLicenceTaskAnswersCustom } from '../helpers/testHelpers/receivingLicence.js' @@ -132,6 +133,14 @@ describe('Check your final answers test', () => { ) }) + it('Should verify the method to receive the licence', async () => { + await finalAnswersPage.navigateToPageAndVerifyTitle() + validateReceiveMethod( + finalAnswersPage.receiveMethodChange, + finalAnswersPage.receiveMethodValue + ) + }) + it('Should submit the page after selecting first declaration', async () => { await finalAnswersPage.navigateToPageAndVerifyTitle() await finalAnswersPage.selectADeclarationAndContinue() diff --git a/user-journey-tests/specs/receiving-the-licence/emailForLicence.spec.js b/user-journey-tests/specs/receiving-the-licence/emailForLicence.spec.js index 170ea6aa..19141db0 100644 --- a/user-journey-tests/specs/receiving-the-licence/emailForLicence.spec.js +++ b/user-journey-tests/specs/receiving-the-licence/emailForLicence.spec.js @@ -1,8 +1,6 @@ import { browser } from '@wdio/globals' -import { waitForPagePath } from '../../helpers/page.js' import emailPage from '../../page-objects/receiving-the-licence/emailPage.js' -import licenceAnswersPage from '../../page-objects/receiving-the-licence/licenceAnswersPage.js' const validSubmissionCheck = async (input, whitespace = false) => { let expected @@ -56,8 +54,6 @@ describe('Email address for licence page test', () => { await emailPage.inputEmailAndContinue('bruce.wayne@gotham.com') await expect(emailPage.emailFieldError()).not.toBeDisplayed() await expect(emailPage.errorSummary).not.toBeDisplayed() - - await waitForPagePath(licenceAnswersPage.pagePath) }) it.skip('Should check answer is maintained when submitting after an error', async () => { diff --git a/user-journey-tests/specs/receiving-the-licence/receiveMethod.spec.js b/user-journey-tests/specs/receiving-the-licence/receiveMethod.spec.js new file mode 100644 index 00000000..704a216b --- /dev/null +++ b/user-journey-tests/specs/receiving-the-licence/receiveMethod.spec.js @@ -0,0 +1,28 @@ +import { browser } from '@wdio/globals' +import receiveMethodPage from '../../page-objects/receiving-the-licence/receiveMethodPage.js' +import emailPage from '../../page-objects/receiving-the-licence/emailPage.js' + +describe('Receive method for licence page test', () => { + beforeEach('Reset browser state and navigate to page', async () => { + await browser.reloadSession() + await receiveMethodPage.navigateToPageAndVerifyTitle() + }) + + it('Should verify that the page errors when no option is selected', async () => { + await receiveMethodPage.receiveMethodErrorTest() + }) + + it('Should select email and continue', async () => { + await receiveMethodPage.selectEmailAndContinue() + await expect(receiveMethodPage.pageError).not.toBeDisplayed() + await expect(receiveMethodPage.errorSummary).not.toBeDisplayed() + await emailPage.verifyPageHeadingAndTitle() + }) + + it('Should choose an option and check its maintained', async () => { + await receiveMethodPage.selectEmailAndContinue() + await emailPage.verifyPageHeadingAndTitle() + await browser.back() + await expect(receiveMethodPage.emailRadio).toBeSelected() + }) +}) diff --git a/user-journey-tests/specs/taskList.spec.js b/user-journey-tests/specs/taskList.spec.js index ec17aa7b..a1195771 100644 --- a/user-journey-tests/specs/taskList.spec.js +++ b/user-journey-tests/specs/taskList.spec.js @@ -2,13 +2,13 @@ import { waitForPagePath } from '../helpers/page.js' import taskListPage from '../page-objects/taskListPage.js' import toFromFarmPage from '../page-objects/origin/toFromFarmPage.js' import checkAnswersPage from '../page-objects/origin/checkAnswersPage.js' -import emailPage from '../page-objects/receiving-the-licence/emailPage.js' import taskListIncompletePage from '../page-objects/taskListIncompletePage.js' import completeOriginTaskAnswers from '../helpers/testHelpers/movementLicence.js' import completeLicenceTaskAnswers from '../helpers/testHelpers/receivingLicence.js' import licenceAnswersPage from '../page-objects/receiving-the-licence/licenceAnswersPage.js' import completeDestinationTask from '../helpers/testHelpers/destination.js' import destinationAnswersPage from '../page-objects/destination/destinationAnswersPage.js' +import receiveMethodPage from '../page-objects/receiving-the-licence/receiveMethodPage.js' describe('Task list page test', () => { beforeEach('Navigate to task list page', async () => { @@ -44,7 +44,7 @@ describe('Task list page test', () => { it('Should link to receiving the licence first question before an application has been started', async () => { await taskListPage.selectReceiveTheLicence() - await waitForPagePath(emailPage.pagePath) + await waitForPagePath(receiveMethodPage.pagePath) }) it('Should link to movement origin summary once that selection has been completed', async () => {