@public-ui/visual-tests 1.7.0-rc.6 → 1.7.0-rc.7
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/kolibri-visual-test.sh +1 -1
- package/package.json +16 -13
- package/playwright.config.ts +59 -0
- package/tests/theme-snapshots.spec.ts +46 -0
- package/tsconfig.json +22 -0
package/kolibri-visual-test.sh
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
# Wrapper script necessary to avoid issues in the monorepos' initial `pnpm i`, when the binary already needs to exist.
|
|
2
2
|
# The actual script is built in the `prepare` hook and available after the `pnpm i` finished.
|
|
3
|
-
node "$(dirname "$0")/dist/index.js"
|
|
3
|
+
node "$(dirname "$0")/dist/index.js" $1
|
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.7",
|
|
4
4
|
"license": "EUPL-1.2",
|
|
5
5
|
"homepage": "https://public-ui.github.io",
|
|
6
6
|
"repository": "https://github.com/public-ui/kolibri",
|
|
@@ -25,24 +25,27 @@
|
|
|
25
25
|
"bin": {
|
|
26
26
|
"kolibri-visual-test": "kolibri-visual-test.sh"
|
|
27
27
|
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@playwright/test": "1.37.1",
|
|
30
|
+
"@public-ui/sample-react": "1.7.0-rc.7",
|
|
31
|
+
"http-server": "14.1.1",
|
|
32
|
+
"portfinder": "1.0.32",
|
|
33
|
+
"tslib": "2.6.2",
|
|
34
|
+
"typescript": "5.2.2"
|
|
35
|
+
},
|
|
28
36
|
"devDependencies": {
|
|
29
37
|
"@types/node": "20.6.0",
|
|
30
38
|
"@typescript-eslint/eslint-plugin": "6.7.0",
|
|
31
39
|
"eslint": "8.49.0",
|
|
32
40
|
"eslint-plugin-no-loops": "0.3.0",
|
|
33
|
-
"knip": "2.
|
|
34
|
-
"npm-check-updates": "16.
|
|
35
|
-
"prettier": "3.0.3"
|
|
36
|
-
"tslib": "2.6.2",
|
|
37
|
-
"typescript": "5.2.2"
|
|
38
|
-
},
|
|
39
|
-
"dependencies": {
|
|
40
|
-
"@playwright/test": "1.37.1",
|
|
41
|
-
"@public-ui/sample-react": "1.7.0-rc.6",
|
|
42
|
-
"http-server": "14.1.1",
|
|
43
|
-
"portfinder": "1.0.32"
|
|
41
|
+
"knip": "2.24.0",
|
|
42
|
+
"npm-check-updates": "16.14.0",
|
|
43
|
+
"prettier": "3.0.3"
|
|
44
44
|
},
|
|
45
45
|
"files": [
|
|
46
|
-
"dist"
|
|
46
|
+
"dist",
|
|
47
|
+
"playwright.config.ts",
|
|
48
|
+
"tests",
|
|
49
|
+
"tsconfig.json"
|
|
47
50
|
]
|
|
48
51
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { defineConfig, devices } from '@playwright/test';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import * as process from 'process';
|
|
4
|
+
|
|
5
|
+
const PORT = Number(process.env.KOLIBRI_VISUAL_TEST_PORT);
|
|
6
|
+
const URL = `http://127.0.0.1:${PORT}`;
|
|
7
|
+
|
|
8
|
+
console.log('Serving React Sample app:', URL);
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* See https://playwright.dev/docs/test-configuration.
|
|
12
|
+
*/
|
|
13
|
+
export default defineConfig({
|
|
14
|
+
testDir: './tests',
|
|
15
|
+
snapshotDir: path.join(process.env.KOLIBRI_CWD, 'snapshots'),
|
|
16
|
+
// snapshotPathTemplate: '',
|
|
17
|
+
outputDir: path.join(process.env.KOLIBRI_CWD, 'test-results'),
|
|
18
|
+
/* Run tests in files in parallel */
|
|
19
|
+
fullyParallel: true,
|
|
20
|
+
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
|
21
|
+
forbidOnly: !!process.env.CI,
|
|
22
|
+
/* Retry on CI only */
|
|
23
|
+
retries: 0, // process.env.CI ? 2 : 0,
|
|
24
|
+
/* Opt out of parallel tests on CI. */
|
|
25
|
+
workers: process.env.CI ? 1 : undefined,
|
|
26
|
+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
|
27
|
+
reporter: 'line',
|
|
28
|
+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
|
29
|
+
use: {
|
|
30
|
+
/* Base URL to use in actions like `await page.goto('/')`. */
|
|
31
|
+
baseURL: URL,
|
|
32
|
+
|
|
33
|
+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
|
34
|
+
trace: 'on-first-retry',
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
/* Configure projects for major browsers */
|
|
38
|
+
projects: [
|
|
39
|
+
// {
|
|
40
|
+
// name: 'chrome',
|
|
41
|
+
// use: { ...devices['Desktop Chrome'] },
|
|
42
|
+
// },
|
|
43
|
+
// {
|
|
44
|
+
// name: 'edge',
|
|
45
|
+
// use: { ...devices['Desktop Edge'] },
|
|
46
|
+
// },
|
|
47
|
+
{
|
|
48
|
+
name: 'firefox',
|
|
49
|
+
use: { ...devices['Desktop Firefox'] },
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
|
|
53
|
+
/* Run your local dev server before starting the tests */
|
|
54
|
+
webServer: {
|
|
55
|
+
command: `http-server ${process.env.KOLIBRI_VISUAL_TESTS_BUILD_PATH} -p ${PORT}`,
|
|
56
|
+
url: URL,
|
|
57
|
+
reuseExistingServer: false,
|
|
58
|
+
},
|
|
59
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { test, expect, TestInfo } from '@playwright/test';
|
|
2
|
+
// @ts-ignore
|
|
3
|
+
import { routes } from '@public-ui/sample-react/src/routes-test.ts';
|
|
4
|
+
|
|
5
|
+
// https://github.com/microsoft/playwright/issues/7575#issuecomment-1288164474
|
|
6
|
+
export const configureSnapshotPath =
|
|
7
|
+
(options?: {}) =>
|
|
8
|
+
({}: any, testInfo: TestInfo): any => {
|
|
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
|
+
return result;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
test.beforeEach(configureSnapshotPath());
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @todo stabilize and re-enable test
|
|
33
|
+
*/
|
|
34
|
+
const blocklist = ['/heading/paragraph'];
|
|
35
|
+
|
|
36
|
+
routes
|
|
37
|
+
.filter((route) => !blocklist.includes(route))
|
|
38
|
+
.forEach((route) => {
|
|
39
|
+
test(`snapshot for ${route}`, async ({ page }) => {
|
|
40
|
+
await page.goto(`/#${route}?hideMenus`, { waitUntil: 'networkidle' });
|
|
41
|
+
await expect(page).toHaveScreenshot({
|
|
42
|
+
fullPage: true,
|
|
43
|
+
maxDiffPixelRatio: 0.03,
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"allowSyntheticDefaultImports": true,
|
|
4
|
+
"allowUnreachableCode": false,
|
|
5
|
+
"declaration": false,
|
|
6
|
+
"experimentalDecorators": true,
|
|
7
|
+
"lib": ["ES2017"],
|
|
8
|
+
"moduleResolution": "nodenext",
|
|
9
|
+
"module": "nodenext",
|
|
10
|
+
"target": "ES2017",
|
|
11
|
+
"noUnusedLocals": true,
|
|
12
|
+
"noUnusedParameters": true,
|
|
13
|
+
"forceConsistentCasingInFileNames": true,
|
|
14
|
+
"importHelpers": true,
|
|
15
|
+
"removeComments": true,
|
|
16
|
+
"types": ["node"],
|
|
17
|
+
"typeRoots": ["node_modules/@types"],
|
|
18
|
+
"strict": true,
|
|
19
|
+
"skipLibCheck": true
|
|
20
|
+
},
|
|
21
|
+
"include": ["src"]
|
|
22
|
+
}
|