-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from digital-land/inputChecks
Input checks
- Loading branch information
Showing
9 changed files
with
237 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npm run lint | ||
npm run lint:fix | ||
npm run lint |
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
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
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
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() | ||
|
||
await page.waitForSelector('input#data-subject.govuk-radios__input') | ||
|
||
const errorLink = await page.getByRole('link', { name: 'Please select a data subject' }) | ||
const fieldError = await page.getByText('Error: Please select a data subject') | ||
const errorSummary = await page.getByText('There is a problem') | ||
|
||
expect(await errorSummary.isVisible(), 'Page should show the error summary').toBeTruthy() | ||
expect(await errorLink.isVisible(), 'Page should the error message that is a link to the problem field').toBeTruthy() | ||
expect(await fieldError.isVisible(), 'Page should show the error message next to the problem field').toBeTruthy() | ||
await errorLink.click() | ||
const problemFieldIsFocused = await page.$eval('input#data-subject.govuk-radios__input', (el) => el === document.activeElement) | ||
expect(problemFieldIsFocused, 'The focus should be on the problem field').toBeTruthy() | ||
|
||
expect(await page.title(), 'Page title should indicate there\'s an error').toMatch(/Error: .*/) | ||
}) | ||
|
||
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() | ||
|
||
// dataset page | ||
await page.getByRole('button', { name: 'Continue' }).click() | ||
|
||
await page.waitForSelector('input#dataset.govuk-radios__input') | ||
|
||
const errorLink = await page.getByRole('link', { name: 'Please select a dataset' }) | ||
const fieldError = await page.getByText('Error: Please select a dataset') | ||
const errorSummary = await page.getByText('There is a problem') | ||
|
||
expect(await errorSummary.isVisible(), 'Page should show the error summary').toBeTruthy() | ||
expect(await errorLink.isVisible(), 'Page should the error message that is a link to the problem field').toBeTruthy() | ||
expect(await fieldError.isVisible(), 'Page should show the error message next to the problem field').toBeTruthy() | ||
await errorLink.click() | ||
const problemFieldIsFocused = await page.$eval('input#dataset.govuk-radios__input', (el) => el === document.activeElement) | ||
expect(problemFieldIsFocused, 'The focus should be on the problem field').toBeTruthy() | ||
|
||
expect(await page.title(), 'Page title should indicate there\'s an error').toMatch(/Error: .*/) | ||
}) | ||
|
||
test('when the user clicks continue on the file upload page without selecting a file, 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 errorLink = await page.getByRole('link', { name: 'Please select a file' }) | ||
const fieldError = await page.getByText('Error: Please select a file') | ||
const errorSummary = await page.getByText('There is a problem') | ||
|
||
expect(await errorSummary.isVisible(), 'Page should show the error summary').toBeTruthy() | ||
expect(await errorLink.isVisible(), 'Page should the error message that is a link to the problem field').toBeTruthy() | ||
expect(await fieldError.isVisible(), 'Page should show the error message next to the problem field').toBeTruthy() | ||
await errorLink.click() | ||
|
||
const problemFieldIsFocused = await page.$eval('input#datafile.govuk-file-upload', (el) => el === document.activeElement) | ||
expect(problemFieldIsFocused, 'The focus should be on the problem field').toBeTruthy() | ||
|
||
expect(await page.title(), 'Page title should indicate there\'s an error').toMatch(/Error: .*/) | ||
}) |
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