From c8f97a06c10a3ba5bd723c94723a7543f136a9b6 Mon Sep 17 00:00:00 2001 From: seatuna Date: Tue, 22 Oct 2024 20:44:32 -0400 Subject: [PATCH 01/15] 1647: add config for running e2e in ci --- .github/workflows/repo-checks.yml | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/.github/workflows/repo-checks.yml b/.github/workflows/repo-checks.yml index 4df2e6a21..30f1c19b0 100644 --- a/.github/workflows/repo-checks.yml +++ b/.github/workflows/repo-checks.yml @@ -60,3 +60,39 @@ jobs: tests/integration/auth.test.ts tests/integration/moderation.test.ts tests/integration/profile.test.ts + + e2e_tests: + name: E2E Tests + runs-on: ubuntu-latest + environment: dev + needs: check_code_quality + + services: + typesense: + image: typesense/typesense:0.24.0 + ports: + - 8108:8108 + env: + TYPESENSE_DATA_DIR: /app/data + TYPESENSE_API_KEY: test-api-key + TYPESENSE_ENABLE_CORS: "true" + volumes: + - typesense-data:/app/data + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: lts/* + - name: Install dependencies + run: yarn install + - name: Install Playwright Browsers + run: yarn playwright install --with-deps + - name: Run Playwright tests + run: yarn test:e2e:headless + - uses: actions/upload-artifact@v4 + if: ${{ !cancelled() }} + with: + name: playwright-report + path: playwright-report/ + retention-days: 30 From 743cf1656b29a3346d1d9ee7904db4fb218a126f Mon Sep 17 00:00:00 2001 From: seatuna Date: Tue, 22 Oct 2024 20:49:20 -0400 Subject: [PATCH 02/15] remove environment --- .github/workflows/repo-checks.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/repo-checks.yml b/.github/workflows/repo-checks.yml index 30f1c19b0..81b24ce65 100644 --- a/.github/workflows/repo-checks.yml +++ b/.github/workflows/repo-checks.yml @@ -64,7 +64,6 @@ jobs: e2e_tests: name: E2E Tests runs-on: ubuntu-latest - environment: dev needs: check_code_quality services: From 7530dd86a8bfbc57359e5a8117e96b6183bfd8eb Mon Sep 17 00:00:00 2001 From: seatuna Date: Tue, 12 Nov 2024 21:33:26 -0500 Subject: [PATCH 03/15] fix broken tests --- components/search/testimony/TestimonyHit.tsx | 4 +++- tests/e2e/browse-bills.spec.ts | 2 +- tests/e2e/helpers.ts | 3 +++ tests/e2e/testimony.spec.ts | 17 +++++++---------- 4 files changed, 14 insertions(+), 12 deletions(-) create mode 100644 tests/e2e/helpers.ts diff --git a/components/search/testimony/TestimonyHit.tsx b/components/search/testimony/TestimonyHit.tsx index 201e7d714..5a3d4cace 100644 --- a/components/search/testimony/TestimonyHit.tsx +++ b/components/search/testimony/TestimonyHit.tsx @@ -37,7 +37,9 @@ const TestimonyResult = ({ hit }: { hit: Hit }) => { const isOrg = hit.authorRole === "organization" const writtenBy = isOrg || hit.public ? ( - {hit.fullName} + + {hit.fullName} + ) : ( hit.fullName ) diff --git a/tests/e2e/browse-bills.spec.ts b/tests/e2e/browse-bills.spec.ts index 84303aec2..726b3949b 100644 --- a/tests/e2e/browse-bills.spec.ts +++ b/tests/e2e/browse-bills.spec.ts @@ -30,7 +30,7 @@ test.describe("Search result test", () => { const queryFilter = await billpage.queryFilter - await expect(queryFilter).toContainText("query:") + await expect(queryFilter).toContainText("Query:") await expect(queryFilter).toContainText(searchTerm) }) diff --git a/tests/e2e/helpers.ts b/tests/e2e/helpers.ts new file mode 100644 index 000000000..c4fb82816 --- /dev/null +++ b/tests/e2e/helpers.ts @@ -0,0 +1,3 @@ +export const rfc3986EncodeURIComponent = (str: string) => { + return encodeURIComponent(str).replace(/[!'()*]/g, escape); +} \ No newline at end of file diff --git a/tests/e2e/testimony.spec.ts b/tests/e2e/testimony.spec.ts index ab57f6012..5f3a8ff61 100644 --- a/tests/e2e/testimony.spec.ts +++ b/tests/e2e/testimony.spec.ts @@ -34,7 +34,7 @@ test.describe("Testimony Search", () => { await testimonyPage.search(queryText) const { queryFilterItem, resultsCountText } = testimonyPage - await expect(queryFilterItem).toContainText("query:") + await expect(queryFilterItem).toContainText("Query:") await expect(queryFilterItem).toContainText(queryText) await expect(resultsCountText).toBeVisible() }) @@ -129,20 +129,17 @@ test.describe("Testimony Filtering", () => { }) test("should filter by author", async ({ page }) => { - const writtenByText = await page - .getByText(/Written by/) - .first() - .textContent() - expect(writtenByText).toBeTruthy() - - if (writtenByText) { - const authorName = writtenByText.slice(11) + const authorName = await page.getByTestId("author").first().textContent() + expect(authorName).toBeTruthy() + + if (authorName) { await page.getByRole("checkbox", { name: authorName }).check() const testimonyPage = new TestimonyPage(page) await expect(testimonyPage.authorFilterItem).toContainText(authorName) + const encodedAuthorName = encodeURIComponent(authorName).replace("'", "%27") await expect(page).toHaveURL( new RegExp( - `.*authorDisplayName%5D%5B0%5D=${encodeURIComponent(authorName)}` + `.*authorDisplayName%5D%5B0%5D=${encodedAuthorName}` ) ) } From 4340592fa7e2e3a7621d47fced9d24a585340500 Mon Sep 17 00:00:00 2001 From: seatuna Date: Tue, 12 Nov 2024 21:39:18 -0500 Subject: [PATCH 04/15] fix formatting --- tests/e2e/helpers.ts | 3 --- tests/e2e/testimony.spec.ts | 9 +++++---- 2 files changed, 5 insertions(+), 7 deletions(-) delete mode 100644 tests/e2e/helpers.ts diff --git a/tests/e2e/helpers.ts b/tests/e2e/helpers.ts deleted file mode 100644 index c4fb82816..000000000 --- a/tests/e2e/helpers.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const rfc3986EncodeURIComponent = (str: string) => { - return encodeURIComponent(str).replace(/[!'()*]/g, escape); -} \ No newline at end of file diff --git a/tests/e2e/testimony.spec.ts b/tests/e2e/testimony.spec.ts index 5f3a8ff61..8146dd903 100644 --- a/tests/e2e/testimony.spec.ts +++ b/tests/e2e/testimony.spec.ts @@ -136,11 +136,12 @@ test.describe("Testimony Filtering", () => { await page.getByRole("checkbox", { name: authorName }).check() const testimonyPage = new TestimonyPage(page) await expect(testimonyPage.authorFilterItem).toContainText(authorName) - const encodedAuthorName = encodeURIComponent(authorName).replace("'", "%27") + const encodedAuthorName = encodeURIComponent(authorName).replace( + "'", + "%27" + ) await expect(page).toHaveURL( - new RegExp( - `.*authorDisplayName%5D%5B0%5D=${encodedAuthorName}` - ) + new RegExp(`.*authorDisplayName%5D%5B0%5D=${encodedAuthorName}`) ) } }) From f188d962c4c15890b278a1f57f20103446bbf498 Mon Sep 17 00:00:00 2001 From: seatuna Date: Tue, 12 Nov 2024 21:56:21 -0500 Subject: [PATCH 05/15] remove typesense service --- .github/workflows/repo-checks.yml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/.github/workflows/repo-checks.yml b/.github/workflows/repo-checks.yml index 81b24ce65..4d3322309 100644 --- a/.github/workflows/repo-checks.yml +++ b/.github/workflows/repo-checks.yml @@ -66,18 +66,6 @@ jobs: runs-on: ubuntu-latest needs: check_code_quality - services: - typesense: - image: typesense/typesense:0.24.0 - ports: - - 8108:8108 - env: - TYPESENSE_DATA_DIR: /app/data - TYPESENSE_API_KEY: test-api-key - TYPESENSE_ENABLE_CORS: "true" - volumes: - - typesense-data:/app/data - steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 From 6f221d0e1b3e55d100398fb05d344599c6eb64b6 Mon Sep 17 00:00:00 2001 From: seatuna Date: Tue, 12 Nov 2024 22:36:08 -0500 Subject: [PATCH 06/15] restore service --- .github/workflows/repo-checks.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/repo-checks.yml b/.github/workflows/repo-checks.yml index 4d3322309..81b24ce65 100644 --- a/.github/workflows/repo-checks.yml +++ b/.github/workflows/repo-checks.yml @@ -66,6 +66,18 @@ jobs: runs-on: ubuntu-latest needs: check_code_quality + services: + typesense: + image: typesense/typesense:0.24.0 + ports: + - 8108:8108 + env: + TYPESENSE_DATA_DIR: /app/data + TYPESENSE_API_KEY: test-api-key + TYPESENSE_ENABLE_CORS: "true" + volumes: + - typesense-data:/app/data + steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 From 36cbd0d15e1cbb5ee3dc9c2212f3311bb43b0dd9 Mon Sep 17 00:00:00 2001 From: seatuna Date: Tue, 19 Nov 2024 19:43:11 -0500 Subject: [PATCH 07/15] remove service --- .github/workflows/repo-checks.yml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/.github/workflows/repo-checks.yml b/.github/workflows/repo-checks.yml index 81b24ce65..4d3322309 100644 --- a/.github/workflows/repo-checks.yml +++ b/.github/workflows/repo-checks.yml @@ -66,18 +66,6 @@ jobs: runs-on: ubuntu-latest needs: check_code_quality - services: - typesense: - image: typesense/typesense:0.24.0 - ports: - - 8108:8108 - env: - TYPESENSE_DATA_DIR: /app/data - TYPESENSE_API_KEY: test-api-key - TYPESENSE_ENABLE_CORS: "true" - volumes: - - typesense-data:/app/data - steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 From 50c49b5ca8521cc611af8cbeafaab501077ea0fb Mon Sep 17 00:00:00 2001 From: seatuna Date: Tue, 19 Nov 2024 21:19:09 -0500 Subject: [PATCH 08/15] test --- .github/workflows/repo-checks.yml | 8 ++------ playwright.config.ts | 10 +++++----- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/.github/workflows/repo-checks.yml b/.github/workflows/repo-checks.yml index 4d3322309..96e1c7404 100644 --- a/.github/workflows/repo-checks.yml +++ b/.github/workflows/repo-checks.yml @@ -67,12 +67,8 @@ jobs: needs: check_code_quality steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: lts/* - - name: Install dependencies - run: yarn install + - uses: actions/checkout@v2 + - uses: ./.github/actions/setup-repo - name: Install Playwright Browsers run: yarn playwright install --with-deps - name: Run Playwright tests diff --git a/playwright.config.ts b/playwright.config.ts index f58a111fe..62bec097b 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -77,9 +77,9 @@ export default defineConfig({ ], /* Run your local dev server before starting the tests */ - webServer: { - command: "yarn dev:up", - url: "http://localhost:3000/", - reuseExistingServer: !process.env.CI - } + // webServer: { + // command: "yarn dev:up", + // url: "http://localhost:3000/", + // reuseExistingServer: !process.env.CI + // } }) From 12f214682b93d4dae720a5fd57bc75223b18c4f2 Mon Sep 17 00:00:00 2001 From: seatuna Date: Tue, 19 Nov 2024 21:23:19 -0500 Subject: [PATCH 09/15] run lint fix --- playwright.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playwright.config.ts b/playwright.config.ts index 62bec097b..b231e6ed0 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -74,7 +74,7 @@ export default defineConfig({ // name: 'Google Chrome', // use: { ...devices['Desktop Chrome'], channel: 'chrome' }, // }, - ], + ] /* Run your local dev server before starting the tests */ // webServer: { From b0e7a609dfc616ce1d853a0cb2958421aa84f56f Mon Sep 17 00:00:00 2001 From: seatuna Date: Sat, 7 Dec 2024 20:50:03 -0500 Subject: [PATCH 10/15] run dev server for tests --- playwright.config.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/playwright.config.ts b/playwright.config.ts index b231e6ed0..f58a111fe 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -74,12 +74,12 @@ export default defineConfig({ // name: 'Google Chrome', // use: { ...devices['Desktop Chrome'], channel: 'chrome' }, // }, - ] + ], /* Run your local dev server before starting the tests */ - // webServer: { - // command: "yarn dev:up", - // url: "http://localhost:3000/", - // reuseExistingServer: !process.env.CI - // } + webServer: { + command: "yarn dev:up", + url: "http://localhost:3000/", + reuseExistingServer: !process.env.CI + } }) From 4e0272f10d0e7e233d7bab5ee9b7aaefb104773e Mon Sep 17 00:00:00 2001 From: seatuna Date: Sat, 7 Dec 2024 21:09:13 -0500 Subject: [PATCH 11/15] test --- playwright.config.ts | 10 +++++----- tests/e2e/adminPage.spec.ts | 7 +++++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/playwright.config.ts b/playwright.config.ts index f58a111fe..62bec097b 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -77,9 +77,9 @@ export default defineConfig({ ], /* Run your local dev server before starting the tests */ - webServer: { - command: "yarn dev:up", - url: "http://localhost:3000/", - reuseExistingServer: !process.env.CI - } + // webServer: { + // command: "yarn dev:up", + // url: "http://localhost:3000/", + // reuseExistingServer: !process.env.CI + // } }) diff --git a/tests/e2e/adminPage.spec.ts b/tests/e2e/adminPage.spec.ts index 1f0c728ec..524a7a5c3 100644 --- a/tests/e2e/adminPage.spec.ts +++ b/tests/e2e/adminPage.spec.ts @@ -21,6 +21,13 @@ test.describe.serial("Admin Page", () => { context = await browser.newContext() page = await context.newPage() + console.log({ + username: process.env.TEST_ADMIN_USERNAME, + pw: process.env.TEST_ADMIN_PASSWORD, + url: process.env.APP_API_URL, + ci: process.env.ci + }) + // Fetch the admin credentials and application URL from the environment variables const adminEmail = process.env.TEST_ADMIN_USERNAME const adminPassword = process.env.TEST_ADMIN_PASSWORD From 309aea6780c6d33516774585cf0b14bd39a8ad70 Mon Sep 17 00:00:00 2001 From: seatuna Date: Sat, 7 Dec 2024 21:15:05 -0500 Subject: [PATCH 12/15] fix lint --- playwright.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playwright.config.ts b/playwright.config.ts index 62bec097b..b231e6ed0 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -74,7 +74,7 @@ export default defineConfig({ // name: 'Google Chrome', // use: { ...devices['Desktop Chrome'], channel: 'chrome' }, // }, - ], + ] /* Run your local dev server before starting the tests */ // webServer: { From b031cade7e474e203c81dc69e7ef4b0a4064e2af Mon Sep 17 00:00:00 2001 From: seatuna Date: Sat, 14 Dec 2024 00:56:14 -0500 Subject: [PATCH 13/15] test --- .github/workflows/repo-checks.yml | 12 +++++++++++- playwright.config.ts | 14 +++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/.github/workflows/repo-checks.yml b/.github/workflows/repo-checks.yml index 96e1c7404..4942de569 100644 --- a/.github/workflows/repo-checks.yml +++ b/.github/workflows/repo-checks.yml @@ -65,15 +65,25 @@ jobs: name: E2E Tests runs-on: ubuntu-latest needs: check_code_quality + environment: dev steps: - uses: actions/checkout@v2 - uses: ./.github/actions/setup-repo + + - name: Cache Node Modules + id: cache-node-modules + uses: actions/cache@v2 + with: + path: | + node_modules + key: modules-${{ hashFiles('package-lock.json') }} + - name: Install Playwright Browsers run: yarn playwright install --with-deps - name: Run Playwright tests run: yarn test:e2e:headless - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@v2 if: ${{ !cancelled() }} with: name: playwright-report diff --git a/playwright.config.ts b/playwright.config.ts index b231e6ed0..ad3c26020 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -11,7 +11,7 @@ import { defineConfig, devices } from "@playwright/test" */ export default defineConfig({ testDir: "./tests/e2e", - timeout: 50000, + timeout: 100000, /* Run tests in files in parallel */ fullyParallel: true, /* Fail the build on CI if you accidentally left test.only in the source code. */ @@ -74,12 +74,12 @@ export default defineConfig({ // name: 'Google Chrome', // use: { ...devices['Desktop Chrome'], channel: 'chrome' }, // }, - ] + ], /* Run your local dev server before starting the tests */ - // webServer: { - // command: "yarn dev:up", - // url: "http://localhost:3000/", - // reuseExistingServer: !process.env.CI - // } + webServer: { + command: "yarn dev:up", + url: "http://localhost:3000/", + reuseExistingServer: !process.env.CI + } }) From 2aac3a9923b6514995f19a4a10d67f8e2ddf8b40 Mon Sep 17 00:00:00 2001 From: seatuna Date: Sat, 14 Dec 2024 01:46:02 -0500 Subject: [PATCH 14/15] add timeout to webserver config --- playwright.config.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/playwright.config.ts b/playwright.config.ts index ad3c26020..2cb15200e 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -11,7 +11,7 @@ import { defineConfig, devices } from "@playwright/test" */ export default defineConfig({ testDir: "./tests/e2e", - timeout: 100000, + timeout: 50000, /* Run tests in files in parallel */ fullyParallel: true, /* Fail the build on CI if you accidentally left test.only in the source code. */ @@ -80,6 +80,7 @@ export default defineConfig({ webServer: { command: "yarn dev:up", url: "http://localhost:3000/", - reuseExistingServer: !process.env.CI + reuseExistingServer: !process.env.CI, + timeout: 100000 } }) From 314d419aa941f0568e0e99ca4649aacb6bb329cf Mon Sep 17 00:00:00 2001 From: seatuna Date: Sat, 14 Dec 2024 15:48:04 -0500 Subject: [PATCH 15/15] test --- .github/workflows/repo-checks.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/repo-checks.yml b/.github/workflows/repo-checks.yml index 4942de569..a0e7582e2 100644 --- a/.github/workflows/repo-checks.yml +++ b/.github/workflows/repo-checks.yml @@ -68,12 +68,12 @@ jobs: environment: dev steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: ./.github/actions/setup-repo - name: Cache Node Modules id: cache-node-modules - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: | node_modules @@ -83,7 +83,7 @@ jobs: run: yarn playwright install --with-deps - name: Run Playwright tests run: yarn test:e2e:headless - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 if: ${{ !cancelled() }} with: name: playwright-report