From 010759443b84d46e947d5ab3ee8e9063f42ec6c7 Mon Sep 17 00:00:00 2001 From: Spencer Peace <47868304+Spencer6497@users.noreply.github.com> Date: Fri, 10 Jan 2025 12:22:11 +0100 Subject: [PATCH] refactor(reduce e2e tests against deployed app) (#1586) Co-authored-by: Spencer Peace <47868304+Spencer6497@users.noreply.github.com> Co-authored-by: chris --- .github/workflows/e2e-test.yml | 3 ++- playwright.config.ts | 15 ++++++++------- tests/e2e/{common => critical}/csrf.spec.ts | 0 tests/e2e/critical/datasubmission.spec.ts | 18 ++++++++++++++++++ tests/e2e/{pages => critical}/homepage.spec.ts | 2 +- .../e2e/{common => critical}/security.spec.ts | 0 6 files changed, 29 insertions(+), 9 deletions(-) rename tests/e2e/{common => critical}/csrf.spec.ts (100%) create mode 100644 tests/e2e/critical/datasubmission.spec.ts rename tests/e2e/{pages => critical}/homepage.spec.ts (95%) rename tests/e2e/{common => critical}/security.spec.ts (100%) diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index e23cb97d4..6778390f3 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -36,6 +36,7 @@ jobs: run: echo "PLAYWRIGHT_VERSION=$(node -e "console.log(require('./package-lock.json').packages[''].devDependencies['@playwright/test'])")" >> $GITHUB_ENV - name: Download Content File + if: inputs.e2e-target != 'preview' uses: actions/download-artifact@v4 with: name: content-file @@ -60,7 +61,7 @@ jobs: GERICHTSFINDER_ENCRYPTION_KEY: "${{ secrets.GERICHTSFINDER_ENCRYPTION_KEY }}" E2E_BASE_URL: "${{ inputs.e2e-target == 'preview' && 'https://a2j-test.dev.ds4g.net/' || 'http://localhost:3000/' }}" E2E_USE_EXISTING_SERVER: "${{ inputs.use-existing-server }}" - run: CMS=FILE npm run test:e2e -- --shard ${{ matrix.shard }}/${{ strategy.job-total }} + run: CMS=FILE npm run test:e2e -- ${{ inputs.e2e-target == 'preview' && '--project=critical' }} --shard ${{ matrix.shard }}/${{ strategy.job-total }} - name: Upload Playwright blob report if: always() diff --git a/playwright.config.ts b/playwright.config.ts index 96cb95a05..2d8002ce5 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -54,19 +54,20 @@ export default defineConfig({ /* Configure projects for major browsers */ projects: [ + { + name: "critical", + use: { ...devices["Desktop Chrome"] }, + testMatch: ["**/critical/**.spec.ts"], + }, { name: "chromium", use: { ...devices["Desktop Chrome"] }, + testIgnore: ["**/critical/**.spec.ts"], }, { - name: "Mobile Android", + name: "mobile", use: { ...devices["Galaxy S8"] }, - // Already covered in primary device tests - testIgnore: [ - "**/accessibilityScans.spec.ts", - "**/csrf.spec.ts", - "**/security.spec.ts", - ], + testIgnore: ["**/critical/**.spec.ts"], }, ], diff --git a/tests/e2e/common/csrf.spec.ts b/tests/e2e/critical/csrf.spec.ts similarity index 100% rename from tests/e2e/common/csrf.spec.ts rename to tests/e2e/critical/csrf.spec.ts diff --git a/tests/e2e/critical/datasubmission.spec.ts b/tests/e2e/critical/datasubmission.spec.ts new file mode 100644 index 000000000..73609fcd4 --- /dev/null +++ b/tests/e2e/critical/datasubmission.spec.ts @@ -0,0 +1,18 @@ +import { test, expect } from "@playwright/test"; +import { CookieSettings } from "../domains/shared/CookieSettings"; + +test.describe("Data submission", () => { + test("radio group value is restored", async ({ page }) => { + await page.goto("/beratungshilfe/vorabcheck"); + const cookieSettings = new CookieSettings(page); + await cookieSettings.acceptCookieBanner(); + + await page.getByLabel("Ja").click(); + await page.getByText("Weiter").click(); + await expect( + page.getByText("wahrscheinlich keine Beratungshilfe"), + ).toBeVisible(); + await page.getByRole("link", { name: "Zurück", exact: true }).click(); + await expect(page.getByLabel("Ja")).toBeChecked(); + }); +}); diff --git a/tests/e2e/pages/homepage.spec.ts b/tests/e2e/critical/homepage.spec.ts similarity index 95% rename from tests/e2e/pages/homepage.spec.ts rename to tests/e2e/critical/homepage.spec.ts index 113a716aa..a962ce46b 100644 --- a/tests/e2e/pages/homepage.spec.ts +++ b/tests/e2e/critical/homepage.spec.ts @@ -1,5 +1,5 @@ import { test, expect } from "@playwright/test"; -import { footerLinks, headerLinks } from "./urlsToCheck"; +import { footerLinks, headerLinks } from "../pages/urlsToCheck"; import { testPageToBeAccessible } from "../util/testPageToBeAccessible"; test.beforeEach(async ({ page }) => { diff --git a/tests/e2e/common/security.spec.ts b/tests/e2e/critical/security.spec.ts similarity index 100% rename from tests/e2e/common/security.spec.ts rename to tests/e2e/critical/security.spec.ts