@public-ui/visual-tests 1.7.0-rc.11 → 1.7.0-rc.12
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 +8 -6
- package/playwright.config.js +1 -1
- package/src/index.js +18 -4
- package/tests/sample-app.routes.js +114 -80
- package/tests/theme-snapshots.spec.js +28 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@public-ui/visual-tests",
|
|
3
|
-
"version": "1.7.0-rc.
|
|
3
|
+
"version": "1.7.0-rc.12",
|
|
4
4
|
"license": "EUPL-1.2",
|
|
5
5
|
"homepage": "https://public-ui.github.io",
|
|
6
6
|
"repository": "https://github.com/public-ui/kolibri",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"sideEffects": false,
|
|
17
17
|
"description": "Provides utility to run visual regression tests for themes.",
|
|
18
18
|
"scripts": {
|
|
19
|
-
"depcheck": "depcheck --ignores=@public-ui/sample-react,
|
|
19
|
+
"depcheck": "depcheck --ignores=@babel/plugin-syntax-import-attributes,@babel/preset-env,@public-ui/sample-react,portfinder,serve",
|
|
20
20
|
"format": "prettier --check src",
|
|
21
21
|
"lint": "eslint src",
|
|
22
22
|
"unused": "knip"
|
|
@@ -26,16 +26,18 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@playwright/test": "1.38.0",
|
|
29
|
-
"@public-ui/sample-react": "1.7.0-rc.
|
|
30
|
-
"
|
|
31
|
-
"
|
|
29
|
+
"@public-ui/sample-react": "1.7.0-rc.12",
|
|
30
|
+
"portfinder": "1.0.32",
|
|
31
|
+
"serve": "14.2.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@babel/eslint-parser": "7.22.15",
|
|
35
|
+
"@babel/plugin-syntax-import-attributes": "7.22.5",
|
|
36
|
+
"@babel/preset-env": "7.22.20",
|
|
35
37
|
"depcheck": "1.4.6",
|
|
36
38
|
"eslint": "8.49.0",
|
|
37
39
|
"eslint-plugin-no-loops": "0.3.0",
|
|
38
|
-
"knip": "2.
|
|
40
|
+
"knip": "2.25.2",
|
|
39
41
|
"prettier": "3.0.3"
|
|
40
42
|
},
|
|
41
43
|
"files": [
|
package/playwright.config.js
CHANGED
|
@@ -52,7 +52,7 @@ export default defineConfig({
|
|
|
52
52
|
|
|
53
53
|
/* Run your local dev server before starting the tests */
|
|
54
54
|
webServer: {
|
|
55
|
-
command: `
|
|
55
|
+
command: `serve ${process.env.KOLIBRI_VISUAL_TESTS_BUILD_PATH} -p ${PORT}`,
|
|
56
56
|
url: URL,
|
|
57
57
|
reuseExistingServer: false,
|
|
58
58
|
},
|
package/src/index.js
CHANGED
|
@@ -19,11 +19,18 @@ if (!tempDir) {
|
|
|
19
19
|
process.env.THEME_MODULE = path.join(process.cwd(), process.env.THEME_MODULE); // Use current working directory (i.e. the theme folder) to complete module path
|
|
20
20
|
const visualsTestModulePath = fileURLToPath(new URL('..', import.meta.url));
|
|
21
21
|
const binaryPath = fileURLToPath(new URL('../node_modules/.bin', import.meta.url));
|
|
22
|
+
const workingDir = fileURLToPath(new URL('../node_modules/@public-ui/sample-react', import.meta.url));
|
|
22
23
|
const buildPath = path.join(tempDir, `kolibri-visual-testing-build-${crypto.randomUUID()}`);
|
|
24
|
+
const packageJsonPath = await import(new URL('../node_modules/@public-ui/sample-react/package.json', import.meta.url), {
|
|
25
|
+
assert: { type: 'json' },
|
|
26
|
+
});
|
|
27
|
+
|
|
23
28
|
process.env.KOLIBRI_VISUAL_TESTS_BUILD_PATH = buildPath;
|
|
24
29
|
|
|
25
|
-
console.log(
|
|
26
|
-
|
|
30
|
+
console.log(`
|
|
31
|
+
Building React Sample App (v${packageJsonPath?.default?.version ?? '#.#.#'}) …`);
|
|
32
|
+
child_process.execFileSync('npm', ['run', 'build', '--', `--output-path=${buildPath}`], {
|
|
33
|
+
cwd: workingDir,
|
|
27
34
|
encoding: 'utf-8',
|
|
28
35
|
});
|
|
29
36
|
|
|
@@ -46,8 +53,15 @@ void (async () => {
|
|
|
46
53
|
|
|
47
54
|
playwright.on('exit', (code) => {
|
|
48
55
|
console.log(`Playwright test finished with exit code ${code}.`);
|
|
49
|
-
|
|
50
|
-
|
|
56
|
+
|
|
57
|
+
if (process.env.KOLIBRI_CLEANUP === '0') {
|
|
58
|
+
console.log('Skipping cleanup up build folder.');
|
|
59
|
+
console.log(`You can serve this build with "npx serve ${buildPath}".`);
|
|
60
|
+
} else {
|
|
61
|
+
console.log('Cleaning up build folder …');
|
|
62
|
+
fs.rmSync(buildPath, { recursive: true, force: true });
|
|
63
|
+
console.log('Cleaning up finished successfully.');
|
|
64
|
+
}
|
|
51
65
|
process.exit(code ?? 1);
|
|
52
66
|
});
|
|
53
67
|
})();
|
|
@@ -1,80 +1,114 @@
|
|
|
1
|
-
export const ROUTES =
|
|
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
|
-
|
|
1
|
+
export const ROUTES = new Map();
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Actually we support the following options:
|
|
5
|
+
*
|
|
6
|
+
* Details: https://playwright.dev/docs/api/class-pageassertions#page-assertions-to-have-screenshot-1
|
|
7
|
+
* - fullPage: boolean (Default: true)
|
|
8
|
+
* - maxDiffPixelRatio: number (Default: undefined)
|
|
9
|
+
* - maxDiffPixels: number (Default: undefined)
|
|
10
|
+
* - threshold: number (Default: undefined)
|
|
11
|
+
* - timeout: number (Default: 0)
|
|
12
|
+
*
|
|
13
|
+
* To set the viewport size, use the following options:
|
|
14
|
+
* - viewportSize: { width, height } (Default: 800x600)
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
ROUTES.set('handout/basic', {
|
|
19
|
+
viewportSize: {
|
|
20
|
+
width: 1920,
|
|
21
|
+
height: 1280,
|
|
22
|
+
},
|
|
23
|
+
waitForTimeout: 500,
|
|
24
|
+
});
|
|
25
|
+
ROUTES.set('abbr/basic', null);
|
|
26
|
+
ROUTES.set('accordion/basic', null);
|
|
27
|
+
ROUTES.set('accordion/header', null);
|
|
28
|
+
ROUTES.set('accordion/headlines', null);
|
|
29
|
+
ROUTES.set('accordion/list', null);
|
|
30
|
+
ROUTES.set('alert/basic', null);
|
|
31
|
+
ROUTES.set('alert/card-msg', null);
|
|
32
|
+
ROUTES.set('alert/html', null);
|
|
33
|
+
ROUTES.set('avatar/basic', null);
|
|
34
|
+
ROUTES.set('badge/basic', null);
|
|
35
|
+
ROUTES.set('badge/button', null);
|
|
36
|
+
ROUTES.set('breadcrumb/basic', null);
|
|
37
|
+
ROUTES.set('button-group/basic', null);
|
|
38
|
+
ROUTES.set('button-link/basic', null);
|
|
39
|
+
ROUTES.set('button-link/icons', null);
|
|
40
|
+
ROUTES.set('button-link/image', null);
|
|
41
|
+
ROUTES.set('button-link/target', null);
|
|
42
|
+
ROUTES.set('button/basic', null);
|
|
43
|
+
ROUTES.set('button/hide-label', null);
|
|
44
|
+
ROUTES.set('button/icons', null);
|
|
45
|
+
ROUTES.set('button/width', null);
|
|
46
|
+
ROUTES.set('card/basic', null);
|
|
47
|
+
ROUTES.set('card/confirm', null);
|
|
48
|
+
ROUTES.set('card/flex', null);
|
|
49
|
+
ROUTES.set('card/selection', null);
|
|
50
|
+
ROUTES.set('details/basic', null);
|
|
51
|
+
ROUTES.set('heading/badge', null);
|
|
52
|
+
ROUTES.set('heading/basic', null);
|
|
53
|
+
ROUTES.set('heading/paragraph', null);
|
|
54
|
+
ROUTES.set('icon/basic', null);
|
|
55
|
+
ROUTES.set('image/basic', null);
|
|
56
|
+
ROUTES.set('indented-text/basic', null);
|
|
57
|
+
ROUTES.set('input-checkbox/basic', null);
|
|
58
|
+
ROUTES.set('input-checkbox/button', null);
|
|
59
|
+
ROUTES.set('input-checkbox/switch', null);
|
|
60
|
+
ROUTES.set('input-color/basic', null);
|
|
61
|
+
ROUTES.set('input-date/basic', null);
|
|
62
|
+
ROUTES.set('input-email/basic', null);
|
|
63
|
+
ROUTES.set('input-file/basic', null);
|
|
64
|
+
ROUTES.set('input-number/basic', null);
|
|
65
|
+
ROUTES.set('input-password/basic', null);
|
|
66
|
+
ROUTES.set('input-password/show-password', null);
|
|
67
|
+
ROUTES.set('input-radio/basic', null);
|
|
68
|
+
ROUTES.set('input-radio/horizontal', null);
|
|
69
|
+
ROUTES.set('input-radio/select', null);
|
|
70
|
+
ROUTES.set('input-range/basic', null);
|
|
71
|
+
ROUTES.set('input-text/basic', null);
|
|
72
|
+
ROUTES.set('input-text/blur', null);
|
|
73
|
+
ROUTES.set('input-text/focus', null);
|
|
74
|
+
ROUTES.set('input-text/hidden-label', null);
|
|
75
|
+
ROUTES.set('kolibri/animated', null);
|
|
76
|
+
ROUTES.set('kolibri/basic', null);
|
|
77
|
+
ROUTES.set('kolibri/no-label', null);
|
|
78
|
+
ROUTES.set('link-button/basic', null);
|
|
79
|
+
ROUTES.set('link-group/basic', null);
|
|
80
|
+
ROUTES.set('link-group/horizontal', null);
|
|
81
|
+
ROUTES.set('link/basic', null);
|
|
82
|
+
ROUTES.set('link/icons', null);
|
|
83
|
+
ROUTES.set('link/image', null);
|
|
84
|
+
ROUTES.set('link/target', null);
|
|
85
|
+
ROUTES.set('logo/basic', null);
|
|
86
|
+
ROUTES.set('nav/active', null);
|
|
87
|
+
ROUTES.set('nav/aria-current', null);
|
|
88
|
+
ROUTES.set('nav/basic', null);
|
|
89
|
+
ROUTES.set('nav/horizontal', null);
|
|
90
|
+
ROUTES.set('pagination/basic', null);
|
|
91
|
+
ROUTES.set('popover/basic', null);
|
|
92
|
+
ROUTES.set('progress/basic', null);
|
|
93
|
+
ROUTES.set('quote/basic', null);
|
|
94
|
+
ROUTES.set('quote/block', null);
|
|
95
|
+
ROUTES.set('select/basic', null);
|
|
96
|
+
ROUTES.set('skip-nav/basic', null);
|
|
97
|
+
ROUTES.set('spin/basic', null);
|
|
98
|
+
ROUTES.set('spin/custom', null);
|
|
99
|
+
ROUTES.set('spin/cycle', null);
|
|
100
|
+
ROUTES.set('split-button/basic', null);
|
|
101
|
+
ROUTES.set('table/badge-size', null);
|
|
102
|
+
ROUTES.set('table/render-cell', null);
|
|
103
|
+
ROUTES.set('table/sort-data', null);
|
|
104
|
+
ROUTES.set('tabs/basic', null);
|
|
105
|
+
ROUTES.set('tabs/icons-only', null);
|
|
106
|
+
ROUTES.set('textarea/adjust-height', null);
|
|
107
|
+
ROUTES.set('textarea/basic', null);
|
|
108
|
+
ROUTES.set('textarea/disabled', null);
|
|
109
|
+
ROUTES.set('textarea/placeholder', null);
|
|
110
|
+
ROUTES.set('textarea/readonly', null);
|
|
111
|
+
ROUTES.set('textarea/resize', null);
|
|
112
|
+
ROUTES.set('textarea/rows', null);
|
|
113
|
+
ROUTES.set('version/basic', null);
|
|
114
|
+
ROUTES.set('version/context', null);
|
|
@@ -15,9 +15,9 @@ export const configureSnapshotPath =
|
|
|
15
15
|
// .replace('-firefox', '')
|
|
16
16
|
|
|
17
17
|
// Remove os name from snapshot name
|
|
18
|
-
.replace('-darwin', '')
|
|
19
|
-
.replace('-linux', '')
|
|
20
|
-
.replace('-windows', '')
|
|
18
|
+
// .replace('-darwin', '')
|
|
19
|
+
// .replace('-linux', '')
|
|
20
|
+
// .replace('-windows', '')
|
|
21
21
|
|
|
22
22
|
// Remove test counter from snapshot name
|
|
23
23
|
.replace('-1-', '-')
|
|
@@ -31,22 +31,39 @@ export const configureSnapshotPath =
|
|
|
31
31
|
|
|
32
32
|
test.beforeEach(configureSnapshotPath());
|
|
33
33
|
|
|
34
|
+
// https://playwright.dev/docs/emulation
|
|
35
|
+
test.use({
|
|
36
|
+
colorScheme: 'light',
|
|
37
|
+
locale: 'de-DE',
|
|
38
|
+
isMobile: false,
|
|
39
|
+
timezoneId: 'Europe/Berlin',
|
|
40
|
+
viewport: {
|
|
41
|
+
width: 800,
|
|
42
|
+
height: 0,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
|
|
34
46
|
/**
|
|
35
47
|
* @todo stabilize and re-enable test
|
|
36
48
|
*/
|
|
37
49
|
const blocklist = [];
|
|
38
50
|
|
|
39
|
-
ROUTES.
|
|
51
|
+
ROUTES.forEach((options, route) => {
|
|
52
|
+
if (blocklist.includes(route)) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
40
55
|
test(`snapshot for ${route}`, async ({ page }) => {
|
|
41
56
|
await page.goto(`/#${route}?hideMenus`, { waitUntil: 'networkidle' });
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
57
|
+
if (options?.viewportSize) {
|
|
58
|
+
await page.setViewportSize(options.viewportSize);
|
|
59
|
+
}
|
|
60
|
+
if (options?.waitForTimeout) {
|
|
61
|
+
await page.waitForTimeout(options.waitForTimeout);
|
|
62
|
+
}
|
|
47
63
|
await expect(page).toHaveScreenshot({
|
|
48
|
-
|
|
49
|
-
maxDiffPixelRatio: 0.
|
|
64
|
+
fullPage: true,
|
|
65
|
+
maxDiffPixelRatio: 0.025,
|
|
66
|
+
...options,
|
|
50
67
|
});
|
|
51
68
|
});
|
|
52
69
|
});
|