/**
* M03-01 客户主数据 - CustomerList 组件渲染测试骨架
*/
import { describe, it, expect, beforeEach, vi } from 'vitest'
import { mount } from '@vue/test-utils'
import { setActivePinia, createPinia } from 'pinia'
vi.mock('@/api/mdmCustomer/index', () => ({
findCrmCustomerPage: vi.fn().mockResolvedValue({
code: 800,
data: { rows: [], total: 0 },
}),
saveCrmCustomer: vi.fn(),
updateCrmCustomer: vi.fn(),
getCrmCustomerById: vi.fn(),
findAddressListByCustomerId: vi.fn(),
saveCrmCustomerAddress: vi.fn(),
deleteCrmCustomerAddress: vi.fn(),
}))
vi.mock('vue-i18n', () => ({
useI18n: () => ({ t: (key: string) => key }),
}))
import CustomerList from '@/views/mdmCustomer/index.vue'
const globalStubs = {
'el-card': { template: '
' },
'el-breadcrumb': { template: '
' },
'el-breadcrumb-item': { template: '' },
'el-alert': { template: '
' },
'el-form': { template: '' },
'el-form-item': { template: '
' },
'el-input': { template: '' },
'el-select': { template: '' },
'el-option': { template: '' },
'gs-table': { template: '
' },
'el-button': { template: '' },
'el-tag': { template: '' },
'el-link': { template: '' },
'el-divider': { template: '' },
'CustomerFormDialog': { template: '' },
'CustomerDetailDrawer': { template: '' },
'AddressFormDialog': { template: '' },
'ConfirmDialog': { template: '' },
}
const globalMocks = {
$t: (key: string) => key,
}
describe('CustomerList 组件', () => {
beforeEach(() => {
setActivePinia(createPinia())
vi.clearAllMocks()
})
it('页面挂载成功', () => {
const wrapper = mount(CustomerList, {
global: { stubs: globalStubs, mocks: globalMocks },
})
expect(wrapper.exists()).toBe(true)
})
it('面包屑渲染', () => {
const wrapper = mount(CustomerList, {
global: { stubs: globalStubs, mocks: globalMocks },
})
const text = wrapper.text()
expect(text).toContain('M03 客户')
expect(text).toContain('M03-01')
})
it('状态流转提示条', () => {
const wrapper = mount(CustomerList, {
global: { stubs: globalStubs, mocks: globalMocks },
})
const text = wrapper.text()
expect(text).toContain('statusFlow')
expect(text).toContain('statusFlowDesc')
})
it('新增客户按钮存在', () => {
const wrapper = mount(CustomerList, {
global: { stubs: globalStubs, mocks: globalMocks },
})
expect(wrapper.text()).toContain('mdmCustomer.addCustomer')
})
})