33 lines
1.2 KiB
TypeScript
33 lines
1.2 KiB
TypeScript
import { expect, test } from '@playwright/test';
|
|
|
|
test('应用外壳在桌面和移动视口均可正常呈现', async ({ page }) => {
|
|
const runtimeErrors: string[] = [];
|
|
|
|
page.on('console', (message) => {
|
|
if (message.type() === 'error' || message.type() === 'warning') {
|
|
runtimeErrors.push(message.text());
|
|
}
|
|
});
|
|
page.on('pageerror', (error) => runtimeErrors.push(error.message));
|
|
|
|
await page.goto('/');
|
|
|
|
await expect(page.locator('main')).toBeVisible();
|
|
await expect(page.getByText('A 股市场分析工具')).toBeVisible();
|
|
await expect(page.getByRole('heading', { name: '盘面先看结论,再看证据' })).toBeVisible();
|
|
|
|
const hasHorizontalOverflow = await page.evaluate(
|
|
() => document.documentElement.scrollWidth > document.documentElement.clientWidth,
|
|
);
|
|
expect(hasHorizontalOverflow).toBe(false);
|
|
expect(runtimeErrors).toEqual([]);
|
|
});
|
|
|
|
test('Web 通过同源代理访问真实 API 健康契约', async ({ request }) => {
|
|
const response = await request.get('/api/v1/health');
|
|
const body = (await response.json()) as { process?: string; status?: string };
|
|
|
|
expect(response.status()).toBe(200);
|
|
expect(body).toMatchObject({ process: 'api', status: 'healthy' });
|
|
});
|