Files
digital-psychology/apps/user-h5/src/pages/StarProfilePage.spec.ts
T
jackyu66gitandCursor bd22d9dddd feat: P1 合盘/星座/问答与测测完整设计包及模拟器取证工具
落地 synastry/star/ask API 与 H5 页面,补齐 cece-frontend-re complete-design 证据文档,并加入 Android 模拟器截图抓取脚本。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-03 11:37:53 +08:00

73 lines
3.1 KiB
TypeScript

import { describe, it, expect, vi, beforeEach } from 'vitest'
import { mount, flushPromises } from '@vue/test-utils'
import StarProfilePage from './StarProfilePage.vue'
const { api, routeQuery } = vi.hoisted(() => ({
api: {
createProfile: vi.fn(),
createStar: vi.fn(),
getReport: vi.fn(),
createOrder: vi.fn(),
payMock: vi.fn(),
},
routeQuery: { y: '1990', m: '5', d: '12' } as Record<string, string>,
}))
vi.mock('../api/client', () => ({ api }))
vi.mock('vue-router', () => ({
useRoute: () => ({ query: routeQuery }),
useRouter: () => ({ back: vi.fn() }),
}))
const summary = {
headline: '小愈的星座更偏「稳健沉淀者」',
one_liner: '一句',
sign_cards: [{ key: 'sun', title: '太阳', label: '金牛', teaser: 't', element: '土', modality: '固定' }],
chart: { note: '热带黄道', asc_lon: 120, houses: [{ num: 1, sign: '狮子' }] },
planets: [
{ key: 'sun', title: '太阳', sign: '金牛', degree: '10.0°', house: 1, lon: 40, element: '土', modality: '固定' },
{ key: 'moon', title: '月亮', sign: '巨蟹', degree: '5.0°', house: 2, lon: 95, element: '水', modality: '开创' },
{ key: 'rise', title: '上升', sign: '狮子', degree: '0.0°', house: 1, lon: 120, element: '火', modality: '固定' },
],
aspects_preview: [{ a: 'sun', b: 'moon', type: 'square', orb: 2, label: '太阳刑相月亮(容许2.0°)', a_title: '太阳', b_title: '月亮' }],
fortune: {
daily: { title: '今日运势', label: '吉', score: 80, tip: 'tip', focus: '行动', lucky: '红', caution: '慢', dims: { love: 1, career: 2, money: 3, mood: 4 } },
lifetime: { title: '一生运势摘要', label: '平稳', score: 70, tip: '人生阶段', focus: '人生阶段', lucky: 'x', caution: 'y', dims: {} },
transits: [{ key: 't1', title: '行运太阳×本命太阳', aspect: '合相', tip: '推进' }],
},
transits: [{ key: 't1', title: '行运太阳×本命太阳', aspect: '合相', tip: '推进' }],
keywords: ['金牛'],
}
describe('StarProfilePage', () => {
beforeEach(() => {
vi.clearAllMocks()
api.createProfile.mockResolvedValue({ id: 'p1' })
api.createStar.mockResolvedValue({
id: 'r1',
has_deep_access: false,
summary,
detail: null,
})
})
it('shows natal wheel and free chart content', async () => {
const w = mount(StarProfilePage, { global: { stubs: { RouterLink: true } } })
await flushPromises()
expect(api.createStar).toHaveBeenCalled()
expect(w.find('svg.wheel').exists() || w.text().includes('本命')).toBe(true)
expect(w.text()).toContain('相位速览')
expect(w.text()).toContain('今日行运')
expect(w.find('svg.wheel').exists()).toBe(true)
})
it('shows lifetime fortune tab', async () => {
const w = mount(StarProfilePage, { global: { stubs: { RouterLink: true } } })
await flushPromises()
await w.findAll('button').find((b) => b.text() === '运势')!.trigger('click')
await w.findAll('button').find((b) => b.text() === '一生')!.trigger('click')
await flushPromises()
expect(w.text()).toContain('一生运势摘要')
})
})