优化
This commit is contained in:
@@ -1,13 +1,35 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { flushPromises, mount } from '@vue/test-utils'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import DashboardView from './DashboardView.vue'
|
||||
|
||||
describe('DashboardView', () => {
|
||||
it('labels placeholder values and keeps task actions non-operational', () => {
|
||||
const wrapper = mount(DashboardView)
|
||||
vi.mock('../api/dashboard', () => ({
|
||||
getTodayNewOrderCount: vi.fn().mockResolvedValue(12),
|
||||
getActiveCustomerCount: vi.fn().mockResolvedValue(8),
|
||||
getDashboardOperationalMetrics: vi.fn().mockResolvedValue({
|
||||
inTransitContainerCount: 3,
|
||||
inTransitTeu: 4.25,
|
||||
unknownContainerTypeCount: 1,
|
||||
pendingCustomsOrderCount: 7,
|
||||
asOf: '2026-09-11T12:00:00',
|
||||
}),
|
||||
}))
|
||||
|
||||
expect(wrapper.text()).toContain('静态演示数据')
|
||||
expect(wrapper.text()).toContain('演示快照:2026-06-02 08:45')
|
||||
describe('DashboardView', () => {
|
||||
beforeEach(() => vi.clearAllMocks())
|
||||
|
||||
it('renders the four live metrics and keeps unfinished task actions non-operational', async () => {
|
||||
const wrapper = mount(DashboardView)
|
||||
await flushPromises()
|
||||
|
||||
expect(wrapper.text()).toContain('四项核心指标已接入实时业务数据')
|
||||
expect(wrapper.text()).toContain('数据更新时间:2026-09-11 12:00')
|
||||
expect(wrapper.findAll('.dashboard-metric')).toHaveLength(4)
|
||||
expect(wrapper.text()).toContain('12 票')
|
||||
expect(wrapper.text()).toContain('4.25 TEU')
|
||||
expect(wrapper.text()).toContain('8 家')
|
||||
expect(wrapper.text()).toContain('7 票')
|
||||
expect(wrapper.text()).toContain('1 柜箱型未知')
|
||||
const taskActions = wrapper.findAll('.dashboard-task-action')
|
||||
expect(taskActions).toHaveLength(3)
|
||||
expect(taskActions.every((button) => button.attributes('disabled') !== undefined)).toBe(true)
|
||||
|
||||
Reference in New Issue
Block a user