@ons/design-system 65.2.0 → 65.2.2
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 +1 -0
- package/components/access-code/example-access-code-error.njk +1 -1
- package/components/access-code/example-access-code.njk +1 -1
- package/components/accordion/example-accordion-open.njk +10 -10
- package/components/accordion/example-accordion.njk +1 -1
- package/components/address-input/example-address-input-editable.njk +2 -2
- package/components/address-input/example-address-input-manual.njk +3 -3
- package/components/address-input/example-address-input.njk +2 -2
- package/components/autosuggest/_macro.njk +1 -0
- package/components/autosuggest/autosuggest.js +2 -1
- package/components/autosuggest/autosuggest.spec.js +89 -55
- package/components/autosuggest/autosuggest.ui.js +8 -12
- package/components/autosuggest/example-autosuggest-country-multiple.njk +4 -3
- package/components/autosuggest/example-autosuggest-country.njk +1 -1
- package/components/back-link/example-back-link.njk +1 -1
- package/components/breadcrumbs/_macro.njk +1 -1
- package/components/breadcrumbs/_macro.spec.js +5 -5
- package/components/card/example-card-set-with-images.njk +3 -3
- package/components/card/example-card-set-with-lists.njk +3 -3
- package/components/card/example-card-set.njk +3 -3
- package/components/card/example-card.njk +1 -1
- package/components/checkboxes/example-checkboxes-disabled.njk +3 -3
- package/components/checkboxes/example-checkboxes-error.njk +7 -7
- package/components/checkboxes/example-checkboxes-with-descriptions.njk +7 -7
- package/components/checkboxes/example-checkboxes-with-hidden-label.njk +9 -9
- package/components/checkboxes/example-checkboxes-with-revealed-checkboxes-expanded.njk +8 -8
- package/components/checkboxes/example-checkboxes-with-revealed-checkboxes.njk +8 -8
- package/components/checkboxes/example-checkboxes-with-revealed-radios-expanded.njk +8 -8
- package/components/checkboxes/example-checkboxes-with-revealed-radios.njk +8 -8
- package/components/checkboxes/example-checkboxes-with-revealed-select-expanded.njk +4 -4
- package/components/checkboxes/example-checkboxes-with-revealed-select.njk +4 -4
- package/components/checkboxes/example-checkboxes-with-revealed-text-input-expanded.njk +6 -6
- package/components/checkboxes/example-checkboxes-with-revealed-text-input.njk +6 -6
- package/components/checkboxes/example-checkboxes-with-select-all-button.njk +4 -4
- package/components/checkboxes/example-checkboxes-with-visible-text-input.njk +6 -6
- package/components/checkboxes/example-checkboxes-without-border.njk +3 -3
- package/components/checkboxes/example-checkboxes.njk +4 -4
- package/components/cookies-banner/_macro.njk +55 -41
- package/components/cookies-banner/_macro.spec.js +9 -27
- package/components/date-input/example-date-input-error.njk +2 -2
- package/components/date-input/example-date-input.njk +1 -1
- package/components/details/example-details-with-warning.njk +1 -1
- package/components/details/example-details.njk +1 -1
- package/components/duration/example-duration-error.njk +6 -6
- package/components/duration/example-duration.njk +5 -5
- package/components/header/example-header-external-with-service-links.njk +1 -1
- package/components/header/example-header-internal.njk +1 -1
- package/components/input/example-input-email.njk +1 -1
- package/components/input/example-input-number.njk +1 -1
- package/components/input/example-input-numeric-values.njk +7 -7
- package/components/input/example-input-text-with-character-limit-checker.njk +1 -1
- package/components/input/example-input-text-with-description.njk +1 -1
- package/components/input/example-input-text.njk +1 -1
- package/components/mutually-exclusive/example-mutually-exclusive-checkboxes.njk +6 -6
- package/components/mutually-exclusive/example-mutually-exclusive-date-with-error.njk +2 -2
- package/components/mutually-exclusive/example-mutually-exclusive-email.njk +2 -2
- package/components/mutually-exclusive/example-mutually-exclusive-multiple-options.njk +5 -5
- package/components/panel/_macro.spec.js +7 -29
- package/components/phase-banner/_macro.njk +1 -1
- package/components/radios/example-radios-with-clear-button-expanded.njk +9 -9
- package/components/radios/example-radios-with-clear-button.njk +9 -9
- package/components/radios/example-radios-with-descriptions.njk +5 -5
- package/components/radios/example-radios-with-error.njk +4 -4
- package/components/radios/example-radios-with-revealed-checkboxes-expanded.njk +8 -8
- package/components/radios/example-radios-with-revealed-checkboxes.njk +8 -8
- package/components/radios/example-radios-with-revealed-radios-expanded.njk +9 -9
- package/components/radios/example-radios-with-revealed-radios.njk +8 -8
- package/components/radios/example-radios-with-revealed-select-expanded.njk +5 -5
- package/components/radios/example-radios-with-revealed-select.njk +4 -4
- package/components/radios/example-radios-with-revealed-text-input-expanded.njk +9 -9
- package/components/radios/example-radios-with-revealed-text-input.njk +9 -9
- package/components/radios/example-radios-with-visible-text-input.njk +3 -3
- package/components/relationships/example-relationships-error.njk +13 -13
- package/components/relationships/example-relationships-you.njk +13 -13
- package/components/relationships/example-relationships.njk +13 -13
- package/components/select/example-select-with-error.njk +1 -1
- package/components/select/example-select-with-inline-label.njk +1 -1
- package/components/select/example-select.njk +1 -1
- package/components/summary/_macro.njk +2 -2
- package/components/summary/_macro.spec.js +28 -25
- package/components/summary/example-summary-grouped-total.njk +2 -0
- package/components/summary/example-summary-grouped-with-errors.njk +4 -0
- package/components/summary/example-summary-grouped.njk +19 -0
- package/components/summary/example-summary-household.njk +5 -0
- package/components/summary/example-summary-hub.njk +8 -0
- package/components/summary/example-summary-multiple.njk +4 -0
- package/components/summary/example-summary.njk +4 -0
- package/components/textarea/example-textarea-error.njk +1 -1
- package/components/upload/example-upload-error.njk +1 -1
- package/components/upload/example-upload.njk +1 -1
- package/package.json +2 -3
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +1 -1
- /package/{fonts → scss/fonts}/opensans-bold.woff +0 -0
- /package/{fonts → scss/fonts}/opensans-bold.woff2 +0 -0
- /package/{fonts → scss/fonts}/opensans-regular.woff +0 -0
- /package/{fonts → scss/fonts}/opensans-regular.woff2 +0 -0
- /package/{fonts → scss/fonts}/robotomono-bold.woff +0 -0
- /package/{fonts → scss/fonts}/robotomono-bold.woff2 +0 -0
- /package/{fonts → scss/fonts}/robotomono-regular.woff +0 -0
- /package/{fonts → scss/fonts}/robotomono-regular.woff2 +0 -0
package/README.md
CHANGED
|
@@ -13,14 +13,14 @@
|
|
|
13
13
|
"name": "dietary",
|
|
14
14
|
"checkboxes": [
|
|
15
15
|
{
|
|
16
|
-
"id": "data",
|
|
16
|
+
"id": "data-checkbox",
|
|
17
17
|
"label": {
|
|
18
18
|
"text": "Data (309)"
|
|
19
19
|
},
|
|
20
20
|
"value": "data"
|
|
21
21
|
},
|
|
22
22
|
{
|
|
23
|
-
"id": "publications",
|
|
23
|
+
"id": "publications-checkbox",
|
|
24
24
|
"label": {
|
|
25
25
|
"text": "Publications (137)"
|
|
26
26
|
},
|
|
@@ -33,21 +33,21 @@
|
|
|
33
33
|
"name": "name",
|
|
34
34
|
"checkboxes": [
|
|
35
35
|
{
|
|
36
|
-
"id": "datasets",
|
|
36
|
+
"id": "datasets-checkbox",
|
|
37
37
|
"label": {
|
|
38
38
|
"text": "Datasets (100)"
|
|
39
39
|
},
|
|
40
40
|
"value": "datasets"
|
|
41
41
|
},
|
|
42
42
|
{
|
|
43
|
-
"id": "timeseries",
|
|
43
|
+
"id": "timeseries-checkbox",
|
|
44
44
|
"label": {
|
|
45
45
|
"text": "Timeseries (20)"
|
|
46
46
|
},
|
|
47
47
|
"value": "timeseries"
|
|
48
48
|
},
|
|
49
49
|
{
|
|
50
|
-
"id": "requested",
|
|
50
|
+
"id": "requested-checkbox",
|
|
51
51
|
"label": {
|
|
52
52
|
"text": "User requested data (16)"
|
|
53
53
|
},
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
59
|
{
|
|
60
|
-
"id": "areas",
|
|
60
|
+
"id": "areas-checkbox",
|
|
61
61
|
"label": {
|
|
62
62
|
"text": "Areas (0)"
|
|
63
63
|
},
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"name": "dietary",
|
|
79
79
|
"checkboxes": [
|
|
80
80
|
{
|
|
81
|
-
"id": "crime",
|
|
81
|
+
"id": "crime-checkbox",
|
|
82
82
|
"label": {
|
|
83
83
|
"text": "Crime (200)"
|
|
84
84
|
},
|
|
@@ -86,14 +86,14 @@
|
|
|
86
86
|
"checked": true
|
|
87
87
|
},
|
|
88
88
|
{
|
|
89
|
-
"id": "education",
|
|
89
|
+
"id": "education-checkbox",
|
|
90
90
|
"label": {
|
|
91
91
|
"text": "Education (55)"
|
|
92
92
|
},
|
|
93
|
-
"value": "education"
|
|
93
|
+
"value": "education-checkbox"
|
|
94
94
|
},
|
|
95
95
|
{
|
|
96
|
-
"id": "disability",
|
|
96
|
+
"id": "disability-checkbox",
|
|
97
97
|
"label": {
|
|
98
98
|
"text": "Disability (67)"
|
|
99
99
|
},
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{% from "components/address-input/_macro.njk" import onsAddressInput %}
|
|
2
2
|
|
|
3
3
|
{{ onsAddressInput({
|
|
4
|
-
"id": "address",
|
|
4
|
+
"id": "address-input-editable",
|
|
5
5
|
"dontWrap": true,
|
|
6
6
|
"label": {
|
|
7
7
|
"text": "Enter address or postcode and select from results",
|
|
8
|
-
"id": "address-label"
|
|
8
|
+
"id": "address-label-input-editable"
|
|
9
9
|
},
|
|
10
10
|
"isEditable": true,
|
|
11
11
|
"mandatory": true,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{% from "components/address-input/_macro.njk" import onsAddressInput %}
|
|
2
2
|
|
|
3
3
|
{{ onsAddressInput({
|
|
4
|
-
"id": "address",
|
|
4
|
+
"id": "address-input-manual",
|
|
5
5
|
"dontWrap": true,
|
|
6
6
|
"manualEntry": true,
|
|
7
7
|
"label": {
|
|
8
8
|
"text": "Enter address or postcode and select from results",
|
|
9
|
-
"id": "address-label"
|
|
9
|
+
"id": "address-label-input-manual"
|
|
10
10
|
},
|
|
11
11
|
"line1": {
|
|
12
12
|
"label": "Address line 1"
|
|
@@ -20,4 +20,4 @@
|
|
|
20
20
|
"postcode": {
|
|
21
21
|
"label": "Postcode"
|
|
22
22
|
}
|
|
23
|
-
}) }}
|
|
23
|
+
}) }}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{% from "components/address-input/_macro.njk" import onsAddressInput %}
|
|
2
2
|
|
|
3
3
|
{{ onsAddressInput({
|
|
4
|
-
"id": "address",
|
|
4
|
+
"id": "address-input",
|
|
5
5
|
"dontWrap": true,
|
|
6
6
|
"label": {
|
|
7
7
|
"text": "Enter address or postcode and select from results",
|
|
8
|
-
"id": "address-label"
|
|
8
|
+
"id": "address-label-input"
|
|
9
9
|
},
|
|
10
10
|
"isEditable": false,
|
|
11
11
|
"mandatory": true,
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
{% if params.tooManyResults %}data-too-many-results="{{ params.tooManyResults }}"{% endif %}
|
|
29
29
|
{% if params.errorMessageAPI %}data-error-api="{{ params.errorMessageAPI }}"{% endif %}
|
|
30
30
|
{% if params.errorMessageAPILinkText %}data-error-api-link-text="{{ params.errorMessageAPILinkText }}"{% endif %}
|
|
31
|
+
{% if params.language %}data-lang="{{ params.language }}"{% endif %}
|
|
31
32
|
{% if params.options %}
|
|
32
33
|
{% if params.options.oneYearAgo %}data-options-one-year-ago="true"{% endif %}
|
|
33
34
|
{% if params.options.regionCode %}data-options-region-code="{{ params.options.regionCode }}"{% endif %}
|
|
@@ -3,6 +3,7 @@ import AutosuggestUI from './autosuggest.ui';
|
|
|
3
3
|
export default class Autosuggest {
|
|
4
4
|
constructor(context) {
|
|
5
5
|
this.context = context;
|
|
6
|
+
this.language = context.getAttribute('data-lang');
|
|
6
7
|
|
|
7
8
|
this.autosuggest = new AutosuggestUI({
|
|
8
9
|
context,
|
|
@@ -13,7 +14,7 @@ export default class Autosuggest {
|
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
get lang() {
|
|
16
|
-
return document.documentElement.getAttribute('lang').toLowerCase();
|
|
17
|
+
return !this.language ? document.documentElement.getAttribute('lang').toLowerCase() : this.language.toLowerCase();
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
async onSelect(result) {
|
|
@@ -25,6 +25,31 @@ const EXAMPLE_AUTOSUGGEST = {
|
|
|
25
25
|
typeMore: 'Continue entering to get suggestions',
|
|
26
26
|
autosuggestData: '/test/fake/api/countries',
|
|
27
27
|
};
|
|
28
|
+
const EXAMPLE_AUTOSUGGEST_WITH_LANGUAGE = {
|
|
29
|
+
id: 'country-of-birth',
|
|
30
|
+
label: {
|
|
31
|
+
text: 'Current name of country',
|
|
32
|
+
description: 'Enter your own answer or select from suggestions',
|
|
33
|
+
id: 'country-of-birth-label',
|
|
34
|
+
classes: 'extra-label-class',
|
|
35
|
+
},
|
|
36
|
+
autocomplete: 'off',
|
|
37
|
+
instructions: 'Use up and down keys to navigate.',
|
|
38
|
+
ariaYouHaveSelected: 'You have selected',
|
|
39
|
+
ariaMinChars: 'Enter 3 or more characters for suggestions.',
|
|
40
|
+
minChars: 3,
|
|
41
|
+
ariaResultsLabel: 'Country suggestions',
|
|
42
|
+
ariaOneResult: 'There is one suggestion available.',
|
|
43
|
+
ariaNResults: 'There are {n} suggestions available.',
|
|
44
|
+
ariaLimitedResults: 'Type more characters to improve your search',
|
|
45
|
+
moreResults: 'Continue entering to improve suggestions',
|
|
46
|
+
resultsTitle: 'Suggestions',
|
|
47
|
+
resultsTitleId: 'country-of-birth-suggestions',
|
|
48
|
+
noResults: 'No suggestions found.',
|
|
49
|
+
typeMore: 'Continue entering to get suggestions',
|
|
50
|
+
autosuggestData: '/test/fake/api/countries',
|
|
51
|
+
language: 'en-gb',
|
|
52
|
+
};
|
|
28
53
|
|
|
29
54
|
describe('script: autosuggest', () => {
|
|
30
55
|
const apiFaker = new PuppeteerEndpointFaker('/test/fake/api');
|
|
@@ -72,11 +97,11 @@ describe('script: autosuggest', () => {
|
|
|
72
97
|
it('the instructions, listbox, and status should become visible', async () => {
|
|
73
98
|
await setTestPage('/test', renderComponent('autosuggest', EXAMPLE_AUTOSUGGEST));
|
|
74
99
|
|
|
75
|
-
const instructionsDisplayStyle = await page.$eval('.ons-js-autosuggest-instructions', node => getComputedStyle(node).display);
|
|
100
|
+
const instructionsDisplayStyle = await page.$eval('.ons-js-autosuggest-instructions', (node) => getComputedStyle(node).display);
|
|
76
101
|
expect(instructionsDisplayStyle).toBe('block');
|
|
77
|
-
const listboxDisplayStyle = await page.$eval('.ons-js-autosuggest-listbox', node => getComputedStyle(node).display);
|
|
102
|
+
const listboxDisplayStyle = await page.$eval('.ons-js-autosuggest-listbox', (node) => getComputedStyle(node).display);
|
|
78
103
|
expect(listboxDisplayStyle).toBe('block');
|
|
79
|
-
const statusDisplayStyle = await page.$eval('.ons-js-autosuggest-aria-status', node => getComputedStyle(node).display);
|
|
104
|
+
const statusDisplayStyle = await page.$eval('.ons-js-autosuggest-aria-status', (node) => getComputedStyle(node).display);
|
|
80
105
|
expect(statusDisplayStyle).toBe('block');
|
|
81
106
|
});
|
|
82
107
|
});
|
|
@@ -88,7 +113,7 @@ describe('script: autosuggest', () => {
|
|
|
88
113
|
await page.type('.ons-js-autosuggest-input', 'Unite', { delay: 20 });
|
|
89
114
|
await page.keyboard.press('ArrowDown');
|
|
90
115
|
|
|
91
|
-
const selectedOption = await page.$eval('.ons-autosuggest__option--focused', node => node.textContent);
|
|
116
|
+
const selectedOption = await page.$eval('.ons-autosuggest__option--focused', (node) => node.textContent);
|
|
92
117
|
expect(selectedOption.trim()).toBe('United States of America');
|
|
93
118
|
});
|
|
94
119
|
|
|
@@ -99,7 +124,7 @@ describe('script: autosuggest', () => {
|
|
|
99
124
|
await page.keyboard.press('ArrowDown');
|
|
100
125
|
await page.keyboard.press('ArrowDown');
|
|
101
126
|
|
|
102
|
-
const selectedOption = await page.$eval('.ons-autosuggest__option--focused', node => node.textContent);
|
|
127
|
+
const selectedOption = await page.$eval('.ons-autosuggest__option--focused', (node) => node.textContent);
|
|
103
128
|
expect(selectedOption.trim()).toBe('United States Virgin Islands');
|
|
104
129
|
});
|
|
105
130
|
|
|
@@ -110,11 +135,11 @@ describe('script: autosuggest', () => {
|
|
|
110
135
|
await page.keyboard.press('ArrowDown');
|
|
111
136
|
await page.keyboard.press('ArrowDown');
|
|
112
137
|
|
|
113
|
-
const ariaSelectedValue = await page.$eval('.ons-autosuggest__option--focused', node => node.getAttribute('aria-selected'));
|
|
138
|
+
const ariaSelectedValue = await page.$eval('.ons-autosuggest__option--focused', (node) => node.getAttribute('aria-selected'));
|
|
114
139
|
expect(ariaSelectedValue).toBe('true');
|
|
115
140
|
|
|
116
|
-
const selectedOptionId = await page.$eval('.ons-autosuggest__option--focused', node => node.getAttribute('id'));
|
|
117
|
-
const ariaActiveDescendant = await page.$eval('.ons-js-autosuggest-input', node => node.getAttribute('aria-activedescendant'));
|
|
141
|
+
const selectedOptionId = await page.$eval('.ons-autosuggest__option--focused', (node) => node.getAttribute('id'));
|
|
142
|
+
const ariaActiveDescendant = await page.$eval('.ons-js-autosuggest-input', (node) => node.getAttribute('aria-activedescendant'));
|
|
118
143
|
expect(ariaActiveDescendant).toBe(selectedOptionId);
|
|
119
144
|
});
|
|
120
145
|
|
|
@@ -124,7 +149,7 @@ describe('script: autosuggest', () => {
|
|
|
124
149
|
await page.type('.ons-js-autosuggest-input', 'Eng', { delay: 20 });
|
|
125
150
|
await page.keyboard.press('ArrowDown');
|
|
126
151
|
|
|
127
|
-
const statusMessage = await page.$eval('.ons-js-autosuggest-aria-status', node => node.textContent);
|
|
152
|
+
const statusMessage = await page.$eval('.ons-js-autosuggest-aria-status', (node) => node.textContent);
|
|
128
153
|
expect(statusMessage.trim()).toBe('England');
|
|
129
154
|
});
|
|
130
155
|
|
|
@@ -135,7 +160,7 @@ describe('script: autosuggest', () => {
|
|
|
135
160
|
await page.keyboard.press('ArrowDown');
|
|
136
161
|
await page.keyboard.press('ArrowDown');
|
|
137
162
|
|
|
138
|
-
const selectedSuggestionCount = await page.$$eval('.ons-autosuggest__option[aria-selected=true]', nodes => nodes.length);
|
|
163
|
+
const selectedSuggestionCount = await page.$$eval('.ons-autosuggest__option[aria-selected=true]', (nodes) => nodes.length);
|
|
139
164
|
expect(selectedSuggestionCount).toBe(1);
|
|
140
165
|
});
|
|
141
166
|
|
|
@@ -147,7 +172,7 @@ describe('script: autosuggest', () => {
|
|
|
147
172
|
await page.keyboard.press('ArrowDown');
|
|
148
173
|
await page.keyboard.press('ArrowDown');
|
|
149
174
|
|
|
150
|
-
const selectedOption = await page.$eval('.ons-autosuggest__option--focused', node => node.textContent);
|
|
175
|
+
const selectedOption = await page.$eval('.ons-autosuggest__option--focused', (node) => node.textContent);
|
|
151
176
|
expect(selectedOption.trim()).toBe('United States Virgin Islands');
|
|
152
177
|
});
|
|
153
178
|
|
|
@@ -162,7 +187,7 @@ describe('script: autosuggest', () => {
|
|
|
162
187
|
await page.keyboard.press('ArrowDown');
|
|
163
188
|
await page.keyboard.press('U');
|
|
164
189
|
|
|
165
|
-
const inputValue = await page.$eval('.ons-js-autosuggest-input', node => node.value);
|
|
190
|
+
const inputValue = await page.$eval('.ons-js-autosuggest-input', (node) => node.value);
|
|
166
191
|
expect(inputValue).toBe('United');
|
|
167
192
|
});
|
|
168
193
|
});
|
|
@@ -174,7 +199,7 @@ describe('script: autosuggest', () => {
|
|
|
174
199
|
await page.type('.ons-js-autosuggest-input', 'Unite', { delay: 20 });
|
|
175
200
|
await page.keyboard.press('ArrowUp');
|
|
176
201
|
|
|
177
|
-
const selectedOption = await page.$eval('.ons-autosuggest__option--focused', node => node.textContent);
|
|
202
|
+
const selectedOption = await page.$eval('.ons-autosuggest__option--focused', (node) => node.textContent);
|
|
178
203
|
expect(selectedOption.trim()).toBe('United States of America');
|
|
179
204
|
});
|
|
180
205
|
|
|
@@ -186,7 +211,7 @@ describe('script: autosuggest', () => {
|
|
|
186
211
|
await page.keyboard.press('ArrowDown');
|
|
187
212
|
await page.keyboard.press('ArrowUp');
|
|
188
213
|
|
|
189
|
-
const selectedOption = await page.$eval('.ons-autosuggest__option--focused', node => node.textContent);
|
|
214
|
+
const selectedOption = await page.$eval('.ons-autosuggest__option--focused', (node) => node.textContent);
|
|
190
215
|
expect(selectedOption.trim()).toBe('United States of America');
|
|
191
216
|
});
|
|
192
217
|
|
|
@@ -198,11 +223,11 @@ describe('script: autosuggest', () => {
|
|
|
198
223
|
await page.keyboard.press('ArrowDown');
|
|
199
224
|
await page.keyboard.press('ArrowUp');
|
|
200
225
|
|
|
201
|
-
const ariaSelectedValue = await page.$eval('.ons-autosuggest__option--focused', node => node.getAttribute('aria-selected'));
|
|
226
|
+
const ariaSelectedValue = await page.$eval('.ons-autosuggest__option--focused', (node) => node.getAttribute('aria-selected'));
|
|
202
227
|
expect(ariaSelectedValue).toBe('true');
|
|
203
228
|
|
|
204
|
-
const selectedOptionId = await page.$eval('.ons-autosuggest__option--focused', node => node.getAttribute('id'));
|
|
205
|
-
const ariaActiveDescendant = await page.$eval('.ons-js-autosuggest-input', node => node.getAttribute('aria-activedescendant'));
|
|
229
|
+
const selectedOptionId = await page.$eval('.ons-autosuggest__option--focused', (node) => node.getAttribute('id'));
|
|
230
|
+
const ariaActiveDescendant = await page.$eval('.ons-js-autosuggest-input', (node) => node.getAttribute('aria-activedescendant'));
|
|
206
231
|
expect(ariaActiveDescendant).toBe(selectedOptionId);
|
|
207
232
|
});
|
|
208
233
|
|
|
@@ -214,7 +239,7 @@ describe('script: autosuggest', () => {
|
|
|
214
239
|
await page.keyboard.press('ArrowDown');
|
|
215
240
|
await page.keyboard.press('ArrowUp');
|
|
216
241
|
|
|
217
|
-
const selectedSuggestionCount = await page.$$eval('.ons-autosuggest__option[aria-selected=true]', nodes => nodes.length);
|
|
242
|
+
const selectedSuggestionCount = await page.$$eval('.ons-autosuggest__option[aria-selected=true]', (nodes) => nodes.length);
|
|
218
243
|
expect(selectedSuggestionCount).toBe(1);
|
|
219
244
|
});
|
|
220
245
|
|
|
@@ -225,7 +250,7 @@ describe('script: autosuggest', () => {
|
|
|
225
250
|
await page.keyboard.press('ArrowUp');
|
|
226
251
|
await page.keyboard.press('ArrowUp');
|
|
227
252
|
|
|
228
|
-
const selectedOption = await page.$eval('.ons-autosuggest__option--focused', node => node.textContent);
|
|
253
|
+
const selectedOption = await page.$eval('.ons-autosuggest__option--focused', (node) => node.textContent);
|
|
229
254
|
expect(selectedOption.trim()).toBe('United States of America');
|
|
230
255
|
});
|
|
231
256
|
|
|
@@ -238,7 +263,7 @@ describe('script: autosuggest', () => {
|
|
|
238
263
|
await page.keyboard.press('ArrowUp');
|
|
239
264
|
await page.keyboard.press('d');
|
|
240
265
|
|
|
241
|
-
const inputValue = await page.$eval('.ons-js-autosuggest-input', node => node.value);
|
|
266
|
+
const inputValue = await page.$eval('.ons-js-autosuggest-input', (node) => node.value);
|
|
242
267
|
expect(inputValue).toBe('United');
|
|
243
268
|
});
|
|
244
269
|
});
|
|
@@ -252,7 +277,7 @@ describe('script: autosuggest', () => {
|
|
|
252
277
|
await page.keyboard.press('ArrowDown');
|
|
253
278
|
await page.keyboard.press('Enter');
|
|
254
279
|
|
|
255
|
-
const inputValue = await page.$eval('.ons-js-autosuggest-input', node => node.value);
|
|
280
|
+
const inputValue = await page.$eval('.ons-js-autosuggest-input', (node) => node.value);
|
|
256
281
|
expect(inputValue).toBe('United States Virgin Islands');
|
|
257
282
|
});
|
|
258
283
|
});
|
|
@@ -264,15 +289,15 @@ describe('script: autosuggest', () => {
|
|
|
264
289
|
await page.type('.ons-js-autosuggest-input', 'Unite', { delay: 20 });
|
|
265
290
|
await page.keyboard.press('Tab');
|
|
266
291
|
|
|
267
|
-
const suggestionCountSample1 = await page.$$eval('.ons-autosuggest__option', nodes => nodes.length);
|
|
292
|
+
const suggestionCountSample1 = await page.$$eval('.ons-autosuggest__option', (nodes) => nodes.length);
|
|
268
293
|
expect(suggestionCountSample1).toBe(2);
|
|
269
294
|
|
|
270
295
|
await page.waitForTimeout(200);
|
|
271
|
-
const suggestionCountSample2 = await page.$$eval('.ons-autosuggest__option', nodes => nodes.length);
|
|
296
|
+
const suggestionCountSample2 = await page.$$eval('.ons-autosuggest__option', (nodes) => nodes.length);
|
|
272
297
|
expect(suggestionCountSample2).toBe(2);
|
|
273
298
|
|
|
274
299
|
await page.waitForTimeout(320);
|
|
275
|
-
const suggestionCountSample3 = await page.$$eval('.ons-autosuggest__option', nodes => nodes.length);
|
|
300
|
+
const suggestionCountSample3 = await page.$$eval('.ons-autosuggest__option', (nodes) => nodes.length);
|
|
276
301
|
expect(suggestionCountSample3).toBe(0);
|
|
277
302
|
});
|
|
278
303
|
|
|
@@ -283,7 +308,7 @@ describe('script: autosuggest', () => {
|
|
|
283
308
|
await page.keyboard.press('Tab');
|
|
284
309
|
await page.waitForTimeout(320);
|
|
285
310
|
|
|
286
|
-
const listboxInnerHTML = await page.$eval('.ons-js-autosuggest-listbox', node => node.innerHTML);
|
|
311
|
+
const listboxInnerHTML = await page.$eval('.ons-js-autosuggest-listbox', (node) => node.innerHTML);
|
|
287
312
|
expect(listboxInnerHTML).toBe('');
|
|
288
313
|
});
|
|
289
314
|
|
|
@@ -294,7 +319,7 @@ describe('script: autosuggest', () => {
|
|
|
294
319
|
await page.keyboard.press('Tab');
|
|
295
320
|
await page.waitForTimeout(320);
|
|
296
321
|
|
|
297
|
-
const hasClass = await page.$eval('.ons-autosuggest', node => node.classList.contains('ons-autosuggest--has-results'));
|
|
322
|
+
const hasClass = await page.$eval('.ons-autosuggest', (node) => node.classList.contains('ons-autosuggest--has-results'));
|
|
298
323
|
expect(hasClass).toBe(false);
|
|
299
324
|
});
|
|
300
325
|
|
|
@@ -318,7 +343,7 @@ describe('script: autosuggest', () => {
|
|
|
318
343
|
await page.type('.ons-js-autosuggest-input', 'Unite', { delay: 20 });
|
|
319
344
|
await page.click('.ons-autosuggest__option:nth-child(2)');
|
|
320
345
|
|
|
321
|
-
const inputValue = await page.$eval('.ons-js-autosuggest-input', node => node.value);
|
|
346
|
+
const inputValue = await page.$eval('.ons-js-autosuggest-input', (node) => node.value);
|
|
322
347
|
expect(inputValue).toBe('United States Virgin Islands');
|
|
323
348
|
});
|
|
324
349
|
});
|
|
@@ -329,7 +354,7 @@ describe('script: autosuggest', () => {
|
|
|
329
354
|
|
|
330
355
|
await page.type('.ons-js-autosuggest-input', 'En', { delay: 20 });
|
|
331
356
|
|
|
332
|
-
const suggestionCount = await page.$$eval('.ons-autosuggest__option', nodes => nodes.length);
|
|
357
|
+
const suggestionCount = await page.$$eval('.ons-autosuggest__option', (nodes) => nodes.length);
|
|
333
358
|
expect(suggestionCount).toBe(0);
|
|
334
359
|
});
|
|
335
360
|
|
|
@@ -338,9 +363,18 @@ describe('script: autosuggest', () => {
|
|
|
338
363
|
|
|
339
364
|
await page.type('.ons-js-autosuggest-input', 'Eng', { delay: 20 });
|
|
340
365
|
|
|
341
|
-
const suggestionCount = await page.$$eval('.ons-autosuggest__option', nodes => nodes.length);
|
|
366
|
+
const suggestionCount = await page.$$eval('.ons-autosuggest__option', (nodes) => nodes.length);
|
|
342
367
|
expect(suggestionCount).toBe(1);
|
|
343
368
|
});
|
|
369
|
+
|
|
370
|
+
it('gets the language if set', async () => {
|
|
371
|
+
await setTestPage('/test', renderComponent('autosuggest', EXAMPLE_AUTOSUGGEST_WITH_LANGUAGE));
|
|
372
|
+
|
|
373
|
+
await page.type('.ons-js-autosuggest-input', 'Eng', { delay: 20 });
|
|
374
|
+
|
|
375
|
+
const attributes = await getNodeAttributes(page, '.ons-js-autosuggest');
|
|
376
|
+
expect(attributes['data-lang']).toBe('en-gb');
|
|
377
|
+
});
|
|
344
378
|
});
|
|
345
379
|
|
|
346
380
|
describe('when the mouse moves over a result and a suggestion is focused', () => {
|
|
@@ -351,7 +385,7 @@ describe('script: autosuggest', () => {
|
|
|
351
385
|
await page.keyboard.press('ArrowDown');
|
|
352
386
|
await page.hover('.ons-autosuggest__option:nth-child(2)');
|
|
353
387
|
|
|
354
|
-
const focusedClassCount = await page.$$eval('.ons-autosuggest__option--focused', nodes => nodes.length);
|
|
388
|
+
const focusedClassCount = await page.$$eval('.ons-autosuggest__option--focused', (nodes) => nodes.length);
|
|
355
389
|
expect(focusedClassCount).toBe(0);
|
|
356
390
|
});
|
|
357
391
|
});
|
|
@@ -371,7 +405,7 @@ describe('script: autosuggest', () => {
|
|
|
371
405
|
await page.hover('.ons-autosuggest__option:nth-child(2)');
|
|
372
406
|
await page.hover('#dummy');
|
|
373
407
|
|
|
374
|
-
const focusedClassCount = await page.$$eval('.ons-autosuggest__option--focused', nodes => nodes.length);
|
|
408
|
+
const focusedClassCount = await page.$$eval('.ons-autosuggest__option--focused', (nodes) => nodes.length);
|
|
375
409
|
expect(focusedClassCount).toBe(1);
|
|
376
410
|
});
|
|
377
411
|
});
|
|
@@ -384,7 +418,7 @@ describe('script: autosuggest', () => {
|
|
|
384
418
|
await page.keyboard.press('ArrowDown');
|
|
385
419
|
await page.type('.ons-js-autosuggest-input', 'd', { delay: 20 });
|
|
386
420
|
|
|
387
|
-
const focusedNodeCount = await page.$$eval('.ons-autosuggest__option--focused', nodes => nodes.length);
|
|
421
|
+
const focusedNodeCount = await page.$$eval('.ons-autosuggest__option--focused', (nodes) => nodes.length);
|
|
388
422
|
expect(focusedNodeCount).toBe(0);
|
|
389
423
|
});
|
|
390
424
|
|
|
@@ -393,7 +427,7 @@ describe('script: autosuggest', () => {
|
|
|
393
427
|
|
|
394
428
|
await page.type('.ons-js-autosuggest-input', 'Unite', { delay: 20 });
|
|
395
429
|
|
|
396
|
-
const ariaExpandedValue = await page.$eval('.ons-js-autosuggest-input', node => node.getAttribute('aria-expanded'));
|
|
430
|
+
const ariaExpandedValue = await page.$eval('.ons-js-autosuggest-input', (node) => node.getAttribute('aria-expanded'));
|
|
397
431
|
expect(ariaExpandedValue).toBe('true');
|
|
398
432
|
});
|
|
399
433
|
|
|
@@ -402,7 +436,7 @@ describe('script: autosuggest', () => {
|
|
|
402
436
|
|
|
403
437
|
await page.type('.ons-js-autosuggest-input', 'Unite', { delay: 20 });
|
|
404
438
|
|
|
405
|
-
const emboldened = await page.$$eval('.ons-autosuggest__option strong', nodes => nodes.map(node => node.textContent));
|
|
439
|
+
const emboldened = await page.$$eval('.ons-autosuggest__option strong', (nodes) => nodes.map((node) => node.textContent));
|
|
406
440
|
expect(emboldened).toEqual(['Unite', 'Unite']);
|
|
407
441
|
});
|
|
408
442
|
|
|
@@ -411,9 +445,9 @@ describe('script: autosuggest', () => {
|
|
|
411
445
|
|
|
412
446
|
await page.type('.ons-js-autosuggest-input', 'tland', { delay: 20 });
|
|
413
447
|
|
|
414
|
-
const matchCount = await page.$$eval('.ons-autosuggest__option', nodes => nodes.length);
|
|
448
|
+
const matchCount = await page.$$eval('.ons-autosuggest__option', (nodes) => nodes.length);
|
|
415
449
|
expect(matchCount).toBe(2);
|
|
416
|
-
const emboldened = await page.$$eval('.ons-autosuggest__option strong', nodes => nodes.map(node => node.textContent));
|
|
450
|
+
const emboldened = await page.$$eval('.ons-autosuggest__option strong', (nodes) => nodes.map((node) => node.textContent));
|
|
417
451
|
expect(emboldened).toEqual(['tland']);
|
|
418
452
|
});
|
|
419
453
|
|
|
@@ -422,7 +456,7 @@ describe('script: autosuggest', () => {
|
|
|
422
456
|
|
|
423
457
|
await page.type('.ons-js-autosuggest-input', 'st', { delay: 20 });
|
|
424
458
|
|
|
425
|
-
const statusMessage = await page.$eval('.ons-js-autosuggest-aria-status', node => node.textContent);
|
|
459
|
+
const statusMessage = await page.$eval('.ons-js-autosuggest-aria-status', (node) => node.textContent);
|
|
426
460
|
expect(statusMessage.trim()).toBe('Enter 3 or more characters for suggestions.');
|
|
427
461
|
});
|
|
428
462
|
|
|
@@ -431,7 +465,7 @@ describe('script: autosuggest', () => {
|
|
|
431
465
|
|
|
432
466
|
await page.type('.ons-js-autosuggest-input', 'Engla', { delay: 20 });
|
|
433
467
|
|
|
434
|
-
const statusMessage = await page.$eval('.ons-js-autosuggest-aria-status', node => node.textContent);
|
|
468
|
+
const statusMessage = await page.$eval('.ons-js-autosuggest-aria-status', (node) => node.textContent);
|
|
435
469
|
expect(statusMessage.trim()).toBe('There is one suggestion available.');
|
|
436
470
|
});
|
|
437
471
|
|
|
@@ -440,7 +474,7 @@ describe('script: autosuggest', () => {
|
|
|
440
474
|
|
|
441
475
|
await page.type('.ons-js-autosuggest-input', 'sta', { delay: 20 });
|
|
442
476
|
|
|
443
|
-
const statusMessage = await page.$eval('.ons-js-autosuggest-aria-status', node => node.textContent);
|
|
477
|
+
const statusMessage = await page.$eval('.ons-js-autosuggest-aria-status', (node) => node.textContent);
|
|
444
478
|
expect(statusMessage.trim()).toBe('There are 2 suggestions available.');
|
|
445
479
|
});
|
|
446
480
|
});
|
|
@@ -452,7 +486,7 @@ describe('script: autosuggest', () => {
|
|
|
452
486
|
|
|
453
487
|
await page.type('.ons-js-autosuggest-input', 'abc', { delay: 20 });
|
|
454
488
|
|
|
455
|
-
const noResultsContent = await page.$eval('.ons-autosuggest__option--no-results', node => node.textContent);
|
|
489
|
+
const noResultsContent = await page.$eval('.ons-autosuggest__option--no-results', (node) => node.textContent);
|
|
456
490
|
expect(noResultsContent).toBe('No suggestions found.');
|
|
457
491
|
});
|
|
458
492
|
|
|
@@ -461,7 +495,7 @@ describe('script: autosuggest', () => {
|
|
|
461
495
|
|
|
462
496
|
await page.type('.ons-js-autosuggest-input', 'abc', { delay: 20 });
|
|
463
497
|
|
|
464
|
-
const ariaExpandedValue = await page.$eval('.ons-js-autosuggest-input', node => node.getAttribute('aria-expanded'));
|
|
498
|
+
const ariaExpandedValue = await page.$eval('.ons-js-autosuggest-input', (node) => node.getAttribute('aria-expanded'));
|
|
465
499
|
expect(ariaExpandedValue).toBe('true');
|
|
466
500
|
});
|
|
467
501
|
|
|
@@ -470,7 +504,7 @@ describe('script: autosuggest', () => {
|
|
|
470
504
|
|
|
471
505
|
await page.type('.ons-js-autosuggest-input', 'ab', { delay: 20 });
|
|
472
506
|
|
|
473
|
-
const statusMessage = await page.$eval('.ons-js-autosuggest-aria-status', node => node.textContent);
|
|
507
|
+
const statusMessage = await page.$eval('.ons-js-autosuggest-aria-status', (node) => node.textContent);
|
|
474
508
|
expect(statusMessage.trim()).toBe('Enter 3 or more characters for suggestions.');
|
|
475
509
|
});
|
|
476
510
|
|
|
@@ -479,7 +513,7 @@ describe('script: autosuggest', () => {
|
|
|
479
513
|
|
|
480
514
|
await page.type('.ons-js-autosuggest-input', 'abc', { delay: 20 });
|
|
481
515
|
|
|
482
|
-
const statusMessage = await page.$eval('.ons-js-autosuggest-aria-status', node => node.textContent);
|
|
516
|
+
const statusMessage = await page.$eval('.ons-js-autosuggest-aria-status', (node) => node.textContent);
|
|
483
517
|
expect(statusMessage.trim()).toBe('No suggestions found.: "abc"');
|
|
484
518
|
});
|
|
485
519
|
});
|
|
@@ -496,7 +530,7 @@ describe('script: autosuggest', () => {
|
|
|
496
530
|
|
|
497
531
|
await page.type('.ons-js-autosuggest-input', 'abc', { delay: 20 });
|
|
498
532
|
|
|
499
|
-
const matchCount = await page.$$eval('.ons-autosuggest__option', nodes => nodes.length);
|
|
533
|
+
const matchCount = await page.$$eval('.ons-autosuggest__option', (nodes) => nodes.length);
|
|
500
534
|
expect(matchCount).toBe(0);
|
|
501
535
|
});
|
|
502
536
|
|
|
@@ -511,7 +545,7 @@ describe('script: autosuggest', () => {
|
|
|
511
545
|
|
|
512
546
|
await page.type('.ons-js-autosuggest-input', 'abc', { delay: 20 });
|
|
513
547
|
|
|
514
|
-
const ariaExpandedValue = await page.$eval('.ons-js-autosuggest-input', node => node.getAttribute('aria-expanded'));
|
|
548
|
+
const ariaExpandedValue = await page.$eval('.ons-js-autosuggest-input', (node) => node.getAttribute('aria-expanded'));
|
|
515
549
|
expect(ariaExpandedValue).toBe('false');
|
|
516
550
|
});
|
|
517
551
|
});
|
|
@@ -532,9 +566,9 @@ describe('script: autosuggest', () => {
|
|
|
532
566
|
});
|
|
533
567
|
|
|
534
568
|
it('shows the type more message', async () => {
|
|
535
|
-
const listItemCount = await page.$$eval('.ons-js-autosuggest-listbox > *', nodes => nodes.length);
|
|
569
|
+
const listItemCount = await page.$$eval('.ons-js-autosuggest-listbox > *', (nodes) => nodes.length);
|
|
536
570
|
expect(listItemCount).toBe(1);
|
|
537
|
-
const noResultsText = await page.$eval('.ons-autosuggest__option--no-results', node => node.innerText);
|
|
571
|
+
const noResultsText = await page.$eval('.ons-autosuggest__option--no-results', (node) => node.innerText);
|
|
538
572
|
expect(noResultsText.trim()).toBe('Continue entering to get suggestions');
|
|
539
573
|
});
|
|
540
574
|
});
|
|
@@ -563,29 +597,29 @@ describe('script: autosuggest', () => {
|
|
|
563
597
|
});
|
|
564
598
|
|
|
565
599
|
it('shows the API error message', async () => {
|
|
566
|
-
const listItemCount = await page.$$eval('.ons-js-autosuggest-listbox > *', nodes => nodes.length);
|
|
600
|
+
const listItemCount = await page.$$eval('.ons-js-autosuggest-listbox > *', (nodes) => nodes.length);
|
|
567
601
|
expect(listItemCount).toBe(1);
|
|
568
|
-
const warningText = await page.$eval('.ons-autosuggest__warning', node => node.textContent);
|
|
602
|
+
const warningText = await page.$eval('.ons-autosuggest__warning', (node) => node.textContent);
|
|
569
603
|
expect(warningText.trim()).toBe('!Sorry, there is a problem.');
|
|
570
604
|
});
|
|
571
605
|
|
|
572
606
|
it('the input should be disabled', async () => {
|
|
573
|
-
const hasDisabledAttribute = await page.$eval('.ons-js-autosuggest-input', node => node.hasAttribute('disabled'));
|
|
607
|
+
const hasDisabledAttribute = await page.$eval('.ons-js-autosuggest-input', (node) => node.hasAttribute('disabled'));
|
|
574
608
|
expect(hasDisabledAttribute).toBe(true);
|
|
575
609
|
});
|
|
576
610
|
|
|
577
611
|
it('the input value should be empty', async () => {
|
|
578
|
-
const inputValue = await page.$eval('.ons-js-autosuggest-input', node => node.value);
|
|
612
|
+
const inputValue = await page.$eval('.ons-js-autosuggest-input', (node) => node.value);
|
|
579
613
|
expect(inputValue).toBe('');
|
|
580
614
|
});
|
|
581
615
|
|
|
582
616
|
it('the label class should be added', async () => {
|
|
583
|
-
const hasClass = await page.$eval('.ons-label', node => node.classList.contains('ons-u-lighter'));
|
|
617
|
+
const hasClass = await page.$eval('.ons-label', (node) => node.classList.contains('ons-u-lighter'));
|
|
584
618
|
expect(hasClass).toBe(true);
|
|
585
619
|
});
|
|
586
620
|
|
|
587
621
|
it('the aria status should be set', async () => {
|
|
588
|
-
const statusMessage = await page.$eval('.ons-js-autosuggest-aria-status', node => node.textContent);
|
|
622
|
+
const statusMessage = await page.$eval('.ons-js-autosuggest-aria-status', (node) => node.textContent);
|
|
589
623
|
expect(statusMessage.trim()).toBe('Sorry, there is a problem.');
|
|
590
624
|
});
|
|
591
625
|
});
|
|
@@ -609,7 +643,7 @@ describe('script: autosuggest', () => {
|
|
|
609
643
|
await page.keyboard.press('Tab');
|
|
610
644
|
await page.focus('.ons-js-autosuggest-input');
|
|
611
645
|
|
|
612
|
-
const inputValue = await page.$eval('.ons-js-autosuggest-input', node => node.value);
|
|
646
|
+
const inputValue = await page.$eval('.ons-js-autosuggest-input', (node) => node.value);
|
|
613
647
|
expect(inputValue).toBe('England, ');
|
|
614
648
|
});
|
|
615
649
|
});
|
|
@@ -627,7 +661,7 @@ describe('script: autosuggest', () => {
|
|
|
627
661
|
await page.type('.ons-js-autosuggest-input', 'England, ', { delay: 20 });
|
|
628
662
|
await page.keyboard.press('Tab');
|
|
629
663
|
|
|
630
|
-
const inputValue = await page.$eval('.ons-js-autosuggest-input', node => node.value);
|
|
664
|
+
const inputValue = await page.$eval('.ons-js-autosuggest-input', (node) => node.value);
|
|
631
665
|
expect(inputValue).toBe('England');
|
|
632
666
|
});
|
|
633
667
|
});
|