落地 synastry/star/ask API 与 H5 页面,补齐 cece-frontend-re complete-design 证据文档,并加入 Android 模拟器截图抓取脚本。 Co-authored-by: Cursor <cursoragent@cursor.com>
112 lines
3.9 KiB
TypeScript
112 lines
3.9 KiB
TypeScript
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||
import { mount, flushPromises } from '@vue/test-utils'
|
||
import SynastryPage from './SynastryPage.vue'
|
||
|
||
const { api } = vi.hoisted(() => ({
|
||
api: {
|
||
listProfiles: vi.fn(),
|
||
createProfile: vi.fn(),
|
||
createSynastry: vi.fn(),
|
||
createSynastryInvite: vi.fn(),
|
||
listSynastryNearby: vi.fn(),
|
||
updateProfile: vi.fn(),
|
||
getReport: vi.fn(),
|
||
createOrder: vi.fn(),
|
||
payMock: vi.fn(),
|
||
},
|
||
}))
|
||
|
||
vi.mock('../api/client', () => ({ api }))
|
||
vi.mock('vue-router', () => ({
|
||
useRoute: () => ({ query: {} }),
|
||
useRouter: () => ({ back: vi.fn() }),
|
||
}))
|
||
|
||
describe('SynastryPage', () => {
|
||
beforeEach(() => {
|
||
vi.clearAllMocks()
|
||
api.listProfiles.mockResolvedValue({
|
||
items: [
|
||
{ id: 'a1', relation: 'self', display_name: '我', birth_date: '1990-05-12' },
|
||
{ id: 'b1', relation: 'other', display_name: 'TA', birth_date: '1992-08-20' },
|
||
],
|
||
})
|
||
})
|
||
|
||
it('generates synastry and shows paywall without deep access', async () => {
|
||
api.createSynastry.mockResolvedValue({
|
||
id: 'r1',
|
||
has_deep_access: false,
|
||
summary: {
|
||
headline: '我 × TA:恋爱 80 · 友情 70 · 婚姻 75',
|
||
one_liner: '五盘合观',
|
||
as_of: '2026-08-02',
|
||
love_index: 80,
|
||
friend_index: 70,
|
||
marriage_index: 75,
|
||
love_note: '恋爱说明',
|
||
me_name: '我',
|
||
other_name: 'TA',
|
||
chart_a: {
|
||
asc_lon: 10,
|
||
planets: [{ key: 'sun', title: '太阳', sign: '金牛', degree: '1°', house: 1, lon: 40 }],
|
||
},
|
||
chart_b: {
|
||
asc_lon: 20,
|
||
planets: [{ key: 'sun', title: '太阳', sign: '狮子', degree: '2°', house: 1, lon: 122 }],
|
||
},
|
||
aspects_preview: [{ label: '我方太阳合相对方月亮(容许1.0°)' }],
|
||
charts: {
|
||
compare: { tip: '比较盘提示' },
|
||
composite: {
|
||
tip: '组合盘:关系整体气质。',
|
||
asc_lon: 30,
|
||
planets: [{ key: 'sun', title: '太阳', sign: '双子', degree: '3°', house: 1, lon: 63 }],
|
||
aspects_preview: [{ label: '太阳六合月亮(容许2.0°)' }],
|
||
},
|
||
composite_progressed: {
|
||
tip: '组合次限',
|
||
planets: [{ key: 'sun', title: '太阳', sign: '巨蟹', degree: '4°', house: 1, lon: 94 }],
|
||
aspects_preview: [],
|
||
},
|
||
davison: { tip: '时空', planets: [], aspects_preview: [] },
|
||
marks_me: { tip: '马克斯我', planets: [], aspects_preview: [] },
|
||
marks_other: { tip: '马克斯TA', planets: [], aspects_preview: [] },
|
||
overlay: {
|
||
tip: '配对盘提示',
|
||
entries: [{ planet: '太阳', sign: '狮子', house: 5, house_tip: '恋爱表达与创造' }],
|
||
},
|
||
davison_progressed: { tip: '时空次限', planets: [], aspects_preview: [] },
|
||
marks_progressed: { tip: '马盘推运', planets: [], aspects_preview: [] },
|
||
},
|
||
},
|
||
detail: null,
|
||
})
|
||
|
||
const w = mount(SynastryPage, { global: { stubs: { RouterLink: true } } })
|
||
await flushPromises()
|
||
await w.find('button.yxg-btn-block').trigger('click')
|
||
await flushPromises()
|
||
expect(api.createSynastry).toHaveBeenCalled()
|
||
const args = api.createSynastry.mock.calls[0]
|
||
expect(args[0]).toBe('a1')
|
||
expect(args[1]).toBe('b1')
|
||
expect(w.text()).toContain('80')
|
||
expect(w.text()).toContain('解锁完整合盘')
|
||
expect(w.text()).not.toContain('相处深析')
|
||
|
||
// switch to composite tab
|
||
const tabs = w.findAll('button.tab')
|
||
const comp = tabs.find((t) => t.text() === '组合')
|
||
expect(comp).toBeTruthy()
|
||
await comp!.trigger('click')
|
||
await flushPromises()
|
||
expect(w.text()).toContain('组合盘:关系整体气质')
|
||
|
||
const prog = w.findAll('button.stab').find((t) => t.text() === '次限')
|
||
await prog!.trigger('click')
|
||
await flushPromises()
|
||
expect(w.text()).toContain('组合次限')
|
||
})
|
||
})
|