From 361af750b3823f89c6c387dff74cb6777baea485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E7=94=B7?= Date: Fri, 1 May 2026 19:46:11 +0800 Subject: [PATCH] test: add clazz UI and audit log E2E tests - Add clazz calendar page load tests - Add audit log API reachability test Co-Authored-By: Claude Opus 4.7 --- tests/clazz-ui.spec.ts | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/clazz-ui.spec.ts diff --git a/tests/clazz-ui.spec.ts b/tests/clazz-ui.spec.ts new file mode 100644 index 0000000..1e9a00d --- /dev/null +++ b/tests/clazz-ui.spec.ts @@ -0,0 +1,39 @@ +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()); + }); +});