@ons/design-system 70.0.13 → 70.0.14
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 +2 -2
- package/components/access-code/_macro.spec.js +170 -136
- package/components/address-input/autosuggest.address.spec.js +17 -12
- package/components/autosuggest/autosuggest.spec.js +7 -5
- package/components/back-to-top/_macro.spec.js +42 -48
- package/components/back-to-top/back-to-top.spec.js +4 -2
- package/components/cookies-banner/cookies-banner.spec.js +1 -1
- package/components/mutually-exclusive/mutually-exclusive.checkboxes.spec.js +7 -5
- package/components/mutually-exclusive/mutually-exclusive.date.spec.js +10 -8
- package/components/mutually-exclusive/mutually-exclusive.duration.spec.js +10 -8
- package/components/mutually-exclusive/mutually-exclusive.email.spec.js +6 -4
- package/components/mutually-exclusive/mutually-exclusive.multiple-options.checkboxes.spec.js +7 -5
- package/components/mutually-exclusive/mutually-exclusive.number.spec.js +6 -4
- package/components/mutually-exclusive/mutually-exclusive.textarea.spec.js +6 -4
- package/components/navigation/navigation.spec.js +8 -6
- package/components/table/table.spec.js +1 -1
- package/components/table-of-contents/toc.spec.js +4 -2
- package/components/timeout-modal/timeout-modal.spec.js +41 -36
- package/components/timeout-panel/timeout-panel.spec.js +4 -2
- package/components/video/video.spec.js +109 -85
- package/js/cookies-settings.spec.js +1 -1
- package/package.json +4 -3
|
@@ -13,6 +13,8 @@ const EXAMPLE_TIMEOUT_PANEL_BASIC = {
|
|
|
13
13
|
endWithFullStop: true,
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
+
const { setTimeout } = require('node:timers/promises');
|
|
17
|
+
|
|
16
18
|
describe('script: timeout panel', () => {
|
|
17
19
|
describe('when the page loads', () => {
|
|
18
20
|
beforeEach(async () => {
|
|
@@ -29,7 +31,7 @@ describe('script: timeout panel', () => {
|
|
|
29
31
|
|
|
30
32
|
it('shows the time counting down', async () => {
|
|
31
33
|
const timeAtStart = await page.$eval('.ons-js-timeout-timer', (element) => element.innerHTML);
|
|
32
|
-
await
|
|
34
|
+
await setTimeout(1000);
|
|
33
35
|
const timeAfterOneSecond = await page.$eval('.ons-js-timeout-timer', (element) => element.innerHTML);
|
|
34
36
|
expect(timeAfterOneSecond).not.toEqual(timeAtStart);
|
|
35
37
|
});
|
|
@@ -130,7 +132,7 @@ describe('script: timeout panel', () => {
|
|
|
130
132
|
});
|
|
131
133
|
|
|
132
134
|
it('then redirects to the provided `redirectUrl`', async () => {
|
|
133
|
-
await
|
|
135
|
+
await setTimeout(2000);
|
|
134
136
|
expect(page.url()).toContain('#!');
|
|
135
137
|
});
|
|
136
138
|
});
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { renderComponent, setTestPage } from '../../tests/helpers/rendering';
|
|
2
2
|
|
|
3
|
+
const { setTimeout } = require('node:timers/promises');
|
|
4
|
+
|
|
3
5
|
const EXAMPLE_VIDEO_YOUTUBE = {
|
|
4
6
|
videoEmbedUrl: 'https://www.youtube.com/embed/_EGJlvkgbPo',
|
|
5
7
|
title: 'Census 2021 promotional TV advert',
|
|
6
8
|
linkText: 'Example link text',
|
|
7
9
|
};
|
|
10
|
+
|
|
8
11
|
const EXAMPLE_VIDEO_VIMEO = {
|
|
9
12
|
videoEmbedUrl: 'https://player.vimeo.com/video/838454524?h=24551a3754',
|
|
10
13
|
title: 'Vimeo Video',
|
|
@@ -14,112 +17,133 @@ const EXAMPLE_VIDEO_VIMEO = {
|
|
|
14
17
|
const EXAMPLE_APPROVED_COOKIE = JSON.stringify({ campaigns: true }).replace(/"/g, "'");
|
|
15
18
|
|
|
16
19
|
describe('script: video', () => {
|
|
17
|
-
|
|
18
|
-
const client = await page.target().createCDPSession();
|
|
19
|
-
await client.send('Network.clearBrowserCookies');
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('should show the placeholder content', async () => {
|
|
23
|
-
await setTestPage('/test', renderComponent('video', EXAMPLE_VIDEO_YOUTUBE));
|
|
24
|
-
|
|
25
|
-
const displayStyle = await page.$eval('.ons-js-video-placeholder', (node) =>
|
|
26
|
-
window.getComputedStyle(node).getPropertyValue('display'),
|
|
27
|
-
);
|
|
28
|
-
expect(displayStyle).toBe('block');
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('should not show the iframe', async () => {
|
|
32
|
-
await setTestPage('/test', renderComponent('video', EXAMPLE_VIDEO_YOUTUBE));
|
|
33
|
-
|
|
34
|
-
const displayStyle = await page.$eval('.ons-js-video-iframe', (node) => window.getComputedStyle(node).getPropertyValue('display'));
|
|
35
|
-
expect(displayStyle).toBe('none');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
describe('when cookies are accepted on page load', () => {
|
|
20
|
+
describe('YouTube videos', () => {
|
|
39
21
|
beforeEach(async () => {
|
|
40
|
-
await page.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
});
|
|
22
|
+
const client = await page.createCDPSession();
|
|
23
|
+
await client.send('Network.clearBrowserCookies');
|
|
24
|
+
});
|
|
44
25
|
|
|
26
|
+
it('should show the placeholder content', async () => {
|
|
45
27
|
await setTestPage('/test', renderComponent('video', EXAMPLE_VIDEO_YOUTUBE));
|
|
46
|
-
});
|
|
47
28
|
|
|
48
|
-
it('should hide the placeholder content', async () => {
|
|
49
29
|
const displayStyle = await page.$eval('.ons-js-video-placeholder', (node) =>
|
|
50
30
|
window.getComputedStyle(node).getPropertyValue('display'),
|
|
51
31
|
);
|
|
52
|
-
expect(displayStyle).toBe('
|
|
53
|
-
}
|
|
32
|
+
expect(displayStyle).toBe('block');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('should not show the iframe', async () => {
|
|
36
|
+
await setTestPage('/test', renderComponent('video', EXAMPLE_VIDEO_YOUTUBE));
|
|
54
37
|
|
|
55
|
-
it('should show the iframe', async () => {
|
|
56
38
|
const displayStyle = await page.$eval('.ons-js-video-iframe', (node) =>
|
|
57
39
|
window.getComputedStyle(node).getPropertyValue('display'),
|
|
58
40
|
);
|
|
59
|
-
expect(displayStyle).toBe('
|
|
60
|
-
}
|
|
41
|
+
expect(displayStyle).toBe('none');
|
|
42
|
+
});
|
|
61
43
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
44
|
+
describe('when cookies are accepted on page load', () => {
|
|
45
|
+
beforeEach(async () => {
|
|
46
|
+
await page.setCookie({
|
|
47
|
+
name: 'ons_cookie_policy',
|
|
48
|
+
value: EXAMPLE_APPROVED_COOKIE,
|
|
49
|
+
});
|
|
66
50
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
expect(src.includes('?dnt=1')).toBe(false);
|
|
70
|
-
}, 10000);
|
|
51
|
+
await setTestPage('/test', renderComponent('video', EXAMPLE_VIDEO_YOUTUBE));
|
|
52
|
+
});
|
|
71
53
|
|
|
72
|
-
|
|
73
|
-
|
|
54
|
+
it('should hide the placeholder content', async () => {
|
|
55
|
+
const displayStyle = await page.$eval('.ons-js-video-placeholder', (node) =>
|
|
56
|
+
window.getComputedStyle(node).getPropertyValue('display'),
|
|
57
|
+
);
|
|
58
|
+
expect(displayStyle).toBe('none');
|
|
59
|
+
}, 10000);
|
|
60
|
+
|
|
61
|
+
it('should show the iframe', async () => {
|
|
62
|
+
const displayStyle = await page.$eval('.ons-js-video-iframe', (node) =>
|
|
63
|
+
window.getComputedStyle(node).getPropertyValue('display'),
|
|
64
|
+
);
|
|
65
|
+
expect(displayStyle).toBe('block');
|
|
66
|
+
}, 10000);
|
|
67
|
+
|
|
68
|
+
it('should add the correct modifier class', async () => {
|
|
69
|
+
const hasClass = await page.$eval('.ons-js-video', (node) => node.classList.contains('ons-video--hasIframe'));
|
|
70
|
+
expect(hasClass).toBe(true);
|
|
71
|
+
}, 10000);
|
|
72
|
+
|
|
73
|
+
it('should not add dnt', async () => {
|
|
74
|
+
const src = await page.$eval('.ons-js-video-iframe', (node) => node.getAttribute('src'));
|
|
75
|
+
expect(src.includes('?dnt=1')).toBe(false);
|
|
76
|
+
}, 10000);
|
|
77
|
+
});
|
|
74
78
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
+
describe('when cookies are accepted via banner', () => {
|
|
80
|
+
beforeEach(async () => {
|
|
81
|
+
await setTestPage(
|
|
82
|
+
'/test',
|
|
83
|
+
`${renderComponent('video', EXAMPLE_VIDEO_YOUTUBE)}
|
|
84
|
+
<div class="ons-cookies-banner ons-u-db"><button class="ons-js-accept-cookies">Accept</button></div>`,
|
|
85
|
+
);
|
|
86
|
+
await page.click('.ons-js-accept-cookies');
|
|
87
|
+
});
|
|
79
88
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
);
|
|
87
|
-
await page.click('.ons-js-accept-cookies');
|
|
88
|
-
});
|
|
89
|
+
it('should hide the placeholder content', async () => {
|
|
90
|
+
const displayStyle = await page.$eval('.ons-js-video-placeholder', (node) =>
|
|
91
|
+
window.getComputedStyle(node).getPropertyValue('display'),
|
|
92
|
+
);
|
|
93
|
+
expect(displayStyle).toBe('none');
|
|
94
|
+
});
|
|
89
95
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
96
|
+
it('should show the iframe', async () => {
|
|
97
|
+
const displayStyle = await page.$eval('.ons-js-video-iframe', (node) =>
|
|
98
|
+
window.getComputedStyle(node).getPropertyValue('display'),
|
|
99
|
+
);
|
|
100
|
+
expect(displayStyle).toBe('block');
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('should add the correct modifier class', async () => {
|
|
104
|
+
const hasClass = await page.$eval('.ons-js-video', (node) => node.classList.contains('ons-video--hasIframe'));
|
|
105
|
+
expect(hasClass).toBe(true);
|
|
106
|
+
}, 10000);
|
|
107
|
+
|
|
108
|
+
it('should not add dnt', async () => {
|
|
109
|
+
const src = await page.$eval('.ons-js-video-iframe', (node) => node.getAttribute('src'));
|
|
110
|
+
expect(src.includes('?dnt=1')).toBe(false);
|
|
111
|
+
}, 10000);
|
|
95
112
|
});
|
|
113
|
+
});
|
|
96
114
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
115
|
+
describe('Vimeo videos', () => {
|
|
116
|
+
describe('when cookies are accepted on page load', () => {
|
|
117
|
+
it('should add dnt', async () => {
|
|
118
|
+
await page.setCookie({
|
|
119
|
+
name: 'ons_cookie_policy',
|
|
120
|
+
value: EXAMPLE_APPROVED_COOKIE,
|
|
121
|
+
});
|
|
122
|
+
await setTestPage('/test', renderComponent('video', EXAMPLE_VIDEO_VIMEO));
|
|
123
|
+
|
|
124
|
+
const src = await page.$eval('.ons-js-video-iframe', (node) => node.getAttribute('src'));
|
|
125
|
+
|
|
126
|
+
await setTimeout(100);
|
|
127
|
+
|
|
128
|
+
expect(src.includes('?dnt=1')).toBe(true);
|
|
129
|
+
}, 10000);
|
|
102
130
|
});
|
|
103
131
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
it('should add dnt to Vimeo videos', async () => {
|
|
114
|
-
await setTestPage(
|
|
115
|
-
'/test',
|
|
116
|
-
`${renderComponent('video', EXAMPLE_VIDEO_VIMEO)}
|
|
117
|
-
<div class="ons-cookies-banner ons-u-db"><button class="ons-js-accept-cookies">Accept</button></div>`,
|
|
118
|
-
);
|
|
119
|
-
await page.click('.ons-js-accept-cookies');
|
|
132
|
+
describe('when cookies are accepted on page load', () => {
|
|
133
|
+
it('when cookies are accepted via banner, should add dnt', async () => {
|
|
134
|
+
await setTestPage(
|
|
135
|
+
'/test',
|
|
136
|
+
`${renderComponent('video', EXAMPLE_VIDEO_VIMEO)}
|
|
137
|
+
<div class="ons-cookies-banner ons-u-db"><button class="ons-js-accept-cookies">Accept</button></div>`,
|
|
138
|
+
);
|
|
139
|
+
await page.click('.ons-js-accept-cookies');
|
|
120
140
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
141
|
+
const src = await page.$eval('.ons-js-video-iframe', (node) => node.getAttribute('src'));
|
|
142
|
+
|
|
143
|
+
await setTimeout(100);
|
|
144
|
+
|
|
145
|
+
expect(src.includes('?dnt=1')).toBe(true);
|
|
146
|
+
}, 10000);
|
|
147
|
+
});
|
|
124
148
|
});
|
|
125
149
|
});
|
|
@@ -38,7 +38,7 @@ const EXAMPLE_PART_COOKIES_SETTINGS_PAGE = `
|
|
|
38
38
|
|
|
39
39
|
describe('script: cookies-settings', () => {
|
|
40
40
|
beforeEach(async () => {
|
|
41
|
-
const client = await page.
|
|
41
|
+
const client = await page.createCDPSession();
|
|
42
42
|
await client.send('Network.clearBrowserCookies');
|
|
43
43
|
});
|
|
44
44
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ons/design-system",
|
|
3
3
|
"description": "ONS Design System built CSS, JS, and Nunjucks templates",
|
|
4
|
-
"version": "70.0.
|
|
4
|
+
"version": "70.0.14",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": {
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"start": "gulp start",
|
|
12
12
|
"watch": "gulp watch",
|
|
13
13
|
"test": "gulp build-assets && TEST_PORT=3020 TEST_WITH_PUPPETEER=1 jest '.*\\.spec\\.js'",
|
|
14
|
+
"test:clear-cache": "jest --clearCache",
|
|
14
15
|
"test:no-build": "TEST_PORT=3020 TEST_WITH_PUPPETEER=1 jest '.*\\.spec\\.js'",
|
|
15
16
|
"test:with-log": "yarn test --no-color 2>test.log",
|
|
16
17
|
"test:start-server": "TEST_PORT=3020 gulp start-dev-server",
|
|
@@ -98,7 +99,7 @@
|
|
|
98
99
|
"jest": "^29.6.1",
|
|
99
100
|
"jest-axe": "^8.0.0",
|
|
100
101
|
"jest-environment-jsdom": "^29.6.1",
|
|
101
|
-
"jest-puppeteer": "^
|
|
102
|
+
"jest-puppeteer": "^10.0.0",
|
|
102
103
|
"lighthouse": "^11.0.0",
|
|
103
104
|
"lint-staged": "^15.2.0",
|
|
104
105
|
"lodash": "^4.17.21",
|
|
@@ -111,7 +112,7 @@
|
|
|
111
112
|
"prepend-file": "^2.0.1",
|
|
112
113
|
"prettier": "^3.2.5",
|
|
113
114
|
"prettier-plugin-jinja-template": "^1.4.0",
|
|
114
|
-
"puppeteer": "^
|
|
115
|
+
"puppeteer": "^22.0.0",
|
|
115
116
|
"remark-cli": "^12.0.0",
|
|
116
117
|
"remark-lint": "^9.1.2",
|
|
117
118
|
"remark-preset-lint-recommended": "^6.1.3",
|