@ons/design-system 50.0.1 → 51.0.0
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 +35 -13
- package/components/access-code/_macro.njk +1 -1
- package/components/access-code/_macro.spec.js +162 -0
- package/components/access-code/uac.spec.js +26 -0
- package/components/accordion/_macro.spec.js +224 -0
- package/components/accordion/accordion.spec.js +134 -0
- package/components/address-input/_macro.njk +1 -1
- package/components/address-input/_macro.spec.js +465 -0
- package/components/address-input/autosuggest.address.js +5 -4
- package/components/address-input/autosuggest.address.setter.js +3 -1
- package/components/address-input/autosuggest.address.spec.js +733 -0
- package/components/address-output/_macro.njk +6 -6
- package/components/address-output/_macro.spec.js +122 -0
- package/components/autosuggest/_macro.njk +1 -1
- package/components/autosuggest/_macro.spec.js +229 -0
- package/components/autosuggest/autosuggest.helpers.js +2 -3
- package/components/autosuggest/autosuggest.helpers.spec.js +85 -0
- package/components/autosuggest/autosuggest.js +4 -2
- package/components/autosuggest/autosuggest.spec.js +625 -0
- package/components/autosuggest/autosuggest.ui.js +6 -2
- package/components/breadcrumbs/_macro.spec.js +129 -0
- package/components/button/_macro.njk +5 -5
- package/components/button/_macro.spec.js +446 -0
- package/components/button/button.spec.js +290 -0
- package/components/call-to-action/_macro.njk +3 -1
- package/components/call-to-action/_macro.spec.js +52 -0
- package/components/card/_macro.njk +26 -19
- package/components/card/_macro.spec.js +261 -0
- package/components/char-check-limit/_macro.spec.js +73 -0
- package/components/char-check-limit/character-check.spec.js +196 -0
- package/components/char-check-limit/character-limit.js +1 -1
- package/components/checkboxes/_checkbox-macro.spec.js +419 -0
- package/components/checkboxes/_macro.njk +1 -3
- package/components/checkboxes/_macro.spec.js +306 -0
- package/components/checkboxes/checkboxes.spec.js +208 -0
- package/components/code-highlight/_macro.spec.js +56 -0
- package/components/code-highlight/code-highlight.spec.js +18 -0
- package/components/collapsible/_macro.spec.js +204 -0
- package/components/collapsible/collapsible.js +2 -1
- package/components/collapsible/collapsible.spec.js +236 -0
- package/components/content-pagination/_macro.spec.js +199 -0
- package/components/cookies-banner/_macro.njk +1 -1
- package/components/cookies-banner/_macro.spec.js +171 -0
- package/components/cookies-banner/cookies-banner.spec.js +90 -0
- package/components/date-input/_macro.njk +6 -3
- package/components/date-input/_macro.spec.js +286 -0
- package/components/document-list/_macro.njk +3 -5
- package/components/document-list/_macro.spec.js +491 -0
- package/components/download-resources/download-resources.spec.js +540 -0
- package/components/duration/_macro.njk +7 -6
- package/components/duration/_macro.spec.js +251 -0
- package/components/error/_macro.spec.js +97 -0
- package/components/external-link/_macro.spec.js +60 -0
- package/components/feedback/_macro.njk +5 -3
- package/components/feedback/_macro.spec.js +122 -0
- package/components/field/_macro.njk +2 -2
- package/components/field/_macro.spec.js +97 -0
- package/components/fieldset/_macro.njk +3 -3
- package/components/fieldset/_macro.spec.js +173 -0
- package/components/footer/_macro.njk +11 -48
- package/components/footer/_macro.spec.js +549 -0
- package/components/header/_macro.njk +2 -2
- package/components/header/_macro.spec.js +562 -0
- package/components/hero/_hero.scss +0 -3
- package/components/hero/_macro.njk +4 -4
- package/components/hero/_macro.spec.js +224 -0
- package/components/icons/_macro.njk +15 -15
- package/components/icons/_macro.spec.js +140 -0
- package/components/images/_macro.njk +1 -1
- package/components/images/_macro.spec.js +121 -0
- package/components/input/_input-type.scss +12 -5
- package/components/input/_macro.njk +4 -5
- package/components/input/_macro.spec.js +658 -0
- package/components/label/_macro.spec.js +189 -0
- package/components/language-selector/_macro.spec.js +129 -0
- package/components/lists/_list.scss +4 -0
- package/components/lists/_macro.njk +4 -7
- package/components/lists/_macro.spec.js +618 -0
- package/components/message/_macro.spec.js +137 -0
- package/components/message-list/_macro.njk +7 -7
- package/components/message-list/_macro.spec.js +159 -0
- package/components/metadata/_macro.spec.js +167 -0
- package/components/modal/_macro.njk +6 -6
- package/components/modal/_macro.spec.js +87 -0
- package/components/modal/modal.spec.js +59 -0
- package/components/mutually-exclusive/_macro.njk +1 -1
- package/components/mutually-exclusive/_macro.spec.js +182 -0
- package/components/mutually-exclusive/mutually-exclusive.checkboxes.spec.js +203 -0
- package/components/mutually-exclusive/mutually-exclusive.date.spec.js +142 -0
- package/components/mutually-exclusive/mutually-exclusive.duration.spec.js +141 -0
- package/components/mutually-exclusive/mutually-exclusive.email.spec.js +117 -0
- package/components/mutually-exclusive/mutually-exclusive.multiple-options.checkboxes.spec.js +213 -0
- package/components/mutually-exclusive/mutually-exclusive.number.spec.js +125 -0
- package/components/mutually-exclusive/mutually-exclusive.textarea.spec.js +131 -0
- package/components/navigation/_macro.njk +6 -6
- package/components/navigation/_macro.spec.js +327 -0
- package/components/navigation/navigation.dom.js +1 -1
- package/components/navigation/navigation.spec.js +232 -0
- package/components/pagination/_macro.njk +1 -1
- package/components/pagination/_macro.spec.js +411 -0
- package/components/panel/_macro.njk +6 -6
- package/components/panel/_macro.spec.js +423 -0
- package/components/password/_macro.spec.js +137 -0
- package/components/password/password.spec.js +40 -0
- package/components/phase-banner/_macro.spec.js +73 -0
- package/components/promotional-banner/_macro.spec.js +97 -0
- package/components/question/_macro.njk +25 -33
- package/components/question/_macro.spec.js +309 -0
- package/components/quote/_macro.spec.js +81 -0
- package/components/radios/_macro.njk +3 -6
- package/components/radios/_macro.spec.js +575 -0
- package/components/radios/radios.spec.js +180 -0
- package/components/related-content/_macro.njk +1 -0
- package/components/related-content/_macro.spec.js +142 -0
- package/components/relationships/_macro.spec.js +108 -0
- package/components/relationships/relationships.spec.js +84 -0
- package/components/reply/_macro.njk +2 -2
- package/components/reply/_macro.spec.js +69 -0
- package/components/reply/reply.spec.js +78 -0
- package/components/search/_macro.njk +14 -12
- package/components/search/_macro.spec.js +44 -0
- package/components/search/_search.scss +7 -7
- package/components/section-navigation/_macro.njk +7 -2
- package/components/section-navigation/_macro.spec.js +206 -0
- package/components/select/_macro.njk +3 -3
- package/components/select/_macro.spec.js +203 -0
- package/components/select/select.spec.js +56 -0
- package/components/share-page/_macro.njk +2 -2
- package/components/share-page/_macro.spec.js +110 -0
- package/components/skip-to-content/_macro.spec.js +57 -0
- package/components/skip-to-content/skip-to-content.spec.js +44 -0
- package/components/status/_macro.spec.js +77 -0
- package/components/summary/_macro.njk +5 -5
- package/components/summary/_macro.spec.js +472 -0
- package/components/table/_macro.njk +2 -2
- package/components/table/_macro.spec.js +557 -0
- package/components/table/table.spec.js +155 -0
- package/components/table-of-contents/_macro.njk +35 -35
- package/components/table-of-contents/_macro.spec.js +178 -0
- package/components/table-of-contents/toc.js +29 -25
- package/components/table-of-contents/toc.spec.js +61 -0
- package/components/tabs/_macro.njk +1 -1
- package/components/tabs/_macro.spec.js +79 -0
- package/components/tabs/tabs.spec.js +162 -0
- package/components/text-indent/_macro.spec.js +52 -0
- package/components/textarea/_macro.njk +5 -3
- package/components/textarea/_macro.spec.js +300 -0
- package/components/textarea/textarea.spec.js +98 -0
- package/components/timeline/_macro.njk +3 -3
- package/components/timeline/_macro.spec.js +81 -0
- package/components/timeout-modal/_macro.spec.js +68 -0
- package/components/timeout-modal/timeout-modal.spec.js +226 -0
- package/components/timeout-panel/_macro.njk +0 -1
- package/components/timeout-panel/_macro.spec.js +54 -0
- package/components/timeout-panel/timeout-panel.dom.js +1 -2
- package/components/timeout-panel/timeout-panel.spec.js +161 -0
- package/components/upload/_macro.spec.js +75 -0
- package/components/video/_macro.spec.js +34 -0
- package/css/census.css +1 -1
- package/css/main.css +1 -1
- package/js/cookies-settings.spec.js +154 -0
- package/package.json +10 -23
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +1 -1
|
@@ -0,0 +1,733 @@
|
|
|
1
|
+
import { PuppeteerEndpointFaker } from '../../tests/helpers/puppeteer';
|
|
2
|
+
import { renderComponent, setTestPage } from '../../tests/helpers/rendering';
|
|
3
|
+
|
|
4
|
+
const EXAMPLE_ADDRESS_INPUT = {
|
|
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
|
+
};
|
|
57
|
+
|
|
58
|
+
const EXAMPLE_ADDRESS_INPUT_WITH_API = {
|
|
59
|
+
...EXAMPLE_ADDRESS_INPUT,
|
|
60
|
+
APIDomain: '/fake/api',
|
|
61
|
+
APIDomainBearerToken: 'someToken',
|
|
62
|
+
externalInitialiser: true,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
describe('script: address-input', () => {
|
|
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',
|
|
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
|
+
},
|
|
117
|
+
],
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
|
|
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
|
+
},
|
|
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',
|
|
169
|
+
},
|
|
170
|
+
],
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
beforeAll(async () => {
|
|
177
|
+
await apiFaker.setup(page);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
beforeEach(async () => {
|
|
181
|
+
await apiFaker.reset();
|
|
182
|
+
});
|
|
183
|
+
|
|
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);
|
|
188
|
+
|
|
189
|
+
expect(apiFaker.getRequestCount('/addresses/eq?input=cf142&limit=10')).toBe(1);
|
|
190
|
+
});
|
|
191
|
+
|
|
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 => node.classList.contains('ons-u-d-no'));
|
|
204
|
+
expect(isSearchElementHidden).toBe(false);
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
describe('when api status is not okay', () => {
|
|
209
|
+
beforeEach(async () => {
|
|
210
|
+
apiFaker.setTemporaryOverride('/addresses/eq?input=cf142&limit=10', {
|
|
211
|
+
data: {
|
|
212
|
+
status: { code: 401 },
|
|
213
|
+
},
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
await setTestPage('/test', renderComponent('address-input', EXAMPLE_ADDRESS_INPUT_WITH_API));
|
|
217
|
+
await page.waitForTimeout(50);
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it('switches to manual input', async () => {
|
|
221
|
+
const isManualElementHidden = await page.$eval('.ons-js-address-input__manual', node =>
|
|
222
|
+
node.classList.contains('ons-u-db-no-js_enabled'),
|
|
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
|
+
});
|
|
233
|
+
});
|
|
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
|
+
|
|
240
|
+
await page.$eval('.ons-js-autosuggest-input', node => (node.value = 'CF14'));
|
|
241
|
+
await page.type('.ons-js-autosuggest-input', '2', { delay: 20 });
|
|
242
|
+
await page.keyboard.press('ArrowDown');
|
|
243
|
+
|
|
244
|
+
const selectedOption = await page.$eval('.ons-autosuggest-input__option--focused', node => node.textContent);
|
|
245
|
+
expect(selectedOption.trim()).toBe('196 College Road, Birmingham, B44 8HF');
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it('provides expected parameters to the address API', async () => {
|
|
249
|
+
await setTestPage('/test', renderComponent('address-input', EXAMPLE_ADDRESS_INPUT_WITH_API));
|
|
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);
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
describe('when the value is a full postcode', () => {
|
|
258
|
+
beforeEach(async () => {
|
|
259
|
+
await setTestPage('/test', renderComponent('address-input', EXAMPLE_ADDRESS_INPUT_WITH_API));
|
|
260
|
+
|
|
261
|
+
await page.$eval('.ons-js-autosuggest-input', node => (node.value = 'CF14 2N'));
|
|
262
|
+
await page.type('.ons-js-autosuggest-input', 'T');
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
it('provides expected parameters to the address API where `limit` is 100', async () => {
|
|
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-input__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-input__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);
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
it('makes expected request when a suggestion is selected', async () => {
|
|
328
|
+
expect(apiFaker.getRequestCount('/addresses/eq/uprn/100070332099?addresstype=paf')).toBe(1);
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
it('populates manual input fields with address from selection', async () => {
|
|
332
|
+
expect(await page.$eval('.ons-js-address-organisation', node => node.value)).toBe('');
|
|
333
|
+
expect(await page.$eval('.ons-js-address-line1', node => node.value)).toBe('196 College Road');
|
|
334
|
+
expect(await page.$eval('.ons-js-address-line2', node => node.value)).toBe('Whitchurch');
|
|
335
|
+
expect(await page.$eval('.ons-js-address-town', node => node.value)).toBe('Cardiff');
|
|
336
|
+
expect(await page.$eval('.ons-js-address-postcode', node => node.value)).toBe('CF14 2NT');
|
|
337
|
+
expect(await page.$eval('.ons-js-hidden-uprn', node => node.value)).toBe('100070332099');
|
|
338
|
+
});
|
|
339
|
+
});
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
describe('when the query is a partial postcode', () => {
|
|
343
|
+
beforeEach(async () => {
|
|
344
|
+
await setTestPage('/test', renderComponent('address-input', EXAMPLE_ADDRESS_INPUT_WITH_API));
|
|
345
|
+
|
|
346
|
+
await page.$eval('.ons-js-autosuggest-input', node => (node.value = 'CF14 '));
|
|
347
|
+
await page.type('.ons-js-autosuggest-input', '2');
|
|
348
|
+
await page.waitForTimeout(200);
|
|
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-input__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
|
+
});
|
|
369
|
+
|
|
370
|
+
it('makes expected request', async () => {
|
|
371
|
+
expect(
|
|
372
|
+
apiFaker.getRequestCount(
|
|
373
|
+
'/addresses/eq/bucket?postcode=CF14%202AA&streetname=Penlline%20Road&townname=Whitchurch&groupfullpostcodes=combo',
|
|
374
|
+
),
|
|
375
|
+
).toBe(1);
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
it('has expected suggestion entries', async () => {
|
|
379
|
+
const suggestions = await page.$$eval('.ons-autosuggest-input__option', nodes => nodes.map(node => node.textContent.trim()));
|
|
380
|
+
expect(suggestions).toEqual(['197 College Road, Whitchurch, Cardiff, CF14 2AB']);
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
describe('when an inner suggestion is selected', () => {
|
|
384
|
+
beforeEach(async () => {
|
|
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
|
+
});
|
|
418
|
+
|
|
419
|
+
apiFaker.setTemporaryOverride('/addresses/eq/uprn/bad?addresstype=paf', {
|
|
420
|
+
data: {
|
|
421
|
+
status: { code: 400 },
|
|
422
|
+
},
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
await setTestPage('/test', renderComponent('address-input', EXAMPLE_ADDRESS_INPUT_WITH_API));
|
|
426
|
+
|
|
427
|
+
await page.$eval('.ons-js-autosuggest-input', node => (node.value = 'cf14'));
|
|
428
|
+
await page.type('.ons-js-autosuggest-input', '2', { delay: 20 });
|
|
429
|
+
await page.keyboard.press('ArrowDown');
|
|
430
|
+
await page.keyboard.press('Enter');
|
|
431
|
+
await page.waitForTimeout(100);
|
|
432
|
+
|
|
433
|
+
const isManualElementHidden = await page.$eval('.ons-js-address-input__manual', node =>
|
|
434
|
+
node.classList.contains('ons-u-db-no-js_enabled'),
|
|
435
|
+
);
|
|
436
|
+
expect(isManualElementHidden).toBe(false);
|
|
437
|
+
|
|
438
|
+
const isSearchElementHidden = await page.$eval('.ons-js-address-input__search', node => node.classList.contains('ons-u-d-no'));
|
|
439
|
+
expect(isSearchElementHidden).toBe(true);
|
|
440
|
+
|
|
441
|
+
const isSearchButtonElementHidden = await page.$eval('.ons-js-address-search-btn', node => node.classList.contains('ons-u-d-no'));
|
|
442
|
+
expect(isSearchButtonElementHidden).toBe(true);
|
|
443
|
+
});
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
describe('when the form is submitted', () => {
|
|
447
|
+
describe('when the selected address is manually changed', () => {
|
|
448
|
+
it('clears the urpn field', async () => {
|
|
449
|
+
await setTestPage(
|
|
450
|
+
'/test',
|
|
451
|
+
`
|
|
452
|
+
<form action="/test/fake/form-handler" method="post">
|
|
453
|
+
${renderComponent('address-input', EXAMPLE_ADDRESS_INPUT_WITH_API)}
|
|
454
|
+
<button type="submit">Submit</button>
|
|
455
|
+
</form>
|
|
456
|
+
`,
|
|
457
|
+
);
|
|
458
|
+
|
|
459
|
+
await page.$eval('form', node =>
|
|
460
|
+
node.addEventListener('submit', event => {
|
|
461
|
+
event.preventDefault();
|
|
462
|
+
return false;
|
|
463
|
+
}),
|
|
464
|
+
);
|
|
465
|
+
|
|
466
|
+
await page.$eval('.ons-js-autosuggest-input', node => (node.value = 'CF14 2N'));
|
|
467
|
+
await page.type('.ons-js-autosuggest-input', 'T', { delay: 20 });
|
|
468
|
+
await page.keyboard.press('ArrowDown');
|
|
469
|
+
await page.keyboard.press('Enter');
|
|
470
|
+
await page.waitForTimeout(100);
|
|
471
|
+
|
|
472
|
+
const urpnValueBefore = await page.$eval('.ons-js-hidden-uprn', node => node.value);
|
|
473
|
+
expect(urpnValueBefore).toBe('100070332099');
|
|
474
|
+
|
|
475
|
+
await page.$eval('.ons-js-address-line1', node => (node.value = 'Something else'));
|
|
476
|
+
await page.click('button[type=submit]');
|
|
477
|
+
|
|
478
|
+
const urpnValueAfter = await page.$eval('.ons-js-hidden-uprn', node => node.value);
|
|
479
|
+
expect(urpnValueAfter).toBe('');
|
|
480
|
+
});
|
|
481
|
+
});
|
|
482
|
+
|
|
483
|
+
describe('when the submit is invalid', () => {
|
|
484
|
+
beforeEach(async () => {
|
|
485
|
+
await setTestPage(
|
|
486
|
+
'/test',
|
|
487
|
+
`
|
|
488
|
+
<div class="ons-question">
|
|
489
|
+
<form action="/test/fake/form-handler" method="post">
|
|
490
|
+
${renderComponent('address-input', EXAMPLE_ADDRESS_INPUT_WITH_API)}
|
|
491
|
+
<button type="submit">Submit</button>
|
|
492
|
+
</form>
|
|
493
|
+
</div>
|
|
494
|
+
`,
|
|
495
|
+
);
|
|
496
|
+
|
|
497
|
+
await page.$eval('form', node =>
|
|
498
|
+
node.addEventListener('submit', event => {
|
|
499
|
+
event.preventDefault();
|
|
500
|
+
return false;
|
|
501
|
+
}),
|
|
502
|
+
);
|
|
503
|
+
|
|
504
|
+
await page.click('button[type=submit]');
|
|
505
|
+
});
|
|
506
|
+
|
|
507
|
+
it('then an error summary panel should be added to the DOM', async () => {
|
|
508
|
+
const panelExists = await page.$$eval('.ons-js-autosuggest-error-panel', nodes => nodes.length === 1);
|
|
509
|
+
expect(panelExists).toBe(true);
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
it('then input should be wrapped in an error', async () => {
|
|
513
|
+
const inputIsError = await page.$$eval('#autosuggest-input-error', nodes => nodes.length === 1);
|
|
514
|
+
expect(inputIsError).toBe(true);
|
|
515
|
+
});
|
|
516
|
+
|
|
517
|
+
describe('when the mode is set to manual', () => {
|
|
518
|
+
it('then the error summary should be removed', async () => {
|
|
519
|
+
await page.click('.ons-js-address-manual-btn');
|
|
520
|
+
|
|
521
|
+
const panelExists = await page.$$eval('.ons-js-autosuggest-error-panel', nodes => nodes.length === 1);
|
|
522
|
+
expect(panelExists).toBe(false);
|
|
523
|
+
});
|
|
524
|
+
});
|
|
525
|
+
});
|
|
526
|
+
});
|
|
527
|
+
});
|
|
528
|
+
|
|
529
|
+
describe('When the manual link is clicked', () => {
|
|
530
|
+
beforeEach(async () => {
|
|
531
|
+
await setTestPage('/test', renderComponent('address-input', EXAMPLE_ADDRESS_INPUT_WITH_API));
|
|
532
|
+
await page.click('.ons-js-address-manual-btn');
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
it('shows manual input fields', async () => {
|
|
536
|
+
const isManualElementHidden = await page.$eval('.ons-js-address-input__manual', node =>
|
|
537
|
+
node.classList.contains('ons-u-db-no-js_enabled'),
|
|
538
|
+
);
|
|
539
|
+
expect(isManualElementHidden).toBe(false);
|
|
540
|
+
const isSearchElementHidden = await page.$eval('.ons-js-address-input__search', node => node.classList.contains('ons-u-d-no'));
|
|
541
|
+
expect(isSearchElementHidden).toBe(true);
|
|
542
|
+
});
|
|
543
|
+
|
|
544
|
+
it('clears autosuggest input', async () => {
|
|
545
|
+
const value = await page.$eval('.ons-js-autosuggest-input', node => node.value);
|
|
546
|
+
expect(value).toBe('');
|
|
547
|
+
});
|
|
548
|
+
|
|
549
|
+
describe('and then the search link is clicked', () => {
|
|
550
|
+
beforeEach(async () => {
|
|
551
|
+
await page.$eval('.ons-js-address-organisation', node => (node.value = 'Test organisation'));
|
|
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
|
+
});
|
|
580
|
+
|
|
581
|
+
describe('When the language is Welsh', () => {
|
|
582
|
+
beforeEach(async () => {
|
|
583
|
+
await setTestPage('/test', renderComponent('address-input', EXAMPLE_ADDRESS_INPUT_WITH_API));
|
|
584
|
+
await page.evaluate(() => document.documentElement.setAttribute('lang', 'cy'));
|
|
585
|
+
});
|
|
586
|
+
|
|
587
|
+
it('then the fetch url should contain the favour Welsh parameter', async () => {
|
|
588
|
+
await page.$eval('.ons-js-autosuggest-input', node => (node.value = '196 coll'));
|
|
589
|
+
await page.type('.ons-js-autosuggest-input', 'e');
|
|
590
|
+
|
|
591
|
+
expect(apiFaker.getRequestCount('/addresses/eq?input=196%20colle&limit=10&favourwelsh=true')).toBe(1);
|
|
592
|
+
});
|
|
593
|
+
});
|
|
594
|
+
|
|
595
|
+
describe('When the component initialises a non-editable address lookup', () => {
|
|
596
|
+
describe('when a query is sent and address selected', () => {
|
|
597
|
+
beforeEach(async () => {
|
|
598
|
+
await setTestPage('/test', renderComponent('address-input', EXAMPLE_ADDRESS_INPUT_WITH_API));
|
|
599
|
+
|
|
600
|
+
await page.$eval('.ons-js-autosuggest-input', node => (node.value = 'CF14'));
|
|
601
|
+
await page.type('.ons-js-autosuggest-input', '2', { delay: 20 });
|
|
602
|
+
await page.keyboard.press('ArrowDown');
|
|
603
|
+
await page.keyboard.press('Enter');
|
|
604
|
+
|
|
605
|
+
await page.waitForTimeout(50);
|
|
606
|
+
});
|
|
607
|
+
|
|
608
|
+
it('then the retrieveAddress function will be called', async () => {
|
|
609
|
+
expect(apiFaker.getRequestCount('/addresses/eq/uprn/100070332099?addresstype=paf')).toBe(1);
|
|
610
|
+
});
|
|
611
|
+
});
|
|
612
|
+
|
|
613
|
+
describe('when the form is submitted', () => {
|
|
614
|
+
describe('when the input is empty', () => {
|
|
615
|
+
beforeEach(async () => {
|
|
616
|
+
await setTestPage(
|
|
617
|
+
'/test',
|
|
618
|
+
`
|
|
619
|
+
<div class="ons-question">
|
|
620
|
+
<form action="/test/fake/form-handler" method="post">
|
|
621
|
+
${renderComponent('address-input', {
|
|
622
|
+
...EXAMPLE_ADDRESS_INPUT_WITH_API,
|
|
623
|
+
isEditable: false,
|
|
624
|
+
})}
|
|
625
|
+
<button type="submit">Submit</button>
|
|
626
|
+
</form>
|
|
627
|
+
</div>
|
|
628
|
+
`,
|
|
629
|
+
);
|
|
630
|
+
|
|
631
|
+
await page.click('button[type=submit]');
|
|
632
|
+
});
|
|
633
|
+
|
|
634
|
+
it('sets aria status message', async () => {
|
|
635
|
+
const statusMessage = await page.$eval('.ons-js-autosuggest-aria-status', node => node.textContent);
|
|
636
|
+
expect(statusMessage).toBe('Enter 3 or more characters for suggestions.');
|
|
637
|
+
});
|
|
638
|
+
});
|
|
639
|
+
});
|
|
640
|
+
});
|
|
641
|
+
|
|
642
|
+
describe.each([
|
|
643
|
+
[
|
|
644
|
+
'english, epoch, workplace',
|
|
645
|
+
'/addresses/eq?input=196%20colle&limit=10&classificationfilter=workplace&eboost=10&epoch=75',
|
|
646
|
+
'/addresses/eq/uprn/100070332099?addresstype=paf&epoch=75',
|
|
647
|
+
'en',
|
|
648
|
+
{
|
|
649
|
+
regionCode: 'gb-eng',
|
|
650
|
+
oneYearAgo: true,
|
|
651
|
+
addressType: 'workplace',
|
|
652
|
+
},
|
|
653
|
+
],
|
|
654
|
+
[
|
|
655
|
+
'ni, educational',
|
|
656
|
+
'/addresses/eq?input=196%20colle&limit=10&classificationfilter=educational&eboost=0&sboost=0&wboost=0',
|
|
657
|
+
'/addresses/eq/uprn/100070332099?addresstype=paf',
|
|
658
|
+
'en',
|
|
659
|
+
{
|
|
660
|
+
regionCode: 'gb-nir',
|
|
661
|
+
addressType: 'educational',
|
|
662
|
+
},
|
|
663
|
+
],
|
|
664
|
+
[
|
|
665
|
+
'ni, workplace',
|
|
666
|
+
'/addresses/eq?input=196%20colle&limit=10&classificationfilter=workplace&nboost=10',
|
|
667
|
+
'/addresses/eq/uprn/100070332099?addresstype=paf',
|
|
668
|
+
'en',
|
|
669
|
+
{
|
|
670
|
+
regionCode: 'gb-nir',
|
|
671
|
+
addressType: 'workplace',
|
|
672
|
+
},
|
|
673
|
+
],
|
|
674
|
+
[
|
|
675
|
+
'wales, workspace',
|
|
676
|
+
'/addresses/eq?input=196%20colle&limit=10&classificationfilter=workplace&wboost=10&favourwelsh=true',
|
|
677
|
+
'/addresses/eq/uprn/100070332099?addresstype=paf',
|
|
678
|
+
'cy',
|
|
679
|
+
{
|
|
680
|
+
regionCode: 'gb-wls',
|
|
681
|
+
addressType: 'workplace',
|
|
682
|
+
},
|
|
683
|
+
],
|
|
684
|
+
])('When the component initialises with options - %s', (_, searchEndpoint, uprnEndpoint, lang, options) => {
|
|
685
|
+
beforeEach(async () => {
|
|
686
|
+
apiFaker.setTemporaryOverride(searchEndpoint, {
|
|
687
|
+
data: {
|
|
688
|
+
status: { code: 200 },
|
|
689
|
+
response: {
|
|
690
|
+
input: '196 colle',
|
|
691
|
+
limit: 10,
|
|
692
|
+
addresses: [
|
|
693
|
+
{
|
|
694
|
+
uprn: '100070332099',
|
|
695
|
+
formattedAddress: '196 College Road, Birmingham, B44 8HF',
|
|
696
|
+
addressType: 'PAF',
|
|
697
|
+
},
|
|
698
|
+
],
|
|
699
|
+
},
|
|
700
|
+
},
|
|
701
|
+
});
|
|
702
|
+
|
|
703
|
+
await setTestPage(
|
|
704
|
+
'/test',
|
|
705
|
+
renderComponent('address-input', {
|
|
706
|
+
...EXAMPLE_ADDRESS_INPUT_WITH_API,
|
|
707
|
+
options,
|
|
708
|
+
}),
|
|
709
|
+
);
|
|
710
|
+
|
|
711
|
+
const setLangAttribute = lang => document.documentElement.setAttribute('lang', lang);
|
|
712
|
+
await page.evaluate(setLangAttribute, lang);
|
|
713
|
+
});
|
|
714
|
+
|
|
715
|
+
it('provides expected parameters to the address API', async () => {
|
|
716
|
+
await page.$eval('.ons-js-autosuggest-input', node => (node.value = '196 coll'));
|
|
717
|
+
await page.type('.ons-js-autosuggest-input', 'e');
|
|
718
|
+
|
|
719
|
+
expect(apiFaker.getRequestCount(searchEndpoint)).toBe(1);
|
|
720
|
+
});
|
|
721
|
+
|
|
722
|
+
it('requests further information for the selected address from the API with the expected parameters', async () => {
|
|
723
|
+
await page.$eval('.ons-js-autosuggest-input', node => (node.value = '196 coll'));
|
|
724
|
+
await page.type('.ons-js-autosuggest-input', 'e', { delay: 20 });
|
|
725
|
+
await page.keyboard.press('ArrowDown');
|
|
726
|
+
await page.keyboard.press('Enter');
|
|
727
|
+
|
|
728
|
+
await page.waitForTimeout(50);
|
|
729
|
+
|
|
730
|
+
expect(apiFaker.getRequestCount(uprnEndpoint)).toBe(1);
|
|
731
|
+
});
|
|
732
|
+
});
|
|
733
|
+
});
|