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() })