@defra-fish/gafl-webapp-service 1.22.1 → 1.23.0-rc.10

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.22.1",
3
+ "version": "1.23.0-rc.10",
4
4
  "description": "The websales frontend for the GAFL service",
5
5
  "type": "module",
6
6
  "engines": {
@@ -36,32 +36,32 @@
36
36
  "prepare": "gulp --gulpfile build/gulpfile.cjs"
37
37
  },
38
38
  "dependencies": {
39
- "@defra-fish/business-rules-lib": "1.22.1",
40
- "@defra-fish/connectors-lib": "1.22.1",
39
+ "@defra-fish/business-rules-lib": "1.23.0-rc.10",
40
+ "@defra-fish/connectors-lib": "1.23.0-rc.10",
41
41
  "@defra/hapi-gapi": "^1.1.0",
42
42
  "@hapi/boom": "^9.1.2",
43
43
  "@hapi/catbox-redis": "^6.0.2",
44
44
  "@hapi/cookie": "^11.0.2",
45
45
  "@hapi/crumb": "^8.0.1",
46
- "@hapi/hapi": "^20.1.3",
47
- "@hapi/inert": "^6.0.3",
46
+ "@hapi/hapi": "^20.2.1",
47
+ "@hapi/inert": "^6.0.5",
48
48
  "@hapi/joi-date": "^2.0.1",
49
49
  "@hapi/scooter": "^6.0.1",
50
50
  "@hapi/vision": "^6.1.0",
51
51
  "blankie": "^5.0.0",
52
- "debug": "^4.3.1",
52
+ "debug": "^4.3.3",
53
53
  "disinfect": "^1.1.0",
54
54
  "find": "^0.3.0",
55
55
  "flatpickr": "^4.6.9",
56
- "govuk-frontend": "^3.12.0",
56
+ "govuk-frontend": "^4.0.1",
57
57
  "hapi-i18n": "^3.0.1",
58
- "joi": "^17.4.0",
58
+ "joi": "^17.6.0",
59
59
  "moment": "^2.29.1",
60
- "moment-timezone": "^0.5.33",
61
- "node-fetch": "^2.6.1",
60
+ "moment-timezone": "^0.5.34",
61
+ "node-fetch": "^2.6.7",
62
62
  "nunjucks": "^3.2.3",
63
- "openid-client": "^4.7.4",
64
- "pdfmake": "^0.1.71",
63
+ "openid-client": "^4.9.1",
64
+ "pdfmake": "^0.1.72",
65
65
  "semver": "^7.3.5",
66
66
  "uuid": "^8.3.2"
67
67
  },
@@ -72,9 +72,9 @@
72
72
  "gulp-concat": "^2.6.1",
73
73
  "gulp-merge": "^0.1.1",
74
74
  "gulp-minify": "^3.1.0",
75
- "gulp-sass": "^4.1.0",
75
+ "gulp-sass": "^4.1.1",
76
76
  "gulp-sourcemaps": "^3.0.0",
77
- "node-sass": "^6.0.0"
77
+ "node-sass": "^6.0.1"
78
78
  },
79
- "gitHead": "b456e0fda4c7a9119146da462fec3c6502a976f9"
79
+ "gitHead": "a6ddfeb935bf94b5b393fbcb5ad518077945850d"
80
80
  }
@@ -0,0 +1,24 @@
1
+ import { getPlugins } from '../plugins'
2
+
3
+ describe('plugins', () => {
4
+ const findPlugin = (pluginArray, pluginName) => pluginArray.find(plugin => plugin?.plugin?.plugin?.name === pluginName)
5
+
6
+ describe('initialiseHapiI18nPlugin', () => {
7
+ it.each([
8
+ [['en'], undefined, undefined],
9
+ [['en'], undefined, false],
10
+ [['en'], undefined, 'false'],
11
+ [['en', 'cy'], 'lang', true],
12
+ [['en', 'cy'], 'lang', 'true']
13
+ ])(
14
+ 'should return the locale as %s and queryParameter as %s, if SHOW_WELSH_CONTENT is %s',
15
+ async (expectedLocale, expectedQueryParamter, showWelshContent) => {
16
+ process.env.SHOW_WELSH_CONTENT = showWelshContent
17
+ const pluginArray = getPlugins()
18
+ const hapI18nPlugin = findPlugin(pluginArray, 'hapi-i18n')
19
+ expect(hapI18nPlugin.options.locales).toStrictEqual(expectedLocale)
20
+ expect(hapI18nPlugin.options.queryParameter).toBe(expectedQueryParamter)
21
+ }
22
+ )
23
+ })
24
+ })
@@ -102,6 +102,7 @@
102
102
  },
103
103
  id: "postcode",
104
104
  name: "postcode",
105
+ hint: { text: mssgs.address_lookup_postcode_hint },
105
106
  value: payload['postcode'],
106
107
  classes: "govuk-input--width-20",
107
108
  attributes: { maxlength: 10 },
@@ -32,6 +32,7 @@
32
32
 
33
33
  {{ govukRadios({
34
34
  idPrefix: "address",
35
+ classes: "address_list",
35
36
  name: "address",
36
37
  items: addressItems,
37
38
  errorMessage: { text: mssgs.address_select_error_choose } if error
@@ -114,7 +114,7 @@
114
114
  {% else %}
115
115
  {% set title = mssgs.licence_confirm_method_where_title_you if data.isLicenceForYou else mssgs.licence_confirm_method_where_title_other %}
116
116
  {% set bodyText = mssgs.licence_confirm_method_where_body_text %}
117
- {% set hintText = mssgs.licence_confirm_method_where_body_hint_you if data.isLicenceForYou else mssgs.licence_confirm_method_how_title_other %}
117
+ {% set hintText = mssgs.licence_confirm_method_where_body_hint_you if data.isLicenceForYou else mssgs.licence_confirm_method_where_body_hint_other %}
118
118
  {% endif %}
119
119
 
120
120
  {% block pageContent %}
package/src/plugins.js CHANGED
@@ -97,13 +97,17 @@ const initialiseHapiGapiPlugin = () => {
97
97
  }
98
98
  }
99
99
 
100
- const initialiseHapiI18nPlugin = () => ({
101
- plugin: HapiI18n,
102
- options: {
103
- locales: ['en'],
104
- directory: path.join(Dirname, 'src/locales')
100
+ const initialiseHapiI18nPlugin = () => {
101
+ const showWelshContent = process.env.SHOW_WELSH_CONTENT?.toLowerCase() === 'true'
102
+ return {
103
+ plugin: HapiI18n,
104
+ options: {
105
+ locales: ['en', ...(showWelshContent ? ['cy'] : [])],
106
+ directory: path.join(Dirname, 'src/locales'),
107
+ ...(showWelshContent && { queryParameter: 'lang' })
108
+ }
105
109
  }
106
- })
110
+ }
107
111
 
108
112
  export const getPlugins = () => {
109
113
  return [
@@ -3,15 +3,38 @@ import fetch from 'node-fetch'
3
3
 
4
4
  jest.mock('node-fetch')
5
5
 
6
- describe('Address lookup service', () => {
6
+ describe('address-lookup-service', () => {
7
7
  beforeAll(() => {
8
8
  process.env.ADDRESS_LOOKUP_KEY = 'ADDRESS_LOOKUP_KEY'
9
9
  process.env.ADDRESS_LOOKUP_URL = 'https://address.lookup.url'
10
10
  })
11
+ beforeEach(jest.clearAllMocks)
11
12
 
12
- it('returns empty array if results node is missing', async () => {
13
- fetch.mockResolvedValue({ json: () => Promise.resolve({}) })
14
- const results = await als()
15
- expect(results).toEqual([])
13
+ describe('default', () => {
14
+ it('returns empty array if results node is missing', async () => {
15
+ fetch.mockResolvedValue({ json: () => Promise.resolve({}) })
16
+ const results = await als()
17
+ expect(results).toEqual([])
18
+ })
19
+
20
+ it.each([
21
+ ['1 HOWECROFT COURT, EASTMEAD LANE, BRISTOL, BS9 1HJ', 'BS9 1HJ', '1 howecroft court, eastmead lane, bristol, BS9 1HJ', 'BS9 1HJ'],
22
+ ['9 ORBIT STREET, ADAMSDOWN, CARDIfF, CF24 0JX', 'CF24 0JX', '9 orbit street, adamsdown, cardiff, CF24 0JX', 'CF24 0JX'],
23
+ ['45 TINTERN CLOSE, EASTBOURNE, BN22 0UF', 'BN22 0UF', '45 tintern close, eastbourne, BN22 0UF', 'BN22 0UF']
24
+ ])('if data is returned from the API, it maps the data correctly in lower case, other than postcode', async (address, postcode, expectedAddress, expectedPostcode) => {
25
+ fetch.mockResolvedValue({
26
+ json: () => ({
27
+ results: [{
28
+ address: address,
29
+ postcode: postcode
30
+ }]
31
+ })
32
+ })
33
+ const results = await als()
34
+ expect(results[0]).toEqual(expect.objectContaining({
35
+ address: expectedAddress,
36
+ postcode: expectedPostcode
37
+ }))
38
+ })
16
39
  })
17
40
  })
@@ -38,7 +38,7 @@ export default async (premises, postcode) => {
38
38
  return results
39
39
  ? results.map((r, idx) => ({
40
40
  id: idx,
41
- address: r.address,
41
+ address: `${r.address.replace(r.postcode, '').toLowerCase()}${r.postcode}`,
42
42
  premises: r.premises,
43
43
  street: r.street_address,
44
44
  locality: r.locality,