2026-08-11 11:26:31 +08:00
import { describe , expect , it } from 'vitest'
import { readFileSync } from 'node:fs'
import { resolve } from 'node:path'
const source = readFileSync ( resolve ( process . cwd (), 'src/modules/customs/pages/CustomsCasesView.vue' ), 'utf8' )
2026-08-11 18:06:35 +08:00
describe ( 'CustomsCasesView' , () => {
it ( 'uses shared list and dialog components' , () => { expect ( source ). toContain ( 'QueryToolbar' ); expect ( source ). toContain ( 'DataTable' ); expect ( source ). toContain ( 'AppDialog' ); expect ( source ). toContain ( "fixed: 'left'" ) })
it ( 'supports create, detail, history and agent submission' , () => { expect ( source ). toContain ( 'createCustomsCase' ); expect ( source ). toContain ( 'getCustomsCase' ); expect ( source ). toContain ( 'submitCustomsCase' ); expect ( source ). toContain ( 'detail.history' ) })
2026-08-11 18:43:56 +08:00
it ( 'localizes backend statuses and timeline actions throughout the page' , () => {
expect ( source ). toContain ( 'customsCaseStatusOptions' )
expect ( source ). toContain ( ':status="customsStatusLabel(row.status)"' )
expect ( source ). toContain ( ':status="customsStatusLabel(detail.customsCase.status)"' )
expect ( source ). toContain ( 'customsHistoryActionLabel(entry.action)' )
expect ( source ). toContain ( 'customsStatusLabel(entry.fromStatus)' )
expect ( source ). toContain ( "detail.value?.customsCase.status === 'READY_TO_SUBMIT'" )
expect ( source ). not . toContain ( "['DRAFT', 'COLLECTING', 'READY', 'SUBMITTED', 'RELEASED', 'REJECTED']" )
})
2026-08-11 18:06:35 +08:00
it ( 'selects business resources instead of asking operators for customer and order ids' , () => {
expect ( source ). toContain ( 'listPlatformTenants' )
expect ( source ). toContain ( 'listPlatformUnifiedOrders' )
expect ( source ). toContain ( 'listContainers' )
expect ( source ). toContain ( 'selectOrder' )
expect ( source ). toContain ( '重新加载选项' )
expect ( source ). not . toContain ( 'label="客户 ID"' )
expect ( source ). not . toContain ( 'label="订单 ID"' )
expect ( source ). not . toContain ( 'label="入库单 ID"' )
})
it ( 'only exposes active customers in create selectors' , () => {
expect ( source ). toContain ( "customers.value.filter((customer) => customer.status === 'ACTIVE')" )
expect ( source ). toContain ( 'v-for="customer in activeCustomers"' )
expect ( source ). not . toContain ( ':disabled="customer.status !== \'ACTIVE\'"' )
})
})