feat: P1 合盘/星座/问答与测测完整设计包及模拟器取证工具
落地 synastry/star/ask API 与 H5 页面,补齐 cece-frontend-re complete-design 证据文档,并加入 Android 模拟器截图抓取脚本。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
import { test, expect } from '@playwright/test'
|
||||
|
||||
function ok(data: unknown) {
|
||||
return {
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
body: JSON.stringify({ code: 0, message: 'success', data }),
|
||||
headers: { 'X-Device-Key': 'e2e-device' },
|
||||
}
|
||||
}
|
||||
|
||||
test('star / rhythm / cards pages render with mocked API', async ({ page }) => {
|
||||
await page.route('**/api/v1/**', async (route) => {
|
||||
const url = route.request().url()
|
||||
const method = route.request().method()
|
||||
|
||||
if (url.includes('/profiles') && method === 'POST') {
|
||||
await route.fulfill(ok({
|
||||
id: 'prof-e2e',
|
||||
user_id: 'u1',
|
||||
relation: 'self',
|
||||
display_name: '我',
|
||||
birth_date: '1983-06-06',
|
||||
created_at: new Date().toISOString(),
|
||||
}))
|
||||
return
|
||||
}
|
||||
if (url.includes('/reports/star') && method === 'POST') {
|
||||
await route.fulfill(ok({
|
||||
id: 'rep-star',
|
||||
type: 'star',
|
||||
has_deep_access: false,
|
||||
summary: { headline: 'E2E星象', one_liner: '星象摘要', keywords: ['灵活'] },
|
||||
detail: null,
|
||||
created_at: new Date().toISOString(),
|
||||
}))
|
||||
return
|
||||
}
|
||||
if (url.includes('/reports/rhythm') && method === 'POST') {
|
||||
await route.fulfill(ok({
|
||||
id: 'rep-rhythm',
|
||||
type: 'rhythm',
|
||||
has_deep_access: false,
|
||||
summary: { headline: 'E2E节律', one_liner: '节律摘要' },
|
||||
detail: null,
|
||||
created_at: new Date().toISOString(),
|
||||
}))
|
||||
return
|
||||
}
|
||||
if (url.includes('/image-cards/scenes')) {
|
||||
await route.fulfill(ok({ items: [{ key: '情绪整理', label: '情绪整理' }] }))
|
||||
return
|
||||
}
|
||||
if (url.includes('/image-cards/quota')) {
|
||||
await route.fulfill(ok({ remaining: 3, daily_free: 3, unlimited: false }))
|
||||
return
|
||||
}
|
||||
if (url.includes('/image-cards/draw') && method === 'POST') {
|
||||
await route.fulfill(ok({
|
||||
scene: '情绪整理',
|
||||
quota_left: 2,
|
||||
cards: [{
|
||||
id: 'c01', title: 'E2E卡片', imagery: '意象', prompt: '反思?', tip: '一小步',
|
||||
}],
|
||||
report: {
|
||||
id: 'rep-card',
|
||||
type: 'image_card',
|
||||
has_deep_access: false,
|
||||
summary: { headline: '意象探索' },
|
||||
detail: null,
|
||||
},
|
||||
}))
|
||||
return
|
||||
}
|
||||
if (url.includes('/solar-terms/today')) {
|
||||
await route.fulfill(ok({ name: '立秋', tip: '收敛节奏', date: '2026-08-02' }))
|
||||
return
|
||||
}
|
||||
if (url.includes('/moods/today')) {
|
||||
await route.fulfill(ok({ mood: null }))
|
||||
return
|
||||
}
|
||||
await route.fulfill(ok({}))
|
||||
})
|
||||
|
||||
await page.goto('/star?y=1983&m=6&d=6')
|
||||
await expect(page.getByRole('heading', { name: '星象性格' })).toBeVisible()
|
||||
await expect(page.getByText('E2E星象')).toBeVisible()
|
||||
await expect(page.getByRole('button', { name: /深度版/ })).toBeVisible()
|
||||
|
||||
await page.goto('/rhythm?y=1992&m=6&d=8')
|
||||
await expect(page.getByRole('heading', { name: '身心节律' })).toBeVisible()
|
||||
await expect(page.getByText('E2E节律')).toBeVisible()
|
||||
|
||||
await page.goto('/cards')
|
||||
await expect(page.getByRole('heading', { name: '意象卡片' })).toBeVisible()
|
||||
await page.locator('input[type="number"]').nth(0).fill('1990')
|
||||
await page.locator('input[type="number"]').nth(1).fill('5')
|
||||
await page.locator('input[type="number"]').nth(2).fill('12')
|
||||
await page.getByRole('button', { name: '抽取卡片' }).click()
|
||||
await expect(page.getByText('E2E卡片')).toBeVisible()
|
||||
|
||||
await page.goto('/companion')
|
||||
await expect(page.getByText('立秋')).toBeVisible()
|
||||
await expect(page.getByText('今日心情')).toBeVisible()
|
||||
})
|
||||
Reference in New Issue
Block a user