@defra-fish/gafl-webapp-service 1.61.0-rc.13 → 1.61.0-rc.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra-fish/gafl-webapp-service",
3
- "version": "1.61.0-rc.13",
3
+ "version": "1.61.0-rc.15",
4
4
  "description": "The websales frontend for the GAFL service",
5
5
  "type": "module",
6
6
  "engines": {
@@ -36,8 +36,8 @@
36
36
  "prepare": "gulp --gulpfile build/gulpfile.cjs"
37
37
  },
38
38
  "dependencies": {
39
- "@defra-fish/business-rules-lib": "1.61.0-rc.13",
40
- "@defra-fish/connectors-lib": "1.61.0-rc.13",
39
+ "@defra-fish/business-rules-lib": "1.61.0-rc.15",
40
+ "@defra-fish/connectors-lib": "1.61.0-rc.15",
41
41
  "@defra/hapi-gapi": "^2.0.0",
42
42
  "@hapi/boom": "^9.1.2",
43
43
  "@hapi/catbox-redis": "^6.0.2",
@@ -79,5 +79,5 @@
79
79
  "./gafl-jest-matchers.js"
80
80
  ]
81
81
  },
82
- "gitHead": "fdd397ab2b9e6fa2346d765f4ada01ce5475dd10"
82
+ "gitHead": "906584338318c1402682d486a40bb72ff1abb37d"
83
83
  }
@@ -1,13 +1,15 @@
1
1
  import handler from '../authentication-handler.js'
2
- import { IDENTIFY, CONTROLLER, RENEWAL_INACTIVE } from '../../uri.js'
2
+ import { LICENCE_NOT_FOUND, CONTROLLER, RENEWAL_INACTIVE } from '../../uri.js'
3
3
  import { salesApi } from '@defra-fish/connectors-lib'
4
4
 
5
5
  jest.mock('../../processors/uri-helper.js')
6
6
  jest.mock('../page-handler.js', () => ({ errorShimm: () => {} }))
7
7
  jest.mock('../../uri.js', () => ({
8
8
  IDENTIFY: {
9
- page: 'identify page',
10
- uri: Symbol('identify uri')
9
+ page: 'identify page'
10
+ },
11
+ LICENCE_NOT_FOUND: {
12
+ uri: Symbol('licence not found uri')
11
13
  },
12
14
  CONTROLLER: {
13
15
  uri: Symbol('controller uri')
@@ -40,7 +42,7 @@ const getSampleAuthResult = (description = 'M', durationMagnitude = 12) => ({
40
42
  })
41
43
 
42
44
  describe.each([
43
- [false, 'identify', IDENTIFY.uri, 1],
45
+ [false, 'licence not found', LICENCE_NOT_FOUND.uri, 1],
44
46
  [getSampleAuthResult(), 'controller', CONTROLLER.uri, -1],
45
47
  [getSampleAuthResult(), 'renewal inactive', RENEWAL_INACTIVE.uri, 61],
46
48
  [getSampleAuthResult(), 'renewal inactive', RENEWAL_INACTIVE.uri, -61],
@@ -1,5 +1,5 @@
1
1
  import { setUpCacheFromAuthenticationResult, setUpPayloads } from '../processors/renewals-write-cache.js'
2
- import { IDENTIFY, CONTROLLER, RENEWAL_INACTIVE } from '../uri.js'
2
+ import { IDENTIFY, RENEWAL_INACTIVE, LICENCE_NOT_FOUND, CONTROLLER } from '../uri.js'
3
3
  import { RENEWAL_ERROR_REASON } from '../constants.js'
4
4
  import { validation, RENEW_BEFORE_DAYS, RENEW_AFTER_DAYS, SERVICE_LOCAL_TIME } from '@defra-fish/business-rules-lib'
5
5
  import Joi from 'joi'
@@ -8,7 +8,7 @@ import moment from 'moment-timezone'
8
8
 
9
9
  /**
10
10
  * Handler to authenticate the user on the easy renewals journey. It will
11
- * (1) Redirect back to the identification page where there is an authentication failure
11
+ * (1) Redirect to an error page where there is an authentication failure
12
12
  * (2) Redirect to an error page where the renewal has expired
13
13
  * (3) Redirect back to an error page where a licence is already issued
14
14
  * (4) Establish the session cache and redirect into the controller where the user is authenticated
@@ -43,9 +43,9 @@ export default async (request, h) => {
43
43
 
44
44
  if (!authenticationResult) {
45
45
  payload.referenceNumber = referenceNumber
46
- await request.cache().helpers.page.setCurrentPermission(IDENTIFY.page, { payload, error: { referenceNumber: 'string.invalid' } })
46
+ await request.cache().helpers.page.setCurrentPermission(IDENTIFY.page, { payload })
47
47
  await request.cache().helpers.status.setCurrentPermission({ referenceNumber, authentication: { authorized: false } })
48
- return h.redirectWithLanguageCode(IDENTIFY.uri)
48
+ return h.redirectWithLanguageCode(LICENCE_NOT_FOUND.uri)
49
49
  } else {
50
50
  // Test for 12 month licence
51
51
  const daysDiff = moment(authenticationResult.permission.endDate).diff(moment().tz(SERVICE_LOCAL_TIME).startOf('day'), 'days')
@@ -332,8 +332,6 @@
332
332
  "identify_error_date_real": "Mae’n rhaid i’r dyddiad geni fod yn ddyddiad dilys",
333
333
  "identify_error_empty_postcode": "Nid ydych wedi nodi cod post",
334
334
  "identify_error_empty": "Rhowch chwe nodyn olaf eich trwydded",
335
- "identify_error_invalid_1": "Nid oes gennym gofnod o rif trwydded sy'n gorffen gyda ",
336
- "identify_error_invalid_2": " sy’n cyd-fynd â'r manylion hyn.",
337
335
  "identify_error_missing_day": "Mae’n rhaid i’r dyddiad geni gynnwys diwrnod",
338
336
  "identify_error_missing_month": "Mae’n rhaid i’r dyddiad geni gynnwys mis",
339
337
  "identify_error_missing_year": "Mae’n rhaid i’r dyddiad geni gynnwys blwyddyn",
@@ -420,6 +418,13 @@
420
418
  "licence_length_title_other": "Am ba hyd y maent am gael y drwydded?",
421
419
  "licence_length_title_you": "Am ba hyd yr hoffech chi gael y drwydded?",
422
420
  "licence_num": "Rhif trwydded",
421
+ "licence_not_found_title": "Ni allwn ddod o hyd i drwydded sy’n cyfateb â'r manylion a roddwyd",
422
+ "licence_not_found_body_1": "Gwiriwch eich bod wedi mewnbynnu’r manylion yn gywir - ",
423
+ "licence_not_found_body_previous_page": "ewch yn ôl i’r dudalen flaenorol",
424
+ "licence_not_found_body_2": "Os byddwch yn parhau i weld y dudalen hon gallwch ofyn am gymorth drwy e-bostio ",
425
+ "licence_not_found_body_ea_link": "enquiries@environment-agency.gov.uk",
426
+ "licence_not_found_body_3": " neu ffonio 03708 506 506 (8am - 6pm o ddydd Llun i ddydd Gwener, ac eithrio gwyliau cyhoeddus). ",
427
+ "licence_not_found_body_call_charges_link": "Gallwch weld costau’r galwadau yma (yn agor mewn tab newydd)",
423
428
  "licence_start_days": " diwrnod nesaf",
424
429
  "licence_start_enter_todays_date": "Rhowch ddyddiad heddiw os ydych chi am i’r drwydded 1 diwrnod neu 8 diwrnod ddechrau yn hwyrach heddiw.",
425
430
  "licence_start_error_date_real": "Mae’n rhaid i ddyddiad dechrau’r drwydded fod yn ddyddiad dilys",
@@ -332,8 +332,6 @@
332
332
  "identify_error_date_real": "Date of birth must be a real date",
333
333
  "identify_error_empty_postcode": "You did not enter a postcode",
334
334
  "identify_error_empty": "Enter the last six characters of your licence number",
335
- "identify_error_invalid_1": "We do not have any record of a licence number ending ",
336
- "identify_error_invalid_2": " matching these details.",
337
335
  "identify_error_missing_day": "Date of birth must include a day",
338
336
  "identify_error_missing_month": "Date of birth must include a month",
339
337
  "identify_error_missing_year": "Date of birth must include a year",
@@ -419,6 +417,13 @@
419
417
  "licence_length_one_day": "1 day licences are valid for 24 hours from the start time that you select.",
420
418
  "licence_length_title_other": "How long do they want the licence for?",
421
419
  "licence_length_title_you": "How long do you want your licence for?",
420
+ "licence_not_found_title": "We cannot find a licence matching the details you provided",
421
+ "licence_not_found_body_1": "Check you have entered your details correctly - ",
422
+ "licence_not_found_body_previous_page": "go back to the previous page",
423
+ "licence_not_found_body_2": "If you keep seeing this page you can get help by emailing ",
424
+ "licence_not_found_body_ea_link": "enquiries@environment-agency.gov.uk",
425
+ "licence_not_found_body_3": " or calling 03708 506 506 (8am to 6pm, Monday to Friday, except public holidays). ",
426
+ "licence_not_found_body_call_charges_link": "View call charges (opens in new tab)",
422
427
  "licence_num": "Licence number",
423
428
  "licence_start_days": " days",
424
429
  "licence_start_enter_todays_date": "Enter today’s date if you want the 1-day or 8-day licence to start later today.",
@@ -9,7 +9,8 @@ import {
9
9
  RENEWAL_INACTIVE,
10
10
  LICENCE_LENGTH,
11
11
  CONTACT_SUMMARY,
12
- NEW_TRANSACTION
12
+ NEW_TRANSACTION,
13
+ LICENCE_NOT_FOUND
13
14
  } from '../../../../uri.js'
14
15
  import { start, stop, initialize, injectWithCookies, mockSalesApi } from '../../../../__mocks__/test-utils-system.js'
15
16
 
@@ -52,15 +53,12 @@ mockSalesApi()
52
53
  salesApi.countries.getAll = jest.fn(() => Promise.resolve(mockDefraCountries))
53
54
 
54
55
  describe('The easy renewal identification page', () => {
55
- it('redirects to identify page when called with an invalid permission reference', async () => {
56
+ it('redirects from identify to licence not found page when called with an invalid permission reference', async () => {
56
57
  const data = await injectWithCookies('GET', RENEWAL_PUBLIC.uri.replace('{referenceNumber}', 'not-a-valid-reference-number'))
57
58
  expect(data.statusCode).toBe(302)
58
59
  expect(data.headers.location).toHaveValidPathFor(IDENTIFY.uri)
59
- const data2 = await injectWithCookies('GET', IDENTIFY.uri)
60
- expect(data2.statusCode).toBe(302)
61
- expect(data2.headers.location).toHaveValidPathFor(IDENTIFY.uri)
62
- const data3 = await injectWithCookies('GET', IDENTIFY.uri)
63
- expect(data3.statusCode).toBe(200)
60
+ const data2 = await injectWithCookies('GET', LICENCE_NOT_FOUND.uri)
61
+ expect(data2.statusCode).toBe(200)
64
62
  })
65
63
 
66
64
  it('returns successfully when called with a valid reference ', async () => {
@@ -87,7 +85,7 @@ describe('The easy renewal identification page', () => {
87
85
  expect(data.headers.location).toHaveValidPathFor(IDENTIFY.uri)
88
86
  })
89
87
 
90
- it('redirects back to itself on posting an valid but not authenticated details', async () => {
88
+ it('redirects to licence not found on posting valid but not authenticated details', async () => {
91
89
  salesApi.authenticate.mockImplementation(jest.fn(async () => new Promise(resolve => resolve(null))))
92
90
  await injectWithCookies('GET', VALID_RENEWAL_PUBLIC_URI)
93
91
  await injectWithCookies('GET', IDENTIFY.uri)
@@ -100,8 +98,8 @@ describe('The easy renewal identification page', () => {
100
98
  expect(data.headers.location).toHaveValidPathFor(AUTHENTICATE.uri)
101
99
  const data2 = await injectWithCookies('GET', AUTHENTICATE.uri)
102
100
  expect(data2.statusCode).toBe(302)
103
- expect(data2.headers.location).toHaveValidPathFor(IDENTIFY.uri)
104
- const data3 = await injectWithCookies('GET', IDENTIFY.uri)
101
+ expect(data2.headers.location).toHaveValidPathFor(LICENCE_NOT_FOUND.uri)
102
+ const data3 = await injectWithCookies('GET', LICENCE_NOT_FOUND.uri)
105
103
  expect(data3.statusCode).toBe(200)
106
104
  })
107
105
 
@@ -15,11 +15,7 @@
15
15
  set errorMap = {
16
16
  'referenceNumber' : {
17
17
  'string.empty': { text: mssgs.identify_error_empty, ref: '#ref' },
18
- 'string.pattern.base': { text: mssgs.identify_error_pattern, ref: '#ref' },
19
- 'string.invalid': {
20
- text: mssgs.identify_error_invalid_1 + payload.referenceNumber + mssgs.identify_error_invalid_2,
21
- ref: "#ref"
22
- }
18
+ 'string.pattern.base': { text: mssgs.identify_error_pattern, ref: '#ref' }
23
19
  },
24
20
  'postcode': {
25
21
  'string.empty': { ref: '#postcode', text: mssgs.identify_error_empty_postcode },
@@ -1,4 +1,4 @@
1
- import { IDENTIFY, AUTHENTICATE, NEW_TRANSACTION } from '../../../uri.js'
1
+ import { IDENTIFY, NEW_TRANSACTION, AUTHENTICATE } from '../../../uri.js'
2
2
  import pageRoute from '../../../routes/page-route.js'
3
3
  import Joi from 'joi'
4
4
  import { validation } from '@defra-fish/business-rules-lib'
@@ -0,0 +1,22 @@
1
+ import pageRoute from '../../../../routes/page-route.js'
2
+ import { LICENCE_NOT_FOUND } from '../../../../uri.js'
3
+ import '../route.js'
4
+
5
+ jest.mock('../../../../routes/page-route.js', () => jest.fn())
6
+ jest.mock('../../../../uri.js', () => ({
7
+ RENEWAL_PUBLIC: { uri: Symbol('renewal public uri') },
8
+ LICENCE_NOT_FOUND: {
9
+ page: Symbol('licence-not-found page'),
10
+ uri: Symbol('licence-not-found uri')
11
+ }
12
+ }))
13
+
14
+ describe('LICENCE_NOT_FOUND route', () => {
15
+ it('passes LICENCE_NOT_FOUND.page as the first argument to pageRoute', () => {
16
+ expect(pageRoute.mock.calls[0][0]).toBe(LICENCE_NOT_FOUND.page)
17
+ })
18
+
19
+ it('passes LICENCE_NOT_FOUND.uri as the second argument to pageRoute', () => {
20
+ expect(pageRoute.mock.calls[0][1]).toBe(LICENCE_NOT_FOUND.uri)
21
+ })
22
+ })
@@ -0,0 +1,23 @@
1
+ {% extends "layout.njk" %}
2
+ {% extends "standard-form.njk" %}
3
+
4
+ {% set title = mssgs.licence_not_found_title %}
5
+
6
+ {% block content %}
7
+ <div class="govuk-grid-row">
8
+ <div class="govuk-grid-column-two-thirds">
9
+ <h1 class="govuk-heading-l">{{ mssgs.licence_not_found_title }}</h1>
10
+ <p class="govuk-body">
11
+ {{ mssgs.licence_not_found_body_1 }}
12
+ <a class="govuk-link" href="/buy/renew/identify">{{ mssgs.licence_not_found_body_previous_page }}</a>{{ mssgs.full_stop }}
13
+ </p>
14
+ <p class="govuk-body">
15
+ {{ mssgs.licence_not_found_body_2 }}
16
+ <a href="mailto:enquiries@environment-agency.gov.uk">{{ mssgs.licence_not_found_body_ea_link }}</a>
17
+ {{ mssgs.licence_not_found_body_3 }}
18
+ <a href="https://www.gov.uk/call-charges" target="_blank" rel="noopener">
19
+ {{ mssgs.licence_not_found_body_call_charges_link }}</a>{{ mssgs.full_stop }}
20
+ </p>
21
+ </div>
22
+ </div>
23
+ {% endblock %}
@@ -0,0 +1,4 @@
1
+ import { LICENCE_NOT_FOUND } from '../../../uri.js'
2
+ import pageRoute from '../../../routes/page-route.js'
3
+
4
+ export default pageRoute(LICENCE_NOT_FOUND.page, LICENCE_NOT_FOUND.uri, null)
@@ -28,7 +28,8 @@ import {
28
28
  RENEWAL_INACTIVE,
29
29
  RENEWAL_START_DATE,
30
30
  CHOOSE_PAYMENT,
31
- SET_UP_PAYMENT
31
+ SET_UP_PAYMENT,
32
+ LICENCE_NOT_FOUND
32
33
  } from '../uri.js'
33
34
 
34
35
  import { CommonResults, CONTACT_SUMMARY_SEEN, ShowDigitalLicencePages } from '../constants.js'
@@ -416,6 +417,11 @@ export default [
416
417
  }
417
418
  },
418
419
 
420
+ {
421
+ current: LICENCE_NOT_FOUND,
422
+ backLink: IDENTIFY.uri
423
+ },
424
+
419
425
  // The change start time is handled directly - not via the controller, as it has dynamic validation
420
426
  {
421
427
  current: RENEWAL_START_DATE,
@@ -30,6 +30,7 @@ import paymentFailed from '../pages/payment/failed/route.js'
30
30
  import identify from '../pages/renewals/identify/route.js'
31
31
  import invalidLink from '../pages/renewals/renewal-inactive/route.js'
32
32
  import renewalStartDate from '../pages/renewals/renewal-start-date/route.js'
33
+ import licenceNotFound from '../pages/renewals/licence-not-found/route.js'
33
34
 
34
35
  import staticAssets from './static-routes.js'
35
36
  import miscRoutes from './misc-routes.js'
@@ -71,7 +72,8 @@ const routes = [
71
72
  ...invalidLink,
72
73
  ...renewalStartDate,
73
74
  ...choosePayment,
74
- ...setUpRecurring
75
+ ...setUpRecurring,
76
+ ...licenceNotFound
75
77
  ]
76
78
 
77
79
  if (process.env.CHANNEL === 'telesales') {
package/src/uri.js CHANGED
@@ -48,6 +48,7 @@ export const IDENTIFY = { uri: '/buy/renew/identify', page: 'identify' }
48
48
  export const RENEWAL_INACTIVE = { uri: '/buy/renew/inactive', page: 'renewal-inactive' }
49
49
  export const AUTHENTICATE = { uri: '/buy/renew/authenticate' }
50
50
  export const RENEWAL_START_DATE = { uri: '/buy/renew/renewal-start-date', page: 'renewal-start-date' }
51
+ export const LICENCE_NOT_FOUND = { uri: '/buy/renew/licence-not-found', page: 'licence-not-found' }
51
52
 
52
53
  export const CONTROLLER = { uri: '/buy' }
53
54
  export const NEW_TRANSACTION = { uri: '/buy/new' }