@public-ui/visual-tests 2.2.7-rc.0 → 2.2.8-rc.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": "2.2.7-rc.0",
3
+ "version": "2.2.8-rc.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.",
@@ -22,19 +25,19 @@
22
25
  "kolibri-visual-test": "src/index.js"
23
26
  },
24
27
  "dependencies": {
25
- "@playwright/test": "1.50.0",
26
- "axe-playwright": "2.0.3",
27
- "portfinder": "1.0.32",
28
+ "@playwright/test": "1.49.1",
29
+ "axe-playwright": "2.1.0",
30
+ "portfinder": "1.0.35",
28
31
  "serve": "14.2.4",
29
- "@public-ui/sample-react": "2.2.7-rc.0"
32
+ "@public-ui/sample-react": "2.2.8-rc.0"
30
33
  },
31
34
  "devDependencies": {
32
- "@babel/eslint-parser": "7.26.5",
35
+ "@babel/eslint-parser": "7.26.10",
33
36
  "@babel/plugin-syntax-import-attributes": "7.26.0",
34
- "@babel/preset-env": "7.26.7",
37
+ "@babel/preset-env": "7.26.9",
35
38
  "eslint": "8.57.1",
36
- "knip": "5.43.6",
37
- "prettier": "3.4.2"
39
+ "knip": "5.46.0",
40
+ "prettier": "3.5.3"
38
41
  },
39
42
  "files": [
40
43
  "playwright.config.js",
@@ -59,4 +59,5 @@ export default defineConfig({
59
59
  url: URL,
60
60
  reuseExistingServer: false,
61
61
  },
62
+ snapshotPathTemplate: `{snapshotDir}/theme-${(process.env.THEME_EXPORT || 'default').toLocaleLowerCase()}/{arg}-{projectName}-{platform}{ext}`,
62
63
  });
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 {
@@ -98,6 +98,11 @@ ROUTES.set('button/baselined', {
98
98
  skipFailures: false,
99
99
  },
100
100
  });
101
+ ROUTES.set('button/short-key', {
102
+ axe: {
103
+ skipFailures: false,
104
+ },
105
+ });
101
106
  ROUTES.set('card/basic', {
102
107
  axe: {
103
108
  skipFailures: false,
@@ -506,6 +511,15 @@ ROUTES.set('scenarios/disabled-interactive-scenario', {
506
511
  skipFailures: false,
507
512
  },
508
513
  });
514
+ ROUTES.set('scenarios/same-height-of-all-interactive-elements', {
515
+ axe: {
516
+ skipFailures: false,
517
+ },
518
+ viewportSize: {
519
+ width: 4000,
520
+ height: 0,
521
+ },
522
+ });
509
523
 
510
524
  /* Focus tests */
511
525
  ROUTES.set('scenarios/focus-elements?component=accordion');
@@ -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,51 @@ 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
+ };
22
+
50
23
  ROUTES.forEach((options, route) => {
51
24
  test(`snapshot for ${route}`, async ({ page }) => {
52
25
  const hideMenusParam = `${route.includes('?') ? '&' : '?'}hideMenus`;
53
- await page.goto(`/#${route}${hideMenusParam}`, { waitUntil: 'networkidle' });
26
+ await page.goto(`/#${route}${hideMenusParam}`);
27
+ await page.waitForLoadState('networkidle');
28
+ await page.addStyleTag({
29
+ content: `
30
+ * {
31
+ transition: none !important;
32
+ animation: none !important;
33
+ }
34
+ `,
35
+ });
54
36
  if (options?.viewportSize) {
55
37
  await page.setViewportSize(options.viewportSize);
56
38
  }
57
39
  if (options?.waitForTimeout) {
58
40
  await page.waitForTimeout(options.waitForTimeout);
59
41
  }
60
- await expect(page).toHaveScreenshot({
61
- fullPage: true,
62
- maxDiffPixelRatio: 0.01,
42
+
43
+ /**
44
+ * We would like to use a readable name for the snapshot file.
45
+ */
46
+ const snapshotName = `snapshot-for-${route.replace(/(\/|\?|&|=)/g, '-')}`;
47
+
48
+ await expect(page).toHaveScreenshot(`${snapshotName}.png`, {
49
+ ...DEFAULT_SNAPSHOT_OPTIONS,
63
50
  ...options,
64
51
  });
65
52
  await page.evaluate(() => {
53
+ // eslint-disable-next-line no-undef
66
54
  document.body.style.zoom = '400%';
55
+ // document.body.style.transform = 'scale(4)';
56
+ // document.body.style.transformOrigin = 'top left';
57
+ // document.body.style.width = '25vw';
67
58
  });
68
- await expect(page).toHaveScreenshot({
69
- fullPage: true,
70
- maxDiffPixelRatio: 0.02,
59
+ await expect(page).toHaveScreenshot(`${snapshotName}-zoom.png`, {
60
+ ...DEFAULT_SNAPSHOT_OPTIONS,
71
61
  ...options,
72
62
  });
73
63
  });