forked from bbc/simorgh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
a11y.js
104 lines (93 loc) · 4.25 KB
/
a11y.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/** This is an extension of the bbc-a11y tool, which verifies whether this application meets
* BBC accessibility guidelines - http://www.bbc.co.uk/guidelines/futuremedia/accessibility/
*
* See https://github.com/bbc/bbc-a11y/blob/master/guides/using/using-bbc-a11y-in-your-project.md
* for further information
*/
const { getPageUrls } = require('./cypress/support/helpers/getPageUrls');
// allPageWidths = [240, 360, 600, 1008, 1280];
// Run a11y on 360px only since designs are done in this width
// This functionality can be extended to allow for testing on all widths
const pageWidths = [360];
const environment = 'local';
const isSmoke = true;
const baseUrl = 'http://localhost:7080';
/**
*
* Suppress errors in scrollable navigation for RTL languages -> '//div[@id='root']/header/nav/div/div[1]/div/ul'
* To be fixed in https://github.com/bbc/simorgh/issues/5222
*/
const mediaEmbedErrorsToSuppress = [
// * Design: Content resizing: Text must be styled with units that are resizable in all browsers
"Text styled with px unit: //button[@id='p_audioui_backInterval']/div/div[1]",
"Text styled with px unit: //button[@id='p_audioui_backInterval']/div/div[2]",
"Text styled with px unit: //button[@id='p_audioui_forwardInterval']/div/div[1]",
"Text styled with px unit: //button[@id='p_audioui_forwardInterval']/div/div[2]",
"Text styled with px unit: //div[@id='p_audioui_backToStartButton_text']",
"Text styled with px unit: //div[@id='p_audioui_toLiveButton_text']",
// * Design: Content resizing: Text cannot be too small
"Text size too small (10px): //div[@id='p_audioui_backToStartButton_text']",
"Text size too small (10px): //div[@id='p_audioui_toLiveButton_text']",
// * Editorial: Indicating language: Html must have lang attribute
'html tag has no lang attribute: /html',
// * Forms: Labelling form controls: Fields must have labels or titles
"Button has no text: //button[@id='p_audioui_playpause']",
"Button has no text: //button[@id='p_audioui_previousButton']",
"Button has no text: //button[@id='p_audioui_nextButton']",
"Button has no text: //div[@id='p_audioui_container']/div[2]/button",
"Button has no text: //button[@id='p_audioui_playbackSettingsButton']",
"Button has no text: //div[@id='p_audioui_container']/div[4]/button",
];
const advertisementErrorsToSuppress = [
// Principles: All documents must have a W3C recommended doctype
// Editorial: Indicating language: Html must have lang attribute
'/iframe',
// Design: Content resizing: Text must be styled with units that are resizable in all browsers
"//div[@id='dotcom-leaderboard']/div/div[1]/a",
"//div[@id='dotcom-mpu']/div/div[1]/a",
];
const pageTypes = {
frontPage: [
"//div[@id='root']/header/nav/div/div[1]/div/ul",
...advertisementErrorsToSuppress,
],
articles: ["//div[@id='root']/header/nav/div/div[1]/div/ul"],
liveRadio: [
...mediaEmbedErrorsToSuppress,
"//div[@id='root']/header/nav/div/div[1]/div/ul",
'/iframe',
],
photoGalleryPage: ["//div[@id='root']/header/nav/div/div[1]/div/ul"],
mostReadPage: ["//div[@id='root']/header/nav/div/div[1]/div/ul"],
mostWatchedPage: ["//div[@id='root']/header/nav/div/div[1]/div/ul"],
storyPage: [
"//div[@id='root']/header/nav/div/div[1]/div/ul",
'/iframe', // same issues as in mediaEmbedErrorsToSuppress but the DOM path is different
"//div[@id='root']/div/div[1]/main/div[37]/div/div/div", // issue with IDT2 includes
"//div[@id='ns_datapic_royal-engagements']",
"//div[@id='ns_datapic_env-test-2']",
"//div[@id='responsive-embed-newsspec-21841-green-diet-app-core-content']",
],
onDemandRadio: [
...mediaEmbedErrorsToSuppress,
"//div[@id='root']/header/nav/div/div[1]/div/ul",
'/iframe',
],
idxPage: ["//div[@id='root']/header/nav/div/div[1]/div/ul"],
onDemandTV: ['/iframe'],
mediaAssetPage: [...mediaEmbedErrorsToSuppress, '/iframe'],
featureIndexPage: [],
};
// eslint-disable-next-line array-callback-return
Object.keys(pageTypes).map(pageType => {
getPageUrls({ pageType, environment, isSmoke })
.toString()
.split(',')
.map(pageUrl => `${baseUrl}${pageUrl}`)
.forEach(url =>
pageWidths.forEach(width =>
// eslint-disable-next-line no-undef
page(url, { width, hide: pageTypes[pageType] }),
),
);
});