-
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 #12 from digital-land/yourEmailPage
Your email page
- Loading branch information
Showing
10 changed files
with
187 additions
and
59 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use strict' | ||
|
||
import MyController from './MyController.js' | ||
|
||
import { validate } from 'email-validator' | ||
|
||
class EmailAddressController extends MyController { | ||
// perform some additional validation on the email address | ||
validate (req, res, next) { | ||
if (!validate(req.form.values['email-address'])) { | ||
const errors = {} | ||
errors['email-address'] = new this.Error('email-address', {}, req.form.values['email-address'], 'Email address is not valid') | ||
next(errors) | ||
} else { | ||
super.validate(req, res, next) | ||
} | ||
} | ||
} | ||
|
||
export default EmailAddressController |
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,70 @@ | ||
{% extends "layouts/main.html" %} | ||
|
||
{% from 'govuk/components/button/macro.njk' import govukButton %} | ||
{% from 'govuk/components/input/macro.njk' import govukInput %} | ||
{% from 'govuk/components/error-message/macro.njk' import govukErrorMessage %} | ||
{% from 'govuk/components/error-summary/macro.njk' import govukErrorSummary %} | ||
|
||
{% set pageName = 'Your email address' %} | ||
|
||
{% set errorMessage = 'Please enter a valid email address' %} | ||
|
||
|
||
{% if 'email-address' in errors %} | ||
{% set datasetError = true %} | ||
{% endif %} | ||
|
||
{% block pageTitle %} | ||
{% if datasetError %} | ||
Error: {{super()}} | ||
{% else %} | ||
{{super()}} | ||
{% endif %} | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
{% if datasetError %} | ||
{{ govukErrorSummary({ | ||
titleText: "There is a problem", | ||
errorList: [ | ||
{ | ||
text: errorMessage, | ||
href: "#email-address" | ||
} | ||
] | ||
}) }} | ||
{% endif %} | ||
|
||
<form novalidate method="post"> | ||
|
||
{{ govukInput({ | ||
id: "email-address", | ||
name: "email-address", | ||
label: { | ||
text: pageName, | ||
isPageHeading: true, | ||
classes: 'govuk-label--l' | ||
}, | ||
type: "email", | ||
autocomplete: "email", | ||
spellcheck: false, | ||
value: data.check.emailAddress, | ||
errorMessage: { | ||
text: errorMessage | ||
} if datasetError else undefined | ||
}) }} | ||
|
||
|
||
|
||
|
||
|
||
|
||
{{ govukButton({ | ||
text: "Continue" | ||
}) }} | ||
</form> | ||
</div> | ||
</div> | ||
{% endblock %} |
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 |
---|---|---|
|
@@ -23,7 +23,7 @@ test('Enter form information', async ({ page }) => { | |
}) | ||
|
||
// currently skipping this test as im not sure how to go about providing the pipeline runner api | ||
test.skip('Enter form information and upload a file with errors and without errors', async ({ page }) => { | ||
test('Enter form information and upload a file with errors and without errors', async ({ page }) => { | ||
await page.goto('/') | ||
await page.getByRole('button', { name: 'Start now' }).click() | ||
|
||
|
@@ -60,4 +60,11 @@ test.skip('Enter form information and upload a file with errors and without erro | |
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('[email protected]') | ||
await page.getByRole('button', { name: 'Continue' }).click() | ||
|
||
await page.waitForURL('**/name') | ||
}) |
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