From 9c363148eb606ceab415d5e5a313308fc9796d75 Mon Sep 17 00:00:00 2001 From: George Goodall Date: Wed, 29 Nov 2023 11:53:52 +0000 Subject: [PATCH 01/10] updated start page to match prototype --- src/views/start.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/views/start.html b/src/views/start.html index 34060625..8ad234b9 100644 --- a/src/views/start.html +++ b/src/views/start.html @@ -15,8 +15,8 @@ - article 4 direction data - conservation area data - - listed building data - - tree preservation order data + {# - listed building data #} + {# - tree preservation order data #} ## Before you start From 6f9cf93c82ce59cd65d4eed8c677f86d73be9e90 Mon Sep 17 00:00:00 2001 From: George Goodall Date: Wed, 29 Nov 2023 11:54:03 +0000 Subject: [PATCH 02/10] removed data-subject page --- src/routes/form-wizard/fields.js | 4 ---- src/routes/form-wizard/steps.js | 7 +------ 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/src/routes/form-wizard/fields.js b/src/routes/form-wizard/fields.js index 1f6b7583..419623e7 100644 --- a/src/routes/form-wizard/fields.js +++ b/src/routes/form-wizard/fields.js @@ -1,10 +1,6 @@ import { validate } from 'email-validator' export default { - 'data-subject': { - validate: 'required', - invalidates: ['datafile', 'dataset', 'validationResult'] - }, dataset: { validate: 'required', invalidates: ['datafile', 'validationResult'] diff --git a/src/routes/form-wizard/steps.js b/src/routes/form-wizard/steps.js index 5ce7e342..406397d1 100644 --- a/src/routes/form-wizard/steps.js +++ b/src/routes/form-wizard/steps.js @@ -13,14 +13,9 @@ export default { '/': { entryPoint: true, resetJourney: true, - next: 'data-subject', + next: 'dataset', template: '../views/start.html' }, - '/data-subject': { - ...baseSettings, - fields: ['data-subject'], - next: 'dataset' - }, '/dataset': { ...baseSettings, controller: datasetController, From eb7196524b326ae09dee1d7c30001ca76305537e Mon Sep 17 00:00:00 2001 From: George Goodall Date: Thu, 30 Nov 2023 14:38:03 +0000 Subject: [PATCH 03/10] only have article 4 and conservation area datasets as options --- src/controllers/datasetController.js | 46 +++------------------- src/controllers/errorsController.js | 1 + src/routes/form-wizard/fields.js | 4 ++ src/routes/form-wizard/steps.js | 5 +++ src/utils/utils.js | 57 ++++++++++++++++++++++++++++ 5 files changed, 73 insertions(+), 40 deletions(-) diff --git a/src/controllers/datasetController.js b/src/controllers/datasetController.js index 5f3904cf..2862c122 100644 --- a/src/controllers/datasetController.js +++ b/src/controllers/datasetController.js @@ -4,51 +4,17 @@ import MyController from './MyController.js' // ToDo: we shouldn't hardcode these values here, should we get them from the API // maybe take from specification -const datasetOptions = { - 'Article 4': [ - { - value: 'article-4-direction', - text: 'Article 4 direction dataset' - }, - { - value: 'article-4-direction area', - text: 'Article 4 direction area dataset' - } - ], - 'Conservation area': [ - { - value: 'conservation-area', - text: 'Conservation area dataset' - }, - { - value: 'conservation-area-document', - text: 'Conservation area document dataset' - } - ], - 'Tree preservation order': [ - { - value: 'tree-preservation-order', - text: 'Tree preservation order dataset' - }, - { - value: 'tree-preservation-zone', - text: 'Tree preservation zone dataset' - }, - { - value: 'tree', - text: 'Tree dataset' - } - ], - 'Listed building': false -} +import { dataSubjects } from '../utils/utils.js' class DatasetController extends MyController { get (req, res, next) { - const dataset = req.sessionModel.get('data-subject') - const options = datasetOptions[dataset] + // const dataset = req.sessionModel.get('data-subject') + // const options = datasetOptions[dataset] + + const options = [dataSubjects['Article 4'].dataSets[0], dataSubjects['Conservation area'].dataSets[0]] if (options) { - this.availableDatasets = options + this.availableDatasets = options.filter(option => option.available) req.form.options.datasetItems = options super.get(req, res, next) } else { diff --git a/src/controllers/errorsController.js b/src/controllers/errorsController.js index 436349a2..da41ea45 100644 --- a/src/controllers/errorsController.js +++ b/src/controllers/errorsController.js @@ -15,6 +15,7 @@ class ErrorsController extends MyController { req.form.options.rows = rows req.form.options.issueCounts = issueCounts req.form.options.columnNames = Object.keys(rows[0]) + req.form.options.dataset = req.sessionModel.get('dataset') // ToDo: should the api return the columns here? // or should we get them from the specification? diff --git a/src/routes/form-wizard/fields.js b/src/routes/form-wizard/fields.js index 419623e7..1f6b7583 100644 --- a/src/routes/form-wizard/fields.js +++ b/src/routes/form-wizard/fields.js @@ -1,6 +1,10 @@ import { validate } from 'email-validator' export default { + 'data-subject': { + validate: 'required', + invalidates: ['datafile', 'dataset', 'validationResult'] + }, dataset: { validate: 'required', invalidates: ['datafile', 'validationResult'] diff --git a/src/routes/form-wizard/steps.js b/src/routes/form-wizard/steps.js index 406397d1..6f9a6ef7 100644 --- a/src/routes/form-wizard/steps.js +++ b/src/routes/form-wizard/steps.js @@ -16,6 +16,11 @@ export default { next: 'dataset', template: '../views/start.html' }, + // '/data-subject': { + // ...baseSettings, + // fields: ['data-subject'], + // next: 'dataset' + // }, '/dataset': { ...baseSettings, controller: datasetController, diff --git a/src/utils/utils.js b/src/utils/utils.js index 5f616e5e..44e8c01b 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -4,3 +4,60 @@ export const severityLevels = { warning: 'warning', error: 'error' } + +export const dataSubjects = { + 'Article 4': { + available: true, + dataSets: [ + { + value: 'article-4-direction', + text: 'Article 4 direction dataset', + available: true + }, + { + value: 'article-4-direction area', + text: 'Article 4 direction area dataset', + available: false + } + ] + }, + 'Conservation area': { + available: true, + dataSets: [ + { + value: 'conservation-area', + text: 'Conservation area dataset', + available: true + }, + { + value: 'conservation-area-document', + text: 'Conservation area document dataset', + available: false + } + ] + }, + 'Tree preservation order': { + available: false, + dataSets: [ + { + value: 'tree-preservation-order', + text: 'Tree preservation order dataset', + available: false + }, + { + value: 'tree-preservation-zone', + text: 'Tree preservation zone dataset', + available: false + }, + { + value: 'tree', + text: 'Tree dataset', + available: false + } + ] + }, + 'Listed building': { + available: false, + dataSets: [] + } +} From 7ae2584d237139bf933162ac13b684e385089d9d Mon Sep 17 00:00:00 2001 From: George Goodall Date: Thu, 30 Nov 2023 14:53:04 +0000 Subject: [PATCH 04/10] update errors page to match prototype --- src/controllers/errorsController.js | 17 +++++++++++++---- src/views/errors.html | 6 +++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/controllers/errorsController.js b/src/controllers/errorsController.js index da41ea45..146dd19e 100644 --- a/src/controllers/errorsController.js +++ b/src/controllers/errorsController.js @@ -2,7 +2,7 @@ import MyController from './MyController.js' -import { severityLevels } from '../utils/utils.js' +import { severityLevels, dataSubjects } from '../utils/utils.js' class ErrorsController extends MyController { get (req, res, next) { @@ -15,9 +15,18 @@ class ErrorsController extends MyController { req.form.options.rows = rows req.form.options.issueCounts = issueCounts req.form.options.columnNames = Object.keys(rows[0]) - req.form.options.dataset = req.sessionModel.get('dataset') - // ToDo: should the api return the columns here? - // or should we get them from the specification? + + const dataSetValue = req.sessionModel.get('dataset') + + // ToDo: optimise this + for(const [key, value] of Object.entries(dataSubjects)) { + for(const dataset of value.dataSets) { + if(dataset.value === dataSetValue) { + req.form.options.dataSubject = key + req.form.options.dataset = dataset.text + } + } + } super.get(req, res, next) } diff --git a/src/views/errors.html b/src/views/errors.html index 6b94b553..2e2692d7 100644 --- a/src/views/errors.html +++ b/src/views/errors.html @@ -10,10 +10,10 @@
- {{values.dataset}} + {{options.dataset}}

- {{pageName}} + Your data has errors

    @@ -27,7 +27,7 @@

    - Errors + Check your errors

    From 9cc03f940f0aea3ff146eed05787c3d2f88f0aec Mon Sep 17 00:00:00 2001 From: George Goodall Date: Thu, 30 Nov 2023 14:53:16 +0000 Subject: [PATCH 05/10] lint fixes --- src/controllers/errorsController.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/controllers/errorsController.js b/src/controllers/errorsController.js index 146dd19e..f369110d 100644 --- a/src/controllers/errorsController.js +++ b/src/controllers/errorsController.js @@ -19,9 +19,9 @@ class ErrorsController extends MyController { const dataSetValue = req.sessionModel.get('dataset') // ToDo: optimise this - for(const [key, value] of Object.entries(dataSubjects)) { - for(const dataset of value.dataSets) { - if(dataset.value === dataSetValue) { + for (const [key, value] of Object.entries(dataSubjects)) { + for (const dataset of value.dataSets) { + if (dataset.value === dataSetValue) { req.form.options.dataSubject = key req.form.options.dataset = dataset.text } From 1ce104c8010ec03bdeab0a1dccbd064d6ce9dd32 Mon Sep 17 00:00:00 2001 From: George Goodall Date: Thu, 30 Nov 2023 15:03:10 +0000 Subject: [PATCH 06/10] removed unused steps --- src/routes/form-wizard/steps.js | 38 ++++++++++++++++----------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/routes/form-wizard/steps.js b/src/routes/form-wizard/steps.js index 6f9a6ef7..8a7a3538 100644 --- a/src/routes/form-wizard/steps.js +++ b/src/routes/form-wizard/steps.js @@ -42,28 +42,28 @@ export default { next: 'no-errors' }, '/no-errors': { - ...baseSettings, - next: 'email-address' - }, - '/email-address': { - ...baseSettings, - fields: ['email-address'], - next: 'name' - }, - '/name': { - ...baseSettings, - fields: ['first-name', 'last-name'], - next: 'lpa' - }, - '/lpa': { - ...baseSettings, - fields: ['lpa'], - next: 'check' - }, - '/check': { ...baseSettings, next: 'confirmation' }, + // '/email-address': { + // ...baseSettings, + // fields: ['email-address'], + // next: 'name' + // }, + // '/name': { + // ...baseSettings, + // fields: ['first-name', 'last-name'], + // next: 'lpa' + // }, + // '/lpa': { + // ...baseSettings, + // fields: ['lpa'], + // next: 'check' + // }, + // '/check': { + // ...baseSettings, + // next: 'confirmation' + // }, '/confirmation': { ...baseSettings, noPost: true From d9d6ecde5c19e51375f9b6d9268f4ad60eaad90f Mon Sep 17 00:00:00 2001 From: George Goodall Date: Thu, 30 Nov 2023 15:03:25 +0000 Subject: [PATCH 07/10] updated confirmation page to match prototype --- src/views/confirmation.html | 64 +++++++++++++++++++++++++++++-------- 1 file changed, 51 insertions(+), 13 deletions(-) diff --git a/src/views/confirmation.html b/src/views/confirmation.html index e249e9b7..9155fdc7 100644 --- a/src/views/confirmation.html +++ b/src/views/confirmation.html @@ -1,27 +1,65 @@ +{% from 'govuk/components/panel/macro.njk' import govukPanel %} +{% from "govuk/components/details/macro.njk" import govukDetails %} + {% extends "layouts/main.html" %} -{% from 'govuk/components/panel/macro.njk' import govukPanel %} -{% set pageName = "Data sent" %} +{% set pageName = "Send your data for us to publish" %} {% block content %} + +{% set example %} + + ## About the data + + This dataset shows the locations of conservation areas. Conservation areas are designated to safeguard areas of special architectural and historic interest, the character and appearance of which it is desirable to preserve or enhance. Within these areas special planning controls operate which need to be considered when undertaking development. + + ## Data + + [Southwark conservations areas (CSV, 188KB)](#) + + ## Licensing + + The data is provided under the [Open Government Licence](#). + +{% endset %} + +{% set content %} + + ## What you need to do next + + You need to send an email to [digitalland@levellingup.gov.uk](mailto:digitalland@levellingup.gov.uk). + + The email must include: + + - your full name + - the name of your local planning authority (LPA) + - a link to a webpage containing the data on your LPA website + + The webpage must include: + + - a link to the data + - a summary of what the data is about + - a statement that the data is provided under the Open Government Licence + + {{ govukDetails({ + summaryText: "Example webpage", + text: example | govukMarkdown(headingsStartWith="m") | safe + }) }} + + ## Give feedback + + [Give feedback about this service](/feedback) (takes 30 seconds). + +{% endset %} +
    {{ govukPanel({ titleHtml: pageName }) }} -

    We’ve sent you a confirmation email.

    - -

    What happens next

    - -

    We’ll send you an email once we publish the data. This usually happens within 5 working days.

    - -

    - Give feedback -

    - -

    Give feedback about this service (takes 30 seconds).

    + {{content | govukMarkdown(headingsStartWith="l") | safe}}
    From b4cbc9981c85caa5225a91507c42d26d503c7e3e Mon Sep 17 00:00:00 2001 From: George Goodall Date: Thu, 30 Nov 2023 15:10:27 +0000 Subject: [PATCH 08/10] fixed errorPage Test --- test/unit/errorsPage.test.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/unit/errorsPage.test.js b/test/unit/errorsPage.test.js index a9e16cec..176011bd 100644 --- a/test/unit/errorsPage.test.js +++ b/test/unit/errorsPage.test.js @@ -73,11 +73,9 @@ describe('errors page', () => { ], issueCounts: { geography: 1 - } - }, - values: { + }, dataset: 'Dataset test' - } + }, } const html = nunjucks.render('errors.html', params).replace(/(\r\n|\n|\r)/gm, '').replace(/\t/gm, '').replace(/\s+/g, ' ') From 31df3fa1f2e7360657f870951074c3d733a00f3c Mon Sep 17 00:00:00 2001 From: George Goodall Date: Thu, 30 Nov 2023 15:10:38 +0000 Subject: [PATCH 09/10] lint fixes --- test/unit/errorsPage.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/errorsPage.test.js b/test/unit/errorsPage.test.js index 176011bd..257a21e1 100644 --- a/test/unit/errorsPage.test.js +++ b/test/unit/errorsPage.test.js @@ -75,7 +75,7 @@ describe('errors page', () => { geography: 1 }, dataset: 'Dataset test' - }, + } } const html = nunjucks.render('errors.html', params).replace(/(\r\n|\n|\r)/gm, '').replace(/\t/gm, '').replace(/\s+/g, ' ') From 0711cdfaca583df3e5bcade65be8b6517a287045 Mon Sep 17 00:00:00 2001 From: George Goodall Date: Thu, 30 Nov 2023 15:25:06 +0000 Subject: [PATCH 10/10] removed unneeded tests and fixed broken ones --- test/acceptance/back_buttons.test.js | 15 +- test/acceptance/pages_load_ok.test.js | 6 +- test/acceptance/upload_data.test.js | 54 +++--- test/acceptance/validation_errors.test.js | 194 ++-------------------- 4 files changed, 50 insertions(+), 219 deletions(-) diff --git a/test/acceptance/back_buttons.test.js b/test/acceptance/back_buttons.test.js index d29f6809..f72d436b 100644 --- a/test/acceptance/back_buttons.test.js +++ b/test/acceptance/back_buttons.test.js @@ -3,28 +3,17 @@ import { test, expect } from '@playwright/test' test.use({ javaScriptEnabled: false }) test.describe('Back buttons work as expected without js for', () => { - test('data subject page', async ({ page, baseURL }) => { + test('data set page', async ({ page, baseURL }) => { await page.goto('/') await page.click('text=Start now') await page.getByRole('link', { name: 'Back', exact: true }).click() expect(page.url()).toBe(baseURL + '/') }) - test('dataset page', async ({ page, baseURL }) => { - await page.goto('/') - await page.click('text=Start now') - await page.getByLabel('Conservation area').check() - await page.getByRole('button', { name: 'Continue' }).click() - await page.getByRole('link', { name: 'Back', exact: true }).click() - expect(page.url()).toBe(baseURL + '/data-subject') - }) - test('upload page', async ({ page, baseURL }) => { await page.goto('/') await page.click('text=Start now') - await page.getByLabel('Conservation area').check() - await page.getByRole('button', { name: 'Continue' }).click() - await page.getByLabel('Conservation area dataset').check() + await page.getByLabel('Article 4 direction dataset').check() await page.getByRole('button', { name: 'Continue' }).click() await page.getByRole('link', { name: 'Back', exact: true }).click() expect(page.url()).toBe(baseURL + '/dataset') diff --git a/test/acceptance/pages_load_ok.test.js b/test/acceptance/pages_load_ok.test.js index 88036f05..51c16f3e 100644 --- a/test/acceptance/pages_load_ok.test.js +++ b/test/acceptance/pages_load_ok.test.js @@ -17,9 +17,9 @@ test('/ loads ok', async ({ page }) => { }) test.describe('without a valid session, the user can not access the later pages', () => { - test('/data-subject', async ({ page }) => { - await checkSessionExpired(page, '/data-subject') - }) + // test('/data-subject', async ({ page }) => { + // await checkSessionExpired(page, '/data-subject') + // }) test('/dataset', async ({ page }) => { await checkSessionExpired(page, '/dataset') diff --git a/test/acceptance/upload_data.test.js b/test/acceptance/upload_data.test.js index 1c3e151a..a68c5297 100644 --- a/test/acceptance/upload_data.test.js +++ b/test/acceptance/upload_data.test.js @@ -1,13 +1,13 @@ -import { test, expect } from '@playwright/test' +import { test } from '@playwright/test' test('Enter form information', async ({ page }) => { await page.goto('/') await page.getByRole('button', { name: 'Start now' }).click() - await page.waitForURL('**/data-subject') + // await page.waitForURL('**/data-subject') - await page.getByLabel('Conservation area').check() - await page.getByRole('button', { name: 'Continue' }).click() + // await page.getByLabel('Conservation area').check() + // await page.getByRole('button', { name: 'Continue' }).click() await page.waitForURL('**/dataset') @@ -27,10 +27,10 @@ test('Enter form information and upload a file with errors and without errors', await page.goto('/') await page.getByRole('button', { name: 'Start now' }).click() - await page.waitForURL('**/data-subject') + // await page.waitForURL('**/data-subject') - await page.getByLabel('Conservation area').check() - await page.getByRole('button', { name: 'Continue' }).click() + // await page.getByLabel('Conservation area').check() + // await page.getByRole('button', { name: 'Continue' }).click() await page.waitForURL('**/dataset') @@ -62,26 +62,26 @@ test('Enter form information and upload a file with errors and without errors', await page.waitForURL('**/no-errors') await page.getByRole('button', { name: 'Continue' }).click() - await page.waitForURL('**/email-address') - await page.getByLabel('Your email address').fill('dataOfficer@fakeLPA.com') - await page.getByRole('button', { name: 'Continue' }).click() - - await page.waitForURL('**/name') - await page.getByLabel('First name').fill('Bob') - await page.getByLabel('Last name').fill('Marley') - await page.getByRole('button', { name: 'Continue' }).click() - - await page.waitForURL('**/lpa') - await page.getByLabel('Local planning authority').fill('My Fake LPA') - await page.getByRole('button', { name: 'Continue' }).click() - - await page.waitForURL('**/check') - expect(await page.getByText('Conservation area', { exact: true }).isVisible(), 'supplied data subject not on check page').toBeTruthy() - expect(await page.getByText('conservation-area', { exact: true }).isVisible(), 'supplied dataset not on check page').toBeTruthy() - expect(await page.getByText('dataOfficer@fakeLPA.com').isVisible(), 'supplied email not on check page').toBeTruthy() - expect(await page.getByText('Bob Marley').isVisible(), 'supplied name not on check page').toBeTruthy() - expect(await page.getByText('My Fake LPA').isVisible(), 'supplied email not on check page').toBeTruthy() - await page.getByRole('button', { name: 'Send data' }).click() + // await page.waitForURL('**/email-address') + // await page.getByLabel('Your email address').fill('dataOfficer@fakeLPA.com') + // await page.getByRole('button', { name: 'Continue' }).click() + + // await page.waitForURL('**/name') + // await page.getByLabel('First name').fill('Bob') + // await page.getByLabel('Last name').fill('Marley') + // await page.getByRole('button', { name: 'Continue' }).click() + + // await page.waitForURL('**/lpa') + // await page.getByLabel('Local planning authority').fill('My Fake LPA') + // await page.getByRole('button', { name: 'Continue' }).click() + + // await page.waitForURL('**/check') + // expect(await page.getByText('Conservation area', { exact: true }).isVisible(), 'supplied data subject not on check page').toBeTruthy() + // expect(await page.getByText('conservation-area', { exact: true }).isVisible(), 'supplied dataset not on check page').toBeTruthy() + // expect(await page.getByText('dataOfficer@fakeLPA.com').isVisible(), 'supplied email not on check page').toBeTruthy() + // expect(await page.getByText('Bob Marley').isVisible(), 'supplied name not on check page').toBeTruthy() + // expect(await page.getByText('My Fake LPA').isVisible(), 'supplied email not on check page').toBeTruthy() + // await page.getByRole('button', { name: 'Send data' }).click() await page.waitForURL('**/confirmation') }) diff --git a/test/acceptance/validation_errors.test.js b/test/acceptance/validation_errors.test.js index b78b1f1d..4a825328 100644 --- a/test/acceptance/validation_errors.test.js +++ b/test/acceptance/validation_errors.test.js @@ -1,28 +1,28 @@ import { test, expect } from '@playwright/test' -test('when the user clicks continue on the data subject page without entering a data subject, the page correctly indicates there\'s an error', async ({ page }) => { - await page.goto('/') - await page.getByRole('button', { name: 'Start now' }).click() - await page.getByRole('button', { name: 'Continue' }).click() +// test('when the user clicks continue on the data subject page without entering a data subject, the page correctly indicates there\'s an error', async ({ page }) => { +// await page.goto('/') +// await page.getByRole('button', { name: 'Start now' }).click() +// await page.getByRole('button', { name: 'Continue' }).click() - const expectedErrors = [ - { - fieldName: 'input#data-subject.govuk-radios__input', - expectedErrorMessage: 'Please select a data subject' - } - ] +// const expectedErrors = [ +// { +// fieldName: 'input#data-subject.govuk-radios__input', +// expectedErrorMessage: 'Please select a data subject' +// } +// ] - await testErrorMessage(page, expectedErrors) -}) +// await testErrorMessage(page, expectedErrors) +// }) test('when the user clicks continue on the dataset page without entering a dataset, the page correctly indicates there\'s an error', async ({ page }) => { await page.goto('/') // start page await page.getByRole('button', { name: 'Start now' }).click() - // data subject page - await page.getByLabel('Conservation area').check() - await page.getByRole('button', { name: 'Continue' }).click() + // // data subject page + // await page.getByLabel('Conservation area').check() + // await page.getByRole('button', { name: 'Continue' }).click() // dataset page await page.getByRole('button', { name: 'Continue' }).click() @@ -42,9 +42,9 @@ test('when the user clicks continue on the file upload page without selecting a // start page await page.getByRole('button', { name: 'Start now' }).click() - // data subject page - await page.getByLabel('Conservation area').check() - await page.getByRole('button', { name: 'Continue' }).click() + // // data subject page + // await page.getByLabel('Conservation area').check() + // await page.getByRole('button', { name: 'Continue' }).click() // dataset page await page.getByLabel('Conservation area dataset').check() @@ -63,164 +63,6 @@ test('when the user clicks continue on the file upload page without selecting a await testErrorMessage(page, expectedErrors) }) -test('when the user clicks continue on the email page without entering a valid email, the page correctly indicates there\'s an error', async ({ page }) => { - await page.goto('/') - // start page - await page.getByRole('button', { name: 'Start now' }).click() - - // data subject page - await page.getByLabel('Conservation area').check() - await page.getByRole('button', { name: 'Continue' }).click() - - // dataset page - await page.getByLabel('Conservation area dataset').check() - await page.getByRole('button', { name: 'Continue' }).click() - - // file upload page - await page.getByRole('button', { name: 'Continue' }).click() - await page.waitForSelector('input#datafile.govuk-file-upload') - - const fileChooserPromise = page.waitForEvent('filechooser') - await page.getByText('Upload data').click() - const fileChooser = await fileChooserPromise - await fileChooser.setFiles('test/testData/conservation-area-ok.csv') - - await page.getByRole('button', { name: 'Continue' }).click() - - await page.waitForURL('**/no-errors') - await page.getByRole('button', { name: 'Continue' }).click() - - await page.waitForURL('**/email-address') - - await page.getByRole('button', { name: 'Continue' }).click() - - let expectedErrors = [ - { - fieldName: 'input#email-address.govuk-input', - expectedErrorMessage: 'Enter an email address' - } - ] - - await testErrorMessage(page, expectedErrors) - - await page.getByLabel('Your email address').fill('invalidEmail1') - await page.getByRole('button', { name: 'Continue' }).click() - - await page.waitForSelector('input#email-address.govuk-input') - - expectedErrors = [ - { - fieldName: 'input#email-address.govuk-input', - expectedErrorMessage: 'Enter an email address in the correct format' - } - ] - - await testErrorMessage(page, expectedErrors) -}) - -test('when the user clicks continue on the name page without correctly completing the form, the page correctly indicates there\'s an error', async ({ page }) => { - await page.goto('/') - // start page - await page.getByRole('button', { name: 'Start now' }).click() - - // data subject page - await page.getByLabel('Conservation area').check() - await page.getByRole('button', { name: 'Continue' }).click() - - // dataset page - await page.getByLabel('Conservation area dataset').check() - await page.getByRole('button', { name: 'Continue' }).click() - - // file upload page - await page.getByRole('button', { name: 'Continue' }).click() - await page.waitForSelector('input#datafile.govuk-file-upload') - - const fileChooserPromise = page.waitForEvent('filechooser') - await page.getByText('Upload data').click() - const fileChooser = await fileChooserPromise - await fileChooser.setFiles('test/testData/conservation-area-ok.csv') - - await page.getByRole('button', { name: 'Continue' }).click() - - await page.waitForURL('**/no-errors') - await page.getByRole('button', { name: 'Continue' }).click() - - await page.waitForURL('**/email-address') - - await page.getByRole('button', { name: 'Continue' }).click() - - await page.getByLabel('Your email address').fill('test@mail.com') - - await page.getByRole('button', { name: 'Continue' }).click() - - await page.waitForURL('**/name') - - await page.getByRole('button', { name: 'Continue' }).click() - - const expectedErrors = [ - { - fieldName: 'input#first-name.govuk-input', - expectedErrorMessage: 'Enter your first name' - }, - { - fieldName: 'input#last-name.govuk-input', - expectedErrorMessage: 'Enter your last name' - } - ] - - await testErrorMessage(page, expectedErrors) -}) - -test('when the user clicks continue on the lpa page without correctly completing the form, the page correctly indicates there\'s an error', async ({ page }) => { - await page.goto('/') - // start page - await page.getByRole('button', { name: 'Start now' }).click() - - // data subject page - await page.getByLabel('Conservation area').check() - await page.getByRole('button', { name: 'Continue' }).click() - - // dataset page - await page.getByLabel('Conservation area dataset').check() - await page.getByRole('button', { name: 'Continue' }).click() - - // file upload page - await page.getByRole('button', { name: 'Continue' }).click() - await page.waitForSelector('input#datafile.govuk-file-upload') - - const fileChooserPromise = page.waitForEvent('filechooser') - await page.getByText('Upload data').click() - const fileChooser = await fileChooserPromise - await fileChooser.setFiles('test/testData/conservation-area-ok.csv') - - await page.getByRole('button', { name: 'Continue' }).click() - - await page.waitForURL('**/no-errors') - await page.getByRole('button', { name: 'Continue' }).click() - - await page.waitForURL('**/email-address') - await page.getByLabel('Your email address').fill('test@mail.com') - await page.getByRole('button', { name: 'Continue' }).click() - - await page.waitForURL('**/name') - await page.getByLabel('First name').fill('Bob') - await page.getByLabel('Last name').fill('Marley') - await page.getByRole('button', { name: 'Continue' }).click() - - await page.waitForURL('**/lpa') - - await page.getByRole('button', { name: 'Continue' }).click() - - const expectedErrors = [ - { - fieldName: 'input#lpa.govuk-input', - expectedErrorMessage: 'Enter the name of your local planning authority' - } - ] - - await testErrorMessage(page, expectedErrors) -}) - const testErrorMessage = async (page, errors) => { for (const { fieldName, expectedErrorMessage } of errors) { await page.waitForSelector(fieldName)