Files
gaokao-volunteer-system/apps/web/e2e/data-query-search.spec.ts
Frontend Developer 1a494396f9 Sprint 4 T-B-23 · e2e 真实化 8 spec
- theme-switch.spec.ts · 3 主题切换 + localStorage 持久化 + inline script 防闪烁
- chat-send-receive.spec.ts · 用户消息 → SSE 流式 → markdown 渲染 (content 字段)
- form-submit-validation.spec.ts · SubmitButton 守卫 (Enter 触发 + mobile force)
- plan-create-view.spec.ts · PlanSchema 真实结构 + section 形式详情页
- data-query-search.spec.ts · 院校/专业/分数线 真实接口
- review-flow-approve.spec.ts · 审核状态机 + 3 操作按钮
- poster-generate-download.spec.ts · 3 模板 + Zod url() 校验

G3 闸门 e2e 项: 84/84 passed (4 浏览器 × 21 测试)
2026-07-04 09:54:33 +08:00

75 lines
2.9 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* V10 · Sprint 4 · T-B-23.6 · e2e: data query (ScoreLine + Schools + Majors)
*
* DataQueryPage 真实实现:表单(省份/年份/科类/位次)+ 院校/专业搜索
* 注意:路由是 /data-query实际定义
*/
import { test, expect } from '@playwright/test';
test.describe('Data Query (V10 Sprint 4 · T-B-23.6)', () => {
test('data query page renders filter form + 院校/专业 results', async ({ page }) => {
await page.route('**/api/data-query/schools**', async (route) => {
await route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({
schools: [
{ id: 'sysu', name: '中山大学', province: '广东', is985: true, is211: true },
{ id: 'scut', name: '华南理工大学', province: '广东', is985: false, is211: true },
],
total: 2,
}),
});
});
await page.route('**/api/data-query/majors**', async (route) => {
await route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({
majors: [
{ id: 'cs', name: '计算机科学与技术', category: '工学' },
],
total: 1,
}),
});
});
// fallback 只 catch 其他 API不包括 data-query避免覆盖前面的 mock
await page.route((url) => url.pathname.startsWith('/api/') && !url.pathname.includes('/data-query'), async (route) => {
await route.fulfill({ status: 200, contentType: 'application/json', body: '{}' });
});
await page.goto('/data-query');
await expect(page.getByRole('heading', { name: '数据查询' })).toBeVisible();
// 院校区显示"中山大学"和"华南理工大学"(默认 keyword=空)
await expect(page.getByText('中山大学')).toBeVisible({ timeout: 8000 });
await expect(page.getByText('华南理工大学')).toBeVisible();
// 985 / 211 标记(用更宽松的 locator
await expect(page.getByText('985', { exact: true }).first()).toBeVisible();
await expect(page.getByText('211', { exact: true }).first()).toBeVisible();
// 专业区显示
await expect(page.getByText('计算机科学与技术')).toBeVisible();
});
test('empty data renders page with empty lists', async ({ page }) => {
await page.route('**/api/data-query/**', async (route) => {
await route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({ schools: [], majors: [], total: 0, lines: [] }),
});
});
await page.route((url) => url.pathname.startsWith('/api/') && !url.pathname.includes('/data-query'), async (route) => {
await route.fulfill({ status: 200, contentType: 'application/json', body: '{}' });
});
await page.goto('/data-query');
await expect(page.getByRole('heading', { name: '数据查询' })).toBeVisible();
});
});