@ons/design-system 70.0.7 → 70.0.8
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/README.md +11 -17
- package/components/access-code/_macro.spec.js +145 -145
- package/components/access-code/access-code.dom.js +5 -5
- package/components/access-code/access-code.js +16 -16
- package/components/access-code/access-code.scss +22 -22
- package/components/access-code/access-code.spec.js +17 -17
- package/components/accordion/_macro.spec.js +154 -154
- package/components/accordion/accordion.dom.js +10 -10
- package/components/accordion/accordion.js +50 -50
- package/components/accordion/accordion.spec.js +104 -104
- package/components/address-input/_macro.spec.js +420 -420
- package/components/address-input/autosuggest.address.dom.js +5 -5
- package/components/address-input/autosuggest.address.error.js +77 -77
- package/components/address-input/autosuggest.address.js +357 -357
- package/components/address-input/autosuggest.address.setter.js +95 -95
- package/components/address-input/autosuggest.address.spec.js +668 -651
- package/components/address-input/example-address-input-editable.njk +1 -1
- package/components/address-input/example-address-input.njk +1 -1
- package/components/address-output/_address-output.scss +3 -3
- package/components/address-output/_macro.spec.js +84 -84
- package/components/autosuggest/_autosuggest.scss +114 -114
- package/components/autosuggest/_macro.spec.js +255 -255
- package/components/autosuggest/autosuggest.dom.js +5 -5
- package/components/autosuggest/autosuggest.helpers.js +11 -11
- package/components/autosuggest/autosuggest.helpers.spec.js +73 -73
- package/components/autosuggest/autosuggest.js +20 -20
- package/components/autosuggest/autosuggest.spec.js +542 -536
- package/components/autosuggest/autosuggest.ui.js +478 -475
- package/components/autosuggest/fuse-config.js +17 -17
- package/components/back-to-top/_back-to-top.scss +27 -27
- package/components/back-to-top/_macro.spec.js +49 -49
- package/components/back-to-top/back-to-top.dom.js +5 -5
- package/components/back-to-top/back-to-top.js +52 -52
- package/components/back-to-top/back-to-top.spec.js +106 -106
- package/components/back-to-top/example-back-to-top.njk +6 -6
- package/components/breadcrumbs/_breadcrumbs.scss +63 -65
- package/components/breadcrumbs/_macro.spec.js +91 -91
- package/components/browser-banner/_browser-banner.scss +23 -23
- package/components/browser-banner/_macro.spec.js +92 -92
- package/components/button/_button.scss +482 -483
- package/components/button/_macro.spec.js +363 -363
- package/components/button/button.dom.js +15 -15
- package/components/button/button.js +53 -53
- package/components/button/button.spec.js +248 -240
- package/components/call-to-action/_call-to-action.scss +5 -5
- package/components/call-to-action/_macro.spec.js +28 -28
- package/components/card/_card.scss +23 -23
- package/components/card/_macro.spec.js +180 -180
- package/components/char-check-limit/_macro.spec.js +48 -48
- package/components/char-check-limit/character-check.js +58 -58
- package/components/char-check-limit/character-check.spec.js +173 -173
- package/components/char-check-limit/character-limit.js +40 -40
- package/components/checkboxes/_checkbox-macro.spec.js +355 -355
- package/components/checkboxes/_checkbox.scss +180 -180
- package/components/checkboxes/_checkboxes.scss +37 -27
- package/components/checkboxes/_macro.spec.js +261 -261
- package/components/checkboxes/checkbox-with-autoselect.js +32 -32
- package/components/checkboxes/checkbox-with-fieldset.js +21 -21
- package/components/checkboxes/checkboxes-with-reveal.js +10 -10
- package/components/checkboxes/checkboxes.dom.js +27 -27
- package/components/checkboxes/checkboxes.spec.js +183 -183
- package/components/content-pagination/_content-pagination.scss +41 -41
- package/components/content-pagination/_macro.spec.js +159 -159
- package/components/cookies-banner/_cookies-banner.scss +22 -22
- package/components/cookies-banner/_macro.spec.js +177 -177
- package/components/cookies-banner/cookies-banner.dom.js +7 -7
- package/components/cookies-banner/cookies-banner.js +76 -76
- package/components/cookies-banner/cookies-banner.spec.js +72 -68
- package/components/date-input/_macro.spec.js +338 -338
- package/components/description-list/_description-list.scss +23 -23
- package/components/description-list/_macro.spec.js +144 -144
- package/components/details/_details.scss +109 -109
- package/components/details/_macro.spec.js +132 -132
- package/components/details/details.dom.js +6 -6
- package/components/details/details.js +60 -60
- package/components/details/details.spec.js +106 -106
- package/components/document-list/_macro.spec.js +444 -444
- package/components/document-list/document-list.scss +145 -149
- package/components/download-resources/_download-resources.scss +109 -108
- package/components/download-resources/download-resources.js +907 -900
- package/components/download-resources/download-resources.spec.js +461 -461
- package/components/duration/_macro.spec.js +291 -291
- package/components/error/_macro.spec.js +72 -72
- package/components/external-link/_external-link.scss +19 -19
- package/components/external-link/_macro.spec.js +68 -68
- package/components/feedback/_feedback.scss +31 -31
- package/components/feedback/_macro.spec.js +72 -72
- package/components/field/_field-group.scss +10 -10
- package/components/field/_field.scss +16 -16
- package/components/field/_macro.spec.js +80 -80
- package/components/fieldset/_fieldset.scss +27 -27
- package/components/fieldset/_macro.spec.js +161 -161
- package/components/footer/_footer.scss +45 -45
- package/components/footer/_macro.spec.js +452 -452
- package/components/header/_header.scss +202 -202
- package/components/header/_macro.spec.js +833 -829
- package/components/helpers/_grid.scss +4 -4
- package/components/hero/_hero.scss +48 -48
- package/components/hero/_macro.spec.js +59 -59
- package/components/icon/_icon.scss +44 -44
- package/components/icon/_macro.spec.js +110 -110
- package/components/image/_image.scss +11 -11
- package/components/image/_macro.spec.js +81 -81
- package/components/input/_input-type.scss +86 -89
- package/components/input/_input.scss +123 -124
- package/components/input/_macro.spec.js +604 -604
- package/components/input/character-check.dom.js +5 -5
- package/components/input/input.dom.js +5 -5
- package/components/input/input.js +10 -10
- package/components/input/input.spec.js +18 -18
- package/components/label/_label.scss +24 -24
- package/components/label/_macro.spec.js +173 -170
- package/components/language-selector/_macro.spec.js +97 -97
- package/components/language-selector/language.scss +7 -7
- package/components/list/_list.scss +84 -84
- package/components/list/_macro.spec.js +583 -583
- package/components/message/_macro.njk +5 -5
- package/components/message/_macro.spec.js +74 -74
- package/components/message/_message.scss +39 -39
- package/components/message-list/_macro.spec.js +86 -86
- package/components/message-list/_message-list.scss +16 -16
- package/components/modal/_macro.spec.js +69 -69
- package/components/modal/_modal.scss +36 -36
- package/components/modal/modal.dom.js +6 -6
- package/components/modal/modal.js +89 -89
- package/components/modal/modal.spec.js +50 -50
- package/components/mutually-exclusive/_macro.spec.js +140 -140
- package/components/mutually-exclusive/mutually-exclusive.checkboxes.spec.js +188 -188
- package/components/mutually-exclusive/mutually-exclusive.date.spec.js +211 -211
- package/components/mutually-exclusive/mutually-exclusive.dom.js +5 -5
- package/components/mutually-exclusive/mutually-exclusive.duration.spec.js +210 -210
- package/components/mutually-exclusive/mutually-exclusive.email.spec.js +90 -90
- package/components/mutually-exclusive/mutually-exclusive.js +137 -137
- package/components/mutually-exclusive/mutually-exclusive.multiple-options.checkboxes.spec.js +197 -197
- package/components/mutually-exclusive/mutually-exclusive.number.spec.js +96 -96
- package/components/mutually-exclusive/mutually-exclusive.textarea.spec.js +102 -102
- package/components/navigation/_macro.spec.js +360 -354
- package/components/navigation/_navigation.scss +122 -123
- package/components/navigation/navigation.dom.js +35 -35
- package/components/navigation/navigation.js +49 -49
- package/components/navigation/navigation.spec.js +249 -249
- package/components/pagination/_macro.spec.js +342 -335
- package/components/pagination/_pagination.scss +58 -58
- package/components/panel/_macro.spec.js +372 -372
- package/components/panel/_panel.scss +200 -199
- package/components/password/_macro.spec.js +95 -95
- package/components/password/password.dom.js +5 -5
- package/components/password/password.js +10 -10
- package/components/password/password.spec.js +26 -26
- package/components/phase-banner/_macro.spec.js +86 -86
- package/components/phase-banner/_phase-banner.scss +16 -16
- package/components/question/_macro.spec.js +235 -235
- package/components/question/_question.scss +24 -24
- package/components/quote/_macro.spec.js +52 -52
- package/components/quote/_quote.scss +24 -24
- package/components/radios/_macro.spec.js +524 -524
- package/components/radios/_radio.scss +49 -48
- package/components/radios/_radios.scss +14 -20
- package/components/radios/check-radios.js +21 -21
- package/components/radios/clear-radios.js +45 -45
- package/components/radios/radio-with-fieldset.js +22 -22
- package/components/radios/radios.dom.js +32 -32
- package/components/radios/radios.spec.js +251 -251
- package/components/related-content/_macro.spec.js +109 -109
- package/components/related-content/_related-content.scss +12 -12
- package/components/related-content/_section-macro.spec.js +20 -20
- package/components/relationships/_macro.spec.js +94 -94
- package/components/relationships/_relationships.scss +9 -9
- package/components/relationships/relationships.dom.js +5 -5
- package/components/relationships/relationships.js +18 -18
- package/components/relationships/relationships.spec.js +71 -71
- package/components/reply/_macro.spec.js +47 -47
- package/components/reply/reply-input.js +15 -15
- package/components/reply/reply.dom.js +5 -5
- package/components/reply/reply.spec.js +57 -57
- package/components/section-navigation/_macro.spec.js +210 -210
- package/components/section-navigation/_section-navigation.scss +76 -76
- package/components/select/_macro.spec.js +166 -166
- package/components/share-page/_macro.spec.js +68 -68
- package/components/skip-to-content/_macro.spec.js +54 -54
- package/components/skip-to-content/_skip.scss +30 -30
- package/components/skip-to-content/skip-to-content.dom.js +6 -6
- package/components/skip-to-content/skip-to-content.js +7 -7
- package/components/skip-to-content/skip-to-content.spec.js +21 -21
- package/components/status/_macro.spec.js +53 -53
- package/components/status/_status.scss +32 -32
- package/components/summary/_macro.spec.js +551 -535
- package/components/summary/_summary.scss +191 -195
- package/components/table/_macro.spec.js +499 -499
- package/components/table/_table.scss +204 -201
- package/components/table/scrollable-table.dom.js +5 -5
- package/components/table/scrollable-table.js +60 -60
- package/components/table/sortable-table.dom.js +5 -5
- package/components/table/sortable-table.js +135 -135
- package/components/table/table.spec.js +144 -140
- package/components/table-of-contents/_macro.spec.js +125 -125
- package/components/table-of-contents/_toc.scss +9 -9
- package/components/table-of-contents/toc.dom.js +5 -5
- package/components/table-of-contents/toc.js +30 -30
- package/components/table-of-contents/toc.spec.js +88 -88
- package/components/tabs/_macro.spec.js +92 -92
- package/components/tabs/_tabs.scss +120 -115
- package/components/tabs/tabs.dom.js +5 -5
- package/components/tabs/tabs.js +266 -266
- package/components/tabs/tabs.spec.js +268 -268
- package/components/text-indent/_macro.spec.js +33 -33
- package/components/text-indent/_text-indent.scss +3 -3
- package/components/textarea/_macro.spec.js +238 -238
- package/components/textarea/textarea.dom.js +5 -5
- package/components/textarea/textarea.spec.js +78 -74
- package/components/timeline/_macro.spec.js +83 -83
- package/components/timeline/_timeline.scss +26 -26
- package/components/timeout-modal/_macro.spec.js +47 -47
- package/components/timeout-modal/timeout-modal.dom.js +9 -9
- package/components/timeout-modal/timeout-modal.js +66 -66
- package/components/timeout-modal/timeout-modal.spec.js +157 -157
- package/components/timeout-panel/_macro.spec.js +41 -41
- package/components/timeout-panel/timeout-panel.dom.js +8 -8
- package/components/timeout-panel/timeout-panel.spec.js +118 -118
- package/components/upload/_macro.spec.js +52 -52
- package/components/upload/_upload.scss +28 -28
- package/components/video/_macro.spec.js +42 -42
- package/components/video/_video.scss +16 -16
- package/components/video/video.dom.js +5 -5
- package/components/video/video.js +32 -32
- package/components/video/video.spec.js +103 -97
- package/css/main.css +1 -1
- package/favicons/manifest.json +25 -25
- package/js/abortable-fetch.js +23 -23
- package/js/analytics.js +53 -53
- package/js/cookies-functions.js +135 -135
- package/js/cookies-settings.dom.js +7 -7
- package/js/cookies-settings.js +77 -77
- package/js/cookies-settings.spec.js +106 -106
- package/js/domready.js +8 -8
- package/js/fetch.js +14 -14
- package/js/inpagelink.dom.js +5 -5
- package/js/inpagelink.js +19 -19
- package/js/polyfills.js +0 -1
- package/js/print-button.js +6 -6
- package/js/timeout.js +211 -211
- package/layout/_template.njk +5 -7
- package/package.json +131 -128
- package/scss/base/_forms.scss +10 -10
- package/scss/base/_global.scss +45 -44
- package/scss/base/_typography.scss +20 -20
- package/scss/helpers/_functions.scss +18 -15
- package/scss/helpers/_mixins.scss +59 -53
- package/scss/helpers/_mq.scss +62 -65
- package/scss/objects/_container.scss +20 -20
- package/scss/objects/_page.scss +33 -33
- package/scss/objects/_spacing.scss +10 -10
- package/scss/overrides/hcm.scss +237 -237
- package/scss/overrides/rtl.scss +95 -95
- package/scss/print.scss +47 -47
- package/scss/utilities/_border.scss +7 -7
- package/scss/utilities/_colors.scss +6 -6
- package/scss/utilities/_display.scss +8 -8
- package/scss/utilities/_float.scss +7 -7
- package/scss/utilities/_grid.scss +144 -144
- package/scss/utilities/_highlight.scss +4 -4
- package/scss/utilities/_margin.scss +17 -17
- package/scss/utilities/_pad.scss +15 -15
- package/scss/utilities/_typography.scss +35 -33
- package/scss/utilities/_utilities.scss +8 -8
- package/scss/utilities/_visibility.scss +25 -25
- package/scss/vars/_colors.scss +116 -116
- package/scss/vars/_forms.scss +22 -22
- package/scss/vars/_grid.scss +11 -9
- package/scss/vars/_typography.scss +54 -54
|
@@ -2,729 +2,746 @@ import { PuppeteerEndpointFaker } from '../../tests/helpers/puppeteer';
|
|
|
2
2
|
import { renderComponent, setTestPage } from '../../tests/helpers/rendering';
|
|
3
3
|
|
|
4
4
|
const EXAMPLE_ADDRESS_INPUT = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
5
|
+
id: 'address',
|
|
6
|
+
autocomplete: 'off',
|
|
7
|
+
label: {
|
|
8
|
+
text: 'Enter address or postcode and select from results',
|
|
9
|
+
},
|
|
10
|
+
legend: 'What is the address?',
|
|
11
|
+
isEditable: true,
|
|
12
|
+
mandatory: true,
|
|
13
|
+
dontWrap: true,
|
|
14
|
+
instructions: 'Use up and down keys to navigate.',
|
|
15
|
+
ariaYouHaveSelected: 'You have selected',
|
|
16
|
+
ariaMinChars: 'Enter 3 or more characters for suggestions.',
|
|
17
|
+
minChars: 3,
|
|
18
|
+
ariaResultsLabel: 'Country suggestions',
|
|
19
|
+
ariaOneResult: 'There is one suggestion available.',
|
|
20
|
+
ariaNResults: 'There are {n} suggestions available.',
|
|
21
|
+
ariaLimitedResults: 'Type more characters to improve your search',
|
|
22
|
+
ariaGroupedResults: 'There are {n} for {x}',
|
|
23
|
+
groupCount: '{n} addresses',
|
|
24
|
+
moreResults: 'Continue entering to improve suggestions',
|
|
25
|
+
resultsTitle: 'Suggestions',
|
|
26
|
+
resultsTitleId: 'country-of-birth-suggestions',
|
|
27
|
+
noResults: 'No suggestions found.',
|
|
28
|
+
tooManyResults: '{n} results found. Enter more of the address to improve results',
|
|
29
|
+
typeMore: 'Continue entering to get suggestions',
|
|
30
|
+
errorTitle: 'There is a problem with your answer',
|
|
31
|
+
errorMessageEnter: 'Enter an address',
|
|
32
|
+
errorMessageSelect: 'Select an address',
|
|
33
|
+
errorMessageAPI: 'Sorry, there is a problem loading addresses',
|
|
34
|
+
errorMessageAPILinkText: 'Enter address manually',
|
|
35
|
+
options: {
|
|
36
|
+
regionCode: 'gb-eng',
|
|
37
|
+
addressType: 'residential',
|
|
38
|
+
},
|
|
39
|
+
organisation: {
|
|
40
|
+
label: 'Organisation',
|
|
41
|
+
},
|
|
42
|
+
line1: {
|
|
43
|
+
label: 'Address line 1',
|
|
44
|
+
},
|
|
45
|
+
line2: {
|
|
46
|
+
label: 'Address line 2',
|
|
47
|
+
},
|
|
48
|
+
town: {
|
|
49
|
+
label: 'Town or city',
|
|
50
|
+
},
|
|
51
|
+
postcode: {
|
|
52
|
+
label: 'Postcode',
|
|
53
|
+
},
|
|
54
|
+
searchButton: 'Search for an address',
|
|
55
|
+
manualLinkText: 'Manually enter address',
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
const EXAMPLE_ADDRESS_INPUT_WITH_API = {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
...EXAMPLE_ADDRESS_INPUT,
|
|
60
|
+
APIDomain: '/fake/api',
|
|
61
|
+
APIDomainBearerToken: 'someToken',
|
|
62
|
+
externalInitialiser: true,
|
|
63
63
|
};
|
|
64
64
|
|
|
65
65
|
describe('script: address-input', () => {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
],
|
|
74
|
-
{
|
|
75
|
-
data: {
|
|
76
|
-
status: { code: 200 },
|
|
77
|
-
response: {
|
|
78
|
-
addresses: [
|
|
79
|
-
{
|
|
80
|
-
uprn: '100070332099',
|
|
81
|
-
formattedAddress: '196 College Road, Birmingham, B44 8HF',
|
|
82
|
-
addressType: 'PAF',
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
uprn: '100100119969',
|
|
86
|
-
formattedAddress: '196 College Road, Whitchurch, Cardiff, CF14 2NZ',
|
|
87
|
-
addressType: 'PAF',
|
|
88
|
-
},
|
|
89
|
-
],
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
apiFaker.setOverrides(['/addresses/eq?input=cf14%202&limit=10'], {
|
|
96
|
-
data: {
|
|
97
|
-
status: { code: 200 },
|
|
98
|
-
response: {
|
|
99
|
-
partpostcode: 'cf14 2',
|
|
100
|
-
postcodes: [
|
|
101
|
-
{
|
|
102
|
-
postcode: 'CF14 2AA',
|
|
103
|
-
streetName: 'Penlline Road',
|
|
104
|
-
townName: 'Whitchurch',
|
|
105
|
-
addressCount: 41,
|
|
106
|
-
firstUprn: 10002526869,
|
|
107
|
-
postTown: 'Cardiff',
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
postcode: 'CF14 2AB',
|
|
111
|
-
streetName: 'Penlline Road',
|
|
112
|
-
townName: 'Whitchurch',
|
|
113
|
-
addressCount: 1,
|
|
114
|
-
firstUprn: 10002511038,
|
|
115
|
-
postTown: 'Cardiff',
|
|
116
|
-
},
|
|
66
|
+
const apiFaker = new PuppeteerEndpointFaker(EXAMPLE_ADDRESS_INPUT_WITH_API.APIDomain);
|
|
67
|
+
|
|
68
|
+
apiFaker.setOverrides(
|
|
69
|
+
[
|
|
70
|
+
'/addresses/eq?input=196%20colle&limit=10',
|
|
71
|
+
'/addresses/eq?input=cf142&limit=10',
|
|
72
|
+
'/addresses/eq?input=cf14%202nt&limit=100&groupfullpostcodes=combo',
|
|
117
73
|
],
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
apiFaker.setOverrides(['/addresses/eq/uprn/10002511038?addresstype=paf'], {
|
|
141
|
-
data: {
|
|
142
|
-
status: { code: 200 },
|
|
143
|
-
response: {
|
|
144
|
-
address: {
|
|
145
|
-
uprn: '10002511038',
|
|
146
|
-
formattedAddress: '197 College Road, Whitchurch, Cardiff, CF14 2AB',
|
|
147
|
-
addressLine1: '197 College Road',
|
|
148
|
-
addressLine2: 'Whitchurch',
|
|
149
|
-
addressLine3: '',
|
|
150
|
-
townName: 'Cardiff',
|
|
151
|
-
postcode: 'CF14 2AB',
|
|
152
|
-
foundAddressType: 'PAF',
|
|
153
|
-
},
|
|
154
|
-
},
|
|
155
|
-
},
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
apiFaker.setOverrides(
|
|
159
|
-
['/addresses/eq/bucket?postcode=CF14%202AA&streetname=Penlline%20Road&townname=Whitchurch&groupfullpostcodes=combo'],
|
|
160
|
-
{
|
|
161
|
-
data: {
|
|
162
|
-
status: { code: 200 },
|
|
163
|
-
response: {
|
|
164
|
-
addresses: [
|
|
165
|
-
{
|
|
166
|
-
uprn: '10002511038',
|
|
167
|
-
formattedAddress: '197 College Road, Whitchurch, Cardiff, CF14 2AB',
|
|
168
|
-
addressType: 'PAF',
|
|
74
|
+
{
|
|
75
|
+
data: {
|
|
76
|
+
status: { code: 200 },
|
|
77
|
+
response: {
|
|
78
|
+
addresses: [
|
|
79
|
+
{
|
|
80
|
+
uprn: '100070332099',
|
|
81
|
+
formattedAddress: '196 College Road, Birmingham, B44 8HF',
|
|
82
|
+
addressType: 'PAF',
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
uprn: '100100119969',
|
|
86
|
+
formattedAddress: '196 College Road, Whitchurch, Cardiff, CF14 2NZ',
|
|
87
|
+
addressType: 'PAF',
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
},
|
|
169
91
|
},
|
|
170
|
-
],
|
|
171
92
|
},
|
|
172
|
-
|
|
173
|
-
},
|
|
174
|
-
);
|
|
175
|
-
|
|
176
|
-
beforeAll(async () => {
|
|
177
|
-
await apiFaker.setup(page);
|
|
178
|
-
});
|
|
93
|
+
);
|
|
179
94
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
95
|
+
apiFaker.setOverrides(['/addresses/eq?input=cf14%202&limit=10'], {
|
|
96
|
+
data: {
|
|
97
|
+
status: { code: 200 },
|
|
98
|
+
response: {
|
|
99
|
+
partpostcode: 'cf14 2',
|
|
100
|
+
postcodes: [
|
|
101
|
+
{
|
|
102
|
+
postcode: 'CF14 2AA',
|
|
103
|
+
streetName: 'Penlline Road',
|
|
104
|
+
townName: 'Whitchurch',
|
|
105
|
+
addressCount: 41,
|
|
106
|
+
firstUprn: 10002526869,
|
|
107
|
+
postTown: 'Cardiff',
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
postcode: 'CF14 2AB',
|
|
111
|
+
streetName: 'Penlline Road',
|
|
112
|
+
townName: 'Whitchurch',
|
|
113
|
+
addressCount: 1,
|
|
114
|
+
firstUprn: 10002511038,
|
|
115
|
+
postTown: 'Cardiff',
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
},
|
|
119
|
+
},
|
|
190
120
|
});
|
|
191
121
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
122
|
+
apiFaker.setOverrides(['/addresses/eq/uprn/100070332099?addresstype=paf', '/addresses/eq/uprn/100070332099?addresstype=paf&epoch=75'], {
|
|
123
|
+
data: {
|
|
124
|
+
status: { code: 200 },
|
|
125
|
+
response: {
|
|
126
|
+
address: {
|
|
127
|
+
uprn: '100070332099',
|
|
128
|
+
formattedAddress: '196 College Road, Whitchurch, Cardiff, CF14 2NT',
|
|
129
|
+
addressLine1: '196 College Road',
|
|
130
|
+
addressLine2: 'Whitchurch',
|
|
131
|
+
addressLine3: '',
|
|
132
|
+
townName: 'Cardiff',
|
|
133
|
+
postcode: 'CF14 2NT',
|
|
134
|
+
foundAddressType: 'PAF',
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
},
|
|
206
138
|
});
|
|
207
139
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
expect(isManualElementHidden).toBe(false);
|
|
225
|
-
const isSearchElementHidden = await page.$eval('.ons-js-address-input__search', (node) => node.classList.contains('ons-u-d-no'));
|
|
226
|
-
expect(isSearchElementHidden).toBe(true);
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
it('hides the search button', async () => {
|
|
230
|
-
const hassClass = await page.$eval('.ons-js-address-search-btn', (node) => node.classList.contains('ons-u-d-no'));
|
|
231
|
-
expect(hassClass).toBe(true);
|
|
232
|
-
});
|
|
140
|
+
apiFaker.setOverrides(['/addresses/eq/uprn/10002511038?addresstype=paf'], {
|
|
141
|
+
data: {
|
|
142
|
+
status: { code: 200 },
|
|
143
|
+
response: {
|
|
144
|
+
address: {
|
|
145
|
+
uprn: '10002511038',
|
|
146
|
+
formattedAddress: '197 College Road, Whitchurch, Cardiff, CF14 2AB',
|
|
147
|
+
addressLine1: '197 College Road',
|
|
148
|
+
addressLine2: 'Whitchurch',
|
|
149
|
+
addressLine3: '',
|
|
150
|
+
townName: 'Cardiff',
|
|
151
|
+
postcode: 'CF14 2AB',
|
|
152
|
+
foundAddressType: 'PAF',
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
},
|
|
233
156
|
});
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
describe('When the user inputs', () => {
|
|
237
|
-
it('navigates to the first suggestion with the "Down" arrow key', async () => {
|
|
238
|
-
await setTestPage('/test', renderComponent('address-input', EXAMPLE_ADDRESS_INPUT_WITH_API));
|
|
239
157
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
158
|
+
apiFaker.setOverrides(
|
|
159
|
+
['/addresses/eq/bucket?postcode=CF14%202AA&streetname=Penlline%20Road&townname=Whitchurch&groupfullpostcodes=combo'],
|
|
160
|
+
{
|
|
161
|
+
data: {
|
|
162
|
+
status: { code: 200 },
|
|
163
|
+
response: {
|
|
164
|
+
addresses: [
|
|
165
|
+
{
|
|
166
|
+
uprn: '10002511038',
|
|
167
|
+
formattedAddress: '197 College Road, Whitchurch, Cardiff, CF14 2AB',
|
|
168
|
+
addressType: 'PAF',
|
|
169
|
+
},
|
|
170
|
+
],
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
);
|
|
243
175
|
|
|
244
|
-
|
|
245
|
-
|
|
176
|
+
beforeAll(async () => {
|
|
177
|
+
await apiFaker.setup(page);
|
|
246
178
|
});
|
|
247
179
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
await page.$eval('.ons-js-autosuggest-input', (node) => (node.value = '196 coll'));
|
|
252
|
-
await page.type('.ons-js-autosuggest-input', 'e');
|
|
253
|
-
|
|
254
|
-
expect(apiFaker.getRequestCount('/addresses/eq?input=196%20colle&limit=10')).toBe(1);
|
|
180
|
+
beforeEach(async () => {
|
|
181
|
+
await apiFaker.reset();
|
|
255
182
|
});
|
|
256
183
|
|
|
257
|
-
describe('
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
await page.$eval('.ons-js-autosuggest-input', (node) => (node.value = 'CF14 2N'));
|
|
262
|
-
await page.type('.ons-js-autosuggest-input', 'T');
|
|
263
|
-
});
|
|
184
|
+
describe('When the component initializes', () => {
|
|
185
|
+
it('checks api status by trying a request', async () => {
|
|
186
|
+
await setTestPage('/test', renderComponent('address-input', EXAMPLE_ADDRESS_INPUT_WITH_API));
|
|
187
|
+
await page.waitForTimeout(50);
|
|
264
188
|
|
|
265
|
-
|
|
266
|
-
expect(apiFaker.getRequestCount('/addresses/eq?input=cf14%202nt&limit=100&groupfullpostcodes=combo')).toBe(1);
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
it('has expected suggestion entries', async () => {
|
|
270
|
-
const suggestions = await page.$$eval('.ons-autosuggest__option', (nodes) => nodes.map((node) => node.textContent.trim()));
|
|
271
|
-
expect(suggestions).toEqual(['196 College Road, Birmingham, B44 8HF', '196 College Road, Whitchurch, Cardiff, CF14 2NZ']);
|
|
272
|
-
});
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
describe('when the query not a partial postcode', () => {
|
|
276
|
-
beforeEach(async () => {
|
|
277
|
-
apiFaker.setTemporaryOverride(
|
|
278
|
-
'/addresses/eq?input=penlline%20road%20whitchurch%20cardiff%20cf14%202nz&limit=100&groupfullpostcodes=combo',
|
|
279
|
-
{
|
|
280
|
-
data: {
|
|
281
|
-
status: { code: 200 },
|
|
282
|
-
response: {
|
|
283
|
-
addresses: [
|
|
284
|
-
{
|
|
285
|
-
uprn: '100070332099',
|
|
286
|
-
formattedAddress: '1 Penlline Road, Whitchurch, Cardiff, CF14 2NZ',
|
|
287
|
-
addressType: 'PAF',
|
|
288
|
-
},
|
|
289
|
-
{
|
|
290
|
-
uprn: '100100119979',
|
|
291
|
-
formattedAddress: '2 Penlline Road, Whitchurch, Cardiff, CF14 2NZ',
|
|
292
|
-
addressType: 'PAF',
|
|
293
|
-
},
|
|
294
|
-
],
|
|
295
|
-
},
|
|
296
|
-
},
|
|
297
|
-
},
|
|
298
|
-
);
|
|
299
|
-
|
|
300
|
-
await setTestPage('/test', renderComponent('address-input', EXAMPLE_ADDRESS_INPUT_WITH_API));
|
|
301
|
-
|
|
302
|
-
await page.$eval('.ons-js-autosuggest-input', (node) => (node.value = 'Penlline Road, Whitchurch, Cardiff, CF14 2N'));
|
|
303
|
-
await page.type('.ons-js-autosuggest-input', 'Z');
|
|
304
|
-
await page.waitForTimeout(100);
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
it('provides expected parameters to the address API', async () => {
|
|
308
|
-
expect(
|
|
309
|
-
apiFaker.getRequestCount(
|
|
310
|
-
'/addresses/eq?input=penlline%20road%20whitchurch%20cardiff%20cf14%202nz&limit=100&groupfullpostcodes=combo',
|
|
311
|
-
),
|
|
312
|
-
).toBe(1);
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
it('has expected suggestion entries', async () => {
|
|
316
|
-
const suggestions = await page.$$eval('.ons-autosuggest__option', (nodes) => nodes.map((node) => node.textContent.trim()));
|
|
317
|
-
expect(suggestions).toEqual(['1 Penlline Road, Whitchurch, Cardiff, CF14 2NZ', '2 Penlline Road, Whitchurch, Cardiff, CF14 2NZ']);
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
describe('when a suggestion is selected', () => {
|
|
321
|
-
beforeEach(async () => {
|
|
322
|
-
await page.keyboard.press('ArrowDown');
|
|
323
|
-
await page.keyboard.press('Enter');
|
|
324
|
-
await page.waitForTimeout(100);
|
|
189
|
+
expect(apiFaker.getRequestCount('/addresses/eq?input=cf142&limit=10')).toBe(1);
|
|
325
190
|
});
|
|
326
191
|
|
|
327
|
-
|
|
328
|
-
|
|
192
|
+
describe('when api status is okay', () => {
|
|
193
|
+
beforeEach(async () => {
|
|
194
|
+
await setTestPage('/test', renderComponent('address-input', EXAMPLE_ADDRESS_INPUT_WITH_API));
|
|
195
|
+
await page.waitForTimeout(50);
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
it('does not switch to manual input', async () => {
|
|
199
|
+
const isManualElementHidden = await page.$eval('.ons-js-address-input__manual', (node) =>
|
|
200
|
+
node.classList.contains('ons-u-db-no-js_enabled'),
|
|
201
|
+
);
|
|
202
|
+
expect(isManualElementHidden).toBe(true);
|
|
203
|
+
const isSearchElementHidden = await page.$eval('.ons-js-address-input__search', (node) =>
|
|
204
|
+
node.classList.contains('ons-u-d-no'),
|
|
205
|
+
);
|
|
206
|
+
expect(isSearchElementHidden).toBe(false);
|
|
207
|
+
});
|
|
329
208
|
});
|
|
330
209
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
210
|
+
describe('when api status is not okay', () => {
|
|
211
|
+
beforeEach(async () => {
|
|
212
|
+
apiFaker.setTemporaryOverride('/addresses/eq?input=cf142&limit=10', {
|
|
213
|
+
data: {
|
|
214
|
+
status: { code: 401 },
|
|
215
|
+
},
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
await setTestPage('/test', renderComponent('address-input', EXAMPLE_ADDRESS_INPUT_WITH_API));
|
|
219
|
+
await page.waitForTimeout(50);
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
it('switches to manual input', async () => {
|
|
223
|
+
const isManualElementHidden = await page.$eval('.ons-js-address-input__manual', (node) =>
|
|
224
|
+
node.classList.contains('ons-u-db-no-js_enabled'),
|
|
225
|
+
);
|
|
226
|
+
expect(isManualElementHidden).toBe(false);
|
|
227
|
+
const isSearchElementHidden = await page.$eval('.ons-js-address-input__search', (node) =>
|
|
228
|
+
node.classList.contains('ons-u-d-no'),
|
|
229
|
+
);
|
|
230
|
+
expect(isSearchElementHidden).toBe(true);
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
it('hides the search button', async () => {
|
|
234
|
+
const hassClass = await page.$eval('.ons-js-address-search-btn', (node) => node.classList.contains('ons-u-d-no'));
|
|
235
|
+
expect(hassClass).toBe(true);
|
|
236
|
+
});
|
|
338
237
|
});
|
|
339
|
-
});
|
|
340
238
|
});
|
|
341
239
|
|
|
342
|
-
describe('
|
|
343
|
-
|
|
344
|
-
|
|
240
|
+
describe('When the user inputs', () => {
|
|
241
|
+
it('navigates to the first suggestion with the "Down" arrow key', async () => {
|
|
242
|
+
await setTestPage('/test', renderComponent('address-input', EXAMPLE_ADDRESS_INPUT_WITH_API));
|
|
345
243
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
});
|
|
350
|
-
|
|
351
|
-
it('provides expected parameters to the address API', async () => {
|
|
352
|
-
expect(apiFaker.getRequestCount('/addresses/eq?input=cf14%202&limit=10')).toBe(1);
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
it('has expected suggestion entries', async () => {
|
|
356
|
-
const suggestions = await page.$$eval('.ons-autosuggest__option', (nodes) => nodes.map((node) => node.textContent.trim()));
|
|
357
|
-
expect(suggestions).toEqual([
|
|
358
|
-
'Penlline Road, Whitchurch, Cardiff, CF14 2AA (41 addresses)',
|
|
359
|
-
'197 College Road, Whitchurch, Cardiff, CF14 2AB',
|
|
360
|
-
]);
|
|
361
|
-
});
|
|
362
|
-
|
|
363
|
-
describe('when a suggestion is selected', () => {
|
|
364
|
-
beforeEach(async () => {
|
|
365
|
-
await page.keyboard.press('ArrowDown');
|
|
366
|
-
await page.keyboard.press('Enter');
|
|
367
|
-
await page.waitForTimeout(200);
|
|
368
|
-
});
|
|
244
|
+
await page.$eval('.ons-js-autosuggest-input', (node) => (node.value = 'CF14'));
|
|
245
|
+
await page.type('.ons-js-autosuggest-input', '2', { delay: 20 });
|
|
246
|
+
await page.keyboard.press('ArrowDown');
|
|
369
247
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
apiFaker.getRequestCount(
|
|
373
|
-
'/addresses/eq/bucket?postcode=CF14%202AA&streetname=Penlline%20Road&townname=Whitchurch&groupfullpostcodes=combo',
|
|
374
|
-
),
|
|
375
|
-
).toBe(1);
|
|
248
|
+
const selectedOption = await page.$eval('.ons-autosuggest__option--focused', (node) => node.textContent);
|
|
249
|
+
expect(selectedOption.trim()).toBe('196 College Road, Birmingham, B44 8HF');
|
|
376
250
|
});
|
|
377
251
|
|
|
378
|
-
it('
|
|
379
|
-
|
|
380
|
-
expect(suggestions).toEqual(['197 College Road, Whitchurch, Cardiff, CF14 2AB']);
|
|
381
|
-
});
|
|
252
|
+
it('provides expected parameters to the address API', async () => {
|
|
253
|
+
await setTestPage('/test', renderComponent('address-input', EXAMPLE_ADDRESS_INPUT_WITH_API));
|
|
382
254
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
await page.keyboard.press('ArrowDown');
|
|
386
|
-
await page.keyboard.press('Enter');
|
|
387
|
-
await page.waitForTimeout(200);
|
|
388
|
-
});
|
|
389
|
-
|
|
390
|
-
it('populates manual input fields with address from selection', async () => {
|
|
391
|
-
expect(await page.$eval('.ons-js-address-organisation', (node) => node.value)).toBe('');
|
|
392
|
-
expect(await page.$eval('.ons-js-address-line1', (node) => node.value)).toBe('197 College Road');
|
|
393
|
-
expect(await page.$eval('.ons-js-address-line2', (node) => node.value)).toBe('Whitchurch');
|
|
394
|
-
expect(await page.$eval('.ons-js-address-town', (node) => node.value)).toBe('Cardiff');
|
|
395
|
-
expect(await page.$eval('.ons-js-address-postcode', (node) => node.value)).toBe('CF14 2AB');
|
|
396
|
-
expect(await page.$eval('.ons-js-hidden-uprn', (node) => node.value)).toBe('10002511038');
|
|
397
|
-
});
|
|
398
|
-
});
|
|
399
|
-
});
|
|
400
|
-
});
|
|
401
|
-
|
|
402
|
-
describe('when there is an error retrieving the address', () => {
|
|
403
|
-
it('switches to manual mode and hides search button', async () => {
|
|
404
|
-
apiFaker.setTemporaryOverride('/addresses/eq?input=cf142&limit=10', {
|
|
405
|
-
data: {
|
|
406
|
-
status: { code: 200 },
|
|
407
|
-
response: {
|
|
408
|
-
addresses: [
|
|
409
|
-
{
|
|
410
|
-
uprn: 'bad',
|
|
411
|
-
formattedAddress: '196 College Road, Birmingham, B44 8HF',
|
|
412
|
-
addressType: 'PAF',
|
|
413
|
-
},
|
|
414
|
-
],
|
|
415
|
-
},
|
|
416
|
-
},
|
|
417
|
-
});
|
|
255
|
+
await page.$eval('.ons-js-autosuggest-input', (node) => (node.value = '196 coll'));
|
|
256
|
+
await page.type('.ons-js-autosuggest-input', 'e');
|
|
418
257
|
|
|
419
|
-
|
|
420
|
-
data: {
|
|
421
|
-
status: { code: 400 },
|
|
422
|
-
},
|
|
258
|
+
expect(apiFaker.getRequestCount('/addresses/eq?input=196%20colle&limit=10')).toBe(1);
|
|
423
259
|
});
|
|
424
260
|
|
|
425
|
-
|
|
261
|
+
describe('when the value is a full postcode', () => {
|
|
262
|
+
beforeEach(async () => {
|
|
263
|
+
await setTestPage('/test', renderComponent('address-input', EXAMPLE_ADDRESS_INPUT_WITH_API));
|
|
426
264
|
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
await page.keyboard.press('Enter');
|
|
431
|
-
await page.waitForTimeout(100);
|
|
265
|
+
await page.$eval('.ons-js-autosuggest-input', (node) => (node.value = 'CF14 2N'));
|
|
266
|
+
await page.type('.ons-js-autosuggest-input', 'T');
|
|
267
|
+
});
|
|
432
268
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
expect(isManualElementHidden).toBe(false);
|
|
269
|
+
it('provides expected parameters to the address API where `limit` is 100', async () => {
|
|
270
|
+
expect(apiFaker.getRequestCount('/addresses/eq?input=cf14%202nt&limit=100&groupfullpostcodes=combo')).toBe(1);
|
|
271
|
+
});
|
|
437
272
|
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
});
|
|
444
|
-
});
|
|
273
|
+
it('has expected suggestion entries', async () => {
|
|
274
|
+
const suggestions = await page.$$eval('.ons-autosuggest__option', (nodes) => nodes.map((node) => node.textContent.trim()));
|
|
275
|
+
expect(suggestions).toEqual(['196 College Road, Birmingham, B44 8HF', '196 College Road, Whitchurch, Cardiff, CF14 2NZ']);
|
|
276
|
+
});
|
|
277
|
+
});
|
|
445
278
|
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
279
|
+
describe('when the query not a partial postcode', () => {
|
|
280
|
+
beforeEach(async () => {
|
|
281
|
+
apiFaker.setTemporaryOverride(
|
|
282
|
+
'/addresses/eq?input=penlline%20road%20whitchurch%20cardiff%20cf14%202nz&limit=100&groupfullpostcodes=combo',
|
|
283
|
+
{
|
|
284
|
+
data: {
|
|
285
|
+
status: { code: 200 },
|
|
286
|
+
response: {
|
|
287
|
+
addresses: [
|
|
288
|
+
{
|
|
289
|
+
uprn: '100070332099',
|
|
290
|
+
formattedAddress: '1 Penlline Road, Whitchurch, Cardiff, CF14 2NZ',
|
|
291
|
+
addressType: 'PAF',
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
uprn: '100100119979',
|
|
295
|
+
formattedAddress: '2 Penlline Road, Whitchurch, Cardiff, CF14 2NZ',
|
|
296
|
+
addressType: 'PAF',
|
|
297
|
+
},
|
|
298
|
+
],
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
|
+
},
|
|
302
|
+
);
|
|
303
|
+
|
|
304
|
+
await setTestPage('/test', renderComponent('address-input', EXAMPLE_ADDRESS_INPUT_WITH_API));
|
|
305
|
+
|
|
306
|
+
await page.$eval('.ons-js-autosuggest-input', (node) => (node.value = 'Penlline Road, Whitchurch, Cardiff, CF14 2N'));
|
|
307
|
+
await page.type('.ons-js-autosuggest-input', 'Z');
|
|
308
|
+
await page.waitForTimeout(100);
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
it('provides expected parameters to the address API', async () => {
|
|
312
|
+
expect(
|
|
313
|
+
apiFaker.getRequestCount(
|
|
314
|
+
'/addresses/eq?input=penlline%20road%20whitchurch%20cardiff%20cf14%202nz&limit=100&groupfullpostcodes=combo',
|
|
315
|
+
),
|
|
316
|
+
).toBe(1);
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
it('has expected suggestion entries', async () => {
|
|
320
|
+
const suggestions = await page.$$eval('.ons-autosuggest__option', (nodes) => nodes.map((node) => node.textContent.trim()));
|
|
321
|
+
expect(suggestions).toEqual([
|
|
322
|
+
'1 Penlline Road, Whitchurch, Cardiff, CF14 2NZ',
|
|
323
|
+
'2 Penlline Road, Whitchurch, Cardiff, CF14 2NZ',
|
|
324
|
+
]);
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
describe('when a suggestion is selected', () => {
|
|
328
|
+
beforeEach(async () => {
|
|
329
|
+
await page.keyboard.press('ArrowDown');
|
|
330
|
+
await page.keyboard.press('Enter');
|
|
331
|
+
await page.waitForTimeout(100);
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
it('makes expected request when a suggestion is selected', async () => {
|
|
335
|
+
expect(apiFaker.getRequestCount('/addresses/eq/uprn/100070332099?addresstype=paf')).toBe(1);
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
it('populates manual input fields with address from selection', async () => {
|
|
339
|
+
expect(await page.$eval('.ons-js-address-organisation', (node) => node.value)).toBe('');
|
|
340
|
+
expect(await page.$eval('.ons-js-address-line1', (node) => node.value)).toBe('196 College Road');
|
|
341
|
+
expect(await page.$eval('.ons-js-address-line2', (node) => node.value)).toBe('Whitchurch');
|
|
342
|
+
expect(await page.$eval('.ons-js-address-town', (node) => node.value)).toBe('Cardiff');
|
|
343
|
+
expect(await page.$eval('.ons-js-address-postcode', (node) => node.value)).toBe('CF14 2NT');
|
|
344
|
+
expect(await page.$eval('.ons-js-hidden-uprn', (node) => node.value)).toBe('100070332099');
|
|
345
|
+
});
|
|
346
|
+
});
|
|
480
347
|
});
|
|
481
|
-
});
|
|
482
348
|
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
349
|
+
describe('when the query is a partial postcode', () => {
|
|
350
|
+
beforeEach(async () => {
|
|
351
|
+
await setTestPage('/test', renderComponent('address-input', EXAMPLE_ADDRESS_INPUT_WITH_API));
|
|
352
|
+
|
|
353
|
+
await page.$eval('.ons-js-autosuggest-input', (node) => (node.value = 'CF14 '));
|
|
354
|
+
await page.type('.ons-js-autosuggest-input', '2');
|
|
355
|
+
await page.waitForTimeout(200);
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
it('provides expected parameters to the address API', async () => {
|
|
359
|
+
expect(apiFaker.getRequestCount('/addresses/eq?input=cf14%202&limit=10')).toBe(1);
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
it('has expected suggestion entries', async () => {
|
|
363
|
+
const suggestions = await page.$$eval('.ons-autosuggest__option', (nodes) => nodes.map((node) => node.textContent.trim()));
|
|
364
|
+
expect(suggestions).toEqual([
|
|
365
|
+
'Penlline Road, Whitchurch, Cardiff, CF14 2AA (41 addresses)',
|
|
366
|
+
'197 College Road, Whitchurch, Cardiff, CF14 2AB',
|
|
367
|
+
]);
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
describe('when a suggestion is selected', () => {
|
|
371
|
+
beforeEach(async () => {
|
|
372
|
+
await page.keyboard.press('ArrowDown');
|
|
373
|
+
await page.keyboard.press('Enter');
|
|
374
|
+
await page.waitForTimeout(200);
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
it('makes expected request', async () => {
|
|
378
|
+
expect(
|
|
379
|
+
apiFaker.getRequestCount(
|
|
380
|
+
'/addresses/eq/bucket?postcode=CF14%202AA&streetname=Penlline%20Road&townname=Whitchurch&groupfullpostcodes=combo',
|
|
381
|
+
),
|
|
382
|
+
).toBe(1);
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
it('has expected suggestion entries', async () => {
|
|
386
|
+
const suggestions = await page.$$eval('.ons-autosuggest__option', (nodes) =>
|
|
387
|
+
nodes.map((node) => node.textContent.trim()),
|
|
388
|
+
);
|
|
389
|
+
expect(suggestions).toEqual(['197 College Road, Whitchurch, Cardiff, CF14 2AB']);
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
describe('when an inner suggestion is selected', () => {
|
|
393
|
+
beforeEach(async () => {
|
|
394
|
+
await page.keyboard.press('ArrowDown');
|
|
395
|
+
await page.keyboard.press('Enter');
|
|
396
|
+
await page.waitForTimeout(200);
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
it('populates manual input fields with address from selection', async () => {
|
|
400
|
+
expect(await page.$eval('.ons-js-address-organisation', (node) => node.value)).toBe('');
|
|
401
|
+
expect(await page.$eval('.ons-js-address-line1', (node) => node.value)).toBe('197 College Road');
|
|
402
|
+
expect(await page.$eval('.ons-js-address-line2', (node) => node.value)).toBe('Whitchurch');
|
|
403
|
+
expect(await page.$eval('.ons-js-address-town', (node) => node.value)).toBe('Cardiff');
|
|
404
|
+
expect(await page.$eval('.ons-js-address-postcode', (node) => node.value)).toBe('CF14 2AB');
|
|
405
|
+
expect(await page.$eval('.ons-js-hidden-uprn', (node) => node.value)).toBe('10002511038');
|
|
406
|
+
});
|
|
407
|
+
});
|
|
408
|
+
});
|
|
505
409
|
});
|
|
506
410
|
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
411
|
+
describe('when there is an error retrieving the address', () => {
|
|
412
|
+
it('switches to manual mode and hides search button', async () => {
|
|
413
|
+
apiFaker.setTemporaryOverride('/addresses/eq?input=cf142&limit=10', {
|
|
414
|
+
data: {
|
|
415
|
+
status: { code: 200 },
|
|
416
|
+
response: {
|
|
417
|
+
addresses: [
|
|
418
|
+
{
|
|
419
|
+
uprn: 'bad',
|
|
420
|
+
formattedAddress: '196 College Road, Birmingham, B44 8HF',
|
|
421
|
+
addressType: 'PAF',
|
|
422
|
+
},
|
|
423
|
+
],
|
|
424
|
+
},
|
|
425
|
+
},
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
apiFaker.setTemporaryOverride('/addresses/eq/uprn/bad?addresstype=paf', {
|
|
429
|
+
data: {
|
|
430
|
+
status: { code: 400 },
|
|
431
|
+
},
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
await setTestPage('/test', renderComponent('address-input', EXAMPLE_ADDRESS_INPUT_WITH_API));
|
|
435
|
+
|
|
436
|
+
await page.$eval('.ons-js-autosuggest-input', (node) => (node.value = 'cf14'));
|
|
437
|
+
await page.type('.ons-js-autosuggest-input', '2', { delay: 20 });
|
|
438
|
+
await page.keyboard.press('ArrowDown');
|
|
439
|
+
await page.keyboard.press('Enter');
|
|
440
|
+
await page.waitForTimeout(100);
|
|
441
|
+
|
|
442
|
+
const isManualElementHidden = await page.$eval('.ons-js-address-input__manual', (node) =>
|
|
443
|
+
node.classList.contains('ons-u-db-no-js_enabled'),
|
|
444
|
+
);
|
|
445
|
+
expect(isManualElementHidden).toBe(false);
|
|
446
|
+
|
|
447
|
+
const isSearchElementHidden = await page.$eval('.ons-js-address-input__search', (node) =>
|
|
448
|
+
node.classList.contains('ons-u-d-no'),
|
|
449
|
+
);
|
|
450
|
+
expect(isSearchElementHidden).toBe(true);
|
|
451
|
+
|
|
452
|
+
const isSearchButtonElementHidden = await page.$eval('.ons-js-address-search-btn', (node) =>
|
|
453
|
+
node.classList.contains('ons-u-d-no'),
|
|
454
|
+
);
|
|
455
|
+
expect(isSearchButtonElementHidden).toBe(true);
|
|
456
|
+
});
|
|
510
457
|
});
|
|
511
458
|
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
459
|
+
describe('when the form is submitted', () => {
|
|
460
|
+
describe('when the selected address is manually changed', () => {
|
|
461
|
+
it('clears the urpn field', async () => {
|
|
462
|
+
await setTestPage(
|
|
463
|
+
'/test',
|
|
464
|
+
`
|
|
465
|
+
<form action="/test/fake/form-handler" method="post">
|
|
466
|
+
${renderComponent('address-input', EXAMPLE_ADDRESS_INPUT_WITH_API)}
|
|
467
|
+
<button type="submit">Submit</button>
|
|
468
|
+
</form>
|
|
469
|
+
`,
|
|
470
|
+
);
|
|
471
|
+
|
|
472
|
+
await page.$eval('form', (node) =>
|
|
473
|
+
node.addEventListener('submit', (event) => {
|
|
474
|
+
event.preventDefault();
|
|
475
|
+
return false;
|
|
476
|
+
}),
|
|
477
|
+
);
|
|
478
|
+
|
|
479
|
+
await page.$eval('.ons-js-autosuggest-input', (node) => (node.value = 'CF14 2N'));
|
|
480
|
+
await page.type('.ons-js-autosuggest-input', 'T', { delay: 20 });
|
|
481
|
+
await page.keyboard.press('ArrowDown');
|
|
482
|
+
await page.keyboard.press('Enter');
|
|
483
|
+
await page.waitForTimeout(100);
|
|
484
|
+
|
|
485
|
+
const urpnValueBefore = await page.$eval('.ons-js-hidden-uprn', (node) => node.value);
|
|
486
|
+
expect(urpnValueBefore).toBe('100070332099');
|
|
487
|
+
|
|
488
|
+
await page.$eval('.ons-js-address-line1', (node) => (node.value = 'Something else'));
|
|
489
|
+
await page.click('button[type=submit]');
|
|
490
|
+
|
|
491
|
+
const urpnValueAfter = await page.$eval('.ons-js-hidden-uprn', (node) => node.value);
|
|
492
|
+
expect(urpnValueAfter).toBe('');
|
|
493
|
+
});
|
|
494
|
+
});
|
|
495
|
+
|
|
496
|
+
describe('when the submit is invalid', () => {
|
|
497
|
+
beforeEach(async () => {
|
|
498
|
+
await setTestPage(
|
|
499
|
+
'/test',
|
|
500
|
+
`
|
|
501
|
+
<div class="ons-question">
|
|
502
|
+
<form action="/test/fake/form-handler" method="post">
|
|
503
|
+
${renderComponent('address-input', EXAMPLE_ADDRESS_INPUT_WITH_API)}
|
|
504
|
+
<button type="submit">Submit</button>
|
|
505
|
+
</form>
|
|
506
|
+
</div>
|
|
507
|
+
`,
|
|
508
|
+
);
|
|
509
|
+
|
|
510
|
+
await page.$eval('form', (node) =>
|
|
511
|
+
node.addEventListener('submit', (event) => {
|
|
512
|
+
event.preventDefault();
|
|
513
|
+
return false;
|
|
514
|
+
}),
|
|
515
|
+
);
|
|
516
|
+
|
|
517
|
+
await page.click('button[type=submit]');
|
|
518
|
+
});
|
|
519
|
+
|
|
520
|
+
it('then an error summary panel should be added to the DOM', async () => {
|
|
521
|
+
const panelExists = await page.$$eval('.ons-js-autosuggest-error-panel', (nodes) => nodes.length === 1);
|
|
522
|
+
expect(panelExists).toBe(true);
|
|
523
|
+
});
|
|
524
|
+
|
|
525
|
+
it('then input should be wrapped in an error', async () => {
|
|
526
|
+
const inputIsError = await page.$$eval('#autosuggest-input-error', (nodes) => nodes.length === 1);
|
|
527
|
+
expect(inputIsError).toBe(true);
|
|
528
|
+
});
|
|
529
|
+
|
|
530
|
+
describe('when the mode is set to manual', () => {
|
|
531
|
+
it('then the error summary should be removed', async () => {
|
|
532
|
+
await page.click('.ons-js-address-manual-btn');
|
|
533
|
+
|
|
534
|
+
const panelExists = await page.$$eval('.ons-js-autosuggest-error-panel', (nodes) => nodes.length === 1);
|
|
535
|
+
expect(panelExists).toBe(false);
|
|
536
|
+
});
|
|
537
|
+
});
|
|
538
|
+
});
|
|
515
539
|
});
|
|
540
|
+
});
|
|
516
541
|
|
|
517
|
-
|
|
518
|
-
|
|
542
|
+
describe('When the manual link is clicked', () => {
|
|
543
|
+
beforeEach(async () => {
|
|
544
|
+
await setTestPage('/test', renderComponent('address-input', EXAMPLE_ADDRESS_INPUT_WITH_API));
|
|
519
545
|
await page.click('.ons-js-address-manual-btn');
|
|
546
|
+
});
|
|
520
547
|
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
548
|
+
it('shows manual input fields', async () => {
|
|
549
|
+
const isManualElementHidden = await page.$eval('.ons-js-address-input__manual', (node) =>
|
|
550
|
+
node.classList.contains('ons-u-db-no-js_enabled'),
|
|
551
|
+
);
|
|
552
|
+
expect(isManualElementHidden).toBe(false);
|
|
553
|
+
const isSearchElementHidden = await page.$eval('.ons-js-address-input__search', (node) =>
|
|
554
|
+
node.classList.contains('ons-u-d-no'),
|
|
555
|
+
);
|
|
556
|
+
expect(isSearchElementHidden).toBe(true);
|
|
524
557
|
});
|
|
525
|
-
});
|
|
526
|
-
});
|
|
527
|
-
});
|
|
528
558
|
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
});
|
|
559
|
+
it('clears autosuggest input', async () => {
|
|
560
|
+
const value = await page.$eval('.ons-js-autosuggest-input', (node) => node.value);
|
|
561
|
+
expect(value).toBe('');
|
|
562
|
+
});
|
|
534
563
|
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
564
|
+
describe('and then the search link is clicked', () => {
|
|
565
|
+
beforeEach(async () => {
|
|
566
|
+
await page.$eval('.ons-js-address-organisation', (node) => (node.value = 'Test organisation'));
|
|
567
|
+
await page.$eval('.ons-js-address-line1', (node) => (node.value = 'Test address line 1'));
|
|
568
|
+
await page.$eval('.ons-js-address-line2', (node) => (node.value = 'Test address line 2'));
|
|
569
|
+
await page.$eval('.ons-js-address-town', (node) => (node.value = 'Test town'));
|
|
570
|
+
await page.$eval('.ons-js-address-postcode', (node) => (node.value = 'PO37 60DE'));
|
|
571
|
+
await page.$eval('.ons-js-hidden-uprn', (node) => (node.value = '100070332099'));
|
|
572
|
+
|
|
573
|
+
await page.click('.ons-js-address-search-btn');
|
|
574
|
+
});
|
|
575
|
+
|
|
576
|
+
it('hides manual input fields', async () => {
|
|
577
|
+
const isManualElementHidden = await page.$eval('.ons-js-address-input__manual', (node) =>
|
|
578
|
+
node.classList.contains('ons-u-db-no-js_enabled'),
|
|
579
|
+
);
|
|
580
|
+
expect(isManualElementHidden).toBe(true);
|
|
581
|
+
const isSearchElementHidden = await page.$eval('.ons-js-address-input__search', (node) =>
|
|
582
|
+
node.classList.contains('ons-u-d-no'),
|
|
583
|
+
);
|
|
584
|
+
expect(isSearchElementHidden).toBe(false);
|
|
585
|
+
});
|
|
586
|
+
|
|
587
|
+
it('clears manual input fields', async () => {
|
|
588
|
+
expect(await page.$eval('.ons-js-address-organisation', (node) => node.value)).toBe('');
|
|
589
|
+
expect(await page.$eval('.ons-js-address-line1', (node) => node.value)).toBe('');
|
|
590
|
+
expect(await page.$eval('.ons-js-address-line2', (node) => node.value)).toBe('');
|
|
591
|
+
expect(await page.$eval('.ons-js-address-town', (node) => node.value)).toBe('');
|
|
592
|
+
expect(await page.$eval('.ons-js-address-postcode', (node) => node.value)).toBe('');
|
|
593
|
+
expect(await page.$eval('.ons-js-hidden-uprn', (node) => node.value)).toBe('');
|
|
594
|
+
});
|
|
595
|
+
});
|
|
542
596
|
});
|
|
543
597
|
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
598
|
+
describe('When the language is Welsh', () => {
|
|
599
|
+
beforeEach(async () => {
|
|
600
|
+
await setTestPage('/test', renderComponent('address-input', EXAMPLE_ADDRESS_INPUT_WITH_API));
|
|
601
|
+
await page.evaluate(() => document.documentElement.setAttribute('lang', 'cy'));
|
|
602
|
+
});
|
|
548
603
|
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
await page.$eval('.ons-js-address-line1', (node) => (node.value = 'Test address line 1'));
|
|
553
|
-
await page.$eval('.ons-js-address-line2', (node) => (node.value = 'Test address line 2'));
|
|
554
|
-
await page.$eval('.ons-js-address-town', (node) => (node.value = 'Test town'));
|
|
555
|
-
await page.$eval('.ons-js-address-postcode', (node) => (node.value = 'PO37 60DE'));
|
|
556
|
-
await page.$eval('.ons-js-hidden-uprn', (node) => (node.value = '100070332099'));
|
|
557
|
-
|
|
558
|
-
await page.click('.ons-js-address-search-btn');
|
|
559
|
-
});
|
|
560
|
-
|
|
561
|
-
it('hides manual input fields', async () => {
|
|
562
|
-
const isManualElementHidden = await page.$eval('.ons-js-address-input__manual', (node) =>
|
|
563
|
-
node.classList.contains('ons-u-db-no-js_enabled'),
|
|
564
|
-
);
|
|
565
|
-
expect(isManualElementHidden).toBe(true);
|
|
566
|
-
const isSearchElementHidden = await page.$eval('.ons-js-address-input__search', (node) => node.classList.contains('ons-u-d-no'));
|
|
567
|
-
expect(isSearchElementHidden).toBe(false);
|
|
568
|
-
});
|
|
569
|
-
|
|
570
|
-
it('clears manual input fields', async () => {
|
|
571
|
-
expect(await page.$eval('.ons-js-address-organisation', (node) => node.value)).toBe('');
|
|
572
|
-
expect(await page.$eval('.ons-js-address-line1', (node) => node.value)).toBe('');
|
|
573
|
-
expect(await page.$eval('.ons-js-address-line2', (node) => node.value)).toBe('');
|
|
574
|
-
expect(await page.$eval('.ons-js-address-town', (node) => node.value)).toBe('');
|
|
575
|
-
expect(await page.$eval('.ons-js-address-postcode', (node) => node.value)).toBe('');
|
|
576
|
-
expect(await page.$eval('.ons-js-hidden-uprn', (node) => node.value)).toBe('');
|
|
577
|
-
});
|
|
578
|
-
});
|
|
579
|
-
});
|
|
604
|
+
it('then the fetch url should contain the favour Welsh parameter', async () => {
|
|
605
|
+
await page.$eval('.ons-js-autosuggest-input', (node) => (node.value = '196 coll'));
|
|
606
|
+
await page.type('.ons-js-autosuggest-input', 'e');
|
|
580
607
|
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
await setTestPage('/test', renderComponent('address-input', EXAMPLE_ADDRESS_INPUT_WITH_API));
|
|
584
|
-
await page.evaluate(() => document.documentElement.setAttribute('lang', 'cy'));
|
|
608
|
+
expect(apiFaker.getRequestCount('/addresses/eq?input=196%20colle&limit=10&favourwelsh=true')).toBe(1);
|
|
609
|
+
});
|
|
585
610
|
});
|
|
586
611
|
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
expect(apiFaker.getRequestCount('/addresses/eq?input=196%20colle&limit=10&favourwelsh=true')).toBe(1);
|
|
592
|
-
});
|
|
593
|
-
});
|
|
612
|
+
describe('When the component initialises a non-editable address lookup', () => {
|
|
613
|
+
describe('when a query is sent and address selected', () => {
|
|
614
|
+
beforeEach(async () => {
|
|
615
|
+
await setTestPage('/test', renderComponent('address-input', EXAMPLE_ADDRESS_INPUT_WITH_API));
|
|
594
616
|
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
617
|
+
await page.$eval('.ons-js-autosuggest-input', (node) => (node.value = 'CF14'));
|
|
618
|
+
await page.type('.ons-js-autosuggest-input', '2', { delay: 20 });
|
|
619
|
+
await page.keyboard.press('ArrowDown');
|
|
620
|
+
await page.keyboard.press('Enter');
|
|
599
621
|
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
await page.keyboard.press('ArrowDown');
|
|
603
|
-
await page.keyboard.press('Enter');
|
|
622
|
+
await page.waitForTimeout(50);
|
|
623
|
+
});
|
|
604
624
|
|
|
605
|
-
|
|
606
|
-
|
|
625
|
+
it('then the retrieveAddress function will be called', async () => {
|
|
626
|
+
expect(apiFaker.getRequestCount('/addresses/eq/uprn/100070332099?addresstype=paf')).toBe(1);
|
|
627
|
+
});
|
|
628
|
+
});
|
|
607
629
|
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
630
|
+
describe('when the form is submitted', () => {
|
|
631
|
+
describe('when the input is empty', () => {
|
|
632
|
+
beforeEach(async () => {
|
|
633
|
+
await setTestPage(
|
|
634
|
+
'/test',
|
|
635
|
+
`
|
|
636
|
+
<div class="ons-question">
|
|
637
|
+
<form action="/test/fake/form-handler" method="post">
|
|
638
|
+
${renderComponent('address-input', { ...EXAMPLE_ADDRESS_INPUT_WITH_API, isEditable: false })}
|
|
639
|
+
<button type="submit">Submit</button>
|
|
640
|
+
</form>
|
|
641
|
+
</div>
|
|
642
|
+
`,
|
|
643
|
+
);
|
|
644
|
+
|
|
645
|
+
await page.click('button[type=submit]');
|
|
646
|
+
});
|
|
647
|
+
|
|
648
|
+
it('sets aria status message', async () => {
|
|
649
|
+
const statusMessage = await page.$eval('.ons-js-autosuggest-aria-status', (node) => node.textContent);
|
|
650
|
+
expect(statusMessage).toBe('Enter 3 or more characters for suggestions.');
|
|
651
|
+
});
|
|
652
|
+
});
|
|
653
|
+
});
|
|
611
654
|
});
|
|
612
655
|
|
|
613
|
-
describe(
|
|
614
|
-
|
|
656
|
+
describe.each([
|
|
657
|
+
[
|
|
658
|
+
'english, epoch, workplace',
|
|
659
|
+
'/addresses/eq?input=196%20colle&limit=10&classificationfilter=workplace&eboost=10&epoch=75',
|
|
660
|
+
'/addresses/eq/uprn/100070332099?addresstype=paf&epoch=75',
|
|
661
|
+
'en',
|
|
662
|
+
{
|
|
663
|
+
regionCode: 'gb-eng',
|
|
664
|
+
oneYearAgo: true,
|
|
665
|
+
addressType: 'workplace',
|
|
666
|
+
},
|
|
667
|
+
],
|
|
668
|
+
[
|
|
669
|
+
'ni, educational',
|
|
670
|
+
'/addresses/eq?input=196%20colle&limit=10&classificationfilter=educational&eboost=0&sboost=0&wboost=0',
|
|
671
|
+
'/addresses/eq/uprn/100070332099?addresstype=paf',
|
|
672
|
+
'en',
|
|
673
|
+
{
|
|
674
|
+
regionCode: 'gb-nir',
|
|
675
|
+
addressType: 'educational',
|
|
676
|
+
},
|
|
677
|
+
],
|
|
678
|
+
[
|
|
679
|
+
'ni, workplace',
|
|
680
|
+
'/addresses/eq?input=196%20colle&limit=10&classificationfilter=workplace&nboost=10',
|
|
681
|
+
'/addresses/eq/uprn/100070332099?addresstype=paf',
|
|
682
|
+
'en',
|
|
683
|
+
{
|
|
684
|
+
regionCode: 'gb-nir',
|
|
685
|
+
addressType: 'workplace',
|
|
686
|
+
},
|
|
687
|
+
],
|
|
688
|
+
[
|
|
689
|
+
'wales, workspace',
|
|
690
|
+
'/addresses/eq?input=196%20colle&limit=10&classificationfilter=workplace&wboost=10&favourwelsh=true',
|
|
691
|
+
'/addresses/eq/uprn/100070332099?addresstype=paf',
|
|
692
|
+
'cy',
|
|
693
|
+
{
|
|
694
|
+
regionCode: 'gb-wls',
|
|
695
|
+
addressType: 'workplace',
|
|
696
|
+
},
|
|
697
|
+
],
|
|
698
|
+
])('When the component initialises with options - %s', (_, searchEndpoint, uprnEndpoint, lang, options) => {
|
|
615
699
|
beforeEach(async () => {
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
700
|
+
apiFaker.setTemporaryOverride(searchEndpoint, {
|
|
701
|
+
data: {
|
|
702
|
+
status: { code: 200 },
|
|
703
|
+
response: {
|
|
704
|
+
input: '196 colle',
|
|
705
|
+
limit: 10,
|
|
706
|
+
addresses: [
|
|
707
|
+
{
|
|
708
|
+
uprn: '100070332099',
|
|
709
|
+
formattedAddress: '196 College Road, Birmingham, B44 8HF',
|
|
710
|
+
addressType: 'PAF',
|
|
711
|
+
},
|
|
712
|
+
],
|
|
713
|
+
},
|
|
714
|
+
},
|
|
715
|
+
});
|
|
716
|
+
|
|
717
|
+
await setTestPage(
|
|
718
|
+
'/test',
|
|
719
|
+
renderComponent('address-input', {
|
|
720
|
+
...EXAMPLE_ADDRESS_INPUT_WITH_API,
|
|
721
|
+
options,
|
|
722
|
+
}),
|
|
723
|
+
);
|
|
724
|
+
|
|
725
|
+
const setLangAttribute = (lang) => document.documentElement.setAttribute('lang', lang);
|
|
726
|
+
await page.evaluate(setLangAttribute, lang);
|
|
634
727
|
});
|
|
635
|
-
});
|
|
636
|
-
});
|
|
637
|
-
});
|
|
638
|
-
|
|
639
|
-
describe.each([
|
|
640
|
-
[
|
|
641
|
-
'english, epoch, workplace',
|
|
642
|
-
'/addresses/eq?input=196%20colle&limit=10&classificationfilter=workplace&eboost=10&epoch=75',
|
|
643
|
-
'/addresses/eq/uprn/100070332099?addresstype=paf&epoch=75',
|
|
644
|
-
'en',
|
|
645
|
-
{
|
|
646
|
-
regionCode: 'gb-eng',
|
|
647
|
-
oneYearAgo: true,
|
|
648
|
-
addressType: 'workplace',
|
|
649
|
-
},
|
|
650
|
-
],
|
|
651
|
-
[
|
|
652
|
-
'ni, educational',
|
|
653
|
-
'/addresses/eq?input=196%20colle&limit=10&classificationfilter=educational&eboost=0&sboost=0&wboost=0',
|
|
654
|
-
'/addresses/eq/uprn/100070332099?addresstype=paf',
|
|
655
|
-
'en',
|
|
656
|
-
{
|
|
657
|
-
regionCode: 'gb-nir',
|
|
658
|
-
addressType: 'educational',
|
|
659
|
-
},
|
|
660
|
-
],
|
|
661
|
-
[
|
|
662
|
-
'ni, workplace',
|
|
663
|
-
'/addresses/eq?input=196%20colle&limit=10&classificationfilter=workplace&nboost=10',
|
|
664
|
-
'/addresses/eq/uprn/100070332099?addresstype=paf',
|
|
665
|
-
'en',
|
|
666
|
-
{
|
|
667
|
-
regionCode: 'gb-nir',
|
|
668
|
-
addressType: 'workplace',
|
|
669
|
-
},
|
|
670
|
-
],
|
|
671
|
-
[
|
|
672
|
-
'wales, workspace',
|
|
673
|
-
'/addresses/eq?input=196%20colle&limit=10&classificationfilter=workplace&wboost=10&favourwelsh=true',
|
|
674
|
-
'/addresses/eq/uprn/100070332099?addresstype=paf',
|
|
675
|
-
'cy',
|
|
676
|
-
{
|
|
677
|
-
regionCode: 'gb-wls',
|
|
678
|
-
addressType: 'workplace',
|
|
679
|
-
},
|
|
680
|
-
],
|
|
681
|
-
])('When the component initialises with options - %s', (_, searchEndpoint, uprnEndpoint, lang, options) => {
|
|
682
|
-
beforeEach(async () => {
|
|
683
|
-
apiFaker.setTemporaryOverride(searchEndpoint, {
|
|
684
|
-
data: {
|
|
685
|
-
status: { code: 200 },
|
|
686
|
-
response: {
|
|
687
|
-
input: '196 colle',
|
|
688
|
-
limit: 10,
|
|
689
|
-
addresses: [
|
|
690
|
-
{
|
|
691
|
-
uprn: '100070332099',
|
|
692
|
-
formattedAddress: '196 College Road, Birmingham, B44 8HF',
|
|
693
|
-
addressType: 'PAF',
|
|
694
|
-
},
|
|
695
|
-
],
|
|
696
|
-
},
|
|
697
|
-
},
|
|
698
|
-
});
|
|
699
|
-
|
|
700
|
-
await setTestPage(
|
|
701
|
-
'/test',
|
|
702
|
-
renderComponent('address-input', {
|
|
703
|
-
...EXAMPLE_ADDRESS_INPUT_WITH_API,
|
|
704
|
-
options,
|
|
705
|
-
}),
|
|
706
|
-
);
|
|
707
|
-
|
|
708
|
-
const setLangAttribute = (lang) => document.documentElement.setAttribute('lang', lang);
|
|
709
|
-
await page.evaluate(setLangAttribute, lang);
|
|
710
|
-
});
|
|
711
728
|
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
729
|
+
it('provides expected parameters to the address API', async () => {
|
|
730
|
+
await page.$eval('.ons-js-autosuggest-input', (node) => (node.value = '196 coll'));
|
|
731
|
+
await page.type('.ons-js-autosuggest-input', 'e');
|
|
715
732
|
|
|
716
|
-
|
|
717
|
-
|
|
733
|
+
expect(apiFaker.getRequestCount(searchEndpoint)).toBe(1);
|
|
734
|
+
});
|
|
718
735
|
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
736
|
+
it('requests further information for the selected address from the API with the expected parameters', async () => {
|
|
737
|
+
await page.$eval('.ons-js-autosuggest-input', (node) => (node.value = '196 coll'));
|
|
738
|
+
await page.type('.ons-js-autosuggest-input', 'e', { delay: 20 });
|
|
739
|
+
await page.keyboard.press('ArrowDown');
|
|
740
|
+
await page.keyboard.press('Enter');
|
|
724
741
|
|
|
725
|
-
|
|
742
|
+
await page.waitForTimeout(50);
|
|
726
743
|
|
|
727
|
-
|
|
744
|
+
expect(apiFaker.getRequestCount(uprnEndpoint)).toBe(1);
|
|
745
|
+
});
|
|
728
746
|
});
|
|
729
|
-
});
|
|
730
747
|
});
|