Skip to content

test: expand coverage for RBAC, Celery tasks, services, routers, agent, and frontend#20

Merged
whittenator merged 2 commits into
mainfrom
claude/test-coverage-analysis-IawF3
Jun 9, 2026
Merged

test: expand coverage for RBAC, Celery tasks, services, routers, agent, and frontend#20
whittenator merged 2 commits into
mainfrom
claude/test-coverage-analysis-IawF3

Conversation

@whittenator

Copy link
Copy Markdown
Owner

Summary

Follows up the test-coverage analysis by closing the highest-risk gaps it identified. Adds 87 new tests across backend, agent, and frontend, plus a CI coverage floor. Measured backend unit coverage rises 60% → 65%.

Area New tests
Backend unit 58
Agent 12
Frontend (Vitest) 17

What changed, by priority

P0 — security & async jobs (were ~0% covered)

  • test_rbac.py — the workspace authorization gate (require_role): role ladder monotonicity, sufficient/insufficient role, non-member 403, and the superuser-email bypass. This was the single auth chokepoint with no tests.
  • test_task_training.py / test_task_onnx_export.py / test_task_prelabels.py — Celery task orchestration: Job/ExperimentRun status transitions (queued→running→succeeded|failed), ONNX artifact creation, prelabel no-op pathing, and cluster release on terminal job status. Uses a stubbed trainer + MINIO_DISABLED=true, so no ML stack is required (stays CI-light).

P1 — service & router holes

  • test_storage_service.py (was 22%) — object-storage plumbing, presign fallback, MINIO_BUCKET/S3_BUCKET precedence.
  • test_evaluation_service.py (was 16%) — summarize/to_dict/write_result, paginated list_evaluations, and the create_evaluation flow incl. validation errors (Celery stubbed).
  • test_inference_service.py — download helper, load-error path, and predict dispatch + temp-file cleanup (cache pre-seeded; runners stubbed).
  • test_api_assets.py / test_api_experiments.py / test_api_ops.py — request-level router tests: reads, pagination, the neighbor cursor, system-status aggregation, upload-url, and frame-extraction validation guards.

P2 — agent & CI

  • agent/tests/test_discover.py — hardware/OS probe parsing + discover() payload shape (hermetic; GPU vendors stubbed).
  • agent/tests/test_identity.py — identity save/load round-trip, 0600 perms, corrupt/missing-file handling.
  • CI: backend unit job now enforces --cov-fail-under=62 (floor below the measured 65%, meant to be ratcheted); frontend job runs npm run test:unit.

Frontend test harness

  • Adds Vitest + jsdom + @testing-library/react with vitest.config.ts and a setup file.
  • token-store, api (URL resolution, bearer header, 401 redirect, error detail), and auth-store (login/logout/restore) unit tests.
  • playwright.config.ts now scopes to *.spec.ts so Vitest (tests/unit/*.test.ts) and Playwright don't overlap.

Verification

  • Backend: new unit tests green; full unit suite 65% coverage (above the 62% floor).
  • Agent: pytest tests/ → 20 passed.
  • Frontend: npm run test:unit → 17 passed; npm run build succeeds.
  • Lint/format: ruff clean, black --check clean on new files.

No source/behavior changes — tests and CI config only.

https://claude.ai/code/session_011h7jZv18xWfFmT6fDz9EU4


Generated by Claude Code

claude added 2 commits May 31, 2026 18:05
…t, and frontend

Backend (unit):
- test_rbac: workspace authorization gate (role ladder, non-member 403,
  superuser bypass) — previously 0% coverage on the central auth chokepoint
- test_task_training / _onnx_export / _prelabels: Celery task orchestration,
  Job status transitions, and cluster release on terminal status (stubbed
  trainer + MINIO_DISABLED, no ML stack required)
- test_storage_service / _evaluation_service / _inference_service: object
  storage plumbing, evaluation helpers + create flow, inference download/
  dispatch
- test_api_assets / _api_experiments / _api_ops: request-level router tests
  covering reads, pagination, neighbor cursor, and validation guards

Agent:
- test_discover: hardware/OS probe parsing + payload shape
- test_identity: persistent identity round-trip, 0600 perms, corrupt-file handling

Frontend (Vitest):
- add vitest + jsdom + testing-library; vitest.config.ts and setup
- token-store, api (url resolution, auth header, 401 redirect, error detail),
  and auth-store (login/logout/restore) unit tests
- playwright now scopes to *.spec.ts so the runners don't overlap

CI:
- enforce backend unit coverage floor (--cov-fail-under=62) to lock in
  coverage and enable ratcheting
- run frontend vitest unit tests in the frontend job

https://claude.ai/code/session_011h7jZv18xWfFmT6fDz9EU4
The 62 floor sat right at the lightweight-CI coverage level (the ML-stack
trainer tests skip in CI, so it measures lower than a full local run),
making the gate prone to flaking red. Drop to 60 for a safe margin; ratchet
up as lightweight-CI coverage genuinely climbs.

https://claude.ai/code/session_011h7jZv18xWfFmT6fDz9EU4
@whittenator whittenator merged commit 6cf5fb9 into main Jun 9, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants