@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,117 @@
|
|
|
1
|
+
import { renderComponent, setTestPage } from '../../tests/helpers/rendering';
|
|
2
|
+
|
|
3
|
+
const SCREEN_READER_TIMEOUT_DELAY = 300;
|
|
4
|
+
|
|
5
|
+
const EXAMPLE_MUTUALLY_EXCLUSIVE_EMAIL_INPUT_PARAMS = {
|
|
6
|
+
id: 'email',
|
|
7
|
+
type: 'email',
|
|
8
|
+
legend: 'Get a confirmation email',
|
|
9
|
+
label: {
|
|
10
|
+
text: 'Enter an email',
|
|
11
|
+
},
|
|
12
|
+
mutuallyExclusive: {
|
|
13
|
+
or: 'Or',
|
|
14
|
+
deselectMessage: 'Selecting this will clear your email',
|
|
15
|
+
deselectGroupAdjective: 'cleared',
|
|
16
|
+
deselectExclusiveOptionAdjective: 'deselected',
|
|
17
|
+
exclusiveOptions: [
|
|
18
|
+
{
|
|
19
|
+
id: 'email-exclusive-option',
|
|
20
|
+
name: 'no-email',
|
|
21
|
+
value: 'no-email',
|
|
22
|
+
label: {
|
|
23
|
+
text: 'I dont want to receive a confirmation email',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
describe('script: mutually-exclusive', () => {
|
|
31
|
+
describe('email input', () => {
|
|
32
|
+
beforeEach(async () => {
|
|
33
|
+
await setTestPage('/test', renderComponent('input', EXAMPLE_MUTUALLY_EXCLUSIVE_EMAIL_INPUT_PARAMS));
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
describe('Given the user populated the email input', () => {
|
|
37
|
+
beforeEach(async () => {
|
|
38
|
+
await page.type('#email', 'email@email.com');
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe('when the user clicks the mutually exclusive option', () => {
|
|
42
|
+
beforeEach(async () => {
|
|
43
|
+
await page.click('#email-exclusive-option');
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('then the mutually exclusive option should be checked', async () => {
|
|
47
|
+
const isChecked = await page.$eval('#email-exclusive-option', node => node.checked);
|
|
48
|
+
expect(isChecked).toBe(true);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('then the email input should be cleared', async () => {
|
|
52
|
+
const inputValue = await page.$eval('#email', node => node.value);
|
|
53
|
+
expect(inputValue).toBe('');
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('then the aria alert should tell the user that the email input has been cleared', async () => {
|
|
57
|
+
await page.waitForTimeout(SCREEN_READER_TIMEOUT_DELAY);
|
|
58
|
+
|
|
59
|
+
const alertText = await page.$eval('.ons-js-exclusive-alert', node => node.textContent);
|
|
60
|
+
expect(alertText).toBe('Enter an email cleared.');
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
describe('Given the user has checked the mutually exclusive exclusive option', () => {
|
|
66
|
+
beforeEach(async () => {
|
|
67
|
+
await page.click('#email-exclusive-option');
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
describe('when the user populates the email input', () => {
|
|
71
|
+
beforeEach(async () => {
|
|
72
|
+
await page.type('#email', 'email@email.com');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('then the exclusive option should be unchecked', async () => {
|
|
76
|
+
const isChecked = await page.$eval('#email-exclusive-option', node => node.checked);
|
|
77
|
+
expect(isChecked).toBe(false);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('then the aria alert should tell the user that the exclusive option has been unchecked', async () => {
|
|
81
|
+
await page.waitForTimeout(SCREEN_READER_TIMEOUT_DELAY);
|
|
82
|
+
|
|
83
|
+
const alertText = await page.$eval('.ons-js-exclusive-alert', node => node.textContent);
|
|
84
|
+
expect(alertText).toBe('I dont want to receive a confirmation email deselected.');
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
describe('Given the user has not populated the email input or checked the exclusive option', () => {
|
|
90
|
+
describe('when the user populates the email input', () => {
|
|
91
|
+
beforeEach(async () => {
|
|
92
|
+
await page.type('#email', 'email@email.com');
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('then the aria alert shouldnt say anything', async () => {
|
|
96
|
+
await page.waitForTimeout(SCREEN_READER_TIMEOUT_DELAY);
|
|
97
|
+
|
|
98
|
+
const alertText = await page.$eval('.ons-js-exclusive-alert', node => node.textContent);
|
|
99
|
+
expect(alertText).toBe('');
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
describe('when the user clicks the mutually exclusive option', () => {
|
|
104
|
+
beforeEach(async () => {
|
|
105
|
+
await page.click('#email-exclusive-option');
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('then the aria alert shouldnt say anything', async () => {
|
|
109
|
+
await page.waitForTimeout(SCREEN_READER_TIMEOUT_DELAY);
|
|
110
|
+
|
|
111
|
+
const alertText = await page.$eval('.ons-js-exclusive-alert', node => node.textContent);
|
|
112
|
+
expect(alertText).toBe('');
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
});
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { renderComponent, setTestPage } from '../../tests/helpers/rendering';
|
|
2
|
+
|
|
3
|
+
const SCREEN_READER_TIMEOUT_DELAY = 300;
|
|
4
|
+
|
|
5
|
+
const EXAMPLE_MUTUALLY_EXCLUSIVE_CHECKBOXES_PARAMS = {
|
|
6
|
+
legend: 'What type of central heating do you have?',
|
|
7
|
+
checkboxesLabel: 'Select all that apply',
|
|
8
|
+
name: 'mutually-exclusive',
|
|
9
|
+
checkboxes: [
|
|
10
|
+
{
|
|
11
|
+
id: 'gas',
|
|
12
|
+
label: {
|
|
13
|
+
text: 'Gas',
|
|
14
|
+
},
|
|
15
|
+
value: 'gas',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
id: 'electric',
|
|
19
|
+
label: {
|
|
20
|
+
text: 'Electric',
|
|
21
|
+
},
|
|
22
|
+
value: 'electric',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: 'solid-fuel',
|
|
26
|
+
label: {
|
|
27
|
+
text: 'Solid fuel',
|
|
28
|
+
},
|
|
29
|
+
value: 'solid-fuel',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: 'other-fuel',
|
|
33
|
+
label: {
|
|
34
|
+
text: 'Other',
|
|
35
|
+
},
|
|
36
|
+
value: 'other',
|
|
37
|
+
other: {
|
|
38
|
+
id: 'other-fuel-textbox',
|
|
39
|
+
name: 'other-fuel-answer',
|
|
40
|
+
label: {
|
|
41
|
+
text: 'Please specify',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
mutuallyExclusive: {
|
|
47
|
+
or: 'or',
|
|
48
|
+
deselectMessage: 'Selecting this will uncheck all other checkboxes',
|
|
49
|
+
deselectGroupAdjective: 'deselected',
|
|
50
|
+
deselectExclusiveOptionAdjective: 'deselected',
|
|
51
|
+
exclusiveOptions: [
|
|
52
|
+
{
|
|
53
|
+
id: 'no-central-heating',
|
|
54
|
+
label: {
|
|
55
|
+
text: 'No central heating',
|
|
56
|
+
},
|
|
57
|
+
value: 'no-central-heating',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: 'dont-know',
|
|
61
|
+
label: {
|
|
62
|
+
text: 'Dont know',
|
|
63
|
+
},
|
|
64
|
+
value: 'dont-know',
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
describe('script: mutually-exclusive', () => {
|
|
71
|
+
describe('checkboxes', () => {
|
|
72
|
+
beforeEach(async () => {
|
|
73
|
+
await setTestPage('/test', renderComponent('checkboxes', EXAMPLE_MUTUALLY_EXCLUSIVE_CHECKBOXES_PARAMS));
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
describe('Given the user has clicked multiple non-exclusive options', () => {
|
|
77
|
+
beforeEach(async () => {
|
|
78
|
+
await page.click('#gas');
|
|
79
|
+
await page.click('#electric');
|
|
80
|
+
await page.click('#other-fuel');
|
|
81
|
+
await page.type('#other-fuel-textbox', 'Biofuel');
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
describe('when the user clicks a mutually exclusive option', () => {
|
|
85
|
+
beforeEach(async () => {
|
|
86
|
+
await page.click('#dont-know');
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('then the mutually exclusive option is checked', async () => {
|
|
90
|
+
const isChecked = await page.$eval('#dont-know', node => node.checked);
|
|
91
|
+
expect(isChecked).toBe(true);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('then the checkboxes are not checked', async () => {
|
|
95
|
+
expect(await page.$eval('#gas', node => node.checked)).toBe(false);
|
|
96
|
+
expect(await page.$eval('#electric', node => node.checked)).toBe(false);
|
|
97
|
+
expect(await page.$eval('#solid-fuel', node => node.checked)).toBe(false);
|
|
98
|
+
expect(await page.$eval('#other-fuel', node => node.checked)).toBe(false);
|
|
99
|
+
expect(await page.$eval('#other-fuel-textbox', node => node.value)).toBe('');
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('then the aria-live message should reflect the removed non exclusive options', async () => {
|
|
103
|
+
await page.waitForTimeout(SCREEN_READER_TIMEOUT_DELAY);
|
|
104
|
+
|
|
105
|
+
const alertText = await page.$eval('.ons-js-exclusive-alert', node => node.textContent);
|
|
106
|
+
expect(alertText).toBe('Gas deselected. Electric deselected. Other deselected. Please specify deselected.');
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
describe('Given the user has clicked the mutually exclusive option', () => {
|
|
112
|
+
beforeEach(async () => {
|
|
113
|
+
await page.click('#dont-know');
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
describe('when the user clicks the non-exclusive options', () => {
|
|
117
|
+
beforeEach(async () => {
|
|
118
|
+
await page.click('#gas');
|
|
119
|
+
await page.click('#electric');
|
|
120
|
+
await page.click('#other-fuel');
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('then the expected checkboxes are checked', async () => {
|
|
124
|
+
expect(await page.$eval('#gas', node => node.checked)).toBe(true);
|
|
125
|
+
expect(await page.$eval('#electric', node => node.checked)).toBe(true);
|
|
126
|
+
expect(await page.$eval('#solid-fuel', node => node.checked)).toBe(false);
|
|
127
|
+
expect(await page.$eval('#other-fuel', node => node.checked)).toBe(true);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('then the exclusive options should not be checked', async () => {
|
|
131
|
+
expect(await page.$eval('#no-central-heating', node => node.checked)).toBe(false);
|
|
132
|
+
expect(await page.$eval('#dont-know', node => node.checked)).toBe(false);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it('then the aria-live message should reflect the removed exclusive option', async () => {
|
|
136
|
+
await page.waitForTimeout(SCREEN_READER_TIMEOUT_DELAY);
|
|
137
|
+
|
|
138
|
+
const alertText = await page.$eval('.ons-js-exclusive-alert', node => node.textContent);
|
|
139
|
+
expect(alertText).toBe('Dont know deselected.');
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
describe('and the user deselects an non-exclusive option', () => {
|
|
143
|
+
beforeEach(async () => {
|
|
144
|
+
await page.click('#electric');
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it('the aria-live message should not be updated', async () => {
|
|
148
|
+
await page.waitForTimeout(SCREEN_READER_TIMEOUT_DELAY);
|
|
149
|
+
|
|
150
|
+
const alertText = await page.$eval('.ons-js-exclusive-alert', node => node.textContent);
|
|
151
|
+
expect(alertText).toBe('Dont know deselected.');
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
describe('Given the user has not clicked the mutually exclusive option', () => {
|
|
158
|
+
describe('when the user clicks multiple non-exclusive options', () => {
|
|
159
|
+
beforeEach(async () => {
|
|
160
|
+
await page.click('#gas');
|
|
161
|
+
await page.click('#electric');
|
|
162
|
+
await page.click('#other-fuel');
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('then the expected checkboxes are checked', async () => {
|
|
166
|
+
expect(await page.$eval('#gas', node => node.checked)).toBe(true);
|
|
167
|
+
expect(await page.$eval('#electric', node => node.checked)).toBe(true);
|
|
168
|
+
expect(await page.$eval('#solid-fuel', node => node.checked)).toBe(false);
|
|
169
|
+
expect(await page.$eval('#other-fuel', node => node.checked)).toBe(true);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it('then the exclusive options should not be checked', async () => {
|
|
173
|
+
expect(await page.$eval('#no-central-heating', node => node.checked)).toBe(false);
|
|
174
|
+
expect(await page.$eval('#dont-know', node => node.checked)).toBe(false);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it('then the aria-live message should say nothing', async () => {
|
|
178
|
+
await page.waitForTimeout(SCREEN_READER_TIMEOUT_DELAY);
|
|
179
|
+
|
|
180
|
+
const alertText = await page.$eval('.ons-js-exclusive-alert', node => node.textContent);
|
|
181
|
+
expect(alertText).toBe('');
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
describe('Given the user has not clicked any of the non-exclusive options', () => {
|
|
187
|
+
describe('when the user clicks the mutually exclusive option', () => {
|
|
188
|
+
beforeEach(async () => {
|
|
189
|
+
await page.click('#dont-know');
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it('then the expected checkboxes are not checked', async () => {
|
|
193
|
+
expect(await page.$eval('#gas', node => node.checked)).toBe(false);
|
|
194
|
+
expect(await page.$eval('#electric', node => node.checked)).toBe(false);
|
|
195
|
+
expect(await page.$eval('#solid-fuel', node => node.checked)).toBe(false);
|
|
196
|
+
expect(await page.$eval('#other-fuel', node => node.checked)).toBe(false);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it('then the exclusive option should be checked', async () => {
|
|
200
|
+
expect(await page.$eval('#no-central-heating', node => node.checked)).toBe(false);
|
|
201
|
+
expect(await page.$eval('#dont-know', node => node.checked)).toBe(true);
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
it('then the aria-live message should say nothing', async () => {
|
|
205
|
+
await page.waitForTimeout(SCREEN_READER_TIMEOUT_DELAY);
|
|
206
|
+
|
|
207
|
+
const alertText = await page.$eval('.ons-js-exclusive-alert', node => node.textContent);
|
|
208
|
+
expect(alertText).toBe('');
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
});
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { renderComponent, setTestPage } from '../../tests/helpers/rendering';
|
|
2
|
+
|
|
3
|
+
const SCREEN_READER_TIMEOUT_DELAY = 300;
|
|
4
|
+
|
|
5
|
+
const EXAMPLE_MUTUALLY_EXCLUSIVE_NUMBER_INPUT_PARAMS = {
|
|
6
|
+
id: 'currency',
|
|
7
|
+
type: 'number',
|
|
8
|
+
legend: 'What is your annual income before tax in 2018/19?',
|
|
9
|
+
width: '5',
|
|
10
|
+
attributes: {
|
|
11
|
+
min: 0,
|
|
12
|
+
},
|
|
13
|
+
label: {
|
|
14
|
+
text: 'Gross annual income',
|
|
15
|
+
},
|
|
16
|
+
prefix: {
|
|
17
|
+
title: 'Pounds',
|
|
18
|
+
text: '£',
|
|
19
|
+
},
|
|
20
|
+
mutuallyExclusive: {
|
|
21
|
+
or: 'Or',
|
|
22
|
+
deselectMessage: 'Selecting this will clear your inputted annual income',
|
|
23
|
+
deselectGroupAdjective: 'cleared',
|
|
24
|
+
deselectExclusiveOptionAdjective: 'deselected',
|
|
25
|
+
exclusiveOptions: [
|
|
26
|
+
{
|
|
27
|
+
id: 'currency-exclusive-option',
|
|
28
|
+
name: 'no-currency',
|
|
29
|
+
value: 'no-currency',
|
|
30
|
+
label: {
|
|
31
|
+
text: 'I prefer not to say',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
describe('script: mutually-exclusive', () => {
|
|
39
|
+
describe('number input', () => {
|
|
40
|
+
beforeEach(async () => {
|
|
41
|
+
await setTestPage('/test', renderComponent('input', EXAMPLE_MUTUALLY_EXCLUSIVE_NUMBER_INPUT_PARAMS));
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
describe('Given the user populated the number input', () => {
|
|
45
|
+
beforeEach(async () => {
|
|
46
|
+
await page.type('#currency', '25000');
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
describe('when the user clicks the mutually exclusive option', () => {
|
|
50
|
+
beforeEach(async () => {
|
|
51
|
+
await page.click('#currency-exclusive-option');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('then the mutually exclusive option should be checked', async () => {
|
|
55
|
+
const isChecked = await page.$eval('#currency-exclusive-option', node => node.checked);
|
|
56
|
+
expect(isChecked).toBe(true);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('then the number input should be cleared', async () => {
|
|
60
|
+
const inputValue = await page.$eval('#currency', node => node.value);
|
|
61
|
+
expect(inputValue).toBe('');
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('then the aria alert should tell the user that the number input has been cleared', async () => {
|
|
65
|
+
await page.waitForTimeout(SCREEN_READER_TIMEOUT_DELAY);
|
|
66
|
+
|
|
67
|
+
const alertText = await page.$eval('.ons-js-exclusive-alert', node => node.textContent);
|
|
68
|
+
expect(alertText).toBe('Gross annual income cleared.');
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
describe('Given the user has checked the mutually exclusive exclusive option', () => {
|
|
74
|
+
beforeEach(async () => {
|
|
75
|
+
await page.click('#currency-exclusive-option');
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
describe('when the user populates the number input', () => {
|
|
79
|
+
beforeEach(async () => {
|
|
80
|
+
await page.type('#currency', '25000');
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('then the exclusive option should be unchecked', async () => {
|
|
84
|
+
const isChecked = await page.$eval('#currency-exclusive-option', node => node.checked);
|
|
85
|
+
expect(isChecked).toBe(false);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('then the aria alert should tell the user that the exclusive option has been unchecked', async () => {
|
|
89
|
+
await page.waitForTimeout(SCREEN_READER_TIMEOUT_DELAY);
|
|
90
|
+
|
|
91
|
+
const alertText = await page.$eval('.ons-js-exclusive-alert', node => node.textContent);
|
|
92
|
+
expect(alertText).toBe('I prefer not to say deselected.');
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
describe('Given the user has not populated the number input or checked the exclusive option', () => {
|
|
98
|
+
describe('when the user populates the number input', () => {
|
|
99
|
+
beforeEach(async () => {
|
|
100
|
+
await page.type('#currency', '25000');
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('then the aria alert shouldnt say anything', async () => {
|
|
104
|
+
await page.waitForTimeout(SCREEN_READER_TIMEOUT_DELAY);
|
|
105
|
+
|
|
106
|
+
const alertText = await page.$eval('.ons-js-exclusive-alert', node => node.textContent);
|
|
107
|
+
expect(alertText).toBe('');
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
describe('when the user clicks the mutually exclusive option', () => {
|
|
112
|
+
beforeEach(async () => {
|
|
113
|
+
await page.click('#currency-exclusive-option');
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('then the aria alert shouldnt say anything', async () => {
|
|
117
|
+
await page.waitForTimeout(SCREEN_READER_TIMEOUT_DELAY);
|
|
118
|
+
|
|
119
|
+
const alertText = await page.$eval('.ons-js-exclusive-alert', node => node.textContent);
|
|
120
|
+
expect(alertText).toBe('');
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
});
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { renderComponent, setTestPage } from '../../tests/helpers/rendering';
|
|
2
|
+
|
|
3
|
+
const SCREEN_READER_TIMEOUT_DELAY = 300;
|
|
4
|
+
|
|
5
|
+
const EXAMPLE_MUTUALLY_EXCLUSIVE_TEXTAREA_PARAMS = {
|
|
6
|
+
id: 'feedback',
|
|
7
|
+
name: 'feedback',
|
|
8
|
+
width: '30',
|
|
9
|
+
legend: 'What do you think of this service?',
|
|
10
|
+
label: {
|
|
11
|
+
text: 'Enter your feedback',
|
|
12
|
+
description: 'For example describe any difficulties you experienced in the use of this service',
|
|
13
|
+
},
|
|
14
|
+
charCheckLimit: {
|
|
15
|
+
limit: 200,
|
|
16
|
+
charCountSingular: 'You have {x} character remaining',
|
|
17
|
+
charCountPlural: 'You have {x} characters remaining',
|
|
18
|
+
},
|
|
19
|
+
mutuallyExclusive: {
|
|
20
|
+
or: 'Or',
|
|
21
|
+
deselectMessage: 'Selecting this will clear your feedback',
|
|
22
|
+
deselectGroupAdjective: 'cleared',
|
|
23
|
+
deselectExclusiveOptionAdjective: 'deselected',
|
|
24
|
+
exclusiveOptions: [
|
|
25
|
+
{
|
|
26
|
+
id: 'feedback-exclusive-option',
|
|
27
|
+
name: 'no-feedback',
|
|
28
|
+
value: 'no-feedback',
|
|
29
|
+
label: {
|
|
30
|
+
text: 'I dont want to provide feedback',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const FAKE_TEXTAREA_INPUT = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.';
|
|
38
|
+
|
|
39
|
+
describe('script: mutually-exclusive', () => {
|
|
40
|
+
describe('textarea', () => {
|
|
41
|
+
beforeEach(async () => {
|
|
42
|
+
await setTestPage('/test', renderComponent('textarea', EXAMPLE_MUTUALLY_EXCLUSIVE_TEXTAREA_PARAMS));
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe('Given the user populated the textarea', () => {
|
|
46
|
+
beforeEach(async () => {
|
|
47
|
+
await page.type('#feedback', FAKE_TEXTAREA_INPUT);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe('when the user clicks the mutually exclusive option', () => {
|
|
51
|
+
beforeEach(async () => {
|
|
52
|
+
await page.click('#feedback-exclusive-option');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('then the mutually exclusive option should be checked', async () => {
|
|
56
|
+
const isChecked = await page.$eval('#feedback-exclusive-option', node => node.checked);
|
|
57
|
+
expect(isChecked).toBe(true);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('then the textarea should be cleared', async () => {
|
|
61
|
+
const textareaValue = await page.$eval('#feedback', node => node.value);
|
|
62
|
+
expect(textareaValue).toBe('');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('then the characters remaining readout should be reset', async () => {
|
|
66
|
+
const limitText = await page.$eval('#feedback-lim-remaining', node => node.textContent);
|
|
67
|
+
expect(limitText).toBe('You have 200 characters remaining');
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('then the aria alert should tell the user that the textarea has been cleared', async () => {
|
|
71
|
+
await page.waitForTimeout(SCREEN_READER_TIMEOUT_DELAY);
|
|
72
|
+
|
|
73
|
+
const alertText = await page.$eval('.ons-js-exclusive-alert', node => node.textContent);
|
|
74
|
+
expect(alertText).toBe('Enter your feedback cleared.');
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
describe('Given the user has checked the mutually exclusive exclusiveOption', () => {
|
|
80
|
+
beforeEach(async () => {
|
|
81
|
+
await page.click('#feedback-exclusive-option');
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
describe('when the user populates the textarea', () => {
|
|
85
|
+
beforeEach(async () => {
|
|
86
|
+
await page.type('#feedback', FAKE_TEXTAREA_INPUT);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('then the exclusive option should be unchecked', async () => {
|
|
90
|
+
const isChecked = await page.$eval('#feedback-exclusive-option', node => node.checked);
|
|
91
|
+
expect(isChecked).toBe(false);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('then the aria alert should tell the user that the exclusive option has been unchecked', async () => {
|
|
95
|
+
await page.waitForTimeout(SCREEN_READER_TIMEOUT_DELAY);
|
|
96
|
+
|
|
97
|
+
const alertText = await page.$eval('.ons-js-exclusive-alert', node => node.textContent);
|
|
98
|
+
expect(alertText).toBe('I dont want to provide feedback deselected.');
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
describe('Given the user has not populated the textarea or checked the exclusive option', () => {
|
|
104
|
+
describe('when the user populates the textarea', () => {
|
|
105
|
+
beforeEach(async () => {
|
|
106
|
+
await page.type('#feedback', FAKE_TEXTAREA_INPUT);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('then the aria alert shouldnt say anything', async () => {
|
|
110
|
+
await page.waitForTimeout(SCREEN_READER_TIMEOUT_DELAY);
|
|
111
|
+
|
|
112
|
+
const alertText = await page.$eval('.ons-js-exclusive-alert', node => node.textContent);
|
|
113
|
+
expect(alertText).toBe('');
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
describe('when the user clicks the mutually exclusive option', () => {
|
|
118
|
+
beforeEach(async () => {
|
|
119
|
+
await page.click('#feedback-exclusive-option');
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it('then the aria alert shouldnt say anything', async () => {
|
|
123
|
+
await page.waitForTimeout(SCREEN_READER_TIMEOUT_DELAY);
|
|
124
|
+
|
|
125
|
+
const alertText = await page.$eval('.ons-js-exclusive-alert', node => node.textContent);
|
|
126
|
+
expect(alertText).toBe('');
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
});
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
}) }}
|
|
32
32
|
</div>
|
|
33
33
|
{% endif %}
|
|
34
|
-
<nav class="ons-navigation ons-js-navigation" id="{{ params.id }}" aria-label="{{ params.ariaLabel | default("Main menu") }}" data-analytics="header-navigation">
|
|
34
|
+
<nav class="ons-navigation ons-navigation--main ons-js-navigation" id="{{ params.id }}" aria-label="{{ params.ariaLabel | default("Main menu") }}" data-analytics="header-navigation">
|
|
35
35
|
<ul class="ons-navigation__list">
|
|
36
36
|
{% for item in (params.itemsList if params.itemsList is iterable else params.itemsList.items()) %}
|
|
37
37
|
<li class="ons-navigation__item {{ item.classes }}{{ ' ons-navigation__item--active' if (item.url == params.currentPath) or (item.url != (params.siteBasePath | default('/')) and item.url in params.currentPath) }}">
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
<div class="ons-container ons-container--gutterless@xxs@l{{ ' ons-container--full-width' if params.fullWidth }}{{ ' ons-container--wide' if params.wide }}">
|
|
48
48
|
<ul class="ons-navigation__list ons-navigation__list">
|
|
49
49
|
{% for item in (params.subNavigation.itemsList if params.subNavigation.itemsList is iterable else params.subNavigation.itemsList.items()) %}
|
|
50
|
-
<li class="ons-navigation__item
|
|
50
|
+
<li class="ons-navigation__item {{ item.classes }}{{ ' ons-navigation__item--active' if (item.url == params.subNavigation.currentPath) or (item.url != (params.subNavigation.siteBasePath | default('/')) and item.url in params.subNavigation.currentPath) }}">
|
|
51
51
|
<a class="ons-navigation__link ons-navigation__link" href="{{ item.url }}" {% if item.id is defined and item.id %}id="{{ item.id }}" {% endif %}>{{ item.title }}</a>
|
|
52
52
|
</li>
|
|
53
53
|
{% endfor %}
|
|
@@ -66,19 +66,19 @@
|
|
|
66
66
|
"aria-expanded": "false"
|
|
67
67
|
}
|
|
68
68
|
}) }}
|
|
69
|
-
<nav class="ons-navigation ons-navigation--sub-mobile ons-u-d-no
|
|
69
|
+
<nav class="ons-navigation ons-navigation--sub-mobile ons-u-d-no ons-js-secondary-nav ons-u-mt-xs" id="{{ params.subNavigation.id }}--mobile" aria-hidden="true" aria-label="{{ params.subNavigation.ariaLabel | default("Section menu") }}" data-analytics="header-section-navigation">
|
|
70
70
|
<div class="ons-container ons-container--gutterless@xxs@l{{ ' ons-container--full-width' if params.fullWidth }}{{ ' ons-container--wide' if params.wide }}">
|
|
71
|
-
<ul class="ons-navigation__list">
|
|
71
|
+
<ul class="ons-navigation__list ons-navigation__list--parent">
|
|
72
72
|
<li class="ons-navigation__item">
|
|
73
73
|
<a class="ons-navigation__link" href="{{ params.subNavigation.overviewURL }}">{{ params.subNavigation.overviewText | default('Overview') }}</a>
|
|
74
74
|
</li>
|
|
75
75
|
{% for item in (params.subNavigation.itemsList if params.subNavigation.itemsList is iterable else params.subNavigation.itemsList.items()) %}
|
|
76
76
|
<li class="ons-navigation__item {{ ' ons-navigation__item--active' if (item.url == params.subNavigation.currentPath) or (item.url != (params.subNavigation.siteBasePath | default('/')) and item.url in params.subNavigation.currentPath) }}">
|
|
77
|
-
<a class="ons-navigation__link" href="{{ item.url }}" {% if item.id is defined and item.id %}id="{{ item.id }}" {% endif %}>{{ item.title }}</a>
|
|
77
|
+
<a class="ons-navigation__link" href="{{ item.url }}" {% if item.id is defined and item.id %}id="{{ item.id }}--mobile" {% endif %}>{{ item.title }}</a>
|
|
78
78
|
{% if item.sections %}
|
|
79
79
|
{% for section in item.sections %}
|
|
80
80
|
{% if section.sectionTitle %}<h3 class="ons-navigation__list-header">{{ section.sectionTitle }}</h3>{% endif %}
|
|
81
|
-
<ul class="ons-navigation__list ons-list--dashed ons-u-ml-s ons-u-mt-xs">
|
|
81
|
+
<ul class="ons-navigation__list ons-navigation__list--child ons-list--dashed ons-u-ml-s ons-u-mt-xs">
|
|
82
82
|
{% for child in section.children %}
|
|
83
83
|
<li class="ons-navigation__item ons-list__item {{ ' ons-navigation__item--active' if (child.url == params.subNavigation.currentPath) or (child.url != (params.subNavigation.sitsiteBasePatheBasePath | default('/')) and child.url in params.subNavigation.currentPath) }}">
|
|
84
84
|
<a class="ons-navigation__link ons-navigation__link--section" href="{{ child.url }}" {% if child.id is defined and child.id %}id="{{ child.id }}" {% endif %}>{{ child.title }}</a>
|