test: cover module access deep routes
This commit is contained in:
@@ -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));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user