2026-09-04 12:41:58 +08:00
|
|
|
import assert from 'node:assert/strict'
|
|
|
|
|
import { readFileSync } from 'node:fs'
|
|
|
|
|
import test from 'node:test'
|
|
|
|
|
|
|
|
|
|
const api = readFileSync(new URL('./api/businessOrders.ts', import.meta.url), 'utf8')
|
|
|
|
|
const routes = readFileSync(new URL('./routes.ts', import.meta.url), 'utf8')
|
|
|
|
|
const view = readFileSync(new URL('./components/BusinessOrdersView.vue', import.meta.url), 'utf8')
|
|
|
|
|
|
|
|
|
|
test('activates all three customer cross-border pages with frozen permissions', () => {
|
|
|
|
|
for (const [path, permission] of [
|
|
|
|
|
['cross-border/procurement', 'merchant:cross-border:procurement'],
|
|
|
|
|
['cross-border/domestic-trucking', 'merchant:cross-border:domestic-trucking'],
|
|
|
|
|
['cross-border/pallet-shipping', 'merchant:cross-border:pallet-shipping'],
|
|
|
|
|
]) {
|
|
|
|
|
assert.match(routes, new RegExp(`path: '${path}'[\\s\\S]*?release: 'active'[\\s\\S]*?permission: '${permission}'`))
|
|
|
|
|
}
|
|
|
|
|
assert.doesNotMatch(view, /PrototypeFeatureView|mock|customerId|tenantId/i)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('uses only merchant overseas endpoints and keeps retry idempotency stable', () => {
|
|
|
|
|
assert.match(api, /overseas-procurements/)
|
|
|
|
|
assert.match(api, /us-truck-orders/)
|
|
|
|
|
assert.match(api, /local-looseboard-orders/)
|
|
|
|
|
assert.doesNotMatch(api, /\/platform\/|\/internal\/|customerId|tenantId/)
|
|
|
|
|
assert.match(view, /const stableSubmitKey = submitKey\.value \|\| idempotencyKey\(\)/)
|
|
|
|
|
assert.match(view, /submitKey\.value = stableSubmitKey/)
|
|
|
|
|
assert.match(view, /idempotencyKey: stableSubmitKey/g)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('covers list detail create loading error empty pagination and actions-first contracts', () => {
|
|
|
|
|
assert.match(view, /mode\.value = 'detail'/)
|
|
|
|
|
assert.match(view, /mode\.value = 'list'/)
|
|
|
|
|
assert.match(view, /mode = 'create'/)
|
|
|
|
|
assert.match(view, /v-loading="loading"/)
|
|
|
|
|
assert.match(view, /type="error"/)
|
|
|
|
|
assert.match(view, /empty-text="暂无订单"/)
|
|
|
|
|
assert.match(view, /<el-pagination/)
|
|
|
|
|
assert.match(view, /<el-table-column label="操作"[^>]*fixed="left"/)
|
2026-09-14 10:02:37 +08:00
|
|
|
assert.match(view, /PENDING_OUTBOUND: '待出库'/)
|
|
|
|
|
assert.match(view, /PARTIALLY_OUTBOUND: '部分出库'/)
|
|
|
|
|
assert.match(view, /OUTBOUNDED: '全部出库'/)
|
|
|
|
|
assert.match(view, /\['入库量', read\(summary, 'inboundQuantity'\)\]/)
|
|
|
|
|
assert.match(view, /\['审核备注', current\.reviewRemark\]/)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('keeps procurement filters, details and forms readable at PDA width', () => {
|
|
|
|
|
assert.match(view, /@media \(max-width: 767px\)/)
|
|
|
|
|
assert.match(view, /\.filter-card :deep\(\.el-form\) \{ display: grid; grid-template-columns: 1fr; \}/)
|
|
|
|
|
assert.match(view, /\.detail-grid \{ grid-template-columns: 1fr; \}/)
|
|
|
|
|
assert.match(view, /\.form-card :deep\(\.el-form-item\) \{ display: block; \}/)
|
|
|
|
|
assert.match(view, /\.budget-form-item :deep\(\.el-form-item__content\) \{ display: flex; flex-wrap: nowrap; \}/)
|
2026-09-04 12:41:58 +08:00
|
|
|
})
|