feat(platform): surface amap operations shortcuts
This commit is contained in:
@@ -5,6 +5,7 @@ import App from '../App';
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
window.history.replaceState(null, '', '/');
|
||||
delete window.__LINGNIU_APP_CONFIG__;
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
@@ -14,6 +15,39 @@ test('renders vehicle platform shell', () => {
|
||||
expect(screen.getAllByText('总览工作台').length).toBeGreaterThanOrEqual(1);
|
||||
});
|
||||
|
||||
test('exposes AMap operations shortcuts when map key is configured', async () => {
|
||||
window.__LINGNIU_APP_CONFIG__ = { amapWebJsKey: 'amap-web-key' };
|
||||
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
|
||||
const path = String(input);
|
||||
if (path.includes('/api/ops/health')) {
|
||||
return {
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: { linkHealth: [], kafkaLag: 0, redisOnlineKeys: 0, tdengineWritable: true, mysqlWritable: true, runtime: { requestTimeoutMs: 5000 } },
|
||||
traceId: 'trace-test',
|
||||
timestamp: 1783094400000
|
||||
})
|
||||
} as Response;
|
||||
}
|
||||
return {
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: { items: [], total: 0, limit: 50, offset: 0 },
|
||||
traceId: 'trace-test',
|
||||
timestamp: 1783094400000
|
||||
})
|
||||
} as Response;
|
||||
});
|
||||
|
||||
render(<App />);
|
||||
|
||||
expect(await screen.findByText('地图就绪')).toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole('button', { name: '实时地图' }));
|
||||
expect(window.location.hash).toBe('#/realtime');
|
||||
fireEvent.click(screen.getByRole('button', { name: '地图回放' }));
|
||||
expect(window.location.hash.startsWith('#/history')).toBe(true);
|
||||
});
|
||||
|
||||
test('shows vehicle service status distribution on dashboard', async () => {
|
||||
window.history.replaceState(null, '', '/#/dashboard');
|
||||
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
|
||||
|
||||
Reference in New Issue
Block a user