This commit is contained in:
2026-10-20 23:34:11 +08:00
parent f155976f52
commit 13e4aa56ec
321 changed files with 6756 additions and 2110 deletions
@@ -13,7 +13,7 @@ vi.mock('../api/tripOperations', () => ({ listTripOperations: vi.fn(), exportTri
const wrappers: VueWrapper[] = []
const layout = { template: '<div><slot name="metrics"/><slot name="state"/><slot/></div>' }
function mount(component: object) { const wrapper = shallowMount(component, { global: { stubs: { AdminPage: layout, ListPageLayout: layout, QueryToolbar: true,
DataTable: { name: 'DataTable', props: ['data', 'columns'], template: '<div><slot name="toolbar-start"/><slot name="toolbar-actions"/><slot name="filters"/><slot name="notices"/></div>' }, ElButton: { template: '<button><slot/></button>' },
DataTable: { name: 'DataTable', props: ['data', 'columns'], template: '<div><header><slot name="toolbar-start"/><slot name="toolbar-actions"/></header><section class="filters"><slot name="filters"/></section><slot name="notices"/></div>' }, ElButton: { template: '<button><slot/></button>' },
ElTooltip: true, LoadErrorState: true, FleetQuoteEditor: true, FleetQuoteImport: true, ApiErrorMeta: true } } }); wrappers.push(wrapper); return wrapper }
afterEach(() => { wrappers.splice(0).forEach(w => w.unmount()); vi.clearAllMocks() })
it('quotes read-only view fetches a page once and hides all write/export tools', async () => {
@@ -21,6 +21,12 @@ it('quotes read-only view fetches a page once and hides all write/export tools',
const wrapper = mount(FleetQuotesView); await flushPromises()
expect(quotes.listFleetQuotes).toHaveBeenCalledTimes(1); expect(wrapper.text()).not.toContain('新增报价'); expect(wrapper.text()).not.toContain('批量导入')
expect(wrapper.findComponent({ name: 'DataTable' }).props('columns')[0]).toMatchObject({ key: 'actions', fixed: 'left' })
const tabs = wrapper.get('header .workbench-list-tabs').findAll('[role="tab"]')
expect(tabs.map(tab => tab.text())).toEqual(['车队采购报价', '外接销售报价'])
expect(wrapper.get('.filters').findComponent(QueryToolbar).exists()).toBe(true)
await tabs[1]!.trigger('click'); await flushPromises()
expect(quotes.listFleetQuotes).toHaveBeenLastCalledWith(expect.objectContaining({ kind: 'SALE', page: 1 }))
expect(tabs[1]!.attributes('aria-selected')).toBe('true')
})
it('operations uses server totals rather than displayed page size', async () => {
vi.mocked(reports.listTripOperations).mockResolvedValue({ page: { records: [], total: 21, page: 1, size: 20, pages: 2 }, summary: { trips: 21, inTransit: 12, completed: 9, physicalPallets: 40, palletSpaces: 40, ownPackages: 70, externalPackages: 10, externalAgreedAmounts: [], costs: { visible: false, unrecordedTrips: null, unallocatedTrips: null, totals: [] } }, charts: { physicalPallets: [], destinationTrips: [], externalAgreedAmounts: [], externalPalletRates: [] } })