diff --git a/.gitignore b/.gitignore index 90cb386124..62bcb59a0a 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ yarn-error.log /hak/**/*.js /scripts/hak/**/*.js .DS_Store +/playwright-report diff --git a/package.json b/package.json index c1515aed3a..45cb7294ea 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "test": "playwright test", "test:open": "yarn test --ui", "test:screenshots:build": "docker build playwright -t element-desktop-playwright --platform linux/amd64", - "test:screenshots:run": "docker run --rm --network host -v $(pwd):/work/element-desktop -v /var/run/docker.sock:/var/run/docker.sock --platform linux/amd64 -it element-desktop-playwright", + "test:screenshots:run": "docker run --rm --network host -v $(pwd):/work/element-desktop -v element-desktop-playwright:/work/element-desktop/node_modules -v /var/run/docker.sock:/var/run/docker.sock --platform linux/amd64 -it element-desktop-playwright", "postinstall": "patch-package && electron-builder install-app-deps" }, "dependencies": { diff --git a/playwright/Dockerfile b/playwright/Dockerfile index a7a5b51160..b69a4a876a 100644 --- a/playwright/Dockerfile +++ b/playwright/Dockerfile @@ -2,7 +2,10 @@ FROM mcr.microsoft.com/playwright:v1.57.0-jammy@sha256:6aca677c27a967caf7673d108 WORKDIR /work/element-desktop -RUN apt-get update && apt-get -y install xvfb && apt-get purge -y --auto-remove && rm -rf /var/lib/apt/lists/* +RUN apt-get update && apt-get -y install xvfb dbus-x11 && apt-get purge -y --auto-remove && rm -rf /var/lib/apt/lists/* + +# Create node_modules & dist dirs so that the volumes have the correct permissions +RUN mkdir node_modules dist && chown 1000:1000 node_modules dist USER 1000:1000 diff --git a/playwright/docker-entrypoint.sh b/playwright/docker-entrypoint.sh index ad39259525..66f98a5be5 100644 --- a/playwright/docker-entrypoint.sh +++ b/playwright/docker-entrypoint.sh @@ -8,4 +8,11 @@ sleep 2 export DISPLAY=:99 -npx playwright test --update-snapshots --reporter line $1 +yarn install --frozen-lockfile +yarn build -l --dir + +PLAYWRIGHT_HTML_OPEN=never ELEMENT_DESKTOP_EXECUTABLE="./dist/linux-unpacked/element-desktop" \ + npx playwright test --update-snapshots --reporter line,html "$1" + +# Clean up +rm -R core qemu_* || exit 0 diff --git a/playwright/element-desktop-test.ts b/playwright/element-desktop-test.ts index 1f53ab645e..743be8da6f 100644 --- a/playwright/element-desktop-test.ts +++ b/playwright/element-desktop-test.ts @@ -84,7 +84,7 @@ export const test = base.extend({ args.unshift(path.join(__dirname, "..", "lib", "electron-main.js")); } - console.log(`Launching '${executablePath}' with args ${args.join(" ")}`); + console.log(`Launching '${executablePath || "electron"}' with args ${args.join(" ")}`); const app = await electron.launch({ env: { diff --git a/playwright/snapshots/launch/launch.spec.ts/App-launch-should-launch-and-render-the-welcome-view-successfully-1-linux.png b/playwright/snapshots/launch/launch.spec.ts/App-launch-should-launch-and-render-the-welcome-view-successfully-1-linux.png index 2841e86288..f0612be6e2 100644 Binary files a/playwright/snapshots/launch/launch.spec.ts/App-launch-should-launch-and-render-the-welcome-view-successfully-1-linux.png and b/playwright/snapshots/launch/launch.spec.ts/App-launch-should-launch-and-render-the-welcome-view-successfully-1-linux.png differ