Makelore 2.0 initial clean snapshot
This commit is contained in:
54
tests/unit/main-layout-module-gate.test.tsx
Normal file
54
tests/unit/main-layout-module-gate.test.tsx
Normal file
@@ -0,0 +1,54 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { MemoryRouter, Route, Routes } from 'react-router-dom';
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { MainLayout } from '@/components/layout/MainLayout';
|
||||
import { useOpencodeStore } from '@/stores/opencode';
|
||||
import { useProjectConfigStore } from '@/stores/project-config';
|
||||
import { createProjectConfig } from '../../shared/project-config';
|
||||
|
||||
vi.mock('@/components/layout/Sidebar', () => ({ Sidebar: () => <aside data-testid="sidebar-stub" /> }));
|
||||
vi.mock('@/components/layout/TitleBar', () => ({ TitleBar: () => <header data-testid="titlebar-stub" /> }));
|
||||
|
||||
function renderLayout(path: string) {
|
||||
render(
|
||||
<MemoryRouter initialEntries={[path]}>
|
||||
<Routes>
|
||||
<Route element={<MainLayout />}>
|
||||
<Route path="*" element={<div data-testid="route-content" />} />
|
||||
</Route>
|
||||
</Routes>
|
||||
</MemoryRouter>,
|
||||
);
|
||||
}
|
||||
|
||||
describe('MainLayout module isolation', () => {
|
||||
beforeEach(() => {
|
||||
const project = {
|
||||
id: 'local-project',
|
||||
path: '/tmp/local-project',
|
||||
name: 'local-project',
|
||||
createdAt: '',
|
||||
updatedAt: '',
|
||||
lastOpenedAt: '',
|
||||
};
|
||||
useOpencodeStore.setState({ activeProject: project });
|
||||
useProjectConfigStore.setState({
|
||||
configsByProjectId: {
|
||||
[project.id]: { ...createProjectConfig('standard-development'), initialized: false },
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('does not overlay the local project initialization gate on AI painting', () => {
|
||||
renderLayout('/image-canvas');
|
||||
|
||||
expect(screen.getByTestId('route-content')).toBeVisible();
|
||||
expect(screen.queryByTestId('project-initialization-gate')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('keeps the local project initialization gate for AI programming routes', () => {
|
||||
renderLayout('/opencode-chat');
|
||||
|
||||
expect(screen.getByTestId('project-initialization-gate')).toBeVisible();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user