@public-ui/visual-tests 3.1.5 → 3.1.6-rc.1
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.1.
|
|
3
|
+
"version": "3.1.6-rc.1",
|
|
4
4
|
"license": "EUPL-1.2",
|
|
5
5
|
"homepage": "https://public-ui.github.io",
|
|
6
6
|
"repository": {
|
|
@@ -25,26 +25,26 @@
|
|
|
25
25
|
"kolibri-visual-test": "src/index.js"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@axe-core/playwright": "4.11.
|
|
28
|
+
"@axe-core/playwright": "4.11.3",
|
|
29
29
|
"axe-html-reporter": "2.2.11",
|
|
30
30
|
"http-server": "14.1.1",
|
|
31
31
|
"portfinder": "1.0.38",
|
|
32
|
-
"@public-ui/sample-react": "3.1.
|
|
32
|
+
"@public-ui/sample-react": "3.1.6-rc.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@babel/eslint-parser": "7.
|
|
36
|
-
"@babel/plugin-syntax-import-attributes": "7.
|
|
37
|
-
"@babel/preset-env": "7.29.
|
|
35
|
+
"@babel/eslint-parser": "7.29.7",
|
|
36
|
+
"@babel/plugin-syntax-import-attributes": "7.29.7",
|
|
37
|
+
"@babel/preset-env": "7.29.7",
|
|
38
38
|
"@eslint/eslintrc": "3.3.5",
|
|
39
39
|
"@eslint/js": "9.39.4",
|
|
40
|
-
"@playwright/test": "1.
|
|
40
|
+
"@playwright/test": "1.61.0",
|
|
41
41
|
"eslint": "9.39.4",
|
|
42
42
|
"knip": "5.88.1",
|
|
43
|
-
"prettier": "3.8.
|
|
43
|
+
"prettier": "3.8.4",
|
|
44
44
|
"prettier-plugin-organize-imports": "4.3.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@playwright/test": "1.
|
|
47
|
+
"@playwright/test": "1.61.0"
|
|
48
48
|
},
|
|
49
49
|
"files": [
|
|
50
50
|
"playwright.config.js",
|
|
@@ -10,6 +10,8 @@ export const ROUTES = new Map();
|
|
|
10
10
|
*
|
|
11
11
|
* Snapshot options:
|
|
12
12
|
* - snapshot:
|
|
13
|
+
* - forceFullPage: boolean (Default: false) — capture the whole page without the body clip, for
|
|
14
|
+
* routes whose fixed-position overlays (modal, popover, toast) extend beyond the body height
|
|
13
15
|
* - options:
|
|
14
16
|
* - maxDiffPixelRatio: number (Default: 0)
|
|
15
17
|
* - skip: boolean (Default: false)
|
|
@@ -577,6 +579,7 @@ ROUTES.set('modal/basic', {
|
|
|
577
579
|
});
|
|
578
580
|
ROUTES.set('modal/basic?show-modal=true', {
|
|
579
581
|
snapshot: {
|
|
582
|
+
forceFullPage: true,
|
|
580
583
|
viewportSize: {
|
|
581
584
|
width: 1920,
|
|
582
585
|
height: 600,
|
|
@@ -614,6 +617,7 @@ ROUTES.set('pagination/basic', {
|
|
|
614
617
|
});
|
|
615
618
|
ROUTES.set('popover-button/basic', {
|
|
616
619
|
snapshot: {
|
|
620
|
+
forceFullPage: true,
|
|
617
621
|
zoom: {
|
|
618
622
|
skip: true,
|
|
619
623
|
},
|
|
@@ -953,6 +957,7 @@ ROUTES.set('textarea/with-counter', {
|
|
|
953
957
|
});
|
|
954
958
|
ROUTES.set('toast/configurator', {
|
|
955
959
|
snapshot: {
|
|
960
|
+
forceFullPage: true,
|
|
956
961
|
viewportSize: {
|
|
957
962
|
width: 600,
|
|
958
963
|
height: 750,
|
|
@@ -7,9 +7,13 @@ test.use({
|
|
|
7
7
|
locale: 'de-DE',
|
|
8
8
|
isMobile: false,
|
|
9
9
|
timezoneId: 'Europe/Berlin',
|
|
10
|
+
/* The height must be a real value: with `height: 0`, Firefox gives full-width blocks no size and
|
|
11
|
+
the document collapses to its narrowest intrinsic width. A real height lets the layout render
|
|
12
|
+
normally, while the screenshots clip to the page content so the viewport height does not leak
|
|
13
|
+
into the captured image. */
|
|
10
14
|
viewport: {
|
|
11
15
|
width: 800,
|
|
12
|
-
height:
|
|
16
|
+
height: 400,
|
|
13
17
|
},
|
|
14
18
|
});
|
|
15
19
|
|
|
@@ -21,6 +25,22 @@ const DEFAULT_SNAPSHOT_OPTIONS = {
|
|
|
21
25
|
timeout: 10000,
|
|
22
26
|
};
|
|
23
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Clips the screenshot to the page content: the document is at least as tall as the viewport, while
|
|
30
|
+
* the body only extends as far as its content renders. Clipping from the document origin with the
|
|
31
|
+
* viewport width keeps the captured geometry identical to a full-page capture, whose height and
|
|
32
|
+
* width the document only grew beyond when the content itself demanded it.
|
|
33
|
+
*/
|
|
34
|
+
async function contentClip(page) {
|
|
35
|
+
const bodyBoundingBox = await page.locator('body').boundingBox();
|
|
36
|
+
return {
|
|
37
|
+
x: 0,
|
|
38
|
+
y: 0,
|
|
39
|
+
width: page.viewportSize().width,
|
|
40
|
+
height: Math.ceil(bodyBoundingBox.y + bodyBoundingBox.height),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
24
44
|
ROUTES.forEach((options, route) => {
|
|
25
45
|
// Skip unnecessary snapshot tests
|
|
26
46
|
if (options?.snapshot?.skip === true && options?.snapshot?.zoom?.skip === true) {
|
|
@@ -55,9 +75,19 @@ ROUTES.forEach((options, route) => {
|
|
|
55
75
|
...options?.snapshot?.options,
|
|
56
76
|
};
|
|
57
77
|
|
|
78
|
+
/**
|
|
79
|
+
* Routes with fixed-position overlays (modal, popover, toast) are captured as a whole page:
|
|
80
|
+
* a clip to the body height would cut the overlay off at the body edge or drop it entirely,
|
|
81
|
+
* because fixed elements position themselves at the viewport and not at the document.
|
|
82
|
+
*/
|
|
83
|
+
const forceFullPage = options?.snapshot?.forceFullPage === true;
|
|
84
|
+
|
|
58
85
|
// Skip unnecessary normal tests
|
|
59
86
|
if (options?.snapshot?.skip !== true) {
|
|
60
|
-
await expect(page).toHaveScreenshot(`${snapshotName}.png`,
|
|
87
|
+
await expect(page).toHaveScreenshot(`${snapshotName}.png`, {
|
|
88
|
+
...SNAPSHOT_OPTIONS,
|
|
89
|
+
clip: forceFullPage ? undefined : await contentClip(page),
|
|
90
|
+
});
|
|
61
91
|
}
|
|
62
92
|
|
|
63
93
|
// Skip unnecessary zoom tests
|
|
@@ -72,6 +102,7 @@ ROUTES.forEach((options, route) => {
|
|
|
72
102
|
await expect(page).toHaveScreenshot(`${snapshotName}-zoom.png`, {
|
|
73
103
|
...SNAPSHOT_OPTIONS,
|
|
74
104
|
...options?.snapshot?.zoom?.options,
|
|
105
|
+
clip: forceFullPage ? undefined : await contentClip(page),
|
|
75
106
|
});
|
|
76
107
|
}
|
|
77
108
|
});
|