@public-ui/visual-tests 3.0.0-rc.8 → 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.
|
@@ -22,6 +22,10 @@ const DEFAULT_SNAPSHOT_OPTIONS = {
|
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
ROUTES.forEach((options, route) => {
|
|
25
|
+
// Skip unnecessary snapshot tests
|
|
26
|
+
if (options?.snapshot?.skip === true && options?.snapshot?.zoom?.skip === true) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
25
29
|
test(`snapshot for ${route}`, async ({ page }) => {
|
|
26
30
|
const hideMenusParam = `${route.includes('?') ? '&' : '?'}hideMenus`;
|
|
27
31
|
await page.goto(`/#${route}${hideMenusParam}`);
|
|
@@ -34,11 +38,11 @@ ROUTES.forEach((options, route) => {
|
|
|
34
38
|
}
|
|
35
39
|
`,
|
|
36
40
|
});
|
|
37
|
-
if (options?.viewportSize) {
|
|
38
|
-
await page.setViewportSize(options
|
|
41
|
+
if (options?.snapshot?.viewportSize) {
|
|
42
|
+
await page.setViewportSize(options?.snapshot?.viewportSize);
|
|
39
43
|
}
|
|
40
|
-
if (options?.waitForTimeout) {
|
|
41
|
-
await page.waitForTimeout(options
|
|
44
|
+
if (options?.snapshot?.waitForTimeout) {
|
|
45
|
+
await page.waitForTimeout(options?.snapshot?.waitForTimeout);
|
|
42
46
|
}
|
|
43
47
|
|
|
44
48
|
/**
|
|
@@ -46,20 +50,29 @@ ROUTES.forEach((options, route) => {
|
|
|
46
50
|
*/
|
|
47
51
|
const snapshotName = `snapshot-for-${route.replace(/(\/|\?|&|=)/g, '-')}`;
|
|
48
52
|
|
|
49
|
-
|
|
53
|
+
const SNAPSHOT_OPTIONS = {
|
|
50
54
|
...DEFAULT_SNAPSHOT_OPTIONS,
|
|
51
|
-
...options,
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
55
|
+
...options?.snapshot?.options,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// Skip unnecessary normal tests
|
|
59
|
+
if (options?.snapshot?.skip !== true) {
|
|
60
|
+
await expect(page).toHaveScreenshot(`${snapshotName}.png`, SNAPSHOT_OPTIONS);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Skip unnecessary zoom tests
|
|
64
|
+
if (options?.snapshot?.zoom?.skip !== true) {
|
|
65
|
+
await page.evaluate(() => {
|
|
66
|
+
// eslint-disable-next-line no-undef
|
|
67
|
+
document.body.style.zoom = '400%';
|
|
68
|
+
// document.body.style.transform = 'scale(4)';
|
|
69
|
+
// document.body.style.transformOrigin = 'top left';
|
|
70
|
+
// document.body.style.width = '25vw';
|
|
71
|
+
});
|
|
72
|
+
await expect(page).toHaveScreenshot(`${snapshotName}-zoom.png`, {
|
|
73
|
+
...SNAPSHOT_OPTIONS,
|
|
74
|
+
...options?.snapshot?.zoom?.options,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
64
77
|
});
|
|
65
78
|
});
|