43 lines
1.6 KiB
TypeScript
43 lines
1.6 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
|
|
test.describe('列表页面', () => {
|
|
const listingPages = [
|
|
{ path: '/courses', title: '专题', skeleton: true },
|
|
{ path: '/prompts', title: '提示词', skeleton: true },
|
|
{ path: '/community', title: '社区', skeleton: true },
|
|
{ path: '/tools', title: 'AI 工具', skeleton: true },
|
|
{ path: '/contents', title: '文章', skeleton: true },
|
|
{ path: '/models', title: '模型', skeleton: false },
|
|
{ path: '/circles', title: '圈子', skeleton: false },
|
|
{ path: '/discover', title: '发现', skeleton: false },
|
|
{ path: '/dashboard', title: '控制台', skeleton: true },
|
|
];
|
|
|
|
for (const { path, title, skeleton } of listingPages) {
|
|
test.describe(`${path}`, () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await page.goto(path);
|
|
});
|
|
|
|
test('页面标题元素存在', async ({ page }) => {
|
|
const anyHeading = page.locator('h1, h2, h3, h4, [class*="text-2xl"], [class*="text-3xl"]');
|
|
const count = await anyHeading.count();
|
|
expect(count).toBeGreaterThanOrEqual(1);
|
|
});
|
|
|
|
test('页面能正常加载', async ({ page }) => {
|
|
await expect(page.locator('body')).not.toHaveText(/500/);
|
|
await expect(page.locator('body')).not.toHaveText(/Application Error/);
|
|
});
|
|
|
|
if (skeleton) {
|
|
test('加载骨架屏显示', async ({ page }) => {
|
|
const skeletons = page.locator('[class*="animate-pulse"], [class*="skeleton"]');
|
|
const count = await skeletons.count();
|
|
expect(count).toBeGreaterThanOrEqual(1);
|
|
});
|
|
}
|
|
});
|
|
}
|
|
});
|