|
1 | 1 | import '@testing-library/jest-dom/vitest'; |
2 | | -import { cleanup, fireEvent, render, screen } from '@testing-library/react'; |
3 | | -import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; |
| 2 | +import { cleanup, render } from '@testing-library/react'; |
| 3 | +import { afterEach, describe, expect, it } from 'vitest'; |
4 | 4 |
|
5 | | -import i18n from '@/i18n'; |
6 | 5 | import App from '@/App'; |
7 | 6 |
|
8 | | -vi.mock('@lobehub/icons', () => ({ |
9 | | - ClaudeCode: () => <span data-testid="icon-claude-code" />, |
10 | | - Codex: () => <span data-testid="icon-codex" />, |
11 | | - ModelIcon: () => <span data-testid="icon-model" />, |
12 | | - OpenCode: () => <span data-testid="icon-opencode" />, |
13 | | -})); |
14 | | - |
15 | | -vi.mock('@/views/viewRegistry', () => ({ |
16 | | - Slot: ({ name }: { name: string }) => <div data-testid={`slot-${name}`}>{name}</div>, |
17 | | -})); |
18 | | - |
19 | | -vi.mock('@/components/SettingsPage', () => ({ |
20 | | - default: () => <div data-testid="settings-page">Settings route content</div>, |
21 | | -})); |
22 | | - |
23 | | -vi.mock('@/components/AuthPage', () => ({ |
24 | | - default: () => <div data-testid="auth-page">Auth route content</div>, |
25 | | -})); |
26 | | - |
27 | 7 | function visibleText(container: HTMLElement) { |
28 | 8 | const clone = container.cloneNode(true) as HTMLElement; |
29 | 9 | clone.querySelectorAll('style, script').forEach((node) => node.remove()); |
30 | 10 | return clone.textContent ?? ''; |
31 | 11 | } |
32 | 12 |
|
33 | | -function renderShell() { |
34 | | - return render(<App />); |
35 | | -} |
36 | | - |
37 | | -describe('Web shell', () => { |
38 | | - beforeEach(async () => { |
39 | | - window.localStorage.clear(); |
40 | | - vi.stubGlobal('matchMedia', vi.fn().mockReturnValue({ |
41 | | - addEventListener: vi.fn(), |
42 | | - addListener: vi.fn(), |
43 | | - dispatchEvent: vi.fn(), |
44 | | - matches: false, |
45 | | - media: '', |
46 | | - onchange: null, |
47 | | - removeEventListener: vi.fn(), |
48 | | - removeListener: vi.fn(), |
49 | | - })); |
50 | | - await i18n.changeLanguage('en'); |
51 | | - }); |
52 | | - |
| 13 | +describe('Web app root', () => { |
53 | 14 | afterEach(() => { |
54 | 15 | cleanup(); |
55 | | - vi.unstubAllGlobals(); |
56 | 16 | }); |
57 | 17 |
|
58 | | - it('renders the workspace shell without raw shell keys or fake live claims', () => { |
59 | | - const { container } = renderShell(); |
| 18 | + it('mounts the provider shell without legacy demo chrome', () => { |
| 19 | + const { container } = render(<App />); |
60 | 20 | const text = visibleText(container); |
61 | 21 |
|
62 | | - expect(screen.getByText('AgentHub')).toBeInTheDocument(); |
63 | | - expect(screen.getByTestId('slot-agent-list')).toBeInTheDocument(); |
64 | | - expect(screen.getByTestId('slot-thread-panel')).toBeInTheDocument(); |
65 | | - expect(screen.getByTestId('slot-main-view')).toBeInTheDocument(); |
66 | | - expect(screen.getByTestId('slot-prompt-input')).toBeInTheDocument(); |
67 | | - fireEvent.click(screen.getByRole('button', { name: 'Open run detail' })); |
68 | | - expect(screen.getByTestId('slot-run-detail')).toBeInTheDocument(); |
69 | | - expect(text).toContain('Hub path idle'); |
70 | | - expect(text).toContain('Sign in for realtime'); |
| 22 | + expect(container.firstElementChild).toBeInstanceOf(HTMLDivElement); |
| 23 | + expect(text).toBe(''); |
71 | 24 | expect(text).not.toMatch(/shell\.(?:brand|toolbar|status|sidebar|statusPanel|workspace|page|source)/); |
72 | 25 | expect(text).not.toMatch(/synced|marketplace connected|session active/i); |
73 | 26 | }); |
74 | | - |
75 | | - it('switches between workspace, messages, and settings surfaces', () => { |
76 | | - renderShell(); |
77 | | - |
78 | | - fireEvent.click(screen.getByRole('tab', { name: 'Messages' })); |
79 | | - expect(screen.getByTestId('slot-im-view')).toBeInTheDocument(); |
80 | | - |
81 | | - fireEvent.click(screen.getByRole('tab', { name: 'Workspace' })); |
82 | | - expect(screen.getByTestId('slot-main-view')).toBeInTheDocument(); |
83 | | - |
84 | | - fireEvent.click(screen.getByRole('button', { name: 'Settings' })); |
85 | | - expect(screen.getByTestId('settings-page')).toBeInTheDocument(); |
86 | | - }); |
87 | | - |
88 | | - it('keeps explicit source state labels visible in the shell chrome', () => { |
89 | | - renderShell(); |
90 | | - |
91 | | - expect(screen.getByText('Hub path idle')).toBeInTheDocument(); |
92 | | - expect(screen.getByText('Sign in for realtime')).toBeInTheDocument(); |
93 | | - expect(screen.getByRole('button', { name: 'Sign in' })).toBeInTheDocument(); |
94 | | - }); |
95 | 27 | }); |
0 commit comments