From 44075dacd2d4fad61a33fbd2a72f29590d3e88d9 Mon Sep 17 00:00:00 2001 From: Andrew Ferrazzutti Date: Mon, 14 Apr 2025 08:32:56 -0400 Subject: [PATCH 1/7] Build Docker image on slim base --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c919d0c94..bf34c6c3c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ COPY ./dist /dist WORKDIR /dist/assets RUN gzip -k ../index.html *.js *.map *.css *.wasm *-app-*.json -FROM nginxinc/nginx-unprivileged:alpine +FROM nginxinc/nginx-unprivileged:alpine-slim COPY --from=builder ./dist /app From 770af22e9905e409cc3f03e0e67f798ba20d1df3 Mon Sep 17 00:00:00 2001 From: Andrew Ferrazzutti Date: Tue, 22 Apr 2025 11:20:03 -0400 Subject: [PATCH 2/7] Add missing EW volume label for playwright compose --- playwright-backend-docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playwright-backend-docker-compose.yml b/playwright-backend-docker-compose.yml index e5cf12b50..9b86f824e 100644 --- a/playwright-backend-docker-compose.yml +++ b/playwright-backend-docker-compose.yml @@ -54,7 +54,7 @@ services: element-web: image: ghcr.io/element-hq/element-web:develop volumes: - - ./backend/ew.test.config.json:/app/config.json + - ./backend/ew.test.config.json:/app/config.json:Z environment: ELEMENT_WEB_PORT: 81 ports: From 073baca418e501ca5e106c1ea81761f2c64f6d2d Mon Sep 17 00:00:00 2001 From: Andrew Ferrazzutti Date: Tue, 22 Apr 2025 15:11:26 -0400 Subject: [PATCH 3/7] Run Playwright tests against Docker container For Playwright end-to-end tests in CI, instead of running a development webserver with `yarn dev`, build and deploy a Docker container for Element Call and use that as the webserver to test against. --- .github/workflows/test.yaml | 4 ++-- playwright.config.ts | 10 +++++--- playwright/fixtures/widget-user.ts | 31 +++++++++++++++++-------- scripts/playwright-webserver-command.sh | 11 +++++++++ 4 files changed, 41 insertions(+), 15 deletions(-) create mode 100755 scripts/playwright-webserver-command.sh diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 85215e689..e564572c1 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -48,9 +48,9 @@ jobs: run: | docker compose -f playwright-backend-docker-compose.yml up -d docker ps - - name: Copy config file - run: cp config/config.devenv.json public/config.json - name: Run Playwright tests + env: + USE_DOCKER: 1 run: yarn playwright test - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 if: ${{ !cancelled() }} diff --git a/playwright.config.ts b/playwright.config.ts index cdb8ec237..f76513145 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -7,6 +7,10 @@ Please see LICENSE in the repository root for full details. import { defineConfig, devices } from "@playwright/test"; +const baseURL = process.env.USE_DOCKER + ? "http://localhost:8080" + : "https://localhost:3000"; + /** * See https://playwright.dev/docs/test-configuration. */ @@ -25,7 +29,7 @@ export default defineConfig({ /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ use: { /* Base URL to use in actions like `await page.goto('/')`. */ - baseURL: "https://localhost:3000", + baseURL, /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ trace: "on-first-retry", @@ -73,8 +77,8 @@ export default defineConfig({ /* Run your local dev server before starting the tests */ webServer: { - command: "yarn dev", - url: "https://localhost:3000", + command: "./scripts/playwright-webserver-command.sh", + url: baseURL, reuseExistingServer: !process.env.CI, ignoreHTTPSErrors: true, }, diff --git a/playwright/fixtures/widget-user.ts b/playwright/fixtures/widget-user.ts index 0a422d201..3a3013154 100644 --- a/playwright/fixtures/widget-user.ts +++ b/playwright/fixtures/widget-user.ts @@ -63,16 +63,27 @@ const CONFIG_JSON = { * Set the Element Call URL in the dev tool settings using `window.mxSettingsStore` via `page.evaluate`. * @param page */ -async function setDevToolElementCallDevUrl(page: Page): Promise { - await page.evaluate(() => { - window.mxSettingsStore.setValue( - "Developer.elementCallUrl", - null, - "device", - "https://localhost:3000/room", - ); - }); -} +const setDevToolElementCallDevUrl = process.env.USE_DOCKER + ? async (page: Page): Promise => { + await page.evaluate(() => { + window.mxSettingsStore.setValue( + "Developer.elementCallUrl", + null, + "device", + "https://localhost:3000/room", + ); + }); + } + : async (page: Page): Promise => { + await page.evaluate(() => { + window.mxSettingsStore.setValue( + "Developer.elementCallUrl", + null, + "device", + "https://localhost:3000/room", + ); + }); + }; export const widgetTest = test.extend({ asWidget: async ({ browser, context }, pUse) => { diff --git a/scripts/playwright-webserver-command.sh b/scripts/playwright-webserver-command.sh new file mode 100755 index 000000000..c96d5bec8 --- /dev/null +++ b/scripts/playwright-webserver-command.sh @@ -0,0 +1,11 @@ +#!/bin/sh +if [ -n "$USE_DOCKER" ]; then + ./scripts/dockerbuild.sh + set -ex + yarn build + docker build -t element-call:testing . + exec docker run --rm --name element-call-testing -p 8080:8080 -v ./config/config.devenv.json:/app/config/json:ro,Z element-call:testing +else + cp config/config.devenv.json public/config.json + exec yarn dev +fi From 4cc817531be739a3a62f8cec0a961d6b68e93d8b Mon Sep 17 00:00:00 2001 From: Andrew Ferrazzutti Date: Tue, 22 Apr 2025 15:33:26 -0400 Subject: [PATCH 4/7] Try to fix CI --- scripts/playwright-webserver-command.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/playwright-webserver-command.sh b/scripts/playwright-webserver-command.sh index c96d5bec8..24eb9913d 100755 --- a/scripts/playwright-webserver-command.sh +++ b/scripts/playwright-webserver-command.sh @@ -1,10 +1,9 @@ #!/bin/sh if [ -n "$USE_DOCKER" ]; then - ./scripts/dockerbuild.sh set -ex yarn build docker build -t element-call:testing . - exec docker run --rm --name element-call-testing -p 8080:8080 -v ./config/config.devenv.json:/app/config/json:ro,Z element-call:testing + docker run --rm --name element-call-testing -p 8080:8080 -v ./config/config.devenv.json:/app/config/json:ro,Z element-call:testing else cp config/config.devenv.json public/config.json exec yarn dev From 0cdd2cb13e5fc4997bd4c534f247302456f4797d Mon Sep 17 00:00:00 2001 From: fkwp Date: Tue, 27 May 2025 19:26:32 +0200 Subject: [PATCH 5/7] fix USE_DOCKER port --- playwright/fixtures/widget-user.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playwright/fixtures/widget-user.ts b/playwright/fixtures/widget-user.ts index 5d033bd2d..f0bc033af 100644 --- a/playwright/fixtures/widget-user.ts +++ b/playwright/fixtures/widget-user.ts @@ -70,7 +70,7 @@ const setDevToolElementCallDevUrl = process.env.USE_DOCKER "Developer.elementCallUrl", null, "device", - "https://localhost:3000/room", + "https://localhost:8080/room", ); }); } From ac8f4d8de4a692cdd6244cecf11a2b0272bf1c63 Mon Sep 17 00:00:00 2001 From: fkwp Date: Tue, 27 May 2025 19:44:52 +0200 Subject: [PATCH 6/7] fix element web fixture protocol --- playwright/fixtures/widget-user.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playwright/fixtures/widget-user.ts b/playwright/fixtures/widget-user.ts index f0bc033af..0bf19b5fb 100644 --- a/playwright/fixtures/widget-user.ts +++ b/playwright/fixtures/widget-user.ts @@ -70,7 +70,7 @@ const setDevToolElementCallDevUrl = process.env.USE_DOCKER "Developer.elementCallUrl", null, "device", - "https://localhost:8080/room", + "http://localhost:8080/room", ); }); } From 78ba04632d09a3d578ffb620f4e102a8482f1daa Mon Sep 17 00:00:00 2001 From: fkwp Date: Fri, 30 May 2025 16:09:36 +0200 Subject: [PATCH 7/7] wip --- scripts/playwright-webserver-command.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/playwright-webserver-command.sh b/scripts/playwright-webserver-command.sh index 24eb9913d..34c1f21c4 100755 --- a/scripts/playwright-webserver-command.sh +++ b/scripts/playwright-webserver-command.sh @@ -3,7 +3,7 @@ if [ -n "$USE_DOCKER" ]; then set -ex yarn build docker build -t element-call:testing . - docker run --rm --name element-call-testing -p 8080:8080 -v ./config/config.devenv.json:/app/config/json:ro,Z element-call:testing + exec docker run --rm --name element-call-testing -p 8080:8080 -v ./config/config.devenv.json:/app/config/json:ro,Z element-call:testing else cp config/config.devenv.json public/config.json exec yarn dev