Files
digital-psychology/apps/user-h5/e2e/portrait-main-path.spec.ts
T
jackyu66gitandCursor 69fa1b85d6 fix(ECR-001): 对齐 Playwright e2e 与 /psy/ base 及现 UI
E2E 改走 /psy 路径并更新过时文案断言,恢复 L3 冒烟;补充 Phase F QA 报告。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-05 18:34:11 +08:00

72 lines
2.4 KiB
TypeScript

import { test, expect } from '@playwright/test'
/** L3: Home → Portrait path with mocked API (membership lexicon + deep gate). */
test('home birth form opens portrait with summary and deep CTA', async ({ page }) => {
await page.route('**/api/v1/**', async (route) => {
const req = route.request()
const url = req.url()
const method = req.method()
if (url.includes('/profiles') && method === 'POST') {
await route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({
code: 0,
message: 'success',
data: {
id: 'prof-e2e',
user_id: 'u1',
relation: 'self',
display_name: '我',
birth_date: '1990-05-12',
created_at: new Date().toISOString(),
},
}),
headers: { 'X-Device-Key': 'e2e-device' },
})
return
}
if (url.includes('/reports/portrait') && method === 'POST') {
await route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({
code: 0,
message: 'success',
data: {
id: 'rep-e2e',
has_deep_access: false,
type: 'portrait',
summary: {
headline: 'E2E画像',
one_liner: '模拟摘要',
life_tip: '好好睡觉',
keywords: ['稳'],
},
detail: null,
created_at: new Date().toISOString(),
},
}),
})
return
}
await route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({ code: 0, message: 'success', data: {} }),
})
})
await page.goto('/psy/')
await expect(page.getByRole('navigation', { name: '主导航' })).toBeVisible()
await expect(page.locator('header').getByRole('button', { name: '添加档案' })).toBeVisible()
await page.goto('/psy/portrait?y=1990&m=5&d=12')
await expect(page.getByRole('navigation', { name: '主导航' })).toBeVisible()
await expect(page.getByRole('heading', { name: '愈心解码' })).toBeVisible()
await expect(page.getByText('模拟摘要').first()).toBeVisible()
await expect(page.getByRole('link', { name: /在报告页打开/ })).toBeVisible()
await expect(page.getByRole('button', { name: /解锁完整分析/ }).first()).toBeVisible()
})