@element-hq/element-web-playwright-common 2.2.7 → 2.4.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/lib/expect/axe.d.ts +1 -1
- package/lib/expect/axe.d.ts.map +1 -1
- package/lib/fixtures/axe.d.ts +1 -1
- package/lib/fixtures/axe.d.ts.map +1 -1
- package/lib/fixtures/axe.js +1 -1
- package/lib/index.d.ts +10 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +11 -1
- package/lib/stale-screenshot-reporter.d.ts +1 -1
- package/lib/stale-screenshot-reporter.d.ts.map +1 -1
- package/lib/stale-screenshot-reporter.js +7 -4
- package/package.json +2 -2
- package/src/expect/axe.ts +1 -1
- package/src/fixtures/axe.ts +1 -1
- package/src/index.ts +21 -1
- package/src/stale-screenshot-reporter.ts +9 -3
package/lib/expect/axe.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ExpectMatcherState, type MatcherReturnType } from "@playwright/test";
|
|
2
|
-
import type AxeBuilder from "@axe-core/playwright";
|
|
2
|
+
import type { AxeBuilder } from "@axe-core/playwright";
|
|
3
3
|
export type Expectations = {
|
|
4
4
|
/**
|
|
5
5
|
* Assert that the given AxeBuilder instance has no violations.
|
package/lib/expect/axe.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"axe.d.ts","sourceRoot":"","sources":["../../src/expect/axe.ts"],"names":[],"mappings":"AAQA,OAAO,EAA8B,KAAK,kBAAkB,EAAE,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE/G,OAAO,KAAK,UAAU,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"axe.d.ts","sourceRoot":"","sources":["../../src/expect/axe.ts"],"names":[],"mappings":"AAQA,OAAO,EAA8B,KAAK,kBAAkB,EAAE,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE/G,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,MAAM,YAAY,GAAG;IACvB;;;OAGG;IACH,kBAAkB,EAAE,CAAC,IAAI,EAAE,kBAAkB,EAAE,QAAQ,EAAE,UAAU,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACtG,CAAC;AAEF,eAAO,MAAM,MAAM,iDAgBjB,CAAC"}
|
package/lib/fixtures/axe.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import AxeBuilder from "@axe-core/playwright";
|
|
1
|
+
import { AxeBuilder } from "@axe-core/playwright";
|
|
2
2
|
export declare const test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & {
|
|
3
3
|
/**
|
|
4
4
|
* AxeBuilder instance for the current page
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"axe.d.ts","sourceRoot":"","sources":["../../src/fixtures/axe.ts"],"names":[],"mappings":"AASA,OAAO,UAAU,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"axe.d.ts","sourceRoot":"","sources":["../../src/fixtures/axe.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAIlD,eAAO,MAAM,IAAI;IACb;;OAEG;SACE,UAAU;wGAMjB,CAAC"}
|
package/lib/fixtures/axe.js
CHANGED
|
@@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|
|
6
6
|
Please see LICENSE files in the repository root for full details.
|
|
7
7
|
*/
|
|
8
8
|
import { test as base } from "@playwright/test";
|
|
9
|
-
import AxeBuilder from "@axe-core/playwright";
|
|
9
|
+
import { AxeBuilder } from "@axe-core/playwright";
|
|
10
10
|
// This fixture is useful for simple component library tests that won't want any extra services like a homeserver, so we
|
|
11
11
|
// explicitly avoid pulling anything more than playwright's base fixtures in.
|
|
12
12
|
export const test = base.extend({
|
package/lib/index.d.ts
CHANGED
|
@@ -27,6 +27,16 @@ export interface TestFixtures {
|
|
|
27
27
|
config: Partial<typeof CONFIG_JSON>;
|
|
28
28
|
labsFlags: string[];
|
|
29
29
|
disablePresence: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Whether the left panel should have its width fixed.
|
|
32
|
+
* This is done because the library that we use for rendering collapsible
|
|
33
|
+
* panels uses math to calculate the width which can sometimes leads to +/-1px
|
|
34
|
+
* difference. While this does not matter to the user, it can lead to screenshot
|
|
35
|
+
* tests failing.
|
|
36
|
+
* Defaults to true, should be set to false via {@link base.use} when you want to test the collapse
|
|
37
|
+
* behaviour.
|
|
38
|
+
*/
|
|
39
|
+
lockLeftPanelWidth: boolean;
|
|
30
40
|
}
|
|
31
41
|
export declare const test: import("playwright/test").TestType<import("playwright/test").PlaywrightTestArgs & import("playwright/test").PlaywrightTestOptions & {
|
|
32
42
|
axe: import("@axe-core/playwright").AxeBuilder;
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,MAAM,IAAI,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAK/E,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AAEnC,OAAO,EAAE,mCAAmC,EAAE,MAAM,oBAAoB,CAAC;AAQzE,MAAM,WAAW,MAAO,SAAQ,UAAU;IACtC,qBAAqB,EAAE;QACnB,cAAc,CAAC,EAAE;YACb,QAAQ,EAAE,MAAM,CAAC;YACjB,WAAW,CAAC,EAAE,MAAM,CAAC;SACxB,CAAC;QACF,mBAAmB,CAAC,EAAE;YAClB,QAAQ,EAAE,MAAM,CAAC;YACjB,WAAW,CAAC,EAAE,MAAM,CAAC;SACxB,CAAC;KACL,CAAC;IACF,yBAAyB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACp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,eAAO,MAAM,WAAW,EAAE,OAAO,CAAC,MAAM,CAevC,CAAC;AAEF,MAAM,WAAW,YAAY;IACzB;;OAEG;IACH,MAAM,EAAE,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC;IAEpC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,eAAe,EAAE,OAAO,CAAC;IACzB;;;;;;;;OAQG;IACH,kBAAkB,EAAE,OAAO,CAAC;CAC/B;AAED,eAAO,MAAM,IAAI;;;;;;;kNAmBf,CAAC;AAEH,OAAO,EAAE,MAAM,EAAE,KAAK,wBAAwB,EAAE,MAAM,mBAAmB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -32,8 +32,18 @@ export const test = base.extend({
|
|
|
32
32
|
config: async ({}, use) => use({}),
|
|
33
33
|
labsFlags: async ({}, use) => use([]),
|
|
34
34
|
disablePresence: async ({}, use) => use(false),
|
|
35
|
-
|
|
35
|
+
lockLeftPanelWidth: true,
|
|
36
|
+
page: async ({ homeserver, context, page, config, labsFlags, disablePresence, lockLeftPanelWidth }, use) => {
|
|
36
37
|
await routeConfigJson(context, homeserver.baseUrl, config, labsFlags, disablePresence);
|
|
38
|
+
if (lockLeftPanelWidth) {
|
|
39
|
+
await page.addStyleTag({
|
|
40
|
+
content: `
|
|
41
|
+
#left-panel {
|
|
42
|
+
flex: 0 0 369.6875px !important;
|
|
43
|
+
}
|
|
44
|
+
`,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
37
47
|
await use(page);
|
|
38
48
|
},
|
|
39
49
|
});
|
|
@@ -8,7 +8,7 @@ export declare const ANNOTATION = "_screenshot";
|
|
|
8
8
|
declare class StaleScreenshotReporter implements Reporter {
|
|
9
9
|
private readonly snapshotRoots;
|
|
10
10
|
private readonly screenshots;
|
|
11
|
-
private failing;
|
|
11
|
+
private readonly failing;
|
|
12
12
|
private success;
|
|
13
13
|
onBegin(config: FullConfig): void;
|
|
14
14
|
onTestEnd(test: TestCase): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stale-screenshot-reporter.d.ts","sourceRoot":"","sources":["../src/stale-screenshot-reporter.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;;GAGG;AACH,eAAO,MAAM,UAAU,gBAAgB,CAAC;AAExC,cAAM,uBAAwB,YAAW,QAAQ;IAC7C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAqB;IACnD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAqB;IACjD,OAAO,CAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"stale-screenshot-reporter.d.ts","sourceRoot":"","sources":["../src/stale-screenshot-reporter.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;;GAGG;AACH,eAAO,MAAM,UAAU,gBAAgB,CAAC;AAExC,cAAM,uBAAwB,YAAW,QAAQ;IAC7C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAqB;IACnD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAqB;IACjD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;IAC7C,OAAO,CAAC,OAAO,CAAQ;IAEhB,OAAO,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAMjC,SAAS,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI;IActC,OAAO,CAAC,KAAK;IAQA,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAuCvC;AAED,eAAe,uBAAuB,CAAC"}
|
|
@@ -19,7 +19,7 @@ export const ANNOTATION = "_screenshot";
|
|
|
19
19
|
class StaleScreenshotReporter {
|
|
20
20
|
snapshotRoots = new Set();
|
|
21
21
|
screenshots = new Set();
|
|
22
|
-
failing =
|
|
22
|
+
failing = new Set();
|
|
23
23
|
success = true;
|
|
24
24
|
onBegin(config) {
|
|
25
25
|
for (const project of config.projects) {
|
|
@@ -28,8 +28,10 @@ class StaleScreenshotReporter {
|
|
|
28
28
|
}
|
|
29
29
|
onTestEnd(test) {
|
|
30
30
|
if (!test.ok()) {
|
|
31
|
-
this.failing
|
|
31
|
+
this.failing.add(test.id);
|
|
32
|
+
return;
|
|
32
33
|
}
|
|
34
|
+
this.failing.delete(test.id); // delete if passed on re-run
|
|
33
35
|
for (const annotation of test.annotations) {
|
|
34
36
|
if (annotation.type === ANNOTATION && annotation.description) {
|
|
35
37
|
this.screenshots.add(annotation.description);
|
|
@@ -44,8 +46,9 @@ class StaleScreenshotReporter {
|
|
|
44
46
|
this.success = false;
|
|
45
47
|
}
|
|
46
48
|
async onExit() {
|
|
47
|
-
if (this.failing)
|
|
48
|
-
|
|
49
|
+
if (this.failing.size) {
|
|
50
|
+
console.error(`${this.failing.size} tests failed, skipping stale screenshot reporter.`);
|
|
51
|
+
}
|
|
49
52
|
if (!this.snapshotRoots.size) {
|
|
50
53
|
this.error("No snapshot directories found, did you set the snapshotDir in your Playwright config?", "");
|
|
51
54
|
return;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@element-hq/element-web-playwright-common",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.4.0",
|
|
5
5
|
"license": "SEE LICENSE IN README.md",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@axe-core/playwright": "^4.10.1",
|
|
33
33
|
"@testcontainers/postgresql": "^11.0.0",
|
|
34
|
-
"glob": "^13.0.
|
|
34
|
+
"glob": "^13.0.5",
|
|
35
35
|
"lodash-es": "^4.17.23",
|
|
36
36
|
"mailpit-api": "^1.2.0",
|
|
37
37
|
"strip-ansi": "^7.1.0",
|
package/src/expect/axe.ts
CHANGED
|
@@ -8,7 +8,7 @@ Please see LICENSE files in the repository root for full details.
|
|
|
8
8
|
|
|
9
9
|
import { test, expect as baseExpect, type ExpectMatcherState, type MatcherReturnType } from "@playwright/test";
|
|
10
10
|
|
|
11
|
-
import type AxeBuilder from "@axe-core/playwright";
|
|
11
|
+
import type { AxeBuilder } from "@axe-core/playwright";
|
|
12
12
|
|
|
13
13
|
export type Expectations = {
|
|
14
14
|
/**
|
package/src/fixtures/axe.ts
CHANGED
|
@@ -7,7 +7,7 @@ Please see LICENSE files in the repository root for full details.
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { test as base } from "@playwright/test";
|
|
10
|
-
import AxeBuilder from "@axe-core/playwright";
|
|
10
|
+
import { AxeBuilder } from "@axe-core/playwright";
|
|
11
11
|
|
|
12
12
|
// This fixture is useful for simple component library tests that won't want any extra services like a homeserver, so we
|
|
13
13
|
// explicitly avoid pulling anything more than playwright's base fixtures in.
|
package/src/index.ts
CHANGED
|
@@ -66,6 +66,16 @@ export interface TestFixtures {
|
|
|
66
66
|
|
|
67
67
|
labsFlags: string[];
|
|
68
68
|
disablePresence: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Whether the left panel should have its width fixed.
|
|
71
|
+
* This is done because the library that we use for rendering collapsible
|
|
72
|
+
* panels uses math to calculate the width which can sometimes leads to +/-1px
|
|
73
|
+
* difference. While this does not matter to the user, it can lead to screenshot
|
|
74
|
+
* tests failing.
|
|
75
|
+
* Defaults to true, should be set to false via {@link base.use} when you want to test the collapse
|
|
76
|
+
* behaviour.
|
|
77
|
+
*/
|
|
78
|
+
lockLeftPanelWidth: boolean;
|
|
69
79
|
}
|
|
70
80
|
|
|
71
81
|
export const test = base.extend<TestFixtures>({
|
|
@@ -73,8 +83,18 @@ export const test = base.extend<TestFixtures>({
|
|
|
73
83
|
config: async ({}, use) => use({}),
|
|
74
84
|
labsFlags: async ({}, use) => use([]),
|
|
75
85
|
disablePresence: async ({}, use) => use(false),
|
|
76
|
-
|
|
86
|
+
lockLeftPanelWidth: true,
|
|
87
|
+
page: async ({ homeserver, context, page, config, labsFlags, disablePresence, lockLeftPanelWidth }, use) => {
|
|
77
88
|
await routeConfigJson(context, homeserver.baseUrl, config, labsFlags, disablePresence);
|
|
89
|
+
if (lockLeftPanelWidth) {
|
|
90
|
+
await page.addStyleTag({
|
|
91
|
+
content: `
|
|
92
|
+
#left-panel {
|
|
93
|
+
flex: 0 0 369.6875px !important;
|
|
94
|
+
}
|
|
95
|
+
`,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
78
98
|
await use(page);
|
|
79
99
|
},
|
|
80
100
|
});
|
|
@@ -25,7 +25,7 @@ export const ANNOTATION = "_screenshot";
|
|
|
25
25
|
class StaleScreenshotReporter implements Reporter {
|
|
26
26
|
private readonly snapshotRoots = new Set<string>();
|
|
27
27
|
private readonly screenshots = new Set<string>();
|
|
28
|
-
private failing =
|
|
28
|
+
private readonly failing = new Set<string>();
|
|
29
29
|
private success = true;
|
|
30
30
|
|
|
31
31
|
public onBegin(config: FullConfig): void {
|
|
@@ -36,8 +36,11 @@ class StaleScreenshotReporter implements Reporter {
|
|
|
36
36
|
|
|
37
37
|
public onTestEnd(test: TestCase): void {
|
|
38
38
|
if (!test.ok()) {
|
|
39
|
-
this.failing
|
|
39
|
+
this.failing.add(test.id);
|
|
40
|
+
return;
|
|
40
41
|
}
|
|
42
|
+
this.failing.delete(test.id); // delete if passed on re-run
|
|
43
|
+
|
|
41
44
|
for (const annotation of test.annotations) {
|
|
42
45
|
if (annotation.type === ANNOTATION && annotation.description) {
|
|
43
46
|
this.screenshots.add(annotation.description);
|
|
@@ -54,7 +57,10 @@ class StaleScreenshotReporter implements Reporter {
|
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
public async onExit(): Promise<void> {
|
|
57
|
-
if (this.failing)
|
|
60
|
+
if (this.failing.size) {
|
|
61
|
+
console.error(`${this.failing.size} tests failed, skipping stale screenshot reporter.`);
|
|
62
|
+
}
|
|
63
|
+
|
|
58
64
|
if (!this.snapshotRoots.size) {
|
|
59
65
|
this.error("No snapshot directories found, did you set the snapshotDir in your Playwright config?", "");
|
|
60
66
|
return;
|