Skip to content

Commit

Permalink
User journey tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joseluisgraa committed Jan 10, 2025
1 parent eaa830a commit 825cfae
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/server/licence/receiveMethod/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
value: value,
items: [
{
id: "email",
id: "receiveMethod",
value: "email",
text: "Email"
},
Expand Down
10 changes: 10 additions & 0 deletions user-journey-tests/helpers/testHelpers/checkAnswers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions user-journey-tests/helpers/testHelpers/receivingLicence.js
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions user-journey-tests/page-objects/finalAnswersPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class FinalAnswersPage extends Page {
return $$(valueIdentifier)[4]
}

get receivingMethodValue() {
get receiveMethodValue() {
return $$(valueIdentifier)[5]
}

Expand Down Expand Up @@ -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"]')
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Original file line number Diff line number Diff line change
@@ -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()
11 changes: 10 additions & 1 deletion user-journey-tests/specs/finalAnswers.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -56,8 +54,6 @@ describe('Email address for licence page test', () => {
await emailPage.inputEmailAndContinue('[email protected]')
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 () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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()
})
})
4 changes: 2 additions & 2 deletions user-journey-tests/specs/taskList.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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 () => {
Expand Down

0 comments on commit 825cfae

Please sign in to comment.