This commit is contained in:
2026-09-10 11:52:30 +08:00
parent 911c6acad2
commit ae7d8fb22e
6 changed files with 238 additions and 7 deletions
@@ -3,7 +3,7 @@ import { flushPromises, mount } from '@vue/test-utils'
import ElementPlus from 'element-plus'
import { createPinia, setActivePinia } from 'pinia'
import CarrierScheduleQueryPanel from './CarrierScheduleQueryPanel.vue'
import { appendCarrierScheduleManualNode, getCarrierScheduleQuery, listCarrierScheduleQueries } from '../api/platformCarrierScheduleQueries'
import { appendCarrierScheduleManualNode, ensureCarrierScheduleQueryForContainer, getCarrierScheduleQuery, listCarrierScheduleQueries } from '../api/platformCarrierScheduleQueries'
import { getPortSchedule } from '../api/platformPortSchedules'
import { useAuthStore } from '@/core/auth/auth'
import { ApiResponseError } from '@/shared/api/http'
@@ -11,6 +11,7 @@ import { ApiResponseError } from '@/shared/api/http'
vi.mock('../api/platformCarrierScheduleQueries', () => ({
listCarrierScheduleQueries: vi.fn(),
getCarrierScheduleQuery: vi.fn(),
ensureCarrierScheduleQueryForContainer: vi.fn(),
appendCarrierScheduleManualNode: vi.fn(),
}))
vi.mock('../api/platformPortSchedules', () => ({ getPortSchedule: vi.fn() }))
@@ -63,6 +64,21 @@ describe('CarrierScheduleQueryPanel loading states', () => {
expect(getPortSchedule).not.toHaveBeenCalled()
})
it('shows manual entry without an existing task and ensures the task on click', async () => {
vi.mocked(listCarrierScheduleQueries).mockResolvedValue({ records: [], page: 1, size: 200, total: 0, pages: 0 })
vi.mocked(ensureCarrierScheduleQueryForContainer).mockResolvedValue({ query: { ...queryView, query: { ...queryView.query, customerId: '0', resultPortScheduleId: null } }, nodes: [], exceptions: [], histories: [] })
const wrapper = mount(CarrierScheduleQueryPanel, { props: { oceanBookingId: '2', containerBookingId: '3' }, global: { plugins: [ElementPlus, pinia] } })
await flushPromises()
const button = wrapper.findAll('button').find((item) => item.text().includes('人工补录节点'))
expect(button).toBeTruthy()
await button!.trigger('click')
await flushPromises()
expect(ensureCarrierScheduleQueryForContainer).toHaveBeenCalledWith('3', expect.any(String))
expect(wrapper.findComponent({ name: 'AppDialog' }).props('modelValue')).toBe(true)
})
it('filters large no-op status batches, keeps real actions, deduplicates only adjacent explicit event keys and sorts newest first', async () => {
vi.mocked(listCarrierScheduleQueries).mockResolvedValue({ records: [], page: 1, size: 200, total: 0, pages: 0 })
const noops = Array.from({ length: 40 }, (_, index) => ({