Files
admin-web/src/modules/overseas-warehouse/pages/phase5Behavior.test.ts
T

55 lines
2.6 KiB
TypeScript

import { readFileSync } from 'node:fs'
import { resolve } from 'node:path'
import { describe, expect, it } from 'vitest'
function source(name: string) { return readFileSync(resolve(process.cwd(), `src/modules/overseas-warehouse/pages/${name}`), 'utf8') }
function expectOperationColumnFirst(name: string) {
const value = source(name)
if (!value.includes("key: 'actions', label: '操作'")) return
expect(value).toMatch(/const columns:[\s\S]*?= \[\s*\{ key: 'actions', label: '操作'/)
}
describe('phase-five outbound, delivery, exception and visit behavior', () => {
it('keeps outbound detail and cancellation scoped only by outboundNo', () => {
const list = source('OutboundsView.vue')
const detail = source('OutboundDetailView.vue')
expect(list).toContain("params: { outboundNo: row.outboundNo }")
expect(list).toContain('access.can(permission.outboundCreate)')
expect(list).toContain('access.can(permission.outboundCancel)')
expect(detail).toContain('getOutbound(outboundNo.value)')
expect(detail).toContain('cancelOutbound(outboundNo.value, reason)')
expect(detail).not.toContain('customerId')
expect(list).toContain("createOneClickDropshipOutbound([...customerIds][0] || ''")
expectOperationColumnFirst('OutboundsView.vue')
})
it('keeps delivery return and status operations on real APIs with independent permissions', () => {
const value = source('DeliveryOrdersView.vue')
expect(value).toContain('permission.deliveryStatus')
expect(value).toContain('permission.deliveryReturn')
expect(value).toContain('updateDeliveryOrderStatus')
expect(value).toContain('markDeliveryReturn')
expect(value).toContain('listDeliveryReturnInboundOptions')
expectOperationColumnFirst('DeliveryOrdersView.vue')
})
it('keeps exception creation and relation resolution on real APIs', () => {
const value = source('ExceptionOrdersView.vue')
expect(value).toContain('permission.exceptionOrderCreate')
expect(value).toContain('resolveExceptionRelation')
expect(value).toContain('createExceptionOrder')
expect(value).toContain('getApiErrorDetails')
expectOperationColumnFirst('ExceptionOrdersView.vue')
})
it('keeps customer visit updates and attachments behind edit permission', () => {
const value = source('CustomerVisitsView.vue')
expect(value).toContain('permission.customerVisitEdit')
expect(value).toContain('saveCustomerVisit')
expect(value).toContain('uploadCustomerVisitAttachment')
expect(value).toContain('getApiErrorDetails')
expectOperationColumnFirst('CustomerVisitsView.vue')
})
})