diff --git a/playwright.config.ts b/playwright.config.ts index fbc33869da..1d35402299 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -46,4 +46,6 @@ export default defineConfig({ use: { crypto: "rust" }, }, ], + snapshotDir: "playwright/snapshots", + snapshotPathTemplate: "{snapshotDir}/{testFilePath}/{arg}-{platform}{ext}", }); diff --git a/playwright/.gitignore b/playwright/.gitignore index 3ffefa9111..2719122491 100644 --- a/playwright/.gitignore +++ b/playwright/.gitignore @@ -2,5 +2,5 @@ /html-report/ /synapselogs/ # Only commit snapshots from Linux -/e2e/*/*-snapshots/*.png -!/e2e/*/*-snapshots/*-linux.png +/snapshots/*/*.png +!/snapshots/*/*-linux.png diff --git a/playwright/Dockerfile b/playwright/Dockerfile new file mode 100644 index 0000000000..ea4063b285 --- /dev/null +++ b/playwright/Dockerfile @@ -0,0 +1,9 @@ +FROM mcr.microsoft.com/playwright:v1.40.0-jammy + +WORKDIR /work/matrix-react-sdk +VOLUME ["/work/element-web/node_modules"] + +RUN apt-get update && apt-get -y install docker.io + +COPY docker-entrypoint.sh /opt/docker-entrypoint.sh +ENTRYPOINT ["bash", "/opt/docker-entrypoint.sh"] diff --git a/playwright/README.md b/playwright/README.md index 0003828c88..ee110a1135 100644 --- a/playwright/README.md +++ b/playwright/README.md @@ -2,14 +2,12 @@ To update snapshots you will need to run Playwright on a Linux machine. If you have access to docker then you can use the following: ```shell +docker build playwright -t matrix-react-sdk-playwright docker run \ --rm \ --network host \ -v $(pwd)/../:/work/ \ - -v playwright-ew-node-modules:/work/element-web/node_modules \ -v /var/run/docker.sock:/var/run/docker.sock \ -v /tmp/:/tmp/ \ - -w /work/matrix-react-sdk \ - -it mcr.microsoft.com/playwright:v1.40.0-jammy \ - sh -c "apt-get update && apt-get -y install docker.io && yarn --cwd ../element-web install && npx playwright test --update-snapshots --reporter line" + -it matrix-react-sdk-playwright ``` diff --git a/playwright/docker-entrypoint.sh b/playwright/docker-entrypoint.sh new file mode 100644 index 0000000000..55554a683a --- /dev/null +++ b/playwright/docker-entrypoint.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +set -e + +yarn --cwd ../element-web install +npx playwright test --update-snapshots --reporter line --project='Legacy Crypto' $1 diff --git a/playwright/e2e/register/email.spec.ts-snapshots/registration-check-your-email-Rust-Crypto-linux.png b/playwright/e2e/register/email.spec.ts-snapshots/registration-check-your-email-Rust-Crypto-linux.png deleted file mode 100644 index 2c63adacd1..0000000000 Binary files a/playwright/e2e/register/email.spec.ts-snapshots/registration-check-your-email-Rust-Crypto-linux.png and /dev/null differ diff --git a/playwright/e2e/user-onboarding/user-onboarding-new.spec.ts b/playwright/e2e/user-onboarding/user-onboarding-new.spec.ts index 106706e965..3c4db3f0cd 100644 --- a/playwright/e2e/user-onboarding/user-onboarding-new.spec.ts +++ b/playwright/e2e/user-onboarding/user-onboarding-new.spec.ts @@ -45,7 +45,7 @@ test.describe("User Onboarding (new user)", () => { await expect( page.getByRole("dialog").getByRole("heading", { level: 2, name: "Download Element" }), ).toBeVisible(); - await expect(page.getByRole("dialog")).toHaveScreenshot(); + await expect(page.locator(".mx_Dialog")).toHaveScreenshot(); }); test("using find friends action should increase progress", async ({ page, homeserver }) => { diff --git a/playwright/e2e/user-onboarding/user-onboarding-new.spec.ts-snapshots/User-Onboarding-new-user-app-download-dialog-1-Legacy-Crypto-linux.png b/playwright/e2e/user-onboarding/user-onboarding-new.spec.ts-snapshots/User-Onboarding-new-user-app-download-dialog-1-Legacy-Crypto-linux.png deleted file mode 100644 index 932bfc6c3a..0000000000 Binary files a/playwright/e2e/user-onboarding/user-onboarding-new.spec.ts-snapshots/User-Onboarding-new-user-app-download-dialog-1-Legacy-Crypto-linux.png and /dev/null differ diff --git a/playwright/e2e/user-onboarding/user-onboarding-new.spec.ts-snapshots/User-Onboarding-new-user-app-download-dialog-1-Rust-Crypto-linux.png b/playwright/e2e/user-onboarding/user-onboarding-new.spec.ts-snapshots/User-Onboarding-new-user-app-download-dialog-1-Rust-Crypto-linux.png deleted file mode 100644 index 932bfc6c3a..0000000000 Binary files a/playwright/e2e/user-onboarding/user-onboarding-new.spec.ts-snapshots/User-Onboarding-new-user-app-download-dialog-1-Rust-Crypto-linux.png and /dev/null differ diff --git a/playwright/e2e/user-onboarding/user-onboarding-new.spec.ts-snapshots/User-Onboarding-new-user-page-is-shown-and-preference-exists-1-Rust-Crypto-linux.png b/playwright/e2e/user-onboarding/user-onboarding-new.spec.ts-snapshots/User-Onboarding-new-user-page-is-shown-and-preference-exists-1-Rust-Crypto-linux.png deleted file mode 100644 index 29f7adc4dd..0000000000 Binary files a/playwright/e2e/user-onboarding/user-onboarding-new.spec.ts-snapshots/User-Onboarding-new-user-page-is-shown-and-preference-exists-1-Rust-Crypto-linux.png and /dev/null differ diff --git a/playwright/e2e/register/email.spec.ts-snapshots/registration-check-your-email-Legacy-Crypto-linux.png b/playwright/snapshots/register/email.spec.ts/registration-check-your-email-linux.png similarity index 100% rename from playwright/e2e/register/email.spec.ts-snapshots/registration-check-your-email-Legacy-Crypto-linux.png rename to playwright/snapshots/register/email.spec.ts/registration-check-your-email-linux.png diff --git a/playwright/snapshots/user-onboarding/user-onboarding-new.spec.ts/User-Onboarding-new-user-app-download-dialog-1-linux.png b/playwright/snapshots/user-onboarding/user-onboarding-new.spec.ts/User-Onboarding-new-user-app-download-dialog-1-linux.png new file mode 100644 index 0000000000..1f64d5efda Binary files /dev/null and b/playwright/snapshots/user-onboarding/user-onboarding-new.spec.ts/User-Onboarding-new-user-app-download-dialog-1-linux.png differ diff --git a/playwright/e2e/user-onboarding/user-onboarding-new.spec.ts-snapshots/User-Onboarding-new-user-page-is-shown-and-preference-exists-1-Legacy-Crypto-linux.png b/playwright/snapshots/user-onboarding/user-onboarding-new.spec.ts/User-Onboarding-new-user-page-is-shown-and-preference-exists-1-linux.png similarity index 100% rename from playwright/e2e/user-onboarding/user-onboarding-new.spec.ts-snapshots/User-Onboarding-new-user-page-is-shown-and-preference-exists-1-Legacy-Crypto-linux.png rename to playwright/snapshots/user-onboarding/user-onboarding-new.spec.ts/User-Onboarding-new-user-page-is-shown-and-preference-exists-1-linux.png