@ons/design-system 68.0.0 → 70.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 +6 -0
- package/components/access-code/_macro.njk +1 -1
- package/components/access-code/_macro.spec.js +2 -10
- package/components/access-code/access-code.dom.js +1 -1
- package/components/access-code/access-code.spec.js +2 -2
- package/components/access-code/example-access-code-error.njk +9 -14
- package/components/access-code/example-access-code.njk +3 -5
- package/components/accordion/accordion.js +4 -4
- package/components/address-input/_macro.spec.js +3 -15
- package/components/address-input/autosuggest.address.dom.js +1 -1
- package/components/address-input/autosuggest.address.js +3 -2
- package/components/address-input/autosuggest.address.setter.js +3 -3
- package/components/address-input/autosuggest.address.spec.js +66 -69
- package/components/address-output/_macro.spec.js +6 -30
- package/components/autosuggest/_autosuggest.scss +1 -1
- package/components/autosuggest/autosuggest.dom.js +1 -1
- package/components/autosuggest/autosuggest.helpers.js +1 -1
- package/components/back-to-top/_back-to-top.scss +34 -0
- package/components/back-to-top/_macro.njk +17 -0
- package/components/back-to-top/_macro.spec.js +60 -0
- package/components/back-to-top/back-to-top.dom.js +12 -0
- package/components/back-to-top/back-to-top.js +58 -0
- package/components/back-to-top/back-to-top.spec.js +117 -0
- package/components/back-to-top/example-back-to-top.njk +37 -0
- package/components/back-to-top/example-full-page-back-to-top.njk +192 -0
- package/components/browser-banner/_macro.spec.js +4 -12
- package/components/button/_macro.njk +6 -6
- package/components/button/_macro.spec.js +1 -5
- package/components/button/button.js +7 -8
- package/components/button/button.spec.js +17 -39
- package/components/call-to-action/_macro.spec.js +2 -6
- package/components/card/_macro.njk +25 -25
- package/components/card/_macro.spec.js +10 -34
- package/components/char-check-limit/_macro.njk +1 -1
- package/components/char-check-limit/_macro.spec.js +3 -7
- package/components/char-check-limit/character-check.spec.js +24 -20
- package/components/checkboxes/_checkbox-macro.njk +1 -1
- package/components/checkboxes/_checkbox.scss +0 -3
- package/components/checkboxes/_macro.spec.js +1 -5
- package/components/checkboxes/checkbox-with-autoselect.js +3 -3
- package/components/checkboxes/checkbox-with-fieldset.js +2 -2
- package/components/checkboxes/checkboxes-with-reveal.js +4 -2
- package/components/checkboxes/checkboxes.dom.js +2 -2
- package/components/checkboxes/checkboxes.spec.js +13 -13
- package/components/content-pagination/_macro.spec.js +2 -2
- package/components/cookies-banner/cookies-banner.dom.js +1 -1
- package/components/cookies-banner/cookies-banner.js +1 -1
- package/components/cookies-banner/cookies-banner.spec.js +7 -7
- package/components/date-input/_macro.njk +71 -69
- package/components/date-input/_macro.spec.js +20 -5
- package/components/date-input/example-date-input-double-field.njk +27 -0
- package/components/date-input/example-date-input-single-field.njk +18 -0
- package/components/details/details.spec.js +12 -12
- package/components/details/example-details-with-warning.njk +5 -7
- package/components/document-list/_macro.spec.js +9 -27
- package/components/document-list/document-list.scss +1 -1
- package/components/document-list/example-document-list-downloads.njk +3 -3
- package/components/document-list/example-document-list-search-result-featured.njk +1 -1
- package/components/document-list/example-document-list-search-results.njk +3 -3
- package/components/download-resources/download-resources.js +54 -54
- package/components/download-resources/download-resources.spec.js +3 -1
- package/components/duration/_macro.njk +52 -48
- package/components/duration/_macro.spec.js +112 -4
- package/components/duration/example-duration-error-for-single-field.njk +1 -1
- package/components/duration/example-duration-single-field.njk +24 -0
- package/components/error/_macro.njk +1 -1
- package/components/error/_macro.spec.js +2 -6
- package/components/feedback/_macro.njk +1 -1
- package/components/feedback/_macro.spec.js +4 -20
- package/components/field/_macro.spec.js +1 -3
- package/components/fieldset/_fieldset.scss +1 -2
- package/components/fieldset/_macro.spec.js +3 -9
- package/components/footer/_footer.scss +8 -0
- package/components/footer/_macro.njk +8 -7
- package/components/footer/_macro.spec.js +14 -2
- package/components/header/_macro.njk +1 -1
- package/components/header/_macro.spec.js +1 -1
- package/components/helpers/grid.njk +15 -15
- package/components/icon/_macro.njk +15 -11
- package/components/icon/_macro.spec.js +8 -16
- package/components/image/_macro.spec.js +1 -5
- package/components/input/_macro.njk +22 -23
- package/components/input/_macro.spec.js +1 -1
- package/components/input/character-check.dom.js +1 -1
- package/components/input/input.spec.js +1 -4
- package/components/label/_label.scss +1 -0
- package/components/label/_macro.njk +2 -2
- package/components/label/_macro.spec.js +4 -13
- package/components/list/_macro.spec.js +4 -12
- package/components/message/_macro.njk +17 -17
- package/components/message/_macro.spec.js +9 -33
- package/components/message-list/_macro.spec.js +7 -39
- package/components/metadata/_macro.njk +10 -10
- package/components/modal/_macro.spec.js +3 -9
- package/components/modal/modal.dom.js +1 -1
- package/components/modal/modal.spec.js +5 -5
- package/components/multiple-input-fields/_macro.njk +49 -0
- package/components/mutually-exclusive/_macro.spec.js +2 -10
- package/components/mutually-exclusive/mutually-exclusive.checkboxes.spec.js +26 -26
- package/components/mutually-exclusive/mutually-exclusive.date.spec.js +9 -9
- package/components/mutually-exclusive/mutually-exclusive.dom.js +1 -1
- package/components/mutually-exclusive/mutually-exclusive.duration.spec.js +8 -8
- package/components/mutually-exclusive/mutually-exclusive.email.spec.js +7 -7
- package/components/mutually-exclusive/mutually-exclusive.js +13 -13
- package/components/mutually-exclusive/mutually-exclusive.multiple-options.checkboxes.spec.js +29 -29
- package/components/mutually-exclusive/mutually-exclusive.number.spec.js +7 -7
- package/components/mutually-exclusive/mutually-exclusive.textarea.spec.js +8 -8
- package/components/navigation/navigation.spec.js +0 -2
- package/components/pagination/_macro.spec.js +11 -53
- package/components/panel/_macro.njk +17 -17
- package/components/panel/_macro.spec.js +25 -25
- package/components/panel/_panel.scss +10 -9
- package/components/panel/example-panel-bare.njk +3 -4
- package/components/panel/example-panel-with-announcement.njk +6 -10
- package/components/panel/example-panel-with-error-summary.njk +2 -2
- package/components/panel/example-panel-with-information.njk +0 -1
- package/components/panel/example-panel-with-success-message.njk +1 -1
- package/components/panel/example-panel-with-warning.njk +2 -3
- package/components/password/password.dom.js +1 -1
- package/components/phase-banner/_macro.spec.js +3 -9
- package/components/question/_macro.njk +1 -1
- package/components/question/_macro.spec.js +5 -19
- package/components/question/_question.scss +1 -4
- package/components/question/example-question-interviewer-note.njk +1 -1
- package/components/quote/_macro.spec.js +2 -10
- package/components/radios/clear-radios.js +3 -3
- package/components/radios/radio-with-fieldset.js +4 -4
- package/components/radios/radios.dom.js +1 -1
- package/components/radios/radios.spec.js +26 -26
- package/components/related-content/_macro.spec.js +2 -4
- package/components/related-content/_section-macro.spec.js +2 -8
- package/components/relationships/example-relationships-error.njk +16 -18
- package/components/relationships/relationships.dom.js +1 -1
- package/components/relationships/relationships.js +2 -2
- package/components/reply/_macro.spec.js +3 -3
- package/components/reply/reply.dom.js +1 -1
- package/components/reply/reply.spec.js +3 -3
- package/components/section-navigation/_macro.njk +12 -12
- package/components/section-navigation/_macro.spec.js +13 -21
- package/components/select/_macro.spec.js +6 -6
- package/components/share-page/_macro.spec.js +6 -14
- package/components/skip-to-content/_macro.spec.js +3 -11
- package/components/skip-to-content/skip-to-content.dom.js +1 -1
- package/components/skip-to-content/skip-to-content.js +1 -1
- package/components/skip-to-content/skip-to-content.spec.js +2 -2
- package/components/status/_macro.njk +2 -2
- package/components/status/_macro.spec.js +5 -9
- package/components/status/example-status-dead.njk +1 -1
- package/components/status/example-status-error.njk +1 -1
- package/components/status/example-status-pending.njk +1 -1
- package/components/status/example-status-small.njk +1 -1
- package/components/status/example-status-success.njk +1 -1
- package/components/summary/_macro.njk +7 -8
- package/components/summary/_macro.spec.js +27 -9
- package/components/table/_macro.spec.js +6 -10
- package/components/table/scrollable-table.dom.js +1 -1
- package/components/table/scrollable-table.js +1 -1
- package/components/table/sortable-table.js +4 -4
- package/components/table/table.spec.js +21 -17
- package/components/table-of-contents/_macro.njk +31 -31
- package/components/table-of-contents/_macro.spec.js +3 -11
- package/components/table-of-contents/toc.dom.js +1 -1
- package/components/table-of-contents/toc.spec.js +36 -32
- package/components/tabs/example-tabs-details.njk +1 -1
- package/components/tabs/tabs.dom.js +1 -1
- package/components/tabs/tabs.js +8 -8
- package/components/text-indent/_macro.spec.js +2 -6
- package/components/textarea/textarea.dom.js +1 -1
- package/components/textarea/textarea.spec.js +8 -8
- package/components/timeout-modal/_macro.spec.js +1 -3
- package/components/timeout-modal/timeout-modal.dom.js +1 -1
- package/components/timeout-modal/timeout-modal.spec.js +10 -10
- package/components/timeout-panel/_macro.njk +16 -17
- package/components/timeout-panel/_macro.spec.js +1 -1
- package/components/timeout-panel/timeout-panel.dom.js +1 -1
- package/components/timeout-panel/timeout-panel.spec.js +8 -8
- package/components/video/_macro.spec.js +1 -5
- package/components/video/video.dom.js +1 -1
- package/components/video/video.spec.js +16 -12
- package/css/main.css +1 -1
- package/favicons/safari-pinned-tab.svg +23 -23
- package/js/analytics.js +15 -14
- package/js/cookies-settings.dom.js +1 -1
- package/js/cookies-settings.spec.js +19 -19
- package/js/domready.js +1 -1
- package/js/fetch.js +1 -1
- package/js/inpagelink.js +3 -3
- package/js/main.js +1 -0
- package/js/print-button.js +1 -1
- package/js/timeout.js +1 -1
- package/package.json +2 -1
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +1 -1
- package/scss/base/_typography.scss +8 -2
- package/scss/main.scss +1 -0
- package/scss/overrides/hcm.scss +8 -1
- package/scss/vars/_colors.scss +2 -1
- package/components/date-field-input/_macro.njk +0 -86
package/README.md
CHANGED
|
@@ -153,3 +153,9 @@ yarn build
|
|
|
153
153
|
- [Sass](https://marketplace.visualstudio.com/items?itemName=robinbentley.sass-indented)
|
|
154
154
|
- [Stylelint](https://marketplace.visualstudio.com/items?itemName=stylelint.vscode-stylelint)
|
|
155
155
|
- [vscode-remark-lint](https://marketplace.visualstudio.com/items?itemName=drewbourne.vscode-remark-lint)
|
|
156
|
+
|
|
157
|
+
## Recommended Visual Studio Code settings for this project
|
|
158
|
+
|
|
159
|
+
- "render whitespace" set to "all"
|
|
160
|
+
- "insert spaces when pressing tab" checked
|
|
161
|
+
- "trim trailing whitespace" checked
|
|
@@ -124,11 +124,7 @@ describe('macro: access-code', () => {
|
|
|
124
124
|
}),
|
|
125
125
|
);
|
|
126
126
|
|
|
127
|
-
expect(
|
|
128
|
-
$('.ons-panel__body')
|
|
129
|
-
.text()
|
|
130
|
-
.trim(),
|
|
131
|
-
).toBe('Example security message.');
|
|
127
|
+
expect($('.ons-panel__body').text().trim()).toBe('Example security message.');
|
|
132
128
|
});
|
|
133
129
|
|
|
134
130
|
it('has provided `postTextBoxLinkText` and `postTextBoxLinkUrl`', () => {
|
|
@@ -139,11 +135,7 @@ describe('macro: access-code', () => {
|
|
|
139
135
|
}),
|
|
140
136
|
);
|
|
141
137
|
|
|
142
|
-
expect(
|
|
143
|
-
$('a[href="#3"]')
|
|
144
|
-
.text()
|
|
145
|
-
.trim(),
|
|
146
|
-
).toBe('Example link text');
|
|
138
|
+
expect($('a[href="#3"]').text().trim()).toBe('Example link text');
|
|
147
139
|
});
|
|
148
140
|
|
|
149
141
|
it('has provided `error` output', () => {
|
|
@@ -14,12 +14,12 @@ describe('script: access-code', () => {
|
|
|
14
14
|
await page.focus('#test-access-code');
|
|
15
15
|
await page.keyboard.type('1234');
|
|
16
16
|
|
|
17
|
-
const valueSample1 = await page.$eval('#test-access-code', element => element.value);
|
|
17
|
+
const valueSample1 = await page.$eval('#test-access-code', (element) => element.value);
|
|
18
18
|
expect(valueSample1).toBe('1234');
|
|
19
19
|
|
|
20
20
|
await page.keyboard.type('5678');
|
|
21
21
|
|
|
22
|
-
const valueSample2 = await page.$eval('#test-access-code', element => element.value);
|
|
22
|
+
const valueSample2 = await page.$eval('#test-access-code', (element) => element.value);
|
|
23
23
|
expect(valueSample2).toBe('12345 678');
|
|
24
24
|
});
|
|
25
25
|
});
|
|
@@ -9,17 +9,14 @@ layout: ~
|
|
|
9
9
|
{% from "components/details/_macro.njk" import onsDetails %}
|
|
10
10
|
|
|
11
11
|
{% set pageConfig = {
|
|
12
|
-
|
|
12
|
+
"title": "Study title"
|
|
13
13
|
} %}
|
|
14
14
|
|
|
15
15
|
{% block main %}
|
|
16
|
-
{% call
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
})
|
|
21
|
-
%}
|
|
22
|
-
|
|
16
|
+
{% call onsPanel({
|
|
17
|
+
"title": "There is a problem with this page",
|
|
18
|
+
"variant": "error"
|
|
19
|
+
}) %}
|
|
23
20
|
{% from "components/list/_macro.njk" import onsList %}
|
|
24
21
|
{{
|
|
25
22
|
onsList({
|
|
@@ -67,18 +64,16 @@ layout: ~
|
|
|
67
64
|
{% set content %}
|
|
68
65
|
<p>If you need to answer separately from the people you live with, you can <a href="#0">request an individual access code</a>.</p>
|
|
69
66
|
{% call onsPanel({
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
%}
|
|
67
|
+
"variant": "warn"
|
|
68
|
+
}) %}
|
|
73
69
|
Someone in your household must still complete a study using this household access code
|
|
74
70
|
{% endcall %}
|
|
75
71
|
{% endset %}
|
|
76
72
|
|
|
77
73
|
{% call onsDetails({
|
|
78
|
-
|
|
74
|
+
"id": "details-access-code-error",
|
|
79
75
|
"title": "Need to answer separately from your household?"
|
|
80
|
-
|
|
81
|
-
%}
|
|
76
|
+
}) %}
|
|
82
77
|
{{ content | safe }}
|
|
83
78
|
{% endcall %}
|
|
84
79
|
{% endblock %}
|
|
@@ -43,9 +43,8 @@ layout: ~
|
|
|
43
43
|
{% set content %}
|
|
44
44
|
<p>If you need to answer separately from the people you live with, you can <a href="#0">request an individual access code</a>.</p>
|
|
45
45
|
{% call onsPanel({
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
%}
|
|
46
|
+
"variant": "warn"
|
|
47
|
+
}) %}
|
|
49
48
|
Someone in your household must still complete a study using this household access code
|
|
50
49
|
{% endcall %}
|
|
51
50
|
{% endset %}
|
|
@@ -53,8 +52,7 @@ layout: ~
|
|
|
53
52
|
{% call onsDetails({
|
|
54
53
|
"id": "details",
|
|
55
54
|
"title": "Need to answer separately from your household?"
|
|
56
|
-
|
|
57
|
-
%}
|
|
55
|
+
}) %}
|
|
58
56
|
{{ content | safe }}
|
|
59
57
|
{% endcall %}
|
|
60
58
|
{% endblock %}
|
|
@@ -5,14 +5,14 @@ export default class Accordion {
|
|
|
5
5
|
this.button = button;
|
|
6
6
|
this.buttonInner = button.querySelector('.ons-accordion__toggle-all-inner');
|
|
7
7
|
this.group = button.getAttribute('data-group');
|
|
8
|
-
this.detailsEls = detailsEls.filter(details => details.group === this.group);
|
|
8
|
+
this.detailsEls = detailsEls.filter((details) => details.group === this.group);
|
|
9
9
|
this.totalDetailsEls = this.detailsEls.length;
|
|
10
10
|
this.buttonOpenEl = this.buttonInner.querySelector('.ons-btn__text');
|
|
11
11
|
this.buttonOpen = this.buttonOpenEl.innerHTML.trim();
|
|
12
12
|
this.closeButton = button.getAttribute('data-close-all');
|
|
13
|
-
this.open = this.detailsEls.find(details => details.open === true);
|
|
13
|
+
this.open = this.detailsEls.find((details) => details.open === true);
|
|
14
14
|
|
|
15
|
-
this.detailsEls.forEach(details => {
|
|
15
|
+
this.detailsEls.forEach((details) => {
|
|
16
16
|
details.onOpen = this.onOpen.bind(this);
|
|
17
17
|
details.onClose = this.onClose.bind(this);
|
|
18
18
|
});
|
|
@@ -31,7 +31,7 @@ export default class Accordion {
|
|
|
31
31
|
|
|
32
32
|
const open = !this.canClose();
|
|
33
33
|
|
|
34
|
-
this.detailsEls.forEach(details => {
|
|
34
|
+
this.detailsEls.forEach((details) => {
|
|
35
35
|
details.setOpen(open);
|
|
36
36
|
});
|
|
37
37
|
}
|
|
@@ -240,11 +240,7 @@ describe('macro: address-input', () => {
|
|
|
240
240
|
}),
|
|
241
241
|
);
|
|
242
242
|
|
|
243
|
-
expect(
|
|
244
|
-
$('.ons-js-address-search-btn')
|
|
245
|
-
.text()
|
|
246
|
-
.trim(),
|
|
247
|
-
).toBe('Search for address');
|
|
243
|
+
expect($('.ons-js-address-search-btn').text().trim()).toBe('Search for address');
|
|
248
244
|
});
|
|
249
245
|
});
|
|
250
246
|
|
|
@@ -408,11 +404,7 @@ describe('macro: address-input', () => {
|
|
|
408
404
|
);
|
|
409
405
|
|
|
410
406
|
expect($('.ons-js-address-manual-btn').attr('href')).toBe('#0');
|
|
411
|
-
expect(
|
|
412
|
-
$('.ons-js-address-manual-btn')
|
|
413
|
-
.text()
|
|
414
|
-
.trim(),
|
|
415
|
-
).toBe('Manually enter address');
|
|
407
|
+
expect($('.ons-js-address-manual-btn').text().trim()).toBe('Manually enter address');
|
|
416
408
|
});
|
|
417
409
|
|
|
418
410
|
it('renders `manualLinkText` with `manualLink` when provided', () => {
|
|
@@ -425,11 +417,7 @@ describe('macro: address-input', () => {
|
|
|
425
417
|
);
|
|
426
418
|
|
|
427
419
|
expect($('.ons-js-address-manual-btn').attr('href')).toBe('https://example.com/edit-address');
|
|
428
|
-
expect(
|
|
429
|
-
$('.ons-js-address-manual-btn')
|
|
430
|
-
.text()
|
|
431
|
-
.trim(),
|
|
432
|
-
).toBe('Manually enter address');
|
|
420
|
+
expect($('.ons-js-address-manual-btn').text().trim()).toBe('Manually enter address');
|
|
433
421
|
});
|
|
434
422
|
});
|
|
435
423
|
|
|
@@ -6,7 +6,7 @@ async function initialiseAddressAutosuggests() {
|
|
|
6
6
|
if (addressAutosuggests.length) {
|
|
7
7
|
const AutosuggestAddress = (await import('./autosuggest.address')).default;
|
|
8
8
|
|
|
9
|
-
addressAutosuggests.forEach(addressAutosuggest => new AutosuggestAddress(addressAutosuggest));
|
|
9
|
+
addressAutosuggests.forEach((addressAutosuggest) => new AutosuggestAddress(addressAutosuggest));
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -224,7 +224,7 @@ export default class AutosuggestAddress {
|
|
|
224
224
|
for (const item of items) {
|
|
225
225
|
if (item.addressCount === 1 && item.firstUprn !== 0) {
|
|
226
226
|
let result = await this.createAddressObject(item.firstUprn);
|
|
227
|
-
const matchingItem = items.findIndex(x => x.firstUprn == result.uprn);
|
|
227
|
+
const matchingItem = items.findIndex((x) => x.firstUprn == result.uprn);
|
|
228
228
|
items[matchingItem] = result;
|
|
229
229
|
}
|
|
230
230
|
}
|
|
@@ -244,7 +244,8 @@ export default class AutosuggestAddress {
|
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
testFullPostcodeQuery(input) {
|
|
247
|
-
const fullPostcodeRegex =
|
|
247
|
+
const fullPostcodeRegex =
|
|
248
|
+
/\b((?:(?:gir)|(?:[a-pr-uwyz])(?:(?:[0-9](?:[a-hjkpstuw]|[0-9])?)|(?:[a-hk-y][0-9](?:[0-9]|[abehmnprv-y])?)))) ?([0-9][abd-hjlnp-uw-z]{2})\b/i;
|
|
248
249
|
const testFullPostcode = fullPostcodeRegex.test(input);
|
|
249
250
|
if (testFullPostcode) {
|
|
250
251
|
return true;
|
|
@@ -103,7 +103,7 @@ export default class AddressSetter {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
clearManualInputs() {
|
|
106
|
-
this.manualInputs.forEach(input => {
|
|
106
|
+
this.manualInputs.forEach((input) => {
|
|
107
107
|
if (input) {
|
|
108
108
|
input.value = '';
|
|
109
109
|
}
|
|
@@ -112,13 +112,13 @@ export default class AddressSetter {
|
|
|
112
112
|
|
|
113
113
|
checkManualInputsValues(onLoad) {
|
|
114
114
|
if (onLoad) {
|
|
115
|
-
this.originalValues = this.manualInputs.map(input => {
|
|
115
|
+
this.originalValues = this.manualInputs.map((input) => {
|
|
116
116
|
if (input) {
|
|
117
117
|
return input.value;
|
|
118
118
|
}
|
|
119
119
|
});
|
|
120
120
|
} else if (this.uprn.value !== '' && this.originalValues.length) {
|
|
121
|
-
this.newValues = this.manualInputs.map(input => {
|
|
121
|
+
this.newValues = this.manualInputs.map((input) => {
|
|
122
122
|
return input.value;
|
|
123
123
|
});
|
|
124
124
|
if (this.originalValues.toString() !== this.newValues.toString()) {
|
|
@@ -196,11 +196,11 @@ describe('script: address-input', () => {
|
|
|
196
196
|
});
|
|
197
197
|
|
|
198
198
|
it('does not switch to manual input', async () => {
|
|
199
|
-
const isManualElementHidden = await page.$eval('.ons-js-address-input__manual', node =>
|
|
199
|
+
const isManualElementHidden = await page.$eval('.ons-js-address-input__manual', (node) =>
|
|
200
200
|
node.classList.contains('ons-u-db-no-js_enabled'),
|
|
201
201
|
);
|
|
202
202
|
expect(isManualElementHidden).toBe(true);
|
|
203
|
-
const isSearchElementHidden = await page.$eval('.ons-js-address-input__search', node => node.classList.contains('ons-u-d-no'));
|
|
203
|
+
const isSearchElementHidden = await page.$eval('.ons-js-address-input__search', (node) => node.classList.contains('ons-u-d-no'));
|
|
204
204
|
expect(isSearchElementHidden).toBe(false);
|
|
205
205
|
});
|
|
206
206
|
});
|
|
@@ -218,16 +218,16 @@ describe('script: address-input', () => {
|
|
|
218
218
|
});
|
|
219
219
|
|
|
220
220
|
it('switches to manual input', async () => {
|
|
221
|
-
const isManualElementHidden = await page.$eval('.ons-js-address-input__manual', node =>
|
|
221
|
+
const isManualElementHidden = await page.$eval('.ons-js-address-input__manual', (node) =>
|
|
222
222
|
node.classList.contains('ons-u-db-no-js_enabled'),
|
|
223
223
|
);
|
|
224
224
|
expect(isManualElementHidden).toBe(false);
|
|
225
|
-
const isSearchElementHidden = await page.$eval('.ons-js-address-input__search', node => node.classList.contains('ons-u-d-no'));
|
|
225
|
+
const isSearchElementHidden = await page.$eval('.ons-js-address-input__search', (node) => node.classList.contains('ons-u-d-no'));
|
|
226
226
|
expect(isSearchElementHidden).toBe(true);
|
|
227
227
|
});
|
|
228
228
|
|
|
229
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'));
|
|
230
|
+
const hassClass = await page.$eval('.ons-js-address-search-btn', (node) => node.classList.contains('ons-u-d-no'));
|
|
231
231
|
expect(hassClass).toBe(true);
|
|
232
232
|
});
|
|
233
233
|
});
|
|
@@ -237,18 +237,18 @@ describe('script: address-input', () => {
|
|
|
237
237
|
it('navigates to the first suggestion with the "Down" arrow key', async () => {
|
|
238
238
|
await setTestPage('/test', renderComponent('address-input', EXAMPLE_ADDRESS_INPUT_WITH_API));
|
|
239
239
|
|
|
240
|
-
await page.$eval('.ons-js-autosuggest-input', node => (node.value = 'CF14'));
|
|
240
|
+
await page.$eval('.ons-js-autosuggest-input', (node) => (node.value = 'CF14'));
|
|
241
241
|
await page.type('.ons-js-autosuggest-input', '2', { delay: 20 });
|
|
242
242
|
await page.keyboard.press('ArrowDown');
|
|
243
243
|
|
|
244
|
-
const selectedOption = await page.$eval('.ons-autosuggest__option--focused', node => node.textContent);
|
|
244
|
+
const selectedOption = await page.$eval('.ons-autosuggest__option--focused', (node) => node.textContent);
|
|
245
245
|
expect(selectedOption.trim()).toBe('196 College Road, Birmingham, B44 8HF');
|
|
246
246
|
});
|
|
247
247
|
|
|
248
248
|
it('provides expected parameters to the address API', async () => {
|
|
249
249
|
await setTestPage('/test', renderComponent('address-input', EXAMPLE_ADDRESS_INPUT_WITH_API));
|
|
250
250
|
|
|
251
|
-
await page.$eval('.ons-js-autosuggest-input', node => (node.value = '196 coll'));
|
|
251
|
+
await page.$eval('.ons-js-autosuggest-input', (node) => (node.value = '196 coll'));
|
|
252
252
|
await page.type('.ons-js-autosuggest-input', 'e');
|
|
253
253
|
|
|
254
254
|
expect(apiFaker.getRequestCount('/addresses/eq?input=196%20colle&limit=10')).toBe(1);
|
|
@@ -258,7 +258,7 @@ describe('script: address-input', () => {
|
|
|
258
258
|
beforeEach(async () => {
|
|
259
259
|
await setTestPage('/test', renderComponent('address-input', EXAMPLE_ADDRESS_INPUT_WITH_API));
|
|
260
260
|
|
|
261
|
-
await page.$eval('.ons-js-autosuggest-input', node => (node.value = 'CF14 2N'));
|
|
261
|
+
await page.$eval('.ons-js-autosuggest-input', (node) => (node.value = 'CF14 2N'));
|
|
262
262
|
await page.type('.ons-js-autosuggest-input', 'T');
|
|
263
263
|
});
|
|
264
264
|
|
|
@@ -267,7 +267,7 @@ describe('script: address-input', () => {
|
|
|
267
267
|
});
|
|
268
268
|
|
|
269
269
|
it('has expected suggestion entries', async () => {
|
|
270
|
-
const suggestions = await page.$$eval('.ons-autosuggest__option', nodes => nodes.map(node => node.textContent.trim()));
|
|
270
|
+
const suggestions = await page.$$eval('.ons-autosuggest__option', (nodes) => nodes.map((node) => node.textContent.trim()));
|
|
271
271
|
expect(suggestions).toEqual(['196 College Road, Birmingham, B44 8HF', '196 College Road, Whitchurch, Cardiff, CF14 2NZ']);
|
|
272
272
|
});
|
|
273
273
|
});
|
|
@@ -299,7 +299,7 @@ describe('script: address-input', () => {
|
|
|
299
299
|
|
|
300
300
|
await setTestPage('/test', renderComponent('address-input', EXAMPLE_ADDRESS_INPUT_WITH_API));
|
|
301
301
|
|
|
302
|
-
await page.$eval('.ons-js-autosuggest-input', node => (node.value = 'Penlline Road, Whitchurch, Cardiff, CF14 2N'));
|
|
302
|
+
await page.$eval('.ons-js-autosuggest-input', (node) => (node.value = 'Penlline Road, Whitchurch, Cardiff, CF14 2N'));
|
|
303
303
|
await page.type('.ons-js-autosuggest-input', 'Z');
|
|
304
304
|
await page.waitForTimeout(100);
|
|
305
305
|
});
|
|
@@ -313,7 +313,7 @@ describe('script: address-input', () => {
|
|
|
313
313
|
});
|
|
314
314
|
|
|
315
315
|
it('has expected suggestion entries', async () => {
|
|
316
|
-
const suggestions = await page.$$eval('.ons-autosuggest__option', nodes => nodes.map(node => node.textContent.trim()));
|
|
316
|
+
const suggestions = await page.$$eval('.ons-autosuggest__option', (nodes) => nodes.map((node) => node.textContent.trim()));
|
|
317
317
|
expect(suggestions).toEqual(['1 Penlline Road, Whitchurch, Cardiff, CF14 2NZ', '2 Penlline Road, Whitchurch, Cardiff, CF14 2NZ']);
|
|
318
318
|
});
|
|
319
319
|
|
|
@@ -329,12 +329,12 @@ describe('script: address-input', () => {
|
|
|
329
329
|
});
|
|
330
330
|
|
|
331
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');
|
|
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
338
|
});
|
|
339
339
|
});
|
|
340
340
|
});
|
|
@@ -343,7 +343,7 @@ describe('script: address-input', () => {
|
|
|
343
343
|
beforeEach(async () => {
|
|
344
344
|
await setTestPage('/test', renderComponent('address-input', EXAMPLE_ADDRESS_INPUT_WITH_API));
|
|
345
345
|
|
|
346
|
-
await page.$eval('.ons-js-autosuggest-input', node => (node.value = 'CF14 '));
|
|
346
|
+
await page.$eval('.ons-js-autosuggest-input', (node) => (node.value = 'CF14 '));
|
|
347
347
|
await page.type('.ons-js-autosuggest-input', '2');
|
|
348
348
|
await page.waitForTimeout(200);
|
|
349
349
|
});
|
|
@@ -353,7 +353,7 @@ describe('script: address-input', () => {
|
|
|
353
353
|
});
|
|
354
354
|
|
|
355
355
|
it('has expected suggestion entries', async () => {
|
|
356
|
-
const suggestions = await page.$$eval('.ons-autosuggest__option', nodes => nodes.map(node => node.textContent.trim()));
|
|
356
|
+
const suggestions = await page.$$eval('.ons-autosuggest__option', (nodes) => nodes.map((node) => node.textContent.trim()));
|
|
357
357
|
expect(suggestions).toEqual([
|
|
358
358
|
'Penlline Road, Whitchurch, Cardiff, CF14 2AA (41 addresses)',
|
|
359
359
|
'197 College Road, Whitchurch, Cardiff, CF14 2AB',
|
|
@@ -376,7 +376,7 @@ describe('script: address-input', () => {
|
|
|
376
376
|
});
|
|
377
377
|
|
|
378
378
|
it('has expected suggestion entries', async () => {
|
|
379
|
-
const suggestions = await page.$$eval('.ons-autosuggest__option', nodes => nodes.map(node => node.textContent.trim()));
|
|
379
|
+
const suggestions = await page.$$eval('.ons-autosuggest__option', (nodes) => nodes.map((node) => node.textContent.trim()));
|
|
380
380
|
expect(suggestions).toEqual(['197 College Road, Whitchurch, Cardiff, CF14 2AB']);
|
|
381
381
|
});
|
|
382
382
|
|
|
@@ -388,12 +388,12 @@ describe('script: address-input', () => {
|
|
|
388
388
|
});
|
|
389
389
|
|
|
390
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');
|
|
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
397
|
});
|
|
398
398
|
});
|
|
399
399
|
});
|
|
@@ -424,21 +424,21 @@ describe('script: address-input', () => {
|
|
|
424
424
|
|
|
425
425
|
await setTestPage('/test', renderComponent('address-input', EXAMPLE_ADDRESS_INPUT_WITH_API));
|
|
426
426
|
|
|
427
|
-
await page.$eval('.ons-js-autosuggest-input', node => (node.value = 'cf14'));
|
|
427
|
+
await page.$eval('.ons-js-autosuggest-input', (node) => (node.value = 'cf14'));
|
|
428
428
|
await page.type('.ons-js-autosuggest-input', '2', { delay: 20 });
|
|
429
429
|
await page.keyboard.press('ArrowDown');
|
|
430
430
|
await page.keyboard.press('Enter');
|
|
431
431
|
await page.waitForTimeout(100);
|
|
432
432
|
|
|
433
|
-
const isManualElementHidden = await page.$eval('.ons-js-address-input__manual', node =>
|
|
433
|
+
const isManualElementHidden = await page.$eval('.ons-js-address-input__manual', (node) =>
|
|
434
434
|
node.classList.contains('ons-u-db-no-js_enabled'),
|
|
435
435
|
);
|
|
436
436
|
expect(isManualElementHidden).toBe(false);
|
|
437
437
|
|
|
438
|
-
const isSearchElementHidden = await page.$eval('.ons-js-address-input__search', node => node.classList.contains('ons-u-d-no'));
|
|
438
|
+
const isSearchElementHidden = await page.$eval('.ons-js-address-input__search', (node) => node.classList.contains('ons-u-d-no'));
|
|
439
439
|
expect(isSearchElementHidden).toBe(true);
|
|
440
440
|
|
|
441
|
-
const isSearchButtonElementHidden = await page.$eval('.ons-js-address-search-btn', node => node.classList.contains('ons-u-d-no'));
|
|
441
|
+
const isSearchButtonElementHidden = await page.$eval('.ons-js-address-search-btn', (node) => node.classList.contains('ons-u-d-no'));
|
|
442
442
|
expect(isSearchButtonElementHidden).toBe(true);
|
|
443
443
|
});
|
|
444
444
|
});
|
|
@@ -456,26 +456,26 @@ describe('script: address-input', () => {
|
|
|
456
456
|
`,
|
|
457
457
|
);
|
|
458
458
|
|
|
459
|
-
await page.$eval('form', node =>
|
|
460
|
-
node.addEventListener('submit', event => {
|
|
459
|
+
await page.$eval('form', (node) =>
|
|
460
|
+
node.addEventListener('submit', (event) => {
|
|
461
461
|
event.preventDefault();
|
|
462
462
|
return false;
|
|
463
463
|
}),
|
|
464
464
|
);
|
|
465
465
|
|
|
466
|
-
await page.$eval('.ons-js-autosuggest-input', node => (node.value = 'CF14 2N'));
|
|
466
|
+
await page.$eval('.ons-js-autosuggest-input', (node) => (node.value = 'CF14 2N'));
|
|
467
467
|
await page.type('.ons-js-autosuggest-input', 'T', { delay: 20 });
|
|
468
468
|
await page.keyboard.press('ArrowDown');
|
|
469
469
|
await page.keyboard.press('Enter');
|
|
470
470
|
await page.waitForTimeout(100);
|
|
471
471
|
|
|
472
|
-
const urpnValueBefore = await page.$eval('.ons-js-hidden-uprn', node => node.value);
|
|
472
|
+
const urpnValueBefore = await page.$eval('.ons-js-hidden-uprn', (node) => node.value);
|
|
473
473
|
expect(urpnValueBefore).toBe('100070332099');
|
|
474
474
|
|
|
475
|
-
await page.$eval('.ons-js-address-line1', node => (node.value = 'Something else'));
|
|
475
|
+
await page.$eval('.ons-js-address-line1', (node) => (node.value = 'Something else'));
|
|
476
476
|
await page.click('button[type=submit]');
|
|
477
477
|
|
|
478
|
-
const urpnValueAfter = await page.$eval('.ons-js-hidden-uprn', node => node.value);
|
|
478
|
+
const urpnValueAfter = await page.$eval('.ons-js-hidden-uprn', (node) => node.value);
|
|
479
479
|
expect(urpnValueAfter).toBe('');
|
|
480
480
|
});
|
|
481
481
|
});
|
|
@@ -494,8 +494,8 @@ describe('script: address-input', () => {
|
|
|
494
494
|
`,
|
|
495
495
|
);
|
|
496
496
|
|
|
497
|
-
await page.$eval('form', node =>
|
|
498
|
-
node.addEventListener('submit', event => {
|
|
497
|
+
await page.$eval('form', (node) =>
|
|
498
|
+
node.addEventListener('submit', (event) => {
|
|
499
499
|
event.preventDefault();
|
|
500
500
|
return false;
|
|
501
501
|
}),
|
|
@@ -505,12 +505,12 @@ describe('script: address-input', () => {
|
|
|
505
505
|
});
|
|
506
506
|
|
|
507
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);
|
|
508
|
+
const panelExists = await page.$$eval('.ons-js-autosuggest-error-panel', (nodes) => nodes.length === 1);
|
|
509
509
|
expect(panelExists).toBe(true);
|
|
510
510
|
});
|
|
511
511
|
|
|
512
512
|
it('then input should be wrapped in an error', async () => {
|
|
513
|
-
const inputIsError = await page.$$eval('#autosuggest-input-error', nodes => nodes.length === 1);
|
|
513
|
+
const inputIsError = await page.$$eval('#autosuggest-input-error', (nodes) => nodes.length === 1);
|
|
514
514
|
expect(inputIsError).toBe(true);
|
|
515
515
|
});
|
|
516
516
|
|
|
@@ -518,7 +518,7 @@ describe('script: address-input', () => {
|
|
|
518
518
|
it('then the error summary should be removed', async () => {
|
|
519
519
|
await page.click('.ons-js-address-manual-btn');
|
|
520
520
|
|
|
521
|
-
const panelExists = await page.$$eval('.ons-js-autosuggest-error-panel', nodes => nodes.length === 1);
|
|
521
|
+
const panelExists = await page.$$eval('.ons-js-autosuggest-error-panel', (nodes) => nodes.length === 1);
|
|
522
522
|
expect(panelExists).toBe(false);
|
|
523
523
|
});
|
|
524
524
|
});
|
|
@@ -533,47 +533,47 @@ describe('script: address-input', () => {
|
|
|
533
533
|
});
|
|
534
534
|
|
|
535
535
|
it('shows manual input fields', async () => {
|
|
536
|
-
const isManualElementHidden = await page.$eval('.ons-js-address-input__manual', node =>
|
|
536
|
+
const isManualElementHidden = await page.$eval('.ons-js-address-input__manual', (node) =>
|
|
537
537
|
node.classList.contains('ons-u-db-no-js_enabled'),
|
|
538
538
|
);
|
|
539
539
|
expect(isManualElementHidden).toBe(false);
|
|
540
|
-
const isSearchElementHidden = await page.$eval('.ons-js-address-input__search', node => node.classList.contains('ons-u-d-no'));
|
|
540
|
+
const isSearchElementHidden = await page.$eval('.ons-js-address-input__search', (node) => node.classList.contains('ons-u-d-no'));
|
|
541
541
|
expect(isSearchElementHidden).toBe(true);
|
|
542
542
|
});
|
|
543
543
|
|
|
544
544
|
it('clears autosuggest input', async () => {
|
|
545
|
-
const value = await page.$eval('.ons-js-autosuggest-input', node => node.value);
|
|
545
|
+
const value = await page.$eval('.ons-js-autosuggest-input', (node) => node.value);
|
|
546
546
|
expect(value).toBe('');
|
|
547
547
|
});
|
|
548
548
|
|
|
549
549
|
describe('and then the search link is clicked', () => {
|
|
550
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'));
|
|
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
557
|
|
|
558
558
|
await page.click('.ons-js-address-search-btn');
|
|
559
559
|
});
|
|
560
560
|
|
|
561
561
|
it('hides manual input fields', async () => {
|
|
562
|
-
const isManualElementHidden = await page.$eval('.ons-js-address-input__manual', node =>
|
|
562
|
+
const isManualElementHidden = await page.$eval('.ons-js-address-input__manual', (node) =>
|
|
563
563
|
node.classList.contains('ons-u-db-no-js_enabled'),
|
|
564
564
|
);
|
|
565
565
|
expect(isManualElementHidden).toBe(true);
|
|
566
|
-
const isSearchElementHidden = await page.$eval('.ons-js-address-input__search', node => node.classList.contains('ons-u-d-no'));
|
|
566
|
+
const isSearchElementHidden = await page.$eval('.ons-js-address-input__search', (node) => node.classList.contains('ons-u-d-no'));
|
|
567
567
|
expect(isSearchElementHidden).toBe(false);
|
|
568
568
|
});
|
|
569
569
|
|
|
570
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('');
|
|
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
577
|
});
|
|
578
578
|
});
|
|
579
579
|
});
|
|
@@ -585,7 +585,7 @@ describe('script: address-input', () => {
|
|
|
585
585
|
});
|
|
586
586
|
|
|
587
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'));
|
|
588
|
+
await page.$eval('.ons-js-autosuggest-input', (node) => (node.value = '196 coll'));
|
|
589
589
|
await page.type('.ons-js-autosuggest-input', 'e');
|
|
590
590
|
|
|
591
591
|
expect(apiFaker.getRequestCount('/addresses/eq?input=196%20colle&limit=10&favourwelsh=true')).toBe(1);
|
|
@@ -597,7 +597,7 @@ describe('script: address-input', () => {
|
|
|
597
597
|
beforeEach(async () => {
|
|
598
598
|
await setTestPage('/test', renderComponent('address-input', EXAMPLE_ADDRESS_INPUT_WITH_API));
|
|
599
599
|
|
|
600
|
-
await page.$eval('.ons-js-autosuggest-input', node => (node.value = 'CF14'));
|
|
600
|
+
await page.$eval('.ons-js-autosuggest-input', (node) => (node.value = 'CF14'));
|
|
601
601
|
await page.type('.ons-js-autosuggest-input', '2', { delay: 20 });
|
|
602
602
|
await page.keyboard.press('ArrowDown');
|
|
603
603
|
await page.keyboard.press('Enter');
|
|
@@ -618,10 +618,7 @@ describe('script: address-input', () => {
|
|
|
618
618
|
`
|
|
619
619
|
<div class="ons-question">
|
|
620
620
|
<form action="/test/fake/form-handler" method="post">
|
|
621
|
-
${renderComponent('address-input', {
|
|
622
|
-
...EXAMPLE_ADDRESS_INPUT_WITH_API,
|
|
623
|
-
isEditable: false,
|
|
624
|
-
})}
|
|
621
|
+
${renderComponent('address-input', { ...EXAMPLE_ADDRESS_INPUT_WITH_API, isEditable: false })}
|
|
625
622
|
<button type="submit">Submit</button>
|
|
626
623
|
</form>
|
|
627
624
|
</div>
|
|
@@ -632,7 +629,7 @@ describe('script: address-input', () => {
|
|
|
632
629
|
});
|
|
633
630
|
|
|
634
631
|
it('sets aria status message', async () => {
|
|
635
|
-
const statusMessage = await page.$eval('.ons-js-autosuggest-aria-status', node => node.textContent);
|
|
632
|
+
const statusMessage = await page.$eval('.ons-js-autosuggest-aria-status', (node) => node.textContent);
|
|
636
633
|
expect(statusMessage).toBe('Enter 3 or more characters for suggestions.');
|
|
637
634
|
});
|
|
638
635
|
});
|
|
@@ -708,19 +705,19 @@ describe('script: address-input', () => {
|
|
|
708
705
|
}),
|
|
709
706
|
);
|
|
710
707
|
|
|
711
|
-
const setLangAttribute = lang => document.documentElement.setAttribute('lang', lang);
|
|
708
|
+
const setLangAttribute = (lang) => document.documentElement.setAttribute('lang', lang);
|
|
712
709
|
await page.evaluate(setLangAttribute, lang);
|
|
713
710
|
});
|
|
714
711
|
|
|
715
712
|
it('provides expected parameters to the address API', async () => {
|
|
716
|
-
await page.$eval('.ons-js-autosuggest-input', node => (node.value = '196 coll'));
|
|
713
|
+
await page.$eval('.ons-js-autosuggest-input', (node) => (node.value = '196 coll'));
|
|
717
714
|
await page.type('.ons-js-autosuggest-input', 'e');
|
|
718
715
|
|
|
719
716
|
expect(apiFaker.getRequestCount(searchEndpoint)).toBe(1);
|
|
720
717
|
});
|
|
721
718
|
|
|
722
719
|
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'));
|
|
720
|
+
await page.$eval('.ons-js-autosuggest-input', (node) => (node.value = '196 coll'));
|
|
724
721
|
await page.type('.ons-js-autosuggest-input', 'e', { delay: 20 });
|
|
725
722
|
await page.keyboard.press('ArrowDown');
|
|
726
723
|
await page.keyboard.press('Enter');
|