优化
This commit is contained in:
@@ -14,6 +14,7 @@ import { getContainer, getContainerOverview, listContainers } from '../api/platf
|
|||||||
vi.mock('@/modules/warehouses', () => ({ listAllPlatformWarehouses: vi.fn() }))
|
vi.mock('@/modules/warehouses', () => ({ listAllPlatformWarehouses: vi.fn() }))
|
||||||
vi.mock('@/modules/master-data', () => ({ listPlatformPartners: vi.fn() }))
|
vi.mock('@/modules/master-data', () => ({ listPlatformPartners: vi.fn() }))
|
||||||
vi.mock('@/modules/ocean-bookings', () => ({ listOceanBookings: vi.fn() }))
|
vi.mock('@/modules/ocean-bookings', () => ({ listOceanBookings: vi.fn() }))
|
||||||
|
vi.mock('@/modules/iam', () => ({ listPlatformTenants: vi.fn().mockResolvedValue({ records: [], page: 1, size: 200, total: 0, pages: 0 }) }))
|
||||||
const accessCan = vi.hoisted(() => vi.fn())
|
const accessCan = vi.hoisted(() => vi.fn())
|
||||||
vi.mock('@/core/access/accessPreview', () => ({ useAccessPreviewStore: () => ({ can: accessCan }) }))
|
vi.mock('@/core/access/accessPreview', () => ({ useAccessPreviewStore: () => ({ can: accessCan }) }))
|
||||||
vi.mock('../api/platformContainerLoading', () => ({ listContainers: vi.fn(), getContainer: vi.fn(), getContainerOverview: vi.fn(), getContainerClearance: vi.fn(), uploadContainerClearance: vi.fn(), completeContainerClearance: vi.fn(), uploadContainerDocument: vi.fn(), downloadContainerDocument: vi.fn(), downloadContainerPdaPhoto: vi.fn(), markContainerException: vi.fn(), cancelContainerException: vi.fn(), createContainer: vi.fn(), updateContainer: vi.fn(), updateContainerTransport: vi.fn() }))
|
vi.mock('../api/platformContainerLoading', () => ({ listContainers: vi.fn(), getContainer: vi.fn(), getContainerOverview: vi.fn(), getContainerClearance: vi.fn(), uploadContainerClearance: vi.fn(), completeContainerClearance: vi.fn(), uploadContainerDocument: vi.fn(), downloadContainerDocument: vi.fn(), downloadContainerPdaPhoto: vi.fn(), markContainerException: vi.fn(), cancelContainerException: vi.fn(), createContainer: vi.fn(), updateContainer: vi.fn(), updateContainerTransport: vi.fn() }))
|
||||||
|
|||||||
@@ -24,6 +24,9 @@ vi.mock('vue-router', () => ({
|
|||||||
vi.mock('@/core/access/accessPreview', () => ({
|
vi.mock('@/core/access/accessPreview', () => ({
|
||||||
useAccessPreviewStore: () => ({ can: () => true }),
|
useAccessPreviewStore: () => ({ can: () => true }),
|
||||||
}))
|
}))
|
||||||
|
vi.mock('@/modules/iam', () => ({
|
||||||
|
listPlatformTenants: vi.fn().mockResolvedValue({ records: [], page: 1, size: 200, total: 0, pages: 0 }),
|
||||||
|
}))
|
||||||
vi.mock('../api/platformContainerLoading', () => ({
|
vi.mock('../api/platformContainerLoading', () => ({
|
||||||
listContainers: vi.fn(),
|
listContainers: vi.fn(),
|
||||||
getSmartLoadingPlanByBooking: vi.fn(),
|
getSmartLoadingPlanByBooking: vi.fn(),
|
||||||
|
|||||||
@@ -38,4 +38,11 @@ describe('CustomsCasesView', () => {
|
|||||||
expect(source).not.toContain("customs:view')\" link")
|
expect(source).not.toContain("customs:view')\" link")
|
||||||
expect(source).toContain(':total="total" stripe row-key="id"')
|
expect(source).toContain(':total="total" stripe row-key="id"')
|
||||||
})
|
})
|
||||||
|
it('uses an active name-only customer selector backed by customerId', () => {
|
||||||
|
expect(source).toContain("listPlatformTenants({ page: 1, size: 200, status: 'ACTIVE' })")
|
||||||
|
expect(source).toContain("customer.status === 'ACTIVE'")
|
||||||
|
expect(source).toContain("customer.legalName?.trim() || customer.tenantName")
|
||||||
|
expect(source).toContain("customerId: String(filters.value.customerId || '') || undefined")
|
||||||
|
expect(source).not.toContain('customer.tenantCode')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -35,3 +35,14 @@ describe('OceanBookingsView visual action contract', () => {
|
|||||||
expect(source).toContain(':total="total" stripe preference-key="ocean-bookings"')
|
expect(source).toContain(':total="total" stripe preference-key="ocean-bookings"')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('OceanBookingsView customer filter contract', () => {
|
||||||
|
const source = readFileSync(resolve(process.cwd(), 'src/modules/ocean-bookings/pages/OceanBookingsView.vue'), 'utf8')
|
||||||
|
it('loads active customers, displays names only and submits customerId', () => {
|
||||||
|
expect(source).toContain("listPlatformTenants({ page: 1, size: 200, status: 'ACTIVE' })")
|
||||||
|
expect(source).toContain("customer.status === 'ACTIVE'")
|
||||||
|
expect(source).toContain("customer.legalName?.trim() || customer.tenantName")
|
||||||
|
expect(source).toContain("customerId: String(query.customerId || '') || undefined")
|
||||||
|
expect(source).not.toContain('customer.tenantCode')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ const source = readFileSync(resolve(process.cwd(), 'src/modules/trucking/pages/T
|
|||||||
vi.mock('../api/platformTrucking', () => ({
|
vi.mock('../api/platformTrucking', () => ({
|
||||||
listTruckAppointments: vi.fn(),
|
listTruckAppointments: vi.fn(),
|
||||||
}))
|
}))
|
||||||
|
vi.mock('@/modules/iam', () => ({
|
||||||
|
listPlatformTenants: vi.fn().mockResolvedValue({ records: [], page: 1, size: 200, total: 0, pages: 0 }),
|
||||||
|
}))
|
||||||
|
|
||||||
const row: TruckAppointmentResource = {
|
const row: TruckAppointmentResource = {
|
||||||
id: '9001', appointmentNo: 'TA-9001', status: 'DISPATCHED', customerName: '示例企业', orderNo: 'ORD-1', containerBookingId: '77',
|
id: '9001', appointmentNo: 'TA-9001', status: 'DISPATCHED', customerName: '示例企业', orderNo: 'ORD-1', containerBookingId: '77',
|
||||||
@@ -34,7 +37,7 @@ describe('TruckAppointmentsView', () => {
|
|||||||
it('loads the real list and renders relationship snapshots', async () => {
|
it('loads the real list and renders relationship snapshots', async () => {
|
||||||
const wrapper = mount(TruckAppointmentsView, { global: { plugins: [ElementPlus] } })
|
const wrapper = mount(TruckAppointmentsView, { global: { plugins: [ElementPlus] } })
|
||||||
await flushPromises()
|
await flushPromises()
|
||||||
expect(listTruckAppointments).toHaveBeenCalledWith({ page: 1, size: 20, keyword: '', status: '', containerBookingId: '', containerType: '' })
|
expect(listTruckAppointments).toHaveBeenCalledWith({ page: 1, size: 20, customerId: '', keyword: '', status: '', containerBookingId: '', containerType: '' })
|
||||||
expect(wrapper.text()).toContain('TA-9001')
|
expect(wrapper.text()).toContain('TA-9001')
|
||||||
expect(wrapper.text()).toContain('CONT-1')
|
expect(wrapper.text()).toContain('CONT-1')
|
||||||
expect(wrapper.text()).not.toContain('77')
|
expect(wrapper.text()).not.toContain('77')
|
||||||
@@ -119,6 +122,13 @@ describe('TruckAppointmentsView', () => {
|
|||||||
expect(source).not.toContain("key: 'payableAmount'")
|
expect(source).not.toContain("key: 'payableAmount'")
|
||||||
expect(source).not.toContain("key: 'receivableAmount'")
|
expect(source).not.toContain("key: 'receivableAmount'")
|
||||||
})
|
})
|
||||||
|
it('filters with an active name-only customer selector and stable customerId', () => {
|
||||||
|
expect(source).toContain("listPlatformTenants({ page: 1, size: 200, status: 'ACTIVE' })")
|
||||||
|
expect(source).toContain("customer.status === 'ACTIVE'")
|
||||||
|
expect(source).toContain("customer.legalName?.trim() || customer.tenantName")
|
||||||
|
expect(source).toContain("customerId: String(model.customerId || '')")
|
||||||
|
expect(source).not.toContain('customer.tenantCode')
|
||||||
|
})
|
||||||
it('uses bordered list actions instead of text links', () => {
|
it('uses bordered list actions instead of text links', () => {
|
||||||
expect(source).toContain('size="small" type="primary" plain')
|
expect(source).toContain('size="small" type="primary" plain')
|
||||||
expect(source).toContain('size="small" :aria-label="appointmentActionLabel(\'编辑\'')
|
expect(source).toContain('size="small" :aria-label="appointmentActionLabel(\'编辑\'')
|
||||||
|
|||||||
Reference in New Issue
Block a user