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,92 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
import { mount, flushPromises } from '@vue/test-utils'
|
||||
import RelationPage from './RelationPage.vue'
|
||||
|
||||
const { api } = vi.hoisted(() => ({
|
||||
api: {
|
||||
listProfiles: vi.fn(),
|
||||
createProfile: vi.fn(),
|
||||
createRelationInsight: vi.fn(),
|
||||
createOrder: vi.fn(),
|
||||
payMock: vi.fn(),
|
||||
getReport: vi.fn(),
|
||||
},
|
||||
}))
|
||||
|
||||
vi.mock('../api/client', () => ({ api }))
|
||||
|
||||
vi.mock('vue-router', () => ({
|
||||
useRoute: () => ({ query: {} }),
|
||||
useRouter: () => ({ back: vi.fn() }),
|
||||
}))
|
||||
|
||||
describe('RelationPage', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
it('generates relation insight summary and gates tips', async () => {
|
||||
api.listProfiles.mockResolvedValue({
|
||||
items: [{ id: 'self1', relation: 'self', display_name: '我', birth_date: '1990-01-01' }],
|
||||
})
|
||||
api.createProfile.mockResolvedValue({ id: 'other1', relation: 'other' })
|
||||
api.createRelationInsight.mockResolvedValue({
|
||||
insight: { id: 'i1', report_id: 'rr1' },
|
||||
report: {
|
||||
id: 'rr1',
|
||||
has_deep_access: false,
|
||||
summary: {
|
||||
me_style: '我·稳',
|
||||
other_style: 'TA·活',
|
||||
diff_one_liner: '节奏不同',
|
||||
me_keywords: ['稳'],
|
||||
other_keywords: ['活'],
|
||||
},
|
||||
detail: null,
|
||||
},
|
||||
})
|
||||
|
||||
const w = mount(RelationPage)
|
||||
await w.findAll('button').find((b) => b.text().includes('开始匹配'))!.trigger('click')
|
||||
await flushPromises()
|
||||
expect(w.text()).toContain('我·稳')
|
||||
expect(w.text()).toContain('节奏不同')
|
||||
expect(w.text()).toContain('解锁完整分析')
|
||||
})
|
||||
|
||||
it('shows tips after deep_access pay', async () => {
|
||||
api.listProfiles.mockResolvedValue({
|
||||
items: [{ id: 'self1', relation: 'self', display_name: '我', birth_date: '1990-01-01' }],
|
||||
})
|
||||
api.createProfile.mockResolvedValue({ id: 'other1' })
|
||||
api.createRelationInsight.mockResolvedValue({
|
||||
insight: { id: 'i1' },
|
||||
report: {
|
||||
id: 'rr1',
|
||||
has_deep_access: false,
|
||||
summary: { me_style: 'A', other_style: 'B', diff_one_liner: 'D', me_keywords: [], other_keywords: [] },
|
||||
detail: null,
|
||||
},
|
||||
})
|
||||
api.createOrder.mockResolvedValue({ order_id: 'o1' })
|
||||
api.payMock.mockResolvedValue({ paid: true })
|
||||
api.getReport.mockResolvedValue({
|
||||
id: 'rr1',
|
||||
has_deep_access: true,
|
||||
summary: { me_style: 'A', other_style: 'B', diff_one_liner: 'D', me_keywords: [], other_keywords: [] },
|
||||
detail: {
|
||||
communication: ['先倾听'],
|
||||
interaction: ['留白'],
|
||||
maintenance: ['定期沟通'],
|
||||
},
|
||||
})
|
||||
|
||||
const w = mount(RelationPage)
|
||||
await w.findAll('button').find((b) => b.text().includes('开始匹配'))!.trigger('click')
|
||||
await flushPromises()
|
||||
await w.findAll('button').find((b) => b.text().includes('解锁完整分析'))!.trigger('click')
|
||||
await flushPromises()
|
||||
expect(w.text()).toContain('可执行建议')
|
||||
expect(w.text()).toContain('先倾听')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user