@ons/design-system 65.2.1 → 65.2.3
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/components/breadcrumbs/_macro.njk +1 -1
- package/components/breadcrumbs/_macro.spec.js +5 -5
- package/components/card/example-card-set-with-lists.njk +6 -6
- package/components/cookies-banner/_macro.njk +55 -41
- package/components/cookies-banner/_macro.spec.js +9 -27
- package/components/download-resources/download-resources.spec.js +37 -36
- package/components/panel/_macro.spec.js +7 -29
- package/components/phase-banner/_macro.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/tabs/_macro.njk +1 -1
- package/components/tabs/example-tabs.njk +1 -0
- package/components/tabs/tabs.spec.js +52 -44
- package/layout/_template.njk +48 -43
- package/package.json +6 -5
- /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
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<ol class="ons-breadcrumbs__items ons-u-fs-s">
|
|
6
6
|
{% for item in params.itemsList %}
|
|
7
7
|
<li class="ons-breadcrumbs__item{{ ' ' + item.itemClasses if item.itemClasses else '' }}" id="breadcrumb-{{ loop.index }}">
|
|
8
|
-
<a class="ons-breadcrumbs__link{{ ' ' + item.linkClasses if item.linkClasses else '' }}" href="{{ item.url }}"{% if item.id %} id="{{ item.id }}"{% endif %}
|
|
8
|
+
<a class="ons-breadcrumbs__link{{ ' ' + item.linkClasses if item.linkClasses else '' }}" href={% if not isDesignSystemExample %}"{{ item.url }}"{% else %}"#0"{% endif %}{% if item.id %} id="{{ item.id }}"{% endif %}
|
|
9
9
|
{% if item.attributes %}{% for attribute, value in (item.attributes.items() if item.attributes is mapping and item.attributes.items else item.attributes) %}{{attribute}}="{{value}}" {% endfor %}{% endif %}
|
|
10
10
|
>{{ item.text }}</a>
|
|
11
11
|
{{
|
|
@@ -97,23 +97,23 @@ describe('macro: breadcrumbs', () => {
|
|
|
97
97
|
it('has provided `url` on `link` elements', () => {
|
|
98
98
|
const $ = cheerio.load(renderComponent('breadcrumbs', EXAMPLE_BREADCRUMBS));
|
|
99
99
|
|
|
100
|
-
const urls = mapAll($('.ons-breadcrumbs__link'), node => node.attr('href'));
|
|
100
|
+
const urls = mapAll($('.ons-breadcrumbs__link'), (node) => node.attr('href'));
|
|
101
101
|
expect(urls).toEqual(['https://example.com/', 'https://example.com/guide/']);
|
|
102
102
|
});
|
|
103
103
|
|
|
104
104
|
it('has provided `text` on `link` elements', () => {
|
|
105
105
|
const $ = cheerio.load(renderComponent('breadcrumbs', EXAMPLE_BREADCRUMBS));
|
|
106
106
|
|
|
107
|
-
const labels = mapAll($('.ons-breadcrumbs__link'), node => node.text().trim());
|
|
107
|
+
const labels = mapAll($('.ons-breadcrumbs__link'), (node) => node.text().trim());
|
|
108
108
|
expect(labels).toEqual(['Home', 'Guide']);
|
|
109
109
|
});
|
|
110
110
|
|
|
111
111
|
it('has provided `attributes` on `link` elements', () => {
|
|
112
112
|
const $ = cheerio.load(renderComponent('breadcrumbs', EXAMPLE_BREADCRUMBS));
|
|
113
113
|
|
|
114
|
-
const testValuesA = mapAll($('.ons-breadcrumbs__link'), node => node.attr('data-a'));
|
|
114
|
+
const testValuesA = mapAll($('.ons-breadcrumbs__link'), (node) => node.attr('data-a'));
|
|
115
115
|
expect(testValuesA).toEqual(['123', '789']);
|
|
116
|
-
const testValuesB = mapAll($('.ons-breadcrumbs__link'), node => node.attr('data-b'));
|
|
116
|
+
const testValuesB = mapAll($('.ons-breadcrumbs__link'), (node) => node.attr('data-b'));
|
|
117
117
|
expect(testValuesB).toEqual(['456', 'ABC']);
|
|
118
118
|
});
|
|
119
119
|
|
|
@@ -123,7 +123,7 @@ describe('macro: breadcrumbs', () => {
|
|
|
123
123
|
|
|
124
124
|
faker.renderComponent('breadcrumbs', EXAMPLE_BREADCRUMBS_MINIMAL);
|
|
125
125
|
|
|
126
|
-
const iconTypes = iconsSpy.occurrences.map(occurrence => occurrence.iconType);
|
|
126
|
+
const iconTypes = iconsSpy.occurrences.map((occurrence) => occurrence.iconType);
|
|
127
127
|
expect(iconTypes).toEqual(['chevron', 'chevron']);
|
|
128
128
|
});
|
|
129
129
|
});
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
"itemsList": [
|
|
14
14
|
{
|
|
15
15
|
"url": '#0',
|
|
16
|
-
"text": 'List item 1'
|
|
16
|
+
"text": 'List item 1 about the census'
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
19
|
"url": '#0',
|
|
20
|
-
"text": 'List item 2'
|
|
20
|
+
"text": 'List item 2 about the census'
|
|
21
21
|
}
|
|
22
22
|
]
|
|
23
23
|
}) }}
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
"itemsList": [
|
|
34
34
|
{
|
|
35
35
|
"url": '#0',
|
|
36
|
-
"text": 'List item 1'
|
|
36
|
+
"text": 'List item 1 about working on the census'
|
|
37
37
|
},
|
|
38
38
|
{
|
|
39
39
|
"url": '#0',
|
|
40
|
-
"text": 'List item 2'
|
|
40
|
+
"text": 'List item 2 about working on the census'
|
|
41
41
|
}
|
|
42
42
|
]
|
|
43
43
|
}) }}
|
|
@@ -53,11 +53,11 @@
|
|
|
53
53
|
"itemsList": [
|
|
54
54
|
{
|
|
55
55
|
"url": '#0',
|
|
56
|
-
"text": 'List item 1'
|
|
56
|
+
"text": 'List item 1 about your data and security'
|
|
57
57
|
},
|
|
58
58
|
{
|
|
59
59
|
"url": '#0',
|
|
60
|
-
"text": 'List item 2'
|
|
60
|
+
"text": 'List item 2 about your data and security'
|
|
61
61
|
}
|
|
62
62
|
]
|
|
63
63
|
}) }}
|
|
@@ -1,35 +1,50 @@
|
|
|
1
1
|
{% macro onsCookiesBanner(params) %}
|
|
2
|
+
{% from "components/button/_macro.njk" import onsButton %}
|
|
3
|
+
|
|
2
4
|
{% if params.lang == 'cy' %}
|
|
3
5
|
{% set ariaLabel = 'Cwcis' %}
|
|
4
6
|
{% set serviceName = 'ons.gov.uk' %}
|
|
7
|
+
{% set defaultCookiesLink = '/cwics' %}
|
|
5
8
|
{% set statementTitle = 'Cwcis ar' %}
|
|
6
9
|
{% set settingsLinkText = 'Gweld cwcis' %}
|
|
7
|
-
{% set settingsLinkURL = params.settingsLinkTextURL | default('/cwics') %}
|
|
8
|
-
{% set statementText = '<p>Ffeiliau bach a gaiff eu storio ar eich dyfais pan fyddwch yn mynd ar wefan yw cwcis. Rydym ni’n defnyddio rhai cwcis hanfodol i wneud i’r wefan hon weithio.</p><p>Hoffem osod <a href="' + settingsLinkURL + '">cwcis ychwanegol</a> er mwyn cofio eich gosodiadau a deall sut rydych chi’n defnyddio’r wefan. Mae hyn yn ein helpu ni i wella ein gwasanaethau.</p>' %}
|
|
9
10
|
{% set acceptButtonText = 'Derbyn cwcis ychwanegol' %}
|
|
10
11
|
{% set rejectButtonText = 'Gwrthod cwcis ychwanegol' %}
|
|
11
12
|
{% set acceptedText = 'Rydych chi wedi derbyn yr holl gwcis ychwanegol.' %}
|
|
12
|
-
{% set rejectedText =
|
|
13
|
-
{% set preferencesText = 'Gallwch chi <a href="' + settingsLinkURL + '">newid eich dewisiadau o ran cwcis</a> ar unrhyw adeg.' %}
|
|
13
|
+
{% set rejectedText = 'Rydych chi wedi gwrthod yr holl gwcis ychwanegol.' %}
|
|
14
14
|
{% set confirmationButtonText = 'Cuddio' %}
|
|
15
|
-
{% set
|
|
15
|
+
{% set contextSuffix = 'neges hon' %}
|
|
16
|
+
{% set beforeLinkPreferencesURL = 'Gallwch chi' %}
|
|
17
|
+
{% set afterLinkPreferencesURL = '"newid eich dewisiadau o ran cwcis</a> ar unrhyw adeg.' %}
|
|
18
|
+
{% set beforeLinkStatementText = '<p>Ffeiliau bach a gaiff eu storio ar eich dyfais pan fyddwch yn mynd ar wefan yw cwcis. Rydym ni’n defnyddio rhai cwcis hanfodol i wneud i’r wefan hon weithio.</p><p>Hoffem osod' %}
|
|
19
|
+
{% set afterLinkStatementText = 'cwcis ychwanegol</a> er mwyn cofio eich gosodiadau a deall sut rydych chi’n defnyddio’r wefan. Mae hyn yn ein helpu ni i wella ein gwasanaethau.</p>' %}
|
|
16
20
|
{% else %}
|
|
17
21
|
{% set ariaLabel = 'Cookies banner' %}
|
|
18
22
|
{% set serviceName = 'ons.gov.uk' %}
|
|
23
|
+
{% set defaultCookiesLink = '/cookies' %}
|
|
19
24
|
{% set statementTitle = 'Cookies on' %}
|
|
20
25
|
{% set settingsLinkText = 'View cookies' %}
|
|
21
|
-
{% set settingsLinkURL = params.settingsLinkTextURL | default('/cookies') %}
|
|
22
|
-
{% set statementText = '<p>Cookies are small files stored on your device when you visit a website. We use some essential cookies to make this website work.</p><p>We would like to set <a href="' + settingsLinkURL + '">additional cookies</a> to remember your settings and understand how you use the site. This helps us to improve our services. </p>' %}
|
|
23
26
|
{% set acceptButtonText = 'Accept additional cookies' %}
|
|
24
27
|
{% set rejectButtonText = 'Reject additional cookies' %}
|
|
25
28
|
{% set acceptedText = 'You have accepted all additional cookies.' %}
|
|
26
|
-
{% set rejectedText =
|
|
27
|
-
{% set preferencesText = 'You can <a href="' + settingsLinkURL + '">change your cookie preferences</a> at any time.' %}
|
|
29
|
+
{% set rejectedText = 'You have rejected all additional cookies.' %}
|
|
28
30
|
{% set confirmationButtonText = 'Hide' %}
|
|
29
31
|
{% set contextSuffix = 'this message' %}
|
|
32
|
+
{% set beforeLinkPreferencesURL = 'You can' %}
|
|
33
|
+
{% set afterLinkPreferencesURL = 'change your cookie preferences</a> at any time.' %}
|
|
34
|
+
{% set beforeLinkStatementText = '<p>Cookies are small files stored on your device when you visit a website. We use some essential cookies to make this website work.</p><p>We would like to set' %}
|
|
35
|
+
{% set afterLinkStatementText = 'additional cookies</a> to remember your settings and understand how you use the site. This helps us to improve our services. </p>' %}
|
|
30
36
|
{% endif %}
|
|
31
37
|
|
|
32
|
-
|
|
38
|
+
{% if not isDesignSystemExample %}
|
|
39
|
+
{% set settingsLinkURL = params.settingsLinkTextURL | default(defaultCookiesLink) %}
|
|
40
|
+
{% else %}
|
|
41
|
+
{% set settingsLinkURL = '#0' %}
|
|
42
|
+
{% endif %}
|
|
43
|
+
|
|
44
|
+
{% set statementText = beforeLinkStatementText + ' <a href="' + settingsLinkURL + '">' + afterLinkStatementText %}
|
|
45
|
+
{% set preferencesText = beforeLinkPreferencesURL + ' <a href="' + settingsLinkURL + '">' + afterLinkPreferencesURL %}
|
|
46
|
+
|
|
47
|
+
<div class="ons-cookies-banner" role="region" aria-label="{{ params.ariaLabel | default(ariaLabel) }}">
|
|
33
48
|
<div class="ons-container{{ ' ons-container--full-width' if params.fullWidth }}{{ ' ons-container--wide' if params.wide }} ons-cookies-banner__primary">
|
|
34
49
|
<div class="ons-grid">
|
|
35
50
|
<div class="ons-grid__col ons-col-8@m">
|
|
@@ -39,50 +54,49 @@
|
|
|
39
54
|
</div>
|
|
40
55
|
<div class="ons-grid ons-grid--flex ons-u-mt-s">
|
|
41
56
|
<div class="ons-grid__col">
|
|
42
|
-
{% from "components/button/_macro.njk" import onsButton %}
|
|
43
57
|
{{
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
58
|
+
onsButton({
|
|
59
|
+
"type": 'button',
|
|
60
|
+
"attributes": {
|
|
61
|
+
"data-button": 'accept'
|
|
62
|
+
},
|
|
63
|
+
"text": params.acceptButtonText | default(acceptButtonText),
|
|
64
|
+
"classes": 'ons-btn--small ons-js-accept-cookies ons-cookies-banner__btn'
|
|
65
|
+
})
|
|
52
66
|
}}
|
|
53
67
|
</div>
|
|
54
68
|
<div class="ons-grid__col">
|
|
55
69
|
{{
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
70
|
+
onsButton({
|
|
71
|
+
"type": 'button',
|
|
72
|
+
"attributes": {
|
|
73
|
+
"data-button": 'reject'
|
|
74
|
+
},
|
|
75
|
+
"text": params.rejectButtonText | default(rejectButtonText),
|
|
76
|
+
"classes": 'ons-btn--small ons-js-reject-cookies ons-cookies-banner__btn'
|
|
77
|
+
})
|
|
64
78
|
}}
|
|
65
79
|
</div>
|
|
66
80
|
<div class="ons-grid__col">
|
|
67
|
-
<a class="ons-cookies-banner__link" href="{{
|
|
81
|
+
<a class="ons-cookies-banner__link" href="{{ settingsLinkURL }}">{{ params.settingsLinkText | default(settingsLinkText) }}</a>
|
|
68
82
|
</div>
|
|
69
83
|
</div>
|
|
70
84
|
</div>
|
|
71
85
|
<div class="ons-container{{ ' ons-container--full-width' if params.fullWidth }}{{ ' ons-container--wide' if params.wide }} ons-cookies-banner__confirmation ons-u-d-no">
|
|
72
86
|
<div class="ons-grid ons-grid--flex ons-grid--between ons-grid--gutterless ons-grid--no-wrap@s ons-grid--vertical-center">
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
87
|
+
<div class="ons-grid__col ons-grid__col--flex ons-col-auto ons-u-flex-shrink@s">
|
|
88
|
+
<p class="ons-cookies-banner__desc ons-u-mb-no@s ons-u-mr-s@s"><span class="ons-js-accepted-text ons-u-d-no">{{ params.acceptedText | default(acceptedText) | safe }} </span><span class="ons-js-rejected-text ons-u-d-no">{{ params.rejectedText | default(rejectedText) | safe }} </span><span class="ons-cookies-banner__preferences-text">{{ params.preferencesText | default(preferencesText) | safe }}</span></p>
|
|
89
|
+
</div>
|
|
90
|
+
<div class="ons-grid__col">
|
|
91
|
+
{{
|
|
92
|
+
onsButton({
|
|
93
|
+
"type": 'button',
|
|
94
|
+
"text": params.confirmationButtonText | default(confirmationButtonText),
|
|
95
|
+
"buttonContext": params.contextSuffix | default(contextSuffix),
|
|
96
|
+
"classes": 'ons-btn--secondary ons-btn--small ons-js-hide-button'
|
|
97
|
+
})
|
|
98
|
+
}}
|
|
99
|
+
</div>
|
|
86
100
|
</div>
|
|
87
101
|
</div>
|
|
88
102
|
</div>
|
|
@@ -43,18 +43,14 @@ describe('macro: cookies-banner', () => {
|
|
|
43
43
|
it('has `statementTitle` title text', () => {
|
|
44
44
|
const $ = cheerio.load(renderComponent('cookies-banner', EXAMPLE_COOKIES_BANNER_PARAMS));
|
|
45
45
|
|
|
46
|
-
const statementTitle = $('.ons-cookies-banner__title')
|
|
47
|
-
.text()
|
|
48
|
-
.trim();
|
|
46
|
+
const statementTitle = $('.ons-cookies-banner__title').text().trim();
|
|
49
47
|
expect(statementTitle).toBe('Cookies on override ons.gov.uk override');
|
|
50
48
|
});
|
|
51
49
|
|
|
52
50
|
it('has `statementText` text', () => {
|
|
53
51
|
const $ = cheerio.load(renderComponent('cookies-banner', EXAMPLE_COOKIES_BANNER_PARAMS));
|
|
54
52
|
|
|
55
|
-
const statementText = $('.ons-cookies-banner__primary .ons-cookies-banner__statement')
|
|
56
|
-
.html()
|
|
57
|
-
.trim();
|
|
53
|
+
const statementText = $('.ons-cookies-banner__primary .ons-cookies-banner__statement').html().trim();
|
|
58
54
|
expect(statementText).toBe('Statement override');
|
|
59
55
|
});
|
|
60
56
|
|
|
@@ -79,9 +75,7 @@ describe('macro: cookies-banner', () => {
|
|
|
79
75
|
it('Renders a link with text', () => {
|
|
80
76
|
const $ = cheerio.load(renderComponent('cookies-banner', EXAMPLE_COOKIES_BANNER_PARAMS));
|
|
81
77
|
|
|
82
|
-
const linkText = $('.ons-cookies-banner__link')
|
|
83
|
-
.text()
|
|
84
|
-
.trim();
|
|
78
|
+
const linkText = $('.ons-cookies-banner__link').text().trim();
|
|
85
79
|
expect(linkText).toBe('Cookie settings override');
|
|
86
80
|
});
|
|
87
81
|
|
|
@@ -97,9 +91,7 @@ describe('macro: cookies-banner', () => {
|
|
|
97
91
|
it('has `preferencesText` text', () => {
|
|
98
92
|
const $ = cheerio.load(renderComponent('cookies-banner', EXAMPLE_COOKIES_BANNER_PARAMS));
|
|
99
93
|
|
|
100
|
-
const preferencesText = $('.ons-cookies-banner__confirmation .ons-cookies-banner__preferences-text')
|
|
101
|
-
.html()
|
|
102
|
-
.trim();
|
|
94
|
+
const preferencesText = $('.ons-cookies-banner__confirmation .ons-cookies-banner__preferences-text').html().trim();
|
|
103
95
|
expect(preferencesText).toBe('Text override');
|
|
104
96
|
});
|
|
105
97
|
|
|
@@ -134,18 +126,14 @@ describe('macro: cookies-banner', () => {
|
|
|
134
126
|
it('has `statementTitle` title text', () => {
|
|
135
127
|
const $ = cheerio.load(renderComponent('cookies-banner', {}));
|
|
136
128
|
|
|
137
|
-
const statementTitle = $('.ons-cookies-banner__title')
|
|
138
|
-
.text()
|
|
139
|
-
.trim();
|
|
129
|
+
const statementTitle = $('.ons-cookies-banner__title').text().trim();
|
|
140
130
|
expect(statementTitle).toBe('Cookies on ons.gov.uk');
|
|
141
131
|
});
|
|
142
132
|
|
|
143
133
|
it('has `statementText` text', () => {
|
|
144
134
|
const $ = cheerio.load(renderComponent('cookies-banner', {}));
|
|
145
135
|
|
|
146
|
-
const statementText = $('.ons-cookies-banner__primary .ons-cookies-banner__statement')
|
|
147
|
-
.html()
|
|
148
|
-
.trim();
|
|
136
|
+
const statementText = $('.ons-cookies-banner__primary .ons-cookies-banner__statement').html().trim();
|
|
149
137
|
expect(statementText).toBe(
|
|
150
138
|
'<p>Cookies are small files stored on your device when you visit a website. We use some essential cookies to make this website work.</p><p>We would like to set <a href="/cookies">additional cookies</a> to remember your settings and understand how you use the site. This helps us to improve our services. </p>',
|
|
151
139
|
);
|
|
@@ -172,9 +160,7 @@ describe('macro: cookies-banner', () => {
|
|
|
172
160
|
it('Renders a link with text', () => {
|
|
173
161
|
const $ = cheerio.load(renderComponent('cookies-banner', {}));
|
|
174
162
|
|
|
175
|
-
const linkText = $('.ons-cookies-banner__link')
|
|
176
|
-
.text()
|
|
177
|
-
.trim();
|
|
163
|
+
const linkText = $('.ons-cookies-banner__link').text().trim();
|
|
178
164
|
expect(linkText).toBe('View cookies');
|
|
179
165
|
});
|
|
180
166
|
|
|
@@ -210,9 +196,7 @@ describe('macro: cookies-banner', () => {
|
|
|
210
196
|
it('has `preferencesText` text', () => {
|
|
211
197
|
const $ = cheerio.load(renderComponent('cookies-banner', {}));
|
|
212
198
|
|
|
213
|
-
const preferencesText = $('.ons-cookies-banner__confirmation .ons-cookies-banner__preferences-text')
|
|
214
|
-
.html()
|
|
215
|
-
.trim();
|
|
199
|
+
const preferencesText = $('.ons-cookies-banner__confirmation .ons-cookies-banner__preferences-text').html().trim();
|
|
216
200
|
expect(preferencesText).toBe('You can <a href="/cookies">change your cookie preferences</a> at any time.');
|
|
217
201
|
});
|
|
218
202
|
|
|
@@ -260,9 +244,7 @@ describe('macro: cookies-banner', () => {
|
|
|
260
244
|
it('has the welsh version of default values', () => {
|
|
261
245
|
const $ = cheerio.load(renderComponent('cookies-banner', { lang: 'cy' }));
|
|
262
246
|
|
|
263
|
-
const statementTitle = $('.ons-cookies-banner__title')
|
|
264
|
-
.text()
|
|
265
|
-
.trim();
|
|
247
|
+
const statementTitle = $('.ons-cookies-banner__title').text().trim();
|
|
266
248
|
expect(statementTitle).toBe('Cwcis ar ons.gov.uk');
|
|
267
249
|
});
|
|
268
250
|
});
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { KnownDevices } from 'puppeteer';
|
|
3
2
|
import { setViewport } from '../../tests/helpers/puppeteer';
|
|
4
3
|
import { renderComponent, renderTemplate, setTestPage } from '../../tests/helpers/rendering';
|
|
5
4
|
|
|
5
|
+
const iPhoneX = KnownDevices['iPhone X'];
|
|
6
|
+
|
|
6
7
|
const EXAMPLE_PAGE = `
|
|
7
8
|
<div class="ons-page">
|
|
8
9
|
<div class="ons-js-adv-filter">
|
|
@@ -199,12 +200,12 @@ describe('script: download-resources', () => {
|
|
|
199
200
|
});
|
|
200
201
|
|
|
201
202
|
it('updates result count text', async () => {
|
|
202
|
-
const resultsCount = await page.$eval('.ons-js-adv-filter__results-count', node => node.textContent.trim());
|
|
203
|
+
const resultsCount = await page.$eval('.ons-js-adv-filter__results-count', (node) => node.textContent.trim());
|
|
203
204
|
expect(resultsCount).toBe('3');
|
|
204
205
|
});
|
|
205
206
|
|
|
206
207
|
it('hides the "No results" content', async () => {
|
|
207
|
-
const isHidden = await page.$eval('.ons-adv-filter__no-results', node => node.classList.contains('ons-u-hidden'));
|
|
208
|
+
const isHidden = await page.$eval('.ons-adv-filter__no-results', (node) => node.classList.contains('ons-u-hidden'));
|
|
208
209
|
expect(isHidden).toBe(true);
|
|
209
210
|
});
|
|
210
211
|
});
|
|
@@ -226,12 +227,12 @@ describe('script: download-resources', () => {
|
|
|
226
227
|
});
|
|
227
228
|
|
|
228
229
|
it('updates result count text', async () => {
|
|
229
|
-
const resultsCount = await page.$eval('.ons-js-adv-filter__results-count', node => node.textContent.trim());
|
|
230
|
+
const resultsCount = await page.$eval('.ons-js-adv-filter__results-count', (node) => node.textContent.trim());
|
|
230
231
|
expect(resultsCount).toBe('0');
|
|
231
232
|
});
|
|
232
233
|
|
|
233
234
|
it('shows the "No results" content', async () => {
|
|
234
|
-
const isHidden = await page.$eval('.ons-adv-filter__no-results', node => node.classList.contains('ons-u-hidden'));
|
|
235
|
+
const isHidden = await page.$eval('.ons-adv-filter__no-results', (node) => node.classList.contains('ons-u-hidden'));
|
|
235
236
|
expect(isHidden).toBe(false);
|
|
236
237
|
});
|
|
237
238
|
});
|
|
@@ -253,12 +254,12 @@ describe('script: download-resources', () => {
|
|
|
253
254
|
});
|
|
254
255
|
|
|
255
256
|
it('updates result count text', async () => {
|
|
256
|
-
const resultsCount = await page.$eval('.ons-js-adv-filter__results-count', node => node.textContent.trim());
|
|
257
|
+
const resultsCount = await page.$eval('.ons-js-adv-filter__results-count', (node) => node.textContent.trim());
|
|
257
258
|
expect(resultsCount).toBe('2');
|
|
258
259
|
});
|
|
259
260
|
|
|
260
261
|
it('hides the "No results" content', async () => {
|
|
261
|
-
const isHidden = await page.$eval('.ons-adv-filter__no-results', node => node.classList.contains('ons-u-hidden'));
|
|
262
|
+
const isHidden = await page.$eval('.ons-adv-filter__no-results', (node) => node.classList.contains('ons-u-hidden'));
|
|
262
263
|
expect(isHidden).toBe(true);
|
|
263
264
|
});
|
|
264
265
|
});
|
|
@@ -281,12 +282,12 @@ describe('script: download-resources', () => {
|
|
|
281
282
|
});
|
|
282
283
|
|
|
283
284
|
it('updates result count text', async () => {
|
|
284
|
-
const resultsCount = await page.$eval('.ons-js-adv-filter__results-count', node => node.textContent.trim());
|
|
285
|
+
const resultsCount = await page.$eval('.ons-js-adv-filter__results-count', (node) => node.textContent.trim());
|
|
285
286
|
expect(resultsCount).toBe('3');
|
|
286
287
|
});
|
|
287
288
|
|
|
288
289
|
it('hides the "No results" content', async () => {
|
|
289
|
-
const isHidden = await page.$eval('.ons-adv-filter__no-results', node => node.classList.contains('ons-u-hidden'));
|
|
290
|
+
const isHidden = await page.$eval('.ons-adv-filter__no-results', (node) => node.classList.contains('ons-u-hidden'));
|
|
290
291
|
expect(isHidden).toBe(true);
|
|
291
292
|
});
|
|
292
293
|
});
|
|
@@ -309,12 +310,12 @@ describe('script: download-resources', () => {
|
|
|
309
310
|
});
|
|
310
311
|
|
|
311
312
|
it('updates result count text', async () => {
|
|
312
|
-
const resultsCount = await page.$eval('.ons-js-adv-filter__results-count', node => node.textContent.trim());
|
|
313
|
+
const resultsCount = await page.$eval('.ons-js-adv-filter__results-count', (node) => node.textContent.trim());
|
|
313
314
|
expect(resultsCount).toBe('0');
|
|
314
315
|
});
|
|
315
316
|
|
|
316
317
|
it('shows the "No results" content', async () => {
|
|
317
|
-
const isHidden = await page.$eval('.ons-adv-filter__no-results', node => node.classList.contains('ons-u-hidden'));
|
|
318
|
+
const isHidden = await page.$eval('.ons-adv-filter__no-results', (node) => node.classList.contains('ons-u-hidden'));
|
|
318
319
|
expect(isHidden).toBe(false);
|
|
319
320
|
});
|
|
320
321
|
});
|
|
@@ -337,12 +338,12 @@ describe('script: download-resources', () => {
|
|
|
337
338
|
});
|
|
338
339
|
|
|
339
340
|
it('updates result count text', async () => {
|
|
340
|
-
const resultsCount = await page.$eval('.ons-js-adv-filter__results-count', node => node.textContent.trim());
|
|
341
|
+
const resultsCount = await page.$eval('.ons-js-adv-filter__results-count', (node) => node.textContent.trim());
|
|
341
342
|
expect(resultsCount).toBe('2');
|
|
342
343
|
});
|
|
343
344
|
|
|
344
345
|
it('hides the "No results" content', async () => {
|
|
345
|
-
const isHidden = await page.$eval('.ons-adv-filter__no-results', node => node.classList.contains('ons-u-hidden'));
|
|
346
|
+
const isHidden = await page.$eval('.ons-adv-filter__no-results', (node) => node.classList.contains('ons-u-hidden'));
|
|
346
347
|
expect(isHidden).toBe(true);
|
|
347
348
|
});
|
|
348
349
|
});
|
|
@@ -365,12 +366,12 @@ describe('script: download-resources', () => {
|
|
|
365
366
|
});
|
|
366
367
|
|
|
367
368
|
it('updates result count text', async () => {
|
|
368
|
-
const resultsCount = await page.$eval('.ons-js-adv-filter__results-count', node => node.textContent.trim());
|
|
369
|
+
const resultsCount = await page.$eval('.ons-js-adv-filter__results-count', (node) => node.textContent.trim());
|
|
369
370
|
expect(resultsCount).toBe('1');
|
|
370
371
|
});
|
|
371
372
|
|
|
372
373
|
it('hides the "No results" content', async () => {
|
|
373
|
-
const isHidden = await page.$eval('.ons-adv-filter__no-results', node => node.classList.contains('ons-u-hidden'));
|
|
374
|
+
const isHidden = await page.$eval('.ons-adv-filter__no-results', (node) => node.classList.contains('ons-u-hidden'));
|
|
374
375
|
expect(isHidden).toBe(true);
|
|
375
376
|
});
|
|
376
377
|
});
|
|
@@ -394,12 +395,12 @@ describe('script: download-resources', () => {
|
|
|
394
395
|
});
|
|
395
396
|
|
|
396
397
|
it('updates result count text', async () => {
|
|
397
|
-
const resultsCount = await page.$eval('.ons-js-adv-filter__results-count', node => node.textContent.trim());
|
|
398
|
+
const resultsCount = await page.$eval('.ons-js-adv-filter__results-count', (node) => node.textContent.trim());
|
|
398
399
|
expect(resultsCount).toBe('2');
|
|
399
400
|
});
|
|
400
401
|
|
|
401
402
|
it('hides the "No results" content', async () => {
|
|
402
|
-
const isHidden = await page.$eval('.ons-adv-filter__no-results', node => node.classList.contains('ons-u-hidden'));
|
|
403
|
+
const isHidden = await page.$eval('.ons-adv-filter__no-results', (node) => node.classList.contains('ons-u-hidden'));
|
|
403
404
|
expect(isHidden).toBe(true);
|
|
404
405
|
});
|
|
405
406
|
});
|
|
@@ -432,7 +433,7 @@ describe('script: download-resources', () => {
|
|
|
432
433
|
|
|
433
434
|
it('resets state of all filter checkboxes ', async () => {
|
|
434
435
|
const selector = '.ons-js-adv-filter__item .ons-js-checkbox';
|
|
435
|
-
const checkboxStates = await page.$$eval(selector, nodes => nodes.map(node => `${node.id}: ${node.checked}`));
|
|
436
|
+
const checkboxStates = await page.$$eval(selector, (nodes) => nodes.map((node) => `${node.id}: ${node.checked}`));
|
|
436
437
|
|
|
437
438
|
expect(checkboxStates).toEqual(['community-groups: false', 'general-public: false', 'booklet: false', 'logo: false']);
|
|
438
439
|
});
|
|
@@ -448,12 +449,12 @@ describe('script: download-resources', () => {
|
|
|
448
449
|
});
|
|
449
450
|
|
|
450
451
|
it('updates result count text', async () => {
|
|
451
|
-
const resultsCount = await page.$eval('.ons-js-adv-filter__results-count', node => node.textContent.trim());
|
|
452
|
+
const resultsCount = await page.$eval('.ons-js-adv-filter__results-count', (node) => node.textContent.trim());
|
|
452
453
|
expect(resultsCount).toBe('3');
|
|
453
454
|
});
|
|
454
455
|
|
|
455
456
|
it('hides the "No results" content', async () => {
|
|
456
|
-
const isHidden = await page.$eval('.ons-adv-filter__no-results', node => node.classList.contains('ons-u-hidden'));
|
|
457
|
+
const isHidden = await page.$eval('.ons-adv-filter__no-results', (node) => node.classList.contains('ons-u-hidden'));
|
|
457
458
|
expect(isHidden).toBe(true);
|
|
458
459
|
});
|
|
459
460
|
});
|
|
@@ -470,19 +471,19 @@ describe('script: download-resources', () => {
|
|
|
470
471
|
});
|
|
471
472
|
|
|
472
473
|
it('hides elements that are only needed for mobile', async () => {
|
|
473
|
-
const displayStyle = await page.$eval('.ons-adv-filter__trigger', node => getComputedStyle(node).display);
|
|
474
|
+
const displayStyle = await page.$eval('.ons-adv-filter__trigger', (node) => getComputedStyle(node).display);
|
|
474
475
|
expect(displayStyle).toBe('none');
|
|
475
476
|
});
|
|
476
477
|
|
|
477
478
|
it('shows filter elements', async () => {
|
|
478
|
-
const displayStyle = await page.$eval('.ons-adv-filter__panel', node => getComputedStyle(node).display);
|
|
479
|
+
const displayStyle = await page.$eval('.ons-adv-filter__panel', (node) => getComputedStyle(node).display);
|
|
479
480
|
expect(displayStyle).not.toBe('none');
|
|
480
481
|
});
|
|
481
482
|
});
|
|
482
483
|
|
|
483
484
|
describe('when the viewport is small', () => {
|
|
484
485
|
beforeEach(async () => {
|
|
485
|
-
await page.emulate(
|
|
486
|
+
await page.emulate(iPhoneX);
|
|
486
487
|
await setTestPage('/test', RENDERED_EXAMPLE_PAGE);
|
|
487
488
|
});
|
|
488
489
|
|
|
@@ -492,27 +493,27 @@ describe('script: download-resources', () => {
|
|
|
492
493
|
});
|
|
493
494
|
|
|
494
495
|
it('shows elements that are only needed for mobile', async () => {
|
|
495
|
-
const displayStyle = await page.$eval('.ons-adv-filter__trigger', node => getComputedStyle(node).display);
|
|
496
|
+
const displayStyle = await page.$eval('.ons-adv-filter__trigger', (node) => getComputedStyle(node).display);
|
|
496
497
|
expect(displayStyle).not.toBe('none');
|
|
497
498
|
});
|
|
498
499
|
|
|
499
500
|
it('hides filter elements', async () => {
|
|
500
|
-
const displayStyle = await page.$eval('.ons-adv-filter__panel', node => getComputedStyle(node).display);
|
|
501
|
+
const displayStyle = await page.$eval('.ons-adv-filter__panel', (node) => getComputedStyle(node).display);
|
|
501
502
|
expect(displayStyle).toBe('none');
|
|
502
503
|
});
|
|
503
504
|
|
|
504
505
|
it('shows filter elements when the "Show filters" button is pressed', async () => {
|
|
505
506
|
await page.click('.ons-js-adv-filter__trigger');
|
|
506
507
|
|
|
507
|
-
const displayStyle = await page.$eval('.ons-adv-filter__panel', node => getComputedStyle(node).display);
|
|
508
|
+
const displayStyle = await page.$eval('.ons-adv-filter__panel', (node) => getComputedStyle(node).display);
|
|
508
509
|
expect(displayStyle).not.toBe('none');
|
|
509
510
|
});
|
|
510
511
|
|
|
511
512
|
it('hides the underlying page elements when the "Show filters" button is pressed', async () => {
|
|
512
513
|
await page.click('.ons-js-adv-filter__trigger');
|
|
513
514
|
|
|
514
|
-
const pageIsHidden = await page.$eval('.ons-page', node => node.classList.contains('ons-u-d-no'));
|
|
515
|
-
const pageIsAriaHidden = await page.$eval('.ons-page', node => node.getAttribute('aria-hidden'));
|
|
515
|
+
const pageIsHidden = await page.$eval('.ons-page', (node) => node.classList.contains('ons-u-d-no'));
|
|
516
|
+
const pageIsAriaHidden = await page.$eval('.ons-page', (node) => node.getAttribute('aria-hidden'));
|
|
516
517
|
|
|
517
518
|
expect(pageIsHidden).toBe(true);
|
|
518
519
|
expect(pageIsAriaHidden).toBe('true');
|
|
@@ -522,7 +523,7 @@ describe('script: download-resources', () => {
|
|
|
522
523
|
await page.click('.ons-js-adv-filter__trigger');
|
|
523
524
|
await page.click('.ons-js-adv-filter__show');
|
|
524
525
|
|
|
525
|
-
const displayStyle = await page.$eval('.ons-adv-filter__panel', node => getComputedStyle(node).display);
|
|
526
|
+
const displayStyle = await page.$eval('.ons-adv-filter__panel', (node) => getComputedStyle(node).display);
|
|
526
527
|
expect(displayStyle).toBe('none');
|
|
527
528
|
});
|
|
528
529
|
|
|
@@ -530,8 +531,8 @@ describe('script: download-resources', () => {
|
|
|
530
531
|
await page.click('.ons-js-adv-filter__trigger');
|
|
531
532
|
await page.click('.ons-js-adv-filter__show');
|
|
532
533
|
|
|
533
|
-
const pageIsHidden = await page.$eval('.ons-page', node => node.classList.contains('ons-u-d-no'));
|
|
534
|
-
const pageIsAriaHidden = await page.$eval('.ons-page', node => node.getAttribute('aria-hidden'));
|
|
534
|
+
const pageIsHidden = await page.$eval('.ons-page', (node) => node.classList.contains('ons-u-d-no'));
|
|
535
|
+
const pageIsAriaHidden = await page.$eval('.ons-page', (node) => node.getAttribute('aria-hidden'));
|
|
535
536
|
|
|
536
537
|
expect(pageIsHidden).toBe(false);
|
|
537
538
|
expect(pageIsAriaHidden).toBe('false');
|
|
@@ -541,7 +542,7 @@ describe('script: download-resources', () => {
|
|
|
541
542
|
await page.click('.ons-js-adv-filter__trigger');
|
|
542
543
|
await page.click('.ons-js-adv-filter__close');
|
|
543
544
|
|
|
544
|
-
const displayStyle = await page.$eval('.ons-adv-filter__panel', node => getComputedStyle(node).display);
|
|
545
|
+
const displayStyle = await page.$eval('.ons-adv-filter__panel', (node) => getComputedStyle(node).display);
|
|
545
546
|
expect(displayStyle).toBe('none');
|
|
546
547
|
});
|
|
547
548
|
|
|
@@ -549,8 +550,8 @@ describe('script: download-resources', () => {
|
|
|
549
550
|
await page.click('.ons-js-adv-filter__trigger');
|
|
550
551
|
await page.click('.ons-js-adv-filter__close');
|
|
551
552
|
|
|
552
|
-
const pageIsHidden = await page.$eval('.ons-page', node => node.classList.contains('ons-u-d-no'));
|
|
553
|
-
const pageIsAriaHidden = await page.$eval('.ons-page', node => node.getAttribute('aria-hidden'));
|
|
553
|
+
const pageIsHidden = await page.$eval('.ons-page', (node) => node.classList.contains('ons-u-d-no'));
|
|
554
|
+
const pageIsAriaHidden = await page.$eval('.ons-page', (node) => node.getAttribute('aria-hidden'));
|
|
554
555
|
|
|
555
556
|
expect(pageIsHidden).toBe(false);
|
|
556
557
|
expect(pageIsAriaHidden).toBe('false');
|
|
@@ -559,7 +560,7 @@ describe('script: download-resources', () => {
|
|
|
559
560
|
});
|
|
560
561
|
|
|
561
562
|
async function getTextContent(page, selector) {
|
|
562
|
-
return await page.$$eval(selector, nodes => nodes.map(node => node.textContent.trim()));
|
|
563
|
+
return await page.$$eval(selector, (nodes) => nodes.map((node) => node.textContent.trim()));
|
|
563
564
|
}
|
|
564
565
|
|
|
565
566
|
async function getFilterSelectionLabels(page) {
|