收口 Makelore 客户端变更
This commit is contained in:
@@ -14,6 +14,14 @@ function LocationProbe() {
|
||||
describe('AI module navigation', () => {
|
||||
beforeEach(() => {
|
||||
useAuthStore.setState({
|
||||
initialized: true,
|
||||
loading: false,
|
||||
accessToken: 'access-token',
|
||||
tokenType: 'Bearer',
|
||||
expiresAt: Date.now() + 60_000,
|
||||
lastActiveAt: Date.now(),
|
||||
canRefresh: true,
|
||||
legacyRefreshToken: null,
|
||||
user: { username: 'zhangsan@example.com', userId: 'user-1', tenantId: null, deptId: null, authorities: [] },
|
||||
});
|
||||
useOpencodeStore.setState({ activeProject: null });
|
||||
@@ -71,6 +79,32 @@ describe('AI module navigation', () => {
|
||||
expect(await screen.findByTestId('location-path')).toHaveTextContent('/opencode-chat');
|
||||
});
|
||||
|
||||
it('keeps the chooser public and sends signed-out users to login when they choose a module', async () => {
|
||||
useAuthStore.setState({
|
||||
accessToken: null,
|
||||
tokenType: null,
|
||||
expiresAt: null,
|
||||
lastActiveAt: null,
|
||||
canRefresh: false,
|
||||
legacyRefreshToken: null,
|
||||
user: null,
|
||||
});
|
||||
|
||||
render(
|
||||
<MemoryRouter initialEntries={['/module-select']}>
|
||||
<Routes>
|
||||
<Route path="/module-select" element={<ModuleSelection />} />
|
||||
<Route path="*" element={<LocationProbe />} />
|
||||
</Routes>
|
||||
</MemoryRouter>,
|
||||
);
|
||||
|
||||
expect(screen.getByTestId('ai-module-selection-page')).toBeInTheDocument();
|
||||
|
||||
fireEvent.click(screen.getByTestId('ai-module-option-programming'));
|
||||
expect(await screen.findByTestId('location-path')).toHaveTextContent('/login');
|
||||
});
|
||||
|
||||
it('keeps the current module active and switches from the Sidebar entry', async () => {
|
||||
render(
|
||||
<MemoryRouter initialEntries={['/image-canvas']}>
|
||||
@@ -82,7 +116,8 @@ describe('AI module navigation', () => {
|
||||
|
||||
expect(screen.getByTestId('sidebar-module-switcher-trigger')).toHaveAttribute('aria-expanded', 'false');
|
||||
expect(screen.getByTestId('sidebar-module-switcher-trigger')).toHaveTextContent('绘画 Canvas');
|
||||
expect(screen.queryByTestId('sidebar-module-painting')).not.toBeInTheDocument();
|
||||
expect(screen.getByTestId('sidebar-module-switcher-menu')).toHaveAttribute('data-state', 'closed');
|
||||
expect(screen.getByTestId('sidebar-module-painting')).toBeInTheDocument();
|
||||
|
||||
fireEvent.click(screen.getByTestId('sidebar-module-switcher-trigger'));
|
||||
expect(screen.getByTestId('sidebar-module-switcher-menu')).toBeInTheDocument();
|
||||
@@ -99,4 +134,15 @@ describe('AI module navigation', () => {
|
||||
fireEvent.click(screen.getByTestId('sidebar-module-programming'));
|
||||
expect(await screen.findByTestId('location-path')).toHaveTextContent('/opencode-chat');
|
||||
});
|
||||
|
||||
it('keeps breathing room around the compact module switcher trigger', () => {
|
||||
render(
|
||||
<MemoryRouter initialEntries={['/opencode-chat']}>
|
||||
<ModuleSwitcher sidebarCollapsed={false} compact />
|
||||
</MemoryRouter>,
|
||||
);
|
||||
|
||||
const trigger = screen.getByTestId('sidebar-module-switcher-trigger');
|
||||
expect(trigger).toHaveClass('inline-flex', 'w-fit', 'px-2');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user