-
Notifications
You must be signed in to change notification settings - Fork 0
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 #15 from DEFRA/exit-page
[UNKNOWN] generic exit page
- Loading branch information
Showing
10 changed files
with
189 additions
and
55 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
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 @@ | ||
/** | ||
* @returns [ boolean | string | null ] | ||
*/ | ||
export default (input) => { | ||
const valid = /([0-9]{2})\/([0-9]{3})\/([0-9]{4})/g | ||
const requiredLength = 11 | ||
|
||
if (!input) { | ||
return [false, 'Enter the farm or premises CPH number'] | ||
} | ||
|
||
if (input && (!valid.test(input) || input.length !== requiredLength)) { | ||
return [ | ||
false, | ||
'Enter the CPH number in the correct format, for example, 12/345/6789' | ||
] | ||
} | ||
|
||
return [true, null] | ||
} |
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,17 @@ | ||
/** | ||
* A GDS styled example home page controller. | ||
* Provided as an example, remove or modify as required. | ||
* @satisfies {Partial<ServerRoute>} | ||
*/ | ||
export const exitPageController = { | ||
handler(_request, h) { | ||
return h.view('exit-page/index', { | ||
pageTitle: 'This service is not available for your movement type', | ||
heading: 'This service is not available for your movement type' | ||
}) | ||
} | ||
} | ||
|
||
/** | ||
* @import { ServerRoute } from '@hapi/hapi' | ||
*/ |
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,34 @@ | ||
import { createServer } from '~/src/server/index.js' | ||
import { statusCodes } from '~/src/server/common/constants/status-codes.js' | ||
|
||
describe('#exitPageController', () => { | ||
/** @type {Server} */ | ||
let server | ||
|
||
beforeAll(async () => { | ||
server = await createServer() | ||
await server.initialize() | ||
}) | ||
|
||
afterAll(async () => { | ||
await server.stop({ timeout: 0 }) | ||
}) | ||
|
||
test('Should provide expected response', async () => { | ||
const { result, statusCode } = await server.inject({ | ||
method: 'GET', | ||
url: '/exit-page' | ||
}) | ||
|
||
expect(result).toEqual( | ||
expect.stringContaining( | ||
'This service is not available for your movement type' | ||
) | ||
) | ||
expect(statusCode).toBe(statusCodes.ok) | ||
}) | ||
}) | ||
|
||
/** | ||
* @import { Server } from '@hapi/hapi' | ||
*/ |
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,28 @@ | ||
import { exitPageController } from '~/src/server/exit-page/controller.js' | ||
|
||
/** | ||
* Sets up the routes used in the home page. | ||
* These routes are registered in src/server/router.js. | ||
*/ | ||
|
||
/** | ||
* @satisfies {ServerRegisterPluginObject<void>} | ||
*/ | ||
export const exitPage = { | ||
plugin: { | ||
name: 'exitPage', | ||
register(server) { | ||
server.route([ | ||
{ | ||
method: 'GET', | ||
path: '/exit-page', | ||
...exitPageController | ||
} | ||
]) | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @import { ServerRegisterPluginObject } from '@hapi/hapi' | ||
*/ |
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,33 @@ | ||
{% extends 'layouts/page.njk' %} | ||
|
||
{% block content %} | ||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
<h1 class="gem-c-title__text govuk-heading-l"> | ||
{{ heading }} | ||
</h1> | ||
|
||
<div class="govuk-body" data-testid="app-page-body"> | ||
<p> | ||
This service is currently only available for movements off your farm or premises. | ||
</p> | ||
|
||
<p> | ||
You need to complete and submit the current form. | ||
</p> | ||
|
||
<p> | ||
<a href="https://www.gov.uk/government/publications/tb-restricted-cattle-application-for-movement-licence-in-england"> | ||
View the application form | ||
</a> | ||
on | ||
<a href="https://www.gov.uk/"> | ||
GOV.UK | ||
</a> | ||
</p> | ||
</div> | ||
</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
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