77 lines
3.9 KiB
TypeScript
77 lines
3.9 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-master-data/pages/${name}.vue`), 'utf8')
|
||
|
|
}
|
||
|
|
|
||
|
|
describe('overseas master data pending-contract pages', () => {
|
||
|
|
it('gives every list query toolbar a unique stable preference key', () => {
|
||
|
|
const expectedKeys = new Map([
|
||
|
|
['OverseasQuotesView', 'overseas-quotes-query'],
|
||
|
|
['ExchangeRatesView', 'overseas-exchange-rates-query'],
|
||
|
|
['VehiclesView', 'overseas-vehicles-query'],
|
||
|
|
])
|
||
|
|
const actualKeys: string[] = []
|
||
|
|
|
||
|
|
for (const [name, expectedKey] of expectedKeys) {
|
||
|
|
const view = source(name)
|
||
|
|
const toolbar = view.match(/<QueryToolbar\b[^>]*\/>/s)?.[0]
|
||
|
|
expect(toolbar, `${name} should render QueryToolbar`).toBeDefined()
|
||
|
|
expect(toolbar).toContain(`preference-key="${expectedKey}"`)
|
||
|
|
const actualKey = toolbar?.match(/preference-key="([^"]+)"/)?.[1]
|
||
|
|
expect(actualKey).toBe(expectedKey)
|
||
|
|
actualKeys.push(actualKey!)
|
||
|
|
}
|
||
|
|
|
||
|
|
expect(new Set(actualKeys).size).toBe(actualKeys.length)
|
||
|
|
})
|
||
|
|
|
||
|
|
it('keeps operation columns first and preserves the prototype fields', () => {
|
||
|
|
const quotes = source('OverseasQuotesView')
|
||
|
|
const exchangeRates = source('ExchangeRatesView')
|
||
|
|
const vehicles = source('VehiclesView')
|
||
|
|
expect(quotes.indexOf("key: 'actions'")).toBeLessThan(quotes.indexOf("key: 'name'"))
|
||
|
|
for (const label of ['报价名称', '海外仓', '服务商', '币种', '生效日期', '失效日期', '报价版本', '状态', '更新时间', '备注']) {
|
||
|
|
expect(quotes).toContain(`label: '${label}'`)
|
||
|
|
}
|
||
|
|
const exchangeColumns = exchangeRates.slice(exchangeRates.indexOf('const columns'))
|
||
|
|
expect(exchangeColumns.indexOf("key: 'actions'")).toBeLessThan(exchangeColumns.indexOf("key: 'month'"))
|
||
|
|
expect(vehicles.indexOf("key: 'actions'")).toBeLessThan(vehicles.indexOf("key: 'plateNumber'"))
|
||
|
|
for (const label of ['自有车辆', '外派车辆', '当前派送单', '最近更换原因']) expect(vehicles).toContain(label)
|
||
|
|
expect(vehicles).toContain("key: 'region'")
|
||
|
|
expect(vehicles).toContain("placeholder: '全部区域'")
|
||
|
|
expect(vehicles).toContain('class="status-tabs"')
|
||
|
|
expect(vehicles).toContain("'status-tab', { 'is-active': ownership === tab.value }")
|
||
|
|
expect(vehicles).not.toContain('<el-segmented')
|
||
|
|
expect(vehicles).not.toContain('aria-label="车辆区域"')
|
||
|
|
})
|
||
|
|
|
||
|
|
it('keeps all write and export entry points disabled with an explicit contract message', () => {
|
||
|
|
for (const name of ['OverseasQuotesView', 'ExchangeRatesView', 'VehiclesView']) {
|
||
|
|
const view = source(name)
|
||
|
|
expect(view).toContain('海外区域')
|
||
|
|
expect(view).toMatch(/<el-button[^>]*disabled/)
|
||
|
|
expect(view).not.toContain('ElMessage.success')
|
||
|
|
}
|
||
|
|
})
|
||
|
|
|
||
|
|
it('uses an independent vehicle detail page without inventing a record', () => {
|
||
|
|
const detail = source('VehicleDetailView')
|
||
|
|
expect(detail).toContain('车辆信息')
|
||
|
|
expect(detail).toContain('派送订单明细')
|
||
|
|
expect(detail).toContain('派送更换记录')
|
||
|
|
expect(detail).toContain('<ContractPendingNotice domain="车辆详情" detail />')
|
||
|
|
expect(detail).not.toContain('AppDrawer')
|
||
|
|
expect(detail).not.toContain('const vehicle =')
|
||
|
|
})
|
||
|
|
|
||
|
|
it('records the prototype evidence before implementation', () => {
|
||
|
|
const matrix = readFileSync(resolve(process.cwd(), 'src/modules/overseas-master-data/PROTOTYPE_MATRIX.md'), 'utf8')
|
||
|
|
for (const id of ['gen-partner-warehouse', 'gen-overseas-quote', 'gen-exchange-rate', 'vehicle-detail']) expect(matrix).toContain(id)
|
||
|
|
for (const modal of ['modal-gen-overseas-quote-detail', 'modal-gen-overseas-quote', 'modal-exchange-rate-edit', 'modal-vehicle-edit']) expect(matrix).toContain(modal)
|
||
|
|
expect(matrix).toContain('原型未定义车辆文件预览、审核/确认流程')
|
||
|
|
})
|
||
|
|
})
|