@public-ui/visual-tests 3.0.0-0edf6aa20a9ac9faa46ebe0e45a8c62841b05164.0 → 3.0.0-638ed75dd472d3e3ad4c1c3a3c72d705e6022731.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@public-ui/visual-tests",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-638ed75dd472d3e3ad4c1c3a3c72d705e6022731.0",
|
|
4
4
|
"license": "EUPL-1.2",
|
|
5
5
|
"homepage": "https://public-ui.github.io",
|
|
6
6
|
"repository": {
|
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
"name": "Informationstechnikzentrum Bund",
|
|
16
16
|
"email": "kolibri@itzbund.de"
|
|
17
17
|
},
|
|
18
|
+
"engines": {
|
|
19
|
+
"pnpm": "^10"
|
|
20
|
+
},
|
|
18
21
|
"type": "module",
|
|
19
22
|
"sideEffects": false,
|
|
20
23
|
"description": "Provides utility to run visual regression tests for themes.",
|
|
@@ -23,18 +26,18 @@
|
|
|
23
26
|
},
|
|
24
27
|
"dependencies": {
|
|
25
28
|
"@playwright/test": "1.49.1",
|
|
26
|
-
"axe-playwright": "2.0
|
|
27
|
-
"portfinder": "1.0.
|
|
29
|
+
"axe-playwright": "2.1.0",
|
|
30
|
+
"portfinder": "1.0.35",
|
|
28
31
|
"serve": "14.2.4",
|
|
29
|
-
"@public-ui/sample-react": "3.0.0-
|
|
32
|
+
"@public-ui/sample-react": "3.0.0-638ed75dd472d3e3ad4c1c3a3c72d705e6022731.0"
|
|
30
33
|
},
|
|
31
34
|
"devDependencies": {
|
|
32
|
-
"@babel/eslint-parser": "7.
|
|
35
|
+
"@babel/eslint-parser": "7.26.10",
|
|
33
36
|
"@babel/plugin-syntax-import-attributes": "7.26.0",
|
|
34
|
-
"@babel/preset-env": "7.26.
|
|
37
|
+
"@babel/preset-env": "7.26.9",
|
|
35
38
|
"eslint": "8.57.1",
|
|
36
|
-
"knip": "5.
|
|
37
|
-
"prettier": "3.
|
|
39
|
+
"knip": "5.46.0",
|
|
40
|
+
"prettier": "3.5.3"
|
|
38
41
|
},
|
|
39
42
|
"files": [
|
|
40
43
|
"playwright.config.js",
|
package/playwright.config.js
CHANGED
package/src/index.js
CHANGED
|
@@ -20,7 +20,7 @@ process.env.THEME_MODULE = path.join(process.cwd(), process.env.THEME_MODULE); /
|
|
|
20
20
|
const visualsTestModulePath = fileURLToPath(new URL('..', import.meta.url));
|
|
21
21
|
const binaryPath = fileURLToPath(new URL('../node_modules/.bin', import.meta.url));
|
|
22
22
|
|
|
23
|
-
let sampleReactPath = '../node_modules/@public-ui/sample-react';
|
|
23
|
+
let sampleReactPath = '../node_modules/@public-ui/visual-tests/node_modules/@public-ui/sample-react';
|
|
24
24
|
let backSteps = ``;
|
|
25
25
|
let workingDir = null;
|
|
26
26
|
do {
|
|
@@ -15,13 +15,6 @@ export const ROUTES = new Map();
|
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
ROUTES.set('handout/basic', {
|
|
19
|
-
viewportSize: {
|
|
20
|
-
width: 1920,
|
|
21
|
-
height: 1280,
|
|
22
|
-
},
|
|
23
|
-
waitForTimeout: 500,
|
|
24
|
-
});
|
|
25
18
|
ROUTES.set('abbr/basic', {
|
|
26
19
|
axe: {
|
|
27
20
|
skipFailures: false,
|
|
@@ -100,6 +93,11 @@ ROUTES.set('button/baselined', {
|
|
|
100
93
|
skipFailures: false,
|
|
101
94
|
},
|
|
102
95
|
});
|
|
96
|
+
ROUTES.set('button/short-key', {
|
|
97
|
+
axe: {
|
|
98
|
+
skipFailures: false,
|
|
99
|
+
},
|
|
100
|
+
});
|
|
103
101
|
ROUTES.set('card/basic', {
|
|
104
102
|
axe: {
|
|
105
103
|
skipFailures: false,
|
|
@@ -1,40 +1,6 @@
|
|
|
1
1
|
import { test, expect } from '@playwright/test';
|
|
2
2
|
import { ROUTES } from './sample-app.routes.js';
|
|
3
3
|
|
|
4
|
-
// https://github.com/microsoft/playwright/issues/7575#issuecomment-1288164474
|
|
5
|
-
export const configureSnapshotPath =
|
|
6
|
-
() =>
|
|
7
|
-
// eslint-disable-next-line no-empty-pattern
|
|
8
|
-
({}, testInfo) => {
|
|
9
|
-
const originalSnapshotPath = testInfo.snapshotPath;
|
|
10
|
-
testInfo.snapshotPath = (snapshotName) => {
|
|
11
|
-
const result = originalSnapshotPath
|
|
12
|
-
.apply(testInfo, [snapshotName])
|
|
13
|
-
|
|
14
|
-
// Remove browser name from snapshot name
|
|
15
|
-
// .replace('-chromium', '')
|
|
16
|
-
// .replace('-firefox', '')
|
|
17
|
-
|
|
18
|
-
// Remove os name from snapshot name
|
|
19
|
-
// .replace('-darwin', '')
|
|
20
|
-
// .replace('-linux', '')
|
|
21
|
-
// .replace('-windows', '')
|
|
22
|
-
|
|
23
|
-
// Remove test counter from snapshot name
|
|
24
|
-
.replace('-1-', '-')
|
|
25
|
-
|
|
26
|
-
// Identify 2. test as zoom snapshot
|
|
27
|
-
.replace('-2-', '-zoom-')
|
|
28
|
-
|
|
29
|
-
// Make different snapshot folder for different themes
|
|
30
|
-
.replace('theme-snapshots.spec.js', `theme-${(process.env.THEME_EXPORT || 'default').toLocaleLowerCase()}`)
|
|
31
|
-
.replace('-snapshots', '');
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
test.beforeEach(configureSnapshotPath());
|
|
37
|
-
|
|
38
4
|
// https://playwright.dev/docs/emulation
|
|
39
5
|
test.use({
|
|
40
6
|
colorScheme: 'light',
|
|
@@ -47,27 +13,52 @@ test.use({
|
|
|
47
13
|
},
|
|
48
14
|
});
|
|
49
15
|
|
|
16
|
+
const DEFAULT_SNAPSHOT_OPTIONS = {
|
|
17
|
+
animations: 'disabled',
|
|
18
|
+
fullPage: true,
|
|
19
|
+
maxDiffPixelRatio: 0,
|
|
20
|
+
scale: 'css', // 'css' or 'device'
|
|
21
|
+
timeout: 10000,
|
|
22
|
+
};
|
|
23
|
+
|
|
50
24
|
ROUTES.forEach((options, route) => {
|
|
51
25
|
test(`snapshot for ${route}`, async ({ page }) => {
|
|
52
26
|
const hideMenusParam = `${route.includes('?') ? '&' : '?'}hideMenus`;
|
|
53
|
-
await page.goto(`/#${route}${hideMenusParam}
|
|
27
|
+
await page.goto(`/#${route}${hideMenusParam}`);
|
|
28
|
+
await page.waitForLoadState('networkidle');
|
|
29
|
+
await page.addStyleTag({
|
|
30
|
+
content: `
|
|
31
|
+
* {
|
|
32
|
+
transition: none !important;
|
|
33
|
+
animation: none !important;
|
|
34
|
+
}
|
|
35
|
+
`,
|
|
36
|
+
});
|
|
54
37
|
if (options?.viewportSize) {
|
|
55
38
|
await page.setViewportSize(options.viewportSize);
|
|
56
39
|
}
|
|
57
40
|
if (options?.waitForTimeout) {
|
|
58
41
|
await page.waitForTimeout(options.waitForTimeout);
|
|
59
42
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* We would like to use a readable name for the snapshot file.
|
|
46
|
+
*/
|
|
47
|
+
const snapshotName = `snapshot-for-${route.replace(/(\/|\?|&|=)/g, '-')}`;
|
|
48
|
+
|
|
49
|
+
await expect(page).toHaveScreenshot(`${snapshotName}.png`, {
|
|
50
|
+
...DEFAULT_SNAPSHOT_OPTIONS,
|
|
63
51
|
...options,
|
|
64
52
|
});
|
|
65
53
|
await page.evaluate(() => {
|
|
54
|
+
// eslint-disable-next-line no-undef
|
|
66
55
|
document.body.style.zoom = '400%';
|
|
56
|
+
// document.body.style.transform = 'scale(4)';
|
|
57
|
+
// document.body.style.transformOrigin = 'top left';
|
|
58
|
+
// document.body.style.width = '25vw';
|
|
67
59
|
});
|
|
68
|
-
await expect(page).toHaveScreenshot({
|
|
69
|
-
|
|
70
|
-
maxDiffPixelRatio: 0.02,
|
|
60
|
+
await expect(page).toHaveScreenshot(`${snapshotName}-zoom.png`, {
|
|
61
|
+
...DEFAULT_SNAPSHOT_OPTIONS,
|
|
71
62
|
...options,
|
|
72
63
|
});
|
|
73
64
|
});
|
|
File without changes
|