test: cover module access deep routes

This commit is contained in:
2026-08-17 09:24:33 +08:00
parent ebe55ba17a
commit 7da5b950ef
2 changed files with 16 additions and 3 deletions

View File

@@ -37,8 +37,8 @@
## Verification
- Red: `module-navigation.test.tsx` failed at `toBeDisabled()` while the static module definition remained enabled.
- Green after first review corrections: focused Vitest (`module-navigation`, `auth-store`, `auth-routes`, `app-module-provider-gate`) — 64 passed.
- Full Vitest — 175 files, 2042 tests passed. An earlier sandboxed run before the review corrections had one environmental `EPERM` because the test could not create worktree `.tmp`; every unrestricted full-suite rerun passed completely.
- Green after review corrections: focused Vitest (`module-navigation`, `auth-store`, `auth-routes`, `app-module-provider-gate`) — 69 passed.
- Full Vitest — 175 files, 2047 tests passed. An earlier sandboxed run before the review corrections had one environmental `EPERM` because the test could not create worktree `.tmp`; every unrestricted full-suite rerun passed completely.
- TypeScript `tsc --noEmit` — passed.
- Scoped ESLint for all changed TypeScript/TSX files — passed.
- Vite production build — passed (Renderer, Electron Main, and preload); existing chunk-size/dynamic-import warnings remain unchanged.
@@ -46,6 +46,7 @@
- Electron E2E was not extended because the shared fixture deliberately bypasses authentication and cannot express a Main-owned Works `/api/auth/me` policy; the user-visible chooser and direct-route behavior are covered at rendered App/Router seams.
- First independent Sol review — FAIL: found a cold-start Programming provider race, terminal `/api/auth/me` 401 fallback, and global `/settings` misclassification. The task returned to In Progress for corrections and re-review.
- Regression-first correction: the cold-start test failed before the Provider gate fix (`initProviders` called once while auth was unresolved), then passed after the fix. Added startup/login/refresh 401 lifecycle, Main-session clear, and Code-disabled global-settings coverage.
- Second independent Sol review — FAIL on test evidence only: production logic passed, but `/settings` Provider initialization and deep/alias pre-layout routing were not explicitly asserted. Added both assertions; the expanded focused and full suites pass.
## Follow-ups

View File

@@ -8,7 +8,11 @@ import { useSettingsStore } from '@/stores/settings';
import { useUserSyncStore } from '@/stores/user-sync';
vi.mock('@/components/layout/MainLayout', () => ({
MainLayout: () => <Outlet />,
MainLayout: () => (
<div data-testid="main-layout">
<Outlet />
</div>
),
}));
vi.mock('@/pages/AiHardware', () => ({
@@ -121,9 +125,14 @@ describe('App programming provider initialization gate', () => {
it.each([
['/opencode-chat', 'programming'],
['/workbench/project-1', 'programming'],
['/chat', 'programming'],
['/image-canvas', 'design'],
['/image-prompts/example', 'design'],
['/learning', 'learning'],
['/learning/course/course-1', 'learning'],
['/ai-hardware', 'robot'],
['/ai-hardware/device-1', 'robot'],
] as const)('redirects disabled %s routes before mounting their module', async (pathname, accessKey) => {
useAuthStore.setState({
moduleAccess: {
@@ -138,6 +147,7 @@ describe('App programming provider initialization gate', () => {
await renderAt(pathname);
expect(await screen.findByText('Module chooser')).toBeInTheDocument();
expect(screen.queryByTestId('main-layout')).not.toBeInTheDocument();
if (accessKey === 'programming') {
expect(initProviders).not.toHaveBeenCalled();
}
@@ -157,5 +167,7 @@ describe('App programming provider initialization gate', () => {
expect(await screen.findByText('Global settings')).toBeInTheDocument();
expect(screen.queryByText('Module chooser')).not.toBeInTheDocument();
expect(screen.getByTestId('main-layout')).toBeInTheDocument();
await waitFor(() => expect(initProviders).toHaveBeenCalledTimes(1));
});
});