test: complete frontend test suite, add lint and CI workflow #45

Merged
eliott merged 6 commits from feat/frontend-tests into develop 2026-05-08 20:48:39 +02:00
Owner

Summary

  • Brings the rollnote-front test coverage to parity with the api: 699 passing Vitest specs across 127 files, plus 6 Playwright e2e tests against a hermetic mock API.
  • Adds ESLint (angular-eslint flat config), a typecheck script, and a Forgejo Actions workflow at .forgejo/workflows/test.yml that runs install -> lint -> typecheck -> unit tests -> Playwright e2e on every PR/push to develop/main.
  • Refactors 7 account/auth components from injectAuthClient() to inject(AUTH_CLIENT) so the Better-Auth client can be faked under TestBed (no runtime behavior change).
  • Polyfills matchMedia, IntersectionObserver, and localStorage in src/test-setup.ts so JSDOM-only specs work without per-spec stubs.
  • Type cleanup: 10 empty `interface UpdateXDto extends CreateXDto {}` declarations rewritten as `type` aliases.

Scope

Area Files
New unit specs (T8-T14) ~73 spec files under `src/app/` and `src/lib/`
New e2e specs `e2e/auth.spec.ts`, `e2e/navigation.spec.ts`, `e2e/shoots.spec.ts` + `e2e/fixtures/mock-api.ts`
Tooling `eslint.config.mjs`, `playwright.config.ts`, `package.json` scripts
CI `.forgejo/workflows/test.yml`
Test infra `src/test-setup.ts`, `src/test-utils/*`
Refactor (DI seam) account drawers + auth components moved to `inject(AUTH_CLIENT)`

Test plan

  • `pnpm test` -> 699 passed / 2 skipped (Leaflet specs that need a real browser)
  • `pnpm lint` -> 0 errors, 1 warning (unavoidable `any` in the Better-Auth proxy bridge, documented inline)
  • `pnpm typecheck` -> clean
  • `pnpm exec playwright test --list` -> 6 tests across 3 files registered
  • Forgejo Actions runs the full workflow on this PR (verify in CI)

🤖 Generated with Claude Code

## Summary - Brings the **rollnote-front** test coverage to parity with the api: 699 passing Vitest specs across 127 files, plus 6 Playwright e2e tests against a hermetic mock API. - Adds ESLint (`angular-eslint` flat config), a `typecheck` script, and a Forgejo Actions workflow at `.forgejo/workflows/test.yml` that runs install -> lint -> typecheck -> unit tests -> Playwright e2e on every PR/push to `develop`/`main`. - Refactors 7 account/auth components from `injectAuthClient()` to `inject(AUTH_CLIENT)` so the Better-Auth client can be faked under TestBed (no runtime behavior change). - Polyfills `matchMedia`, `IntersectionObserver`, and `localStorage` in `src/test-setup.ts` so JSDOM-only specs work without per-spec stubs. - Type cleanup: 10 empty \`interface UpdateXDto extends CreateXDto {}\` declarations rewritten as \`type\` aliases. ## Scope | Area | Files | | --- | --- | | New unit specs (T8-T14) | ~73 spec files under \`src/app/**\` and \`src/lib/**\` | | New e2e specs | \`e2e/auth.spec.ts\`, \`e2e/navigation.spec.ts\`, \`e2e/shoots.spec.ts\` + \`e2e/fixtures/mock-api.ts\` | | Tooling | \`eslint.config.mjs\`, \`playwright.config.ts\`, \`package.json\` scripts | | CI | \`.forgejo/workflows/test.yml\` | | Test infra | \`src/test-setup.ts\`, \`src/test-utils/*\` | | Refactor (DI seam) | account drawers + auth components moved to \`inject(AUTH_CLIENT)\` | ## Test plan - [x] \`pnpm test\` -> 699 passed / 2 skipped (Leaflet specs that need a real browser) - [x] \`pnpm lint\` -> 0 errors, 1 warning (unavoidable \`any\` in the Better-Auth proxy bridge, documented inline) - [x] \`pnpm typecheck\` -> clean - [x] \`pnpm exec playwright test --list\` -> 6 tests across 3 files registered - [ ] Forgejo Actions runs the full workflow on this PR (verify in CI) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Adds src/test-utils/ helpers and 178+ specs across pure utils, guards,
interceptor, lib + feature services, directives, and lib UI/common
components. Replaces 11 of 24 scaffolded specs with real tests.

Two DI seams added so auth-touching code is testable without vi.mock
(which is disabled by Angular's @angular/build:unit-test builder for
relative imports):
- SESSION token in src/app/auth-session.ts
- AUTH_CLIENT token in src/app/auth.ts

Status: 191 passing / 14 failing. The 14 failures are pre-existing
ng-generate scaffolds that already failed on develop. See
../TESTING-TODO.md for the full remaining task list.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
test: complete frontend test suite, add lint and CI workflow
Some checks failed
tests / test (pull_request) Failing after 7s
a260bf2c68
- Unit tests: 699 passing Vitest specs across 127 files covering
  services, guards, interceptors, directives, pure utils, and every
  feature component (auth, account, frames, shoots, settings subtree,
  changelog, admin, app shell).
- e2e: Playwright config with hermetic API mocks, plus auth,
  navigation, and shoots flows (6 tests in 3 files).
- Tooling: ESLint (angular-eslint) and tsc --noEmit scripts wired up,
  config tuned for project conventions; new pnpm lint, typecheck,
  e2e, and e2e:ui scripts.
- Test infra: src/test-setup.ts polyfills matchMedia,
  IntersectionObserver, and localStorage for JSDOM.
- DI seam: 7 components migrated from injectAuthClient() to
  inject(AUTH_CLIENT) so the Better-Auth client can be faked in tests.
- Type cleanup: empty UpdateXDto interfaces extending CreateXDto
  converted to type aliases (no behavior change).
- CI: .forgejo/workflows/test.yml runs install, lint, typecheck,
  unit tests, then Playwright e2e on the docker runner.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ci: drop explicit pnpm version, defer to package.json packageManager
Some checks failed
tests / test (pull_request) Failing after 4m26s
bc0cfb27bf
pnpm/action-setup@v4 fails with ERR_PNPM_BAD_PM_VERSION when both the
workflow `version` input and package.json `packageManager` are set.
The api avoids this because it has no `packageManager` field; the
front does (`pnpm@10.33.0`), so `version` has to go.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
fix(build): exclude test-utils and test-setup from app tsconfig
Some checks failed
tests / test (pull_request) Failing after 2m16s
05ae5ac356
ng serve was compiling src/test-utils/router-stub.ts (which uses
Vitest's `vi.fn()`) into the app build, breaking the e2e webServer
in CI. Spec files were already excluded; extend the same treatment
to the test-only helpers and global setup.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
fix(e2e): correct API URL patterns for shoots/folder/changelog mocks
Some checks failed
tests / test (pull_request) Failing after 2m18s
9bee86dc51
The shoot/folder/changelog endpoints live at the API root
(`${apiUrl}/shoot`, `/folder`, `/changelog`), not under `/api/`.
Only Better-Auth uses `/api/auth/*`. The previous patterns
(`**/api/shoot/paginated*`) never matched, so `/shoots` rendered
with "Failed to fetch" and the shoot-card test couldn't find
"Morning roll".

- Move built-in mocks to register first so caller-supplied routes
  (registered last) win per Playwright's LIFO route resolution.
- Add a catch-all for `/shoot` and `/frame` so navigation tests
  don't show error toasts.
- shoots.spec: register the override AFTER mockApi() and use a
  regex that targets `/shoot?...` (paginated list) without
  shadowing `/shoot/<id>` paths.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
fix(e2e): match shoot list response shape (plain array, not paginated)
All checks were successful
tests / test (pull_request) Successful in 2m11s
f7fc8b4987
The Shoots page calls ShootService.getAll() (-> ?all=true, returns
Shoot[]), not getPaginated() (-> {data, total, page, ...}). The
fixture's catch-all and the test override were both returning the
paginated shape, so .length was undefined and the page rendered
the empty state.

- shoots.spec: override returns a plain array.
- mock-api fixture: catch-all inspects `all=true` and returns the
  matching shape (array vs paginated object).

Verified locally: 6/6 e2e tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
eliott merged commit c401f3442c into develop 2026-05-08 20:48:39 +02:00
eliott deleted branch feat/frontend-tests 2026-05-08 20:48:39 +02:00
Sign in to join this conversation.
No reviewers
No labels
run-ci
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
RollNote/rollnote-front!45
No description provided.