@grafana/plugin-e2e 3.3.2 → 3.4.0-canary.2462.22113308144.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.
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var AxeBuilder = require('@axe-core/playwright');
|
|
4
|
+
|
|
5
|
+
const scanForA11yViolations = async ({ page }, use, testInfo) => {
|
|
6
|
+
const builder = new AxeBuilder({ page }).withTags([
|
|
7
|
+
"wcag2a",
|
|
8
|
+
"wcag2aa",
|
|
9
|
+
"wcag21a",
|
|
10
|
+
"wcag21aa"
|
|
11
|
+
/*'best-practice'*/
|
|
12
|
+
]);
|
|
13
|
+
use(async (options) => {
|
|
14
|
+
if (options) {
|
|
15
|
+
builder.options(options);
|
|
16
|
+
}
|
|
17
|
+
const accessibilityScanResults = await builder.analyze();
|
|
18
|
+
testInfo.annotations.push({
|
|
19
|
+
type: "axe-a11y",
|
|
20
|
+
description: JSON.stringify(accessibilityScanResults, null, 2)
|
|
21
|
+
});
|
|
22
|
+
return accessibilityScanResults;
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
exports.scanForA11yViolations = scanForA11yViolations;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as _playwright_test from '@playwright/test';
|
|
2
2
|
import { Locator, Request, Response as Response$1, APIRequestContext, TestInfo, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, MatcherReturnType, Page } from '@playwright/test';
|
|
3
3
|
export { selectors } from '@playwright/test';
|
|
4
|
+
import { RunOptions, AxeResults } from 'axe-core';
|
|
4
5
|
import { SelectorsOf, versionedPages, versionedComponents } from '@grafana/e2e-selectors';
|
|
5
6
|
import * as playwright_core from 'playwright-core';
|
|
6
7
|
|
|
@@ -931,6 +932,14 @@ type PluginFixture = {
|
|
|
931
932
|
* Fixture command that navigates to an AppPage for a given plugin.
|
|
932
933
|
*/
|
|
933
934
|
gotoAppPage: (args: GotoAppPageArgs) => Promise<AppPage>;
|
|
935
|
+
/**
|
|
936
|
+
* Fixture command that scans the current page for accessibility violations using axe-core.
|
|
937
|
+
* By default, it checks for WCAG 2.0 A and AA level violations, as well as WCAG 2.1 A and AA.
|
|
938
|
+
* You can customize the rules that are checked by passing options to the command.
|
|
939
|
+
*
|
|
940
|
+
* You can use this in conjuntion with the .toHaveNoA11yViolations matcher to assert that there are no accessibility violations on the page.
|
|
941
|
+
*/
|
|
942
|
+
scanForA11yViolations: (options?: RunOptions) => Promise<AxeResults>;
|
|
934
943
|
};
|
|
935
944
|
/**
|
|
936
945
|
* The context object passed to page object models
|
|
@@ -1284,6 +1293,11 @@ declare function toBeChecked(target: Switch | Locator, options?: {
|
|
|
1284
1293
|
timeout?: number;
|
|
1285
1294
|
}): Promise<MatcherReturnType>;
|
|
1286
1295
|
|
|
1296
|
+
declare function toHaveNoA11yViolations(results: AxeResults, options?: {
|
|
1297
|
+
threshold?: number;
|
|
1298
|
+
ignoredRules?: string[];
|
|
1299
|
+
}): Promise<MatcherReturnType>;
|
|
1300
|
+
|
|
1287
1301
|
declare function toHaveChecked(radioGroup: RadioGroup, expected: string, options?: {
|
|
1288
1302
|
timeout?: number;
|
|
1289
1303
|
}): Promise<MatcherReturnType>;
|
|
@@ -1337,6 +1351,7 @@ declare const expect: _playwright_test.Expect<{
|
|
|
1337
1351
|
toBeChecked: typeof toBeChecked;
|
|
1338
1352
|
toHaveChecked: typeof toHaveChecked;
|
|
1339
1353
|
toHaveColor: typeof toHaveColor;
|
|
1354
|
+
toHaveNoA11yViolations: typeof toHaveNoA11yViolations;
|
|
1340
1355
|
}>;
|
|
1341
1356
|
|
|
1342
1357
|
declare global {
|
package/dist/index.js
CHANGED
|
@@ -30,6 +30,7 @@ var panelEditPage = require('./fixtures/panelEditPage.js');
|
|
|
30
30
|
var selectors = require('./fixtures/selectors.js');
|
|
31
31
|
var variableEditPage = require('./fixtures/variableEditPage.js');
|
|
32
32
|
var alertRuleEditPage = require('./fixtures/alertRuleEditPage.js');
|
|
33
|
+
var scanForA11yViolations = require('./fixtures/scanForA11yViolations.js');
|
|
33
34
|
var options = require('./options.js');
|
|
34
35
|
var toHaveAlert = require('./matchers/toHaveAlert.js');
|
|
35
36
|
var toDisplayPreviews = require('./matchers/toDisplayPreviews.js');
|
|
@@ -38,6 +39,7 @@ var variablePage = require('./fixtures/variablePage.js');
|
|
|
38
39
|
var gotoVariablePage = require('./fixtures/commands/gotoVariablePage.js');
|
|
39
40
|
var toHaveSelected = require('./matchers/toHaveSelected.js');
|
|
40
41
|
var toBeChecked = require('./matchers/toBeChecked.js');
|
|
42
|
+
var toHaveNoA11yViolations = require('./matchers/toHaveNoA11yViolations.js');
|
|
41
43
|
var toHaveChecked = require('./matchers/toHaveChecked.js');
|
|
42
44
|
var toHaveColor = require('./matchers/toHaveColor.js');
|
|
43
45
|
var DataSourcePicker = require('./models/components/DataSourcePicker.js');
|
|
@@ -91,6 +93,7 @@ const test = testWithInternal.extend({
|
|
|
91
93
|
gotoDataSourceConfigPage: gotoDataSourceConfigPage.gotoDataSourceConfigPage,
|
|
92
94
|
gotoAppConfigPage: gotoAppConfigPage.gotoAppConfigPage,
|
|
93
95
|
gotoAppPage: gotoAppPage.gotoAppPage,
|
|
96
|
+
scanForA11yViolations: scanForA11yViolations.scanForA11yViolations,
|
|
94
97
|
...options.options
|
|
95
98
|
});
|
|
96
99
|
const expect = test$1.expect.extend({
|
|
@@ -100,7 +103,8 @@ const expect = test$1.expect.extend({
|
|
|
100
103
|
toHaveSelected: toHaveSelected.toHaveSelected,
|
|
101
104
|
toBeChecked: toBeChecked.toBeChecked,
|
|
102
105
|
toHaveChecked: toHaveChecked.toHaveChecked,
|
|
103
|
-
toHaveColor: toHaveColor.toHaveColor
|
|
106
|
+
toHaveColor: toHaveColor.toHaveColor,
|
|
107
|
+
toHaveNoA11yViolations: toHaveNoA11yViolations.toHaveNoA11yViolations
|
|
104
108
|
});
|
|
105
109
|
|
|
106
110
|
Object.defineProperty(exports, "selectors", {
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
async function toHaveNoA11yViolations(results, options) {
|
|
4
|
+
const threshold = options?.threshold ?? 0;
|
|
5
|
+
let violations = [];
|
|
6
|
+
try {
|
|
7
|
+
violations = results.violations.filter((violation) => !options?.ignoredRules?.includes(violation.id));
|
|
8
|
+
if (violations.length > threshold) {
|
|
9
|
+
throw new Error(`${violations.length} Axe violations found (Threshold: ${threshold})`);
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
pass: true,
|
|
13
|
+
expected: threshold,
|
|
14
|
+
message: () => `Fewer than ${threshold} Axe violations found.`
|
|
15
|
+
};
|
|
16
|
+
} catch (err) {
|
|
17
|
+
let message = err instanceof Error ? err.toString() : "Unknown error";
|
|
18
|
+
if (violations.length > 0) {
|
|
19
|
+
const violationDetails = violations.flatMap((v) => [
|
|
20
|
+
`- Rule: ${v.id}`,
|
|
21
|
+
` Description: ${v.description}`,
|
|
22
|
+
` Docs: ${v.helpUrl}`,
|
|
23
|
+
` Affected nodes:
|
|
24
|
+
${v.nodes.map((node) => ` - ${node.html}`).join("\n")}`
|
|
25
|
+
]).join("\n");
|
|
26
|
+
message += `
|
|
27
|
+
|
|
28
|
+
Axe Violations:
|
|
29
|
+
${violationDetails}`;
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
message: () => message,
|
|
33
|
+
pass: false
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
exports.toHaveNoA11yViolations = toHaveNoA11yViolations;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grafana/plugin-e2e",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0-canary.2462.22113308144.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -39,13 +39,15 @@
|
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@playwright/test": "^1.58.1",
|
|
41
41
|
"@types/uuid": "^11.0.0",
|
|
42
|
+
"axe-core": "^4.11.1",
|
|
42
43
|
"dotenv": "^17.2.4"
|
|
43
44
|
},
|
|
44
45
|
"dependencies": {
|
|
46
|
+
"@axe-core/playwright": "^4.11.1",
|
|
45
47
|
"@grafana/e2e-selectors": "12.4.0-21983999378",
|
|
46
48
|
"semver": "^7.5.4",
|
|
47
49
|
"uuid": "^13.0.0",
|
|
48
50
|
"yaml": "^2.3.4"
|
|
49
51
|
},
|
|
50
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "2461eb0e2375ab90ee71a022aac299aef99c8de1"
|
|
51
53
|
}
|