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'" ) })
2026-08-11 19:59:15 +08:00
it ( 'supports detail, history and agent submission' , () => { 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 19:59:15 +08:00
it ( 'does not expose internal id inputs while resource query APIs are unavailable' , () => {
expect ( source ). not . toContain ( 'createCustomsCase' )
expect ( source ). not . toContain ( '新增报关' )
expect ( source ). not . toContain ( '资料清单版本 ID' )
expect ( source ). not . toContain ( "key: 'orderId', type: 'input'" )
expect ( source ). not . toContain ( "key: 'inboundId', type: 'input'" )
2026-08-11 18:06:35 +08:00
})
2026-08-12 10:59:49 +08:00
it ( 'does not render technical order or inbound ids in the list' , () => {
expect ( source ). toContain ( "label: '订单关联'" )
expect ( source ). toContain ( "label: '入库单关联'" )
expect ( source ). toContain ( "return value ? '已关联' : '未关联'" )
expect ( source ). not . toContain ( "label: '订单标识'" )
expect ( source ). not . toContain ( "label: '入库单标识'" )
})
2026-08-12 17:34:06 +08:00
it ( 'keeps the detail dialog responsive with internal scrolling' , () => {
expect ( source ). toContain ( 'width:min(900px,calc(100vw - 28px))!important' )
expect ( source ). toContain ( 'max-height:90vh' )
expect ( source ). toContain ( 'overflow-y:auto' )
})
2026-08-12 17:45:49 +08:00
it ( 'uses a bordered view action instead of a text link' , () => {
expect ( source ). toContain ( 'size="small" type="primary" plain' )
expect ( source ). not . toContain ( "customs:view')\" link" )
2026-08-12 18:16:44 +08:00
expect ( source ). toContain ( ':total="total" stripe row-key="id"' )
2026-08-12 17:45:49 +08:00
})
2026-08-11 18:06:35 +08:00
})