chore: 清理旧测试基础设施并添加新测试框架

- 清理废弃的 CI/CD 工作流文件与 dogfood 输出
- 添加 vitest 测试环境配置(mocks、setup 文件)
- 添加算法、服务、页面、工具类的单元测试
- 更新 vitest 配置、依赖与文档
This commit is contained in:
2026-08-12 18:53:15 +08:00
parent 039fbe4f4c
commit 0f8b29874f
37 changed files with 3511 additions and 617 deletions
@@ -0,0 +1,41 @@
import { describe, it, expect, vi } from 'vitest'
import { mount } from '@vue/test-utils'
import { createI18n } from 'vue-i18n'
import FortunePage from '../index.vue'
const i18n = createI18n({
legacy: false,
locale: 'zh-CN',
messages: {
'zh-CN': {
fortune: {
daily: '日运',
monthly: '月运',
yearly: '年运',
},
},
},
})
function mountPage() {
return mount(FortunePage, {
global: {
plugins: [i18n],
stubs: {
picker: true,
},
},
})
}
describe('FortunePage', () => {
it('应包含运势类型切换', () => {
const wrapper = mountPage()
expect(wrapper.find('[data-test="fortune-tabs"]').exists()).toBe(true)
})
it('默认应显示日运', () => {
const wrapper = mountPage()
expect(wrapper.vm.activeTab).toBe('daily')
})
})
@@ -0,0 +1,47 @@
import { describe, it, expect, vi } from 'vitest'
import { mount } from '@vue/test-utils'
import { createI18n } from 'vue-i18n'
import ZiweiPage from '../index.vue'
const i18n = createI18n({
legacy: false,
locale: 'zh-CN',
messages: {
'zh-CN': {
ziwei: {
generateChart: '排盘',
birthTime: '出生时间',
gender: '性别',
},
},
},
})
function mountPage() {
return mount(ZiweiPage, {
global: {
plugins: [i18n],
stubs: {
picker: true,
},
},
})
}
describe('ZiweiPage', () => {
it('应包含出生信息输入表单', () => {
const wrapper = mountPage()
expect(wrapper.find('[data-test="birth-form"]').exists()).toBe(true)
})
it('应包含排盘按钮', () => {
const wrapper = mountPage()
expect(wrapper.find('[data-test="generate-btn"]').exists()).toBe(true)
})
it('点击排盘按钮应触发计算', async () => {
const wrapper = mountPage()
await wrapper.find('[data-test="generate-btn"]').trigger('click')
expect(wrapper.vm.isCalculating).toBeDefined()
})
})