Files
digital-psychology/apps/user-h5/e2e/portrait-main-path.spec.ts
T
jackyu66gitandCursor 5ceb3ce749
ci / h5 (push) Canceled after 0s
ci / api (push) Canceled after 0s
ci / ess-docs (push) Canceled after 0s
feat(ECR-010): Ops-E 系统运营;修复登出解绑;P2 Complete
落地管理员 RBAC/封禁/推送任务 stub,logout 解绑 device 并统一各页 ensureAccount,同时收口 P2 生日生成与状态文档。

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

94 lines
3.0 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('/auth/me')) {
await route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({
code: 0,
message: 'success',
data: { id: 'u1', phone: '13800000000' },
}),
headers: { 'X-Device-Key': 'e2e-device' },
})
return
}
if (url.includes('/profiles') && method === 'GET') {
await route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({ code: 0, message: 'success', data: { items: [] } }),
headers: { 'X-Device-Key': 'e2e-device' },
})
return
}
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: '愈心解码', level: 1 })).toBeVisible()
await expect(page.getByText('模拟摘要').first()).toBeVisible()
await expect(page.getByRole('link', { name: /在报告页打开/ })).toBeVisible()
await expect(page.getByRole('button', { name: /解锁完整分析/ }).first()).toBeVisible()
})