From 7da5b950eff6d628197d1379da3ae31148ae9f11 Mon Sep 17 00:00:00 2001 From: brother7 <7brother7@gmail.com> Date: Mon, 17 Aug 2026 09:24:33 +0800 Subject: [PATCH] test: cover module access deep routes --- .../20260817-makelore-module-access-6f2a91c4.md | 5 +++-- tests/unit/app-module-provider-gate.test.tsx | 14 +++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.project-docs/30-worklog/tasks/20260817-makelore-module-access-6f2a91c4.md b/.project-docs/30-worklog/tasks/20260817-makelore-module-access-6f2a91c4.md index 8746f52..f563993 100644 --- a/.project-docs/30-worklog/tasks/20260817-makelore-module-access-6f2a91c4.md +++ b/.project-docs/30-worklog/tasks/20260817-makelore-module-access-6f2a91c4.md @@ -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 diff --git a/tests/unit/app-module-provider-gate.test.tsx b/tests/unit/app-module-provider-gate.test.tsx index 33e0831..670d484 100644 --- a/tests/unit/app-module-provider-gate.test.tsx +++ b/tests/unit/app-module-provider-gate.test.tsx @@ -8,7 +8,11 @@ import { useSettingsStore } from '@/stores/settings'; import { useUserSyncStore } from '@/stores/user-sync'; vi.mock('@/components/layout/MainLayout', () => ({ - MainLayout: () => , + MainLayout: () => ( +
+ +
+ ), })); 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)); }); });