Files
huike-e2e-moicen/tests/clazz-ui.spec.ts
T

40 lines
1.6 KiB
TypeScript
Raw Normal View History

2026-05-01 19:46:11 +08:00
import { expect, test } from './fixtures';
test.describe('排课页面 UI', () => {
test('排课日历页应正常加载(无JS崩溃)', async ({ page }) => {
await page.goto('/clazz', { waitUntil: 'domcontentloaded', timeout: 60_000 });
await expect(page.locator('#app')).toBeVisible({ timeout: 60_000 });
// FullCalendar 应初始化
await expect(page.locator('.fc')).toBeVisible({ timeout: 30_000 });
});
test('排课日历无报错', async ({ page }) => {
const errors: string[] = [];
page.on('pageerror', (err) => errors.push(err.message));
await page.goto('/clazz', { waitUntil: 'domcontentloaded', timeout: 60_000 });
await page.waitForTimeout(3000);
// 不应有 JS 运行时错误
expect(errors.filter(e => !e.includes('ResizeObserver') && !e.includes('not implemented'))).toEqual([]);
});
test('排课日历初始化后应显示基本骨架', async ({ page }) => {
await page.goto('/clazz', { waitUntil: 'domcontentloaded', timeout: 60_000 });
await expect(page.locator('#app')).toBeVisible({ timeout: 60_000 });
// FullCalendar 应有视图容器 (timeGridWeek)
await expect(page.locator('.fc-timegrid')).toBeVisible({ timeout: 30_000 });
// 应有表头
await expect(page.locator('.fc-toolbar')).toBeVisible({ timeout: 15_000 });
});
});
test.describe('审计日志 API', () => {
test('审计日志列表API应返回200', async ({ request }) => {
const resp = await request.get('/api/v1/clazz/audit-log/list?clazz_id=nonexistent');
// 未带有效 auth 应返回 401 或 400, 但不应 500
expect([400, 401, 403]).toContain(resp.status());
});
});