Skip to content

Commit

Permalink
Merge pull request #81 from DEFRA/DSFAAP-612_Privacy-policy-page
Browse files Browse the repository at this point in the history
DSFAAP-612: Privacy policy page
  • Loading branch information
joseluisgraa authored Dec 19, 2024
2 parents cad6b60 + 19377f3 commit bd54dd9
Show file tree
Hide file tree
Showing 9 changed files with 629 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/server/common/templates/layouts/page.njk
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
meta: {
items: [
{
href: "https://www.gov.uk/help/privacy-notice",
href: "/privacy-policy",
text: "Privacy"
},
{
Expand Down
15 changes: 15 additions & 0 deletions src/server/privacy-policy/controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* @satisfies {Partial<ServerRoute>}
*/
export const privacyPolicyController = {
handler(_request, h) {
return h.view('privacy-policy/index', {
pageTitle: 'Privacy Policy',
heading: 'Privacy Policy'
})
}
}

/**
* @import { ServerRoute } from '@hapi/hapi'
*/
32 changes: 32 additions & 0 deletions src/server/privacy-policy/controller.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { createServer } from '~/src/server/index.js'
import { statusCodes } from '~/src/server/common/constants/status-codes.js'
import { parseDocument } from '~/src/server/common/test-helpers/dom.js'

describe('#privacyPolicyController', () => {
/** @type {Server} */
let server

beforeAll(async () => {
server = await createServer()
await server.initialize()
})

afterAll(async () => {
await server.stop({ timeout: 0 })
})

it('Should provide expected response', async () => {
const { payload, statusCode } = await server.inject({
method: 'GET',
url: '/privacy-policy'
})

expect(parseDocument(payload).title).toBe('Privacy Policy')

expect(statusCode).toBe(statusCodes.ok)
})
})

/**
* @import { Server } from '@hapi/hapi'
*/
28 changes: 28 additions & 0 deletions src/server/privacy-policy/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { privacyPolicyController } from './controller.js'

/**
* Sets up the routes used in the privacy policy page.
* These routes are registered in src/server/router.js.
*/

/**
* @satisfies {ServerRegisterPluginObject<void>}
*/
export const privacyPolicy = {
plugin: {
name: 'privacy-policy',
register(server) {
server.route([
{
method: 'GET',
path: '/privacy-policy',
...privacyPolicyController
}
])
}
}
}

/**
* @import { ServerRegisterPluginObject } from '@hapi/hapi'
*/
Loading

0 comments on commit bd54dd9

Please sign in to comment.