Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 0 additions & 51 deletions .github/workflows/test-pr.yml

This file was deleted.

81 changes: 81 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Tests

on:
pull_request:
paths:
- 'app/**'
- 'compose.test.yaml'
- 'dev/dev-db.sql'
- '.github/workflows/tests.yml'

jobs:
unit:
name: Unit tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./app
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: './app/package-lock.json'

- run: npm ci

- name: Run unit tests with coverage
run: npm test -- --coverage

- name: Upload coverage reports
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-report
path: ./app/coverage/
retention-days: 30

- name: Comment coverage on PR
uses: davelosert/vitest-coverage-report-action@v2
if: always()
with:
working-directory: ./app
json-summary-path: ./coverage/coverage-summary.json
json-final-path: ./coverage/coverage-final.json

e2e:
name: E2E tests
runs-on: ubuntu-latest
needs: unit
defaults:
run:
working-directory: ./app
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: './app/package-lock.json'

- run: npm ci

- name: Install Playwright browsers
run: npx playwright install --with-deps chromium

- name: Generate Prisma client
run: npx prisma generate

- name: Build app
run: npm run build

- name: Start test database
run: npm run test:db:up

- name: Run E2E tests
run: npm run test:e2e
33 changes: 0 additions & 33 deletions .github/workflows/ui-tests.yml

This file was deleted.

20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,27 @@ Run from `app/`. Other scripts in `package.json` are container-internal or unuse
| ---------------- | --------------------------------------------------------- |
| `npm run lint` | Prettier check + ESLint |
| `npm run format` | Prettier write |
| `npm test` | Vitest (currently only a placeholder test) |
| `npm run dev` | Vite dev server — usually invoked by `dev/load-dev-db.sh` |

## Testing

Run from `app/`.

| Command | What it runs |
| ---------------------- | --------------------------------------------------------------------------------------------- |
| `npm test` | **Unit tests** (Vitest) — colocated `*.test.js` files; mock external deps, no Docker needed. |
| `npm run test:watch` | Same suite in watch mode for local iteration. |
| `npm run test:e2e` | **End-to-end tests** (Playwright) — drive Chromium against a real SvelteKit + Postgres stack. |
| `npm run test:all` | Unit then E2E in sequence. |
| `npm run test:db:up` | Start the Postgres test container (required before E2E). |
| `npm run test:db:down` | Stop + wipe the test container. |

First-time E2E setup: `npx playwright install chromium` (browser binaries) and `npx prisma generate` (Prisma client) from `app/`.

The E2E suite runs against a Postgres container seeded from `dev/dev-db.sql` — the same dump used for local dev. The fresher that dump is, the more representative the tests are; running them against stale seed data may pass while real production data would fail.

CI posts a coverage report on each PR, generated from the **unit** suite only (`npm test -- --coverage`). E2E tests aren't instrumented, so the percentages reflect only what the unit/Vitest tests exercise. Run locally the same way to preview the report at `app/coverage/index.html`, which is git-ignored.

## Environment variables

The webapp expects the following (referenced from `app/src/lib/server/secrets.js` and route handlers). In production these are set on the App Runner service; in local dev, set them in your shell or in `app/.env`. Note that the recurring Lambda jobs do not read these from `.env`; they pull equivalents from SSM at invocation time.
Expand Down
Loading
Loading