From a7be0bfa966a2cfc41292f928314969f6fd65352 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Kj=C3=A6r?= Date: Wed, 10 Jan 2024 05:39:18 +0100 Subject: [PATCH] Run e2e tests on Vercel deployments --- .github/workflows/vercel-deploy.yml | 10 ++++++++++ .../{ui-app.spec.ts => ui-app/i18n.spec.ts} | 2 +- .../i18n.spec.ts} | 2 +- justfile | 16 ++++++++-------- 4 files changed, 20 insertions(+), 10 deletions(-) rename deployment/end2end/tests/{ui-app.spec.ts => ui-app/i18n.spec.ts} (86%) rename deployment/end2end/tests/{ui-internal.spec.ts => ui-internal/i18n.spec.ts} (84%) diff --git a/.github/workflows/vercel-deploy.yml b/.github/workflows/vercel-deploy.yml index 2f08b5f..901d682 100644 --- a/.github/workflows/vercel-deploy.yml +++ b/.github/workflows/vercel-deploy.yml @@ -58,5 +58,15 @@ jobs: run: | echo "Preview URLs:" >> $GITHUB_STEP_SUMMARY url="$(bunx vercel deploy --prod --scope=${{ secrets.VERCEL_ORG_ID }} --token=${{ secrets.VERCEL_TOKEN }})" + echo "url=$url" >> $GITHUB_OUTPUT echo "- Direct URL: $url" >> $GITHUB_STEP_SUMMARY echo $GITHUB_STEP_SUMMARY + + - name: Install dependencies and setup Playwright + run: just setup deployment + + - name: End-to-end tests + working-directory: ./deployment + env: + UI_INTERNAL_E2E_URL: ${{ steps.deployment.outputs.url }} + run: just e2e deployment ui-internal diff --git a/deployment/end2end/tests/ui-app.spec.ts b/deployment/end2end/tests/ui-app/i18n.spec.ts similarity index 86% rename from deployment/end2end/tests/ui-app.spec.ts rename to deployment/end2end/tests/ui-app/i18n.spec.ts index 27a4eee..9c29c6c 100644 --- a/deployment/end2end/tests/ui-app.spec.ts +++ b/deployment/end2end/tests/ui-app/i18n.spec.ts @@ -1,6 +1,6 @@ import { expect, test } from '@playwright/test'; -const SERVER = `https://${process.env.DOMAIN}`; +const SERVER = process.env.UI_APP_E2E_URL ?? `https://${process.env.DOMAIN}`; test('localization translates text when changing language', async ({ page }) => { await page.goto(`${SERVER}/`); diff --git a/deployment/end2end/tests/ui-internal.spec.ts b/deployment/end2end/tests/ui-internal/i18n.spec.ts similarity index 84% rename from deployment/end2end/tests/ui-internal.spec.ts rename to deployment/end2end/tests/ui-internal/i18n.spec.ts index c1108ed..7436b62 100644 --- a/deployment/end2end/tests/ui-internal.spec.ts +++ b/deployment/end2end/tests/ui-internal/i18n.spec.ts @@ -1,6 +1,6 @@ import { expect, test } from '@playwright/test'; -const SERVER = `https://internal.${process.env.DOMAIN}`; +const SERVER = process.env.UI_INTERNAL_E2E_URL ?? `https://internal.${process.env.DOMAIN}`; test('localization translates text when changing language', async ({ page }) => { await page.goto(`${SERVER}/`); diff --git a/justfile b/justfile index 490766a..b5280ac 100644 --- a/justfile +++ b/justfile @@ -207,17 +207,17 @@ test project: just _test-{{project}} # Run End-to-End tests for , e.g. `just e2e ui-internal`. -e2e project: - just _e2e-{{project}} +e2e project +tests="": + just _e2e-{{project}} {{tests}} -_e2e-deployment: - cd deployment/end2end && bun run e2e +_e2e-deployment +tests="": + cd deployment/end2end && bun run e2e {{tests}} -_e2e-ui-app: - cd ui-app/end2end && bun run e2e +_e2e-ui-app +tests="": + cd ui-app/end2end && bun run e2e {{tests}} -_e2e-ui-internal: - cd ui-internal/end2end && bun run e2e +_e2e-ui-internal +tests="": + cd ui-internal/end2end && bun run e2e {{tests}} # Run development server, e.g. `just dev ui-app`. dev project: