Skip to content

Commit e9171cc

Browse files
test(mobile): 新增 App 冒烟测试——Mobile 首测 2 passed
vite.config 新增 test.jsdom 环境配置,新增 @testing-library 依赖。
1 parent 25df320 commit e9171cc

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { describe, it, expect, vi } from 'vitest';
2+
import { render, screen } from '@testing-library/react';
3+
import '@testing-library/jest-dom/vitest';
4+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
5+
import { App } from '../App';
6+
7+
Element.prototype.scrollIntoView = vi.fn();
8+
9+
vi.mock('../native/mobileCommands', () => ({
10+
signIn: vi.fn(),
11+
checkSession: vi.fn(),
12+
clearSession: vi.fn(),
13+
testAlert: vi.fn(),
14+
}));
15+
16+
vi.mock('../native/hubHealth', () => ({
17+
checkHubHealth: vi.fn(() => Promise.resolve({ reachable: true })),
18+
}));
19+
20+
function renderWithProviders(ui: React.ReactElement) {
21+
const queryClient = new QueryClient({
22+
defaultOptions: { queries: { retry: false } },
23+
});
24+
return render(
25+
<QueryClientProvider client={queryClient}>{ui}</QueryClientProvider>,
26+
);
27+
}
28+
29+
describe('Mobile App', () => {
30+
it('renders the bottom navigation bar', () => {
31+
renderWithProviders(<App />);
32+
expect(screen.getByText('Threads')).toBeInTheDocument();
33+
});
34+
35+
it('starts on the threads view', () => {
36+
renderWithProviders(<App />);
37+
expect(screen.getByText('Threads')).toBeInTheDocument();
38+
});
39+
});

0 commit comments

Comments
 (0)