@element-hq/element-web-playwright-common 2.2.6 → 2.3.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/Dockerfile CHANGED
@@ -6,6 +6,13 @@ WORKDIR /work
6
6
  # fonts-dejavu is needed for the same RTL rendering as on CI
7
7
  RUN apt-get update && apt-get -y install docker.io fonts-dejavu
8
8
 
9
+ # Set up corepack
10
+ RUN corepack enable
11
+ ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0
12
+
13
+ # Add environment variable so consumers can skip developer-centric scripts
14
+ ENV PLAYWRIGHT_COMMON_DOCKER=1
15
+
9
16
  COPY docker-entrypoint.sh /docker-entrypoint.sh
10
17
 
11
18
  ENTRYPOINT ["/docker-entrypoint.sh"]
@@ -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.
@@ -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;AAEnD,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"}
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"}
@@ -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;AAI9C,eAAO,MAAM,IAAI;IACb;;OAEG;SACE,UAAU;wGAMjB,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"}
@@ -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;
@@ -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;IACpD,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAGD,eAAO,MAAM,WAAW,EAA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C,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
- page: async ({ homeserver, context, page, config, labsFlags, disablePresence }, use) => {
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
  });
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.2.6",
4
+ "version": "2.3.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.1",
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",
@@ -56,6 +56,7 @@ RUN_ARGS=(
56
56
  )
57
57
 
58
58
  DEFAULT_ARGS=(--grep @screenshot)
59
+ LINK_MODULES=true
59
60
 
60
61
  # Some arguments to customise behaviour so the same script / image can be
61
62
  # re-used for other screenshot generation.
@@ -72,6 +73,11 @@ while [[ $# -gt 0 ]]; do
72
73
  RUN_ARGS+=(--mount "${mount_param}" -e YARN_INSTALL=true)
73
74
  shift
74
75
  ;;
76
+ # Disables the automatic detection & linking of node_modules which can clash with developer tooling e.g. pnpm-link
77
+ --no-link-modules)
78
+ LINK_MODULES=false
79
+ shift
80
+ ;;
75
81
  # Sets a different entrypoint (in which case the default arguments to the script will be ignored)
76
82
  --entrypoint)
77
83
  shift
@@ -87,16 +93,17 @@ done
87
93
 
88
94
  build_image
89
95
 
90
- # Ensure we pass all symlinked node_modules to the container
91
- pushd node_modules > /dev/null
92
- SYMLINKS=$(find . -maxdepth 2 -type l -not -path "./.bin/*")
93
- popd > /dev/null
94
- for LINK in $SYMLINKS; do
95
- TARGET=$(readlink -f "node_modules/$LINK") || true
96
- if [ -d "$TARGET" ]; then
97
- if [ -n "$docker_is_podman" ]; then
98
- echo -e "\033[31m" >&2
99
- cat <<'EOF' >&2
96
+ if [[ $LINK_MODULES == true ]]; then
97
+ # Ensure we pass all symlinked node_modules to the container
98
+ pushd node_modules > /dev/null
99
+ SYMLINKS=$(find . -maxdepth 2 -type l -not -path "./.bin/*")
100
+ popd > /dev/null
101
+ for LINK in $SYMLINKS; do
102
+ TARGET=$(readlink -f "node_modules/$LINK") || true
103
+ if [ -d "$TARGET" ]; then
104
+ if [ -n "$docker_is_podman" ]; then
105
+ echo -e "\033[31m" >&2
106
+ cat <<'EOF' >&2
100
107
  WARNING: `node_modules` contains symlinks, and the support for this in
101
108
  `playwright-screenshots.sh` is broken under podman due to
102
109
  https://github.com/containers/podman/issues/25947.
@@ -104,12 +111,13 @@ https://github.com/containers/podman/issues/25947.
104
111
  If you get errors such as 'Error: crun: creating `<path>`', then retry this
105
112
  having `yarn unlink`ed the relevant node modules.
106
113
  EOF
107
- echo -e "\033[0m" >&2
114
+ echo -e "\033[0m" >&2
115
+ fi
116
+ echo "mounting linked package ${LINK:2} in container"
117
+ RUN_ARGS+=( "-v" "$TARGET:/work/node_modules/${LINK:2}" )
108
118
  fi
109
- echo "mounting linked package ${LINK:2} in container"
110
- RUN_ARGS+=( "-v" "$TARGET:/work/node_modules/${LINK:2}" )
111
- fi
112
- done
119
+ done
120
+ fi
113
121
 
114
122
  # Our Playwright fixtures use Testcontainers [1], which uses a docker image
115
123
  # called Ryuk [2], which will clean up any dangling containers/networks/etc
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
  /**
@@ -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
- page: async ({ homeserver, context, page, config, labsFlags, disablePresence }, use) => {
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
  });