test: expand coverage for RBAC, Celery tasks, services, routers, agent, and frontend#20
Merged
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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%.
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/ExperimentRunstatus 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_BUCKETprecedence.test_evaluation_service.py(was 16%) —summarize/to_dict/write_result, paginatedlist_evaluations, and thecreate_evaluationflow incl. validation errors (Celery stubbed).test_inference_service.py— download helper, load-error path, andpredictdispatch + 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,0600perms, corrupt/missing-file handling.--cov-fail-under=62(floor below the measured 65%, meant to be ratcheted); frontend job runsnpm run test:unit.Frontend test harness
vitest.config.tsand a setup file.token-store,api(URL resolution, bearer header, 401 redirect, error detail), andauth-store(login/logout/restore) unit tests.playwright.config.tsnow scopes to*.spec.tsso Vitest (tests/unit/*.test.ts) and Playwright don't overlap.Verification
pytest tests/→ 20 passed.npm run test:unit→ 17 passed;npm run buildsucceeds.ruffclean,black --checkclean on new files.No source/behavior changes — tests and CI config only.
https://claude.ai/code/session_011h7jZv18xWfFmT6fDz9EU4
Generated by Claude Code