Integration/coverage merge#22
Merged
Merged
Conversation
…integration/coverage-merge
There was a problem hiding this comment.
Pull request overview
This PR consolidates integration/coverage work by adding substantial frontend + backend test coverage around “Role D” flows (reports/experiment-runs/dispatches/etc.) and includes a few backend fixes discovered while expanding those tests (order lab-id normalization, avoiding async-session lazy loads, and enforcing auth on orders endpoints).
Changes:
- Added Vitest coverage for service-layer API wrappers and report UI components (tables/modals), plus small Sidebar nav/test updates.
- Added/expanded backend integration and service-level tests across multiple modules (reports, experiment-runs, dispatches, machines, recipes, workflow helpers), including enabling previously-xfailed dependency routing tests.
- Backend fixes: normalize
order_items.lab_idto canonicalLab.idUUID on create/update, refresh ORM entities to avoidMissingGreenlet, and require authentication on orders “get/history” routes.
Reviewed changes
Copilot reviewed 16 out of 18 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/src/services/tests/role-d-api.test.ts | Adds wrapper-level tests for Role D-facing service API modules (closures/dispatches/experiments/dashboard/machines/recipes). |
| frontend/src/services/tests/reports-api.test.ts | Adds tests validating reports API wrapper request shapes and response unwrapping. |
| frontend/src/services/tests/notifications-issues-api.test.ts | Adds tests for issue/notification API wrappers (paging + action endpoints). |
| frontend/src/lib/tests/errorMessage.test.ts | Adds unit tests for errorMessage() extraction/fallback logic. |
| frontend/src/lib/tests/displayNames.test.ts | Adds unit tests for master-data/user display-name helpers. |
| frontend/components/Sidebar.tsx | Removes “系統設定” entry and renames/retitles tools link as “系統工具”. |
| frontend/components/tests/Sidebar.test.tsx | Updates Sidebar expectations to match the new “系統工具” label. |
| frontend/app/report/components/tests/ReportTable.test.tsx | Adds interaction tests for report table actions (edit/submit/review/publish/offline). |
| frontend/app/report/components/tests/ReportModals.test.tsx | Adds tests for create/edit report modals (template selection, payload shaping, defaults). |
| backend/tests/test_route_integration.py | Enables dependency-next tests (removes xfail), updates sampleId usage, and arranges completed WIPs for dependency progression. |
| backend/tests/e_tests/test_workflow_helpers.py | Adds unit tests for workflow helper functions using a lightweight fake DB result adapter. |
| backend/tests/e_tests/test_reports_service.py | Adds service-level tests for ReportService behaviors (scope, lifecycle, transitions, errors). |
| backend/tests/e_tests/test_recipes_service.py | Adds service-level tests for recipe scope/validation and update behavior. |
| backend/tests/e_tests/test_machines_service.py | Adds service-level tests for machine scoping, defaults, validation, and status updates. |
| backend/tests/e_tests/test_experiment_runs_service.py | Adds service-level tests for experiment run lifecycle and permission/scoping errors. |
| backend/tests/e_tests/test_dispatches_service.py | Adds service-level tests for dispatch strategy ordering, state transitions, and validation. |
| backend/tests/d_tests/test_reports.py | Adds endpoint-level integration tests for /api/reports contract, permissions, and state machine. |
| backend/tests/d_tests/test_experiment_runs.py | Adds endpoint-level integration tests for /api/experiment-runs contract, permissions, and state machine. |
| backend/tests/d_tests/init.py | Initializes d_tests package for test discovery/import consistency. |
| backend/tests/c_tests/test_recipes.py | Adds endpoint-level integration tests for /api/recipes contract and permission model. |
| backend/tests/c_tests/test_dispatches.py | Adds endpoint-level integration tests for /api/dispatches contract and state machine. |
| backend/tests/a_tests/test_others.py | Adds endpoint tests locking in error-envelope normalization for legacy others.py routes (and masked/shadowed behaviors). |
| backend/tests/a_tests/test_orders.py | Expands/adjusts endpoint-level integration tests for orders, including auth expectations and lab approval behavior. |
| backend/tests/a_tests/init.py | Initializes a_tests package for test discovery/import consistency. |
| backend/app/routes/orders.py | Enforces authentication on GET /api/orders/{id} and /history via Depends(get_current_user). |
| backend/app/repos/order_repo.py | Normalizes submitted labId (code/uuid) to canonical Lab.id when persisting order items; threads lab lookup map from validation. |
| backend/app/modules/reports/service.py | Re-fetches newly created report with eager-loading to avoid post-commit lazy loads on async sessions. |
| backend/app/modules/recipes/service.py | Refreshes recipe after commit to safely serialize server-updated updated_at without async lazy-load (MissingGreenlet). |
| backend/app/modules/recipes/repository.py | Adds refresh() method to support post-commit reloads. |
| backend/app/common/errors.py | Aligns ValidationError default status with HTTP_422_UNPROCESSABLE_CONTENT. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
314551176
approved these changes
Jun 2, 2026
314551176
approved these changes
Jun 2, 2026
ChuuuDwarf
approved these changes
Jun 2, 2026
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.
No description provided.