2026-09-10 15:34:03 +08:00
|
|
|
import assert from 'node:assert/strict'
|
|
|
|
|
import { readFileSync } from 'node:fs'
|
|
|
|
|
import test from 'node:test'
|
|
|
|
|
|
|
|
|
|
const view = readFileSync(new URL('./WarehouseServiceView.vue', import.meta.url), 'utf8')
|
|
|
|
|
const api = readFileSync(new URL('../api/warehouseServices.ts', import.meta.url), 'utf8')
|
|
|
|
|
|
|
|
|
|
test('仓储转运先选择入仓方式并按方式切换地址信息', () => {
|
|
|
|
|
assert.match(view, /value="WAREHOUSE_PICKUP">仓库上门提货/)
|
|
|
|
|
assert.match(view, /value="CUSTOMER_DELIVERY">客户送货到仓/)
|
|
|
|
|
assert.match(view, /form\.deliveryMethod === 'WAREHOUSE_PICKUP'.*提货地址/s)
|
|
|
|
|
assert.match(view, /form\.deliveryMethod === 'CUSTOMER_DELIVERY'.*送货地址.*收货联系人.*联系电话/s)
|
|
|
|
|
assert.match(view, /getMerchantWarehouseDetail\(form\.warehouse\)/)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('仓储转运允许暂未确定 FBA 去向并显式选择是否换标', () => {
|
|
|
|
|
assert.match(view, /是否已有 FBA 去向/)
|
|
|
|
|
assert.match(view, /:value="false">暂未确定/)
|
|
|
|
|
assert.match(view, /transferHasFbaDestination.*目的 FBA 仓/s)
|
|
|
|
|
assert.match(view, /是否需要换标/)
|
|
|
|
|
assert.match(view, /:value="false">不需要换标/)
|
|
|
|
|
assert.match(view, /:value="true">需要换标/)
|
|
|
|
|
assert.match(api, /fbaWarehouseCode\?: string/)
|
|
|
|
|
assert.match(api, /fbaShipmentNo\?: string/)
|
|
|
|
|
})
|
2026-09-10 15:56:39 +08:00
|
|
|
|
|
|
|
|
test('仓储转运不要求客户填写内部入仓号和箱唛', () => {
|
|
|
|
|
const transferConfig = view.match(/transfer:\s*\{[^\n]+/)?.[0] || ''
|
|
|
|
|
const transferSubmit = view.match(/await createTransfer\(\{[^\n]+/)?.[0] || ''
|
|
|
|
|
const transferCargoTable = view.match(/<template v-else>[\s\S]*?<\/template>\s*<\/div>\s*<div class="warehouse-submit-bar"/)?.[0] || ''
|
|
|
|
|
assert.doesNotMatch(transferConfig, /进仓编号/)
|
|
|
|
|
assert.doesNotMatch(transferSubmit, /inboundCode|sourceLastlegOrderIds|shippingMark/)
|
|
|
|
|
assert.match(transferCargoTable, /预计箱数/)
|
|
|
|
|
assert.doesNotMatch(transferCargoTable, /props\.service === 'transfer'.*FNSKU \/ 箱唛/)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('上门提货不提交物流号,需要换标仅提示入库后绑定', () => {
|
|
|
|
|
assert.match(view, /trackingNo:\s*form\.deliveryMethod === 'CUSTOMER_DELIVERY'\s*\?[^:]+:\s*undefined/)
|
|
|
|
|
assert.match(view, /完成入库后再绑定换标单/)
|
|
|
|
|
assert.match(view, /form\.deliveryMethod === 'CUSTOMER_DELIVERY'.*物流跟踪号/s)
|
|
|
|
|
})
|