收口 Makelore 客户端变更
Some checks failed
Electron E2E / Electron E2E (macos-latest) (push) Has been cancelled
Electron E2E / Electron E2E (ubuntu-latest) (push) Has been cancelled
Electron E2E / Electron E2E (windows-latest) (push) Has been cancelled

This commit is contained in:
inman
2026-08-12 22:35:06 +08:00
parent 253bad8b40
commit f4113a872f
232 changed files with 4617 additions and 20121 deletions

View File

@@ -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');
});
});