fix: align fleet controls and protect appointment retries
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import CapacityInquiryTable from '../components/CapacityInquiryTable.vue'
|
||||
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
|
||||
import { shallowMount, flushPromises, type VueWrapper } from '@vue/test-utils'
|
||||
import { createPinia } from 'pinia'
|
||||
@@ -223,3 +224,37 @@ it('highlights only the allowed current step and keeps other actions secondary',
|
||||
await wrapper.setProps({ inquiry: { ...inquiry, progress: { ...inquiry.progress, primaryAction: 'INCOMING' } } })
|
||||
expect(section.findAll('button').filter(item => !item.element.closest('details')).map(item => item.text())).toEqual(['安排来货'])
|
||||
})
|
||||
|
||||
it('shows the selected destination capacity when confirming and never treats unknown capacity as zero', async () => {
|
||||
state.manage = true
|
||||
const knownOffer = { ...offer, capacityKnown: true, destinations: [
|
||||
{ ...offer.destinations[0]!, remaining: { palletSpaces: 0, weightKg: 12, volumeCbm: 3 } },
|
||||
{ destinationKey: 'FBA:ACY2', name: 'ACY2', deliveryIndex: 2, remaining: { palletSpaces: 7, weightKg: 800, volumeCbm: 20 } },
|
||||
] }
|
||||
const { wrapper } = mount(CapacityInquiryDialog, { modelValue: true, offer: knownOffer, inquiry, readonly: false, confirmMode: true })
|
||||
await flushPromises()
|
||||
expect(wrapper.get('[aria-label="本目的站可接余位"]').text()).toContain('0 托位 · 12 kg · 3 m³')
|
||||
wrapper.findAllComponents({ name: 'ElSelect' })[1]!.vm.$emit('update:modelValue', 'FBA:ACY2'); await flushPromises()
|
||||
expect(wrapper.get('[aria-label="本目的站可接余位"]').text()).toContain('7 托位 · 800 kg · 20 m³')
|
||||
await wrapper.setProps({ offer: { ...knownOffer, capacityKnown: false } })
|
||||
expect(wrapper.get('[aria-label="本目的站可接余位"]').text()).toContain('待调度核对')
|
||||
expect(wrapper.get('[aria-label="本目的站可接余位"]').text()).not.toContain('800')
|
||||
expect(api.saveAndConfirmInquiry).not.toHaveBeenCalled()
|
||||
})
|
||||
it('prioritizes the allowed current list action and keeps other actions in the overflow menu', async () => {
|
||||
state.manage = true
|
||||
const wrapper = shallowMount(CapacityInquiryTable, { props: { rows: [inquiry], total: 1, loading: false }, global: { directives: { loading: () => undefined }, stubs: {
|
||||
DataTable: { props: ['data'], template: '<div><slot name="actions" :row="data[0]"/></div>' },
|
||||
RowActions: { name: 'RowActions', props: ['actions', 'maxVisible'], template: '<div/>' },
|
||||
} } })
|
||||
wrappers.push(wrapper)
|
||||
const actions = () => wrapper.findComponent({ name: 'RowActions' }).props('actions') as { key: string; visible?: boolean; priority?: number }[]
|
||||
const primary = () => actions().filter(item => item.visible !== false).sort((a,b) => (b.priority || 0) - (a.priority || 0))[0]?.key
|
||||
expect(wrapper.findComponent({ name: 'RowActions' }).props('maxVisible')).toBe(1)
|
||||
expect(primary()).toBe('edit')
|
||||
await wrapper.setProps({ rows: [{ ...inquiry, progress: { ...inquiry.progress, primaryAction: 'INCOMING' }, actions: { ...inquiry.actions, canEdit: false, canConfirm: false } }] })
|
||||
expect(primary()).toBe('view')
|
||||
state.links.add('platform:fleet:trip:booking-edit')
|
||||
await wrapper.setProps({ rows: [{ ...inquiry, progress: { ...inquiry.progress, primaryAction: 'INCOMING' } }] })
|
||||
expect(primary()).toBe('incoming')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user