@public-ui/visual-tests 3.0.0-rc.7 → 3.0.0-rc.9
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-rc.
|
|
3
|
+
"version": "3.0.0-rc.9",
|
|
4
4
|
"license": "EUPL-1.2",
|
|
5
5
|
"homepage": "https://public-ui.github.io",
|
|
6
6
|
"repository": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"axe-playwright": "2.1.0",
|
|
30
30
|
"portfinder": "1.0.35",
|
|
31
31
|
"serve": "14.2.4",
|
|
32
|
-
"@public-ui/sample-react": "3.0.0-rc.
|
|
32
|
+
"@public-ui/sample-react": "3.0.0-rc.9"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@babel/eslint-parser": "7.26.10",
|
|
@@ -46,7 +46,8 @@
|
|
|
46
46
|
],
|
|
47
47
|
"scripts": {
|
|
48
48
|
"format": "prettier --check src",
|
|
49
|
-
"lint": "eslint
|
|
49
|
+
"lint": "pnpm lint:eslint",
|
|
50
|
+
"lint:eslint": "eslint src",
|
|
50
51
|
"unused": "knip",
|
|
51
52
|
"postinstall": "pnpm exec playwright install"
|
|
52
53
|
}
|
package/playwright.config.js
CHANGED
|
@@ -2,19 +2,24 @@ import { defineConfig, devices } from '@playwright/test';
|
|
|
2
2
|
import * as path from 'path';
|
|
3
3
|
import * as process from 'process';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
const
|
|
5
|
+
// Validate and set ENVs
|
|
6
|
+
const PORT = parseInt(process.env.KOLIBRI_VISUAL_TEST_PORT || '', 10);
|
|
7
|
+
const BASE_URL = `http://localhost:${PORT}`;
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
const CWD = process.env.KOLIBRI_CWD ?? '';
|
|
10
|
+
const TIMEOUT = parseInt(process.env.KOLIBRI_VISUAL_TESTS_TIMEOUT || '15000', 10);
|
|
11
|
+
const EXPECT_TIMEOUT = parseInt(process.env.KOLIBRI_VISUAL_TESTS_EXPECT_TIMEOUT || '5000', 10);
|
|
12
|
+
const BUILD_PATH = process.env.KOLIBRI_VISUAL_TESTS_BUILD_PATH ?? '';
|
|
13
|
+
const THEME = (process.env.THEME_EXPORT || 'default').toLocaleLowerCase();
|
|
9
14
|
|
|
10
15
|
/**
|
|
11
16
|
* See https://playwright.dev/docs/test-configuration.
|
|
12
17
|
*/
|
|
13
18
|
export default defineConfig({
|
|
14
19
|
testDir: './tests',
|
|
15
|
-
snapshotDir: path.join(
|
|
20
|
+
snapshotDir: path.join(CWD, 'snapshots'),
|
|
16
21
|
// snapshotPathTemplate: '',
|
|
17
|
-
outputDir: path.join(
|
|
22
|
+
outputDir: path.join(CWD, 'test-results'),
|
|
18
23
|
/* Run tests in files in parallel */
|
|
19
24
|
fullyParallel: true,
|
|
20
25
|
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
|
@@ -24,20 +29,20 @@ export default defineConfig({
|
|
|
24
29
|
/* Opt out of parallel tests on CI. */
|
|
25
30
|
workers: process.env.CI ? 1 : undefined,
|
|
26
31
|
/* Allow to override the expectation timeout for slow environments */
|
|
27
|
-
timeout:
|
|
32
|
+
timeout: TIMEOUT,
|
|
28
33
|
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
|
29
34
|
reporter: 'line',
|
|
30
35
|
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
|
31
36
|
use: {
|
|
32
37
|
/* Base URL to use in actions like `await page.goto('/')`. */
|
|
33
|
-
baseURL:
|
|
38
|
+
baseURL: BASE_URL,
|
|
34
39
|
|
|
35
40
|
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
|
36
41
|
trace: 'on-first-retry',
|
|
37
42
|
},
|
|
38
43
|
|
|
39
44
|
expect: {
|
|
40
|
-
timeout:
|
|
45
|
+
timeout: EXPECT_TIMEOUT,
|
|
41
46
|
},
|
|
42
47
|
|
|
43
48
|
/* Configure projects for major browsers */
|
|
@@ -59,9 +64,9 @@ export default defineConfig({
|
|
|
59
64
|
/* Run your local dev server before starting the tests */
|
|
60
65
|
webServer: {
|
|
61
66
|
command: `npx serve -p ${PORT}`,
|
|
62
|
-
cwd: path.resolve(
|
|
63
|
-
url:
|
|
67
|
+
cwd: path.resolve(BUILD_PATH),
|
|
68
|
+
url: BASE_URL,
|
|
64
69
|
reuseExistingServer: false,
|
|
65
70
|
},
|
|
66
|
-
snapshotPathTemplate: `{snapshotDir}/theme-${
|
|
71
|
+
snapshotPathTemplate: `{snapshotDir}/theme-${THEME}/{arg}-{projectName}-{platform}{ext}`,
|
|
67
72
|
});
|
|
@@ -36,21 +36,31 @@ test.use({
|
|
|
36
36
|
},
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
-
const blocklist = [];
|
|
40
|
-
|
|
41
39
|
ROUTES.forEach((options, route) => {
|
|
42
|
-
|
|
40
|
+
// Skip unnecessary axe tests
|
|
41
|
+
if (options?.axe?.skip === true) {
|
|
43
42
|
return;
|
|
44
43
|
}
|
|
45
44
|
test(`snapshot for ${route}`, async ({ page }, testInfo) => {
|
|
46
45
|
const outputPath = rename(testInfo.outputDir);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
const hideMenusParam = `${route.includes('?') ? '&' : '?'}hideMenus`;
|
|
47
|
+
await page.goto(`/#${route}${hideMenusParam}`);
|
|
48
|
+
await page.waitForLoadState('networkidle');
|
|
49
|
+
await page.addStyleTag({
|
|
50
|
+
content: `
|
|
51
|
+
* {
|
|
52
|
+
transition: none !important;
|
|
53
|
+
animation: none !important;
|
|
54
|
+
}
|
|
55
|
+
`,
|
|
56
|
+
});
|
|
57
|
+
if (options?.snapshot?.viewportSize) {
|
|
58
|
+
await page.setViewportSize(options?.snapshot?.viewportSize);
|
|
50
59
|
}
|
|
51
|
-
if (options?.waitForTimeout) {
|
|
52
|
-
await page.waitForTimeout(options
|
|
60
|
+
if (options?.snapshot?.waitForTimeout) {
|
|
61
|
+
await page.waitForTimeout(options?.snapshot?.waitForTimeout);
|
|
53
62
|
}
|
|
63
|
+
|
|
54
64
|
await injectAxe(page);
|
|
55
65
|
await checkA11y(
|
|
56
66
|
page,
|
|
@@ -67,7 +77,7 @@ ROUTES.forEach((options, route) => {
|
|
|
67
77
|
html: true,
|
|
68
78
|
},
|
|
69
79
|
},
|
|
70
|
-
options?.axe?.skipFailures ??
|
|
80
|
+
options?.axe?.skipFailures ?? false,
|
|
71
81
|
'html',
|
|
72
82
|
{
|
|
73
83
|
outputDirPath: outputPath.replace(/\/[^/]+$/, ''),
|