Skip to content

Commit

Permalink
rename playwright tests: d2d to e2e, lib-ui to ladle (#900)
Browse files Browse the repository at this point in the history
  • Loading branch information
jschuurk-kr authored Jan 24, 2025
1 parent 53593fa commit 9504df5
Show file tree
Hide file tree
Showing 16 changed files with 32 additions and 31 deletions.
20 changes: 11 additions & 9 deletions .github/workflows/build-lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ jobs:
name: frontend-build
path: frontend/dist

playwright-ui:
name: Playwright UI tests
playwright-ladle:
name: Playwright ladle tests
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
Expand All @@ -132,13 +132,14 @@ jobs:
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps --no-shell
- name: Run UI e2e tests
run: npm run e2e:lib-ui
- name: Run ladle playwright tests
run: npm run test:ladle

playwright-d2d:
name: Playwright d2d tests (${{ matrix.os }})
playwright-e2e:
name: Playwright e2e tests (${{ matrix.os }})
needs:
- backend # frontend is included in backend build
- backend
- frontend # for the tests, frontend build is included in backend job
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
Expand All @@ -164,13 +165,14 @@ jobs:
- name: make backend build executable
run: chmod a+x ../builds/backend/abacus
if: runner.os != 'Windows'
- name: Run DOM to Database e2e tests
run: npm run e2e:d2d
- name: Run e2e playwright tests
run: npm run test:e2e

deploy:
name: Deploy to abacus-test.nl
needs:
- backend
- frontend # for the tests, frontend build is included in backend job
environment:
name: test
url: https://${{ github.sha }}.abacus-test.nl
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ jobs:
name: abacus-${{ matrix.target.os }}
path: ${{ matrix.target.binary }}

playwright-d2d:
name: Playwright d2d tests (${{ matrix.os }}, ${{ matrix.shardIndex }}/${{ matrix.shardTotal }})
playwright-e2e:
name: Playwright e2e tests (${{ matrix.os }}, ${{ matrix.shardIndex }}/${{ matrix.shardTotal }})
needs:
- build
strategy:
Expand Down Expand Up @@ -89,14 +89,14 @@ jobs:
- name: make backend build executable
run: chmod a+x ../builds/backend/abacus
if: runner.os != 'Windows'
- name: Run DOM to Database e2e tests
run: npm run e2e:d2d -- --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
- name: Run Playwright e2e tests
run: npm run test:e2e -- --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}

release:
name: Release
needs:
- build
- playwright-d2d
- playwright-e2e
runs-on: ubuntu-latest
permissions:
# contents write permission is needed to push the tag
Expand Down
6 changes: 3 additions & 3 deletions frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ Browser tests using Playwright:

```sh
# tests for ui components using ladle:
npm run e2e:lib-ui
npm run test:ladle

# tests for frontend with backend and database
# tests use database at backend/target/debug/playwright.sqlite
# build frontend, build backend, setup fresh seeded database:
npm run e2e:d2d
npm run test:e2e
# run tests, expect builds and database to be available:
npm run e2e:d2d-dev
npm run test:e2e-dev
```

### UI Component development
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { expect } from "@playwright/test";
import { fillDataEntry } from "e2e-tests/e2e-test-helpers";
import { formatNumber } from "e2e-tests/e2e-test-utils";
import {
CandidatesListPage,
CheckAndSavePage,
Expand All @@ -15,6 +13,8 @@ import {
import { VotersCounts, VotesCounts } from "@kiesraad/api";

import { test } from "./fixtures";
import { fillDataEntry } from "./helpers-utils/e2e-test-helpers";
import { formatNumber } from "./helpers-utils/e2e-test-utils";
import {
noErrorsWarningsResponse,
noRecountNoDifferencesDataEntry,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
PollingStationChoicePage,
RecountedPage,
VotersAndVotesPage,
} from "./page-objects/data_entry";
} from "../page-objects/data_entry";

export async function fillDataEntry(page: Page, results: PollingStationResults) {
const recountedPage = new RecountedPage(page);
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { expect } from "@playwright/test";
import { PollingStationFormPgObj } from "e2e-tests/page-objects/polling_station/PollingStationFormPgObj";

import { PollingStationListEmptyPgObj } from "../page-objects/polling_station/PollingStationListEmptyPgObj";
import { PollingStationListPgObj } from "../page-objects/polling_station/PollingStationListPgObj";
import { test } from "./fixtures";
import { PollingStationListEmptyPgObj } from "./page-objects/polling_station/PollingStationListEmptyPgObj";
import { PollingStationListPgObj } from "./page-objects/polling_station/PollingStationListPgObj";

test.describe("Polling station CRUD", () => {
test("it redirects correctly after successful create of first polling station of an election", async ({
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"prettier": "prettier --ignore-unknown --write .",
"preview": "vite preview",
"test": "vitest",
"e2e:lib-ui": "playwright test -c playwright.lib-ui.config.ts",
"e2e:d2d": "cross-env LOCAL_CI=true playwright test -c playwright.d2d.config.ts",
"e2e:d2d-dev": "playwright test -c playwright.d2d.config.ts",
"test:e2e": "cross-env LOCAL_CI=true playwright test -c playwright.e2e.config.ts",
"test:e2e-dev": "playwright test -c playwright.e2e.config.ts",
"test:ladle": "playwright test -c playwright.ladle.config.ts",
"ladle": "ladle serve",
"build:ladle": "ladle build",
"start:msw": "cross-env API_MODE=mock vite",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ function returnWebserverCommand(): string {

const config: PlaywrightTestConfig = defineConfig({
...commonConfig,
testDir: "./e2e-tests/dom-to-db-tests",
outputDir: "./test-results/dom-to-db",
testDir: "./e2e-tests",
outputDir: "./test-results/e2e-tests",
testMatch: /\.e2e\.ts/,
use: {
...commonConfig.use,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import commonConfig from "./playwright.common.config";
const config: PlaywrightTestConfig = defineConfig({
...commonConfig,
testDir: "./lib/ui",
outputDir: "./test-results/lib-ui",
outputDir: "./test-results/ladle",
testMatch: /\.e2e\.ts/,
use: {
...commonConfig.use,
Expand Down
5 changes: 2 additions & 3 deletions frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@
"app/**/*",
"lib/**/*",
"scripts/**/*",
"playwright.app.config.ts",
"playwright.d2d.config.ts",
"playwright.lib-ui.config.ts",
"playwright.e2e.config.ts",
"playwright.ladle.config.ts",
"vite.config.ts",
"e2e-tests/**/*"
]
Expand Down

0 comments on commit 9504df5

Please sign in to comment.