Release: test infrastructure, rules overhaul, and design refresh #30

Merged
TheFurya merged 43 commits from develop into main 2026-02-21 16:58:18 +01:00
3 changed files with 78 additions and 35 deletions
Showing only changes of commit bf3a3d3329 - Show all commits

View File

@@ -0,0 +1,25 @@
---
# nuzlocke-tracker-4a6i
title: Replace CI pipeline with test suite
status: completed
type: task
priority: normal
created_at: 2026-02-21T13:01:01Z
updated_at: 2026-02-21T13:10:15Z
---
Replace the current `.github/workflows/ci.yml` with a workflow that runs the actual test suites. The existing jobs (lint, format, type check) are already enforced by pre-commit hooks (prek), so CI should focus on test execution instead.
## Context
- **Backend integration tests**: pytest with `TEST_DATABASE_URL` pointing at a postgres service container. Default URL: `postgresql+asyncpg://postgres:postgres@localhost:5433/nuzlocke_test`. Tests live in `backend/tests/`.
- **Frontend unit tests**: vitest (`npm run test -- --run`). No external services needed.
- **E2e tests**: Playwright. `e2e/global-setup.ts` uses `docker compose -p nuzlocke-test -f docker-compose.test.yml up -d --build` to start a test API + DB, then seeds data via the API. `playwright.config.ts` spins up `npm run dev` as the webServer. Need to install Chromium via `npx playwright install --with-deps chromium`.
## Checklist
- [x] Add `backend-tests` job: postgres service container (image postgres:16-alpine, user/pass/db matching conftest defaults), install deps with `uv`, run `pytest backend/tests/ -q`
- [x] Add `frontend-tests` job: node 24, `npm ci` in `frontend/`, run `npm run test -- --run`
- [x] Add `e2e-tests` job: install Docker Compose, install Playwright + Chromium deps, run `npx playwright test` from `frontend/`; upload HTML report as artifact on failure
- [x] Keep the `actions-lint` job (actionlint + zizmor); remove `backend-lint` and `frontend-lint` jobs
- [x] Pin all action versions to SHA with version comments; pass `zizmor` audit

View File

@@ -1,11 +1,11 @@
--- ---
# nuzlocke-tracker-yzpb # nuzlocke-tracker-yzpb
title: Implement Unit & Integration Tests title: Implement Unit & Integration Tests
status: todo status: completed
type: epic type: epic
priority: high priority: high
created_at: 2026-02-10T09:32:47Z created_at: 2026-02-10T09:32:47Z
updated_at: 2026-02-21T11:29:02Z updated_at: 2026-02-21T13:00:44Z
--- ---
Add comprehensive unit and integration test coverage to both the backend (FastAPI/Python) and frontend (React/TypeScript). The project currently has zero tests — pytest is configured in pyproject.toml with pytest-asyncio and httpx, but no actual test files exist. The frontend has no test tooling at all. Add comprehensive unit and integration test coverage to both the backend (FastAPI/Python) and frontend (React/TypeScript). The project currently has zero tests — pytest is configured in pyproject.toml with pytest-asyncio and httpx, but no actual test files exist. The frontend has no test tooling at all.
@@ -21,7 +21,7 @@ Add comprehensive unit and integration test coverage to both the backend (FastAP
## Success Criteria ## Success Criteria
- [x] Backend test infrastructure is set up (conftest, fixtures, test DB) - [x] Backend test infrastructure is set up (conftest, fixtures, test DB)
- [ ] Backend schemas and services have unit test coverage - [x] Backend schemas and services have unit test coverage
- [x] Backend API endpoints have integration test coverage - [x] Backend API endpoints have integration test coverage
- [x] Frontend test infrastructure is set up (Vitest, RTL) - [x] Frontend test infrastructure is set up (Vitest, RTL)
- [x] Frontend utilities and hooks have unit test coverage - [x] Frontend utilities and hooks have unit test coverage

View File

@@ -22,40 +22,39 @@ permissions:
contents: read contents: read
jobs: jobs:
backend-lint: backend-tests:
runs-on: ubuntu-latest runs-on: ubuntu-latest
services:
postgres:
image: postgres:16-alpine
ports:
- 5433:5432
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: nuzlocke_test
options: >-
--health-cmd "pg_isready -U postgres"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps: steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with: with:
persist-credentials: false persist-credentials: false
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 - uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6.8.0
with: with:
python-version: "3.14" python-version: "3.14"
- run: pip install ruff ty - name: Install dependencies
- name: Check linting run: uv pip install --system -e ".[dev]"
run: ruff check backend/ working-directory: backend
- name: Check formatting - name: Run tests
run: ruff format --check backend/ run: pytest -q
- name: Type check working-directory: backend
run: ty check backend/src/ env:
continue-on-error: true TEST_DATABASE_URL: postgresql+asyncpg://postgres:postgres@localhost:5433/nuzlocke_test
actions-lint: frontend-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
persist-credentials: false
- name: Install actionlint
run: |
bash <(curl -sL https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
sudo mv actionlint /usr/local/bin/
- name: Lint GitHub Actions
run: actionlint
- name: Audit GitHub Actions security
run: pipx run zizmor .github/workflows/
frontend-lint:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
@@ -67,12 +66,31 @@ jobs:
- name: Install dependencies - name: Install dependencies
run: npm ci run: npm ci
working-directory: frontend working-directory: frontend
- name: Lint - name: Run tests
run: npm run lint run: npm test
working-directory: frontend working-directory: frontend
- name: Check formatting
run: npx oxfmt --check "src/" e2e-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
persist-credentials: false
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: "24"
- name: Install dependencies
run: npm ci
working-directory: frontend working-directory: frontend
- name: Type check - name: Install Playwright browsers
run: npx tsc -b run: npx playwright install --with-deps chromium
working-directory: frontend working-directory: frontend
- name: Run e2e tests
run: npm run test:e2e
working-directory: frontend
- name: Upload Playwright report
if: failure()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: playwright-report
path: frontend/playwright-report/