优化
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { transpileModule, ScriptTarget } from 'typescript'
|
||||
|
||||
const view = readFileSync(new URL('./WarehouseServiceView.vue', import.meta.url), 'utf8')
|
||||
function setup() {
|
||||
const body = view.slice(view.indexOf('async function selectTransferInventory('), view.indexOf('function selectTransferInboundMethod('))
|
||||
const code = transpileModule(body, { compilerOptions: { target: ScriptTarget.ES2022 } }).outputText
|
||||
const ctx = { selectedTransferInventory: {value:''}, selectedTransferSourceOrderIds:{value:[]},
|
||||
transferSourceCartons:{value:[{cartonMark:'OLD'}]}, transferSourceError:{value:'OLD'}, transferSourceLoading:{value:true},
|
||||
transferDestinationType:{value:'NONE'}, form:{warehouse:'WH',inboundNo:''},
|
||||
transferInventoryCandidates:{value:[{inboundCode:'IN',skuCode:'SKU',productNameZh:'货品',availablePackages:2},
|
||||
{inboundCode:'IN',skuCode:'SKU',availablePackages:3},{inboundCode:'OTHER',skuCode:'OTHER',availablePackages:99}]},
|
||||
cargoRows:{value:[]}, inventoryQuantity:Number, createCargoRow:()=>({expectedPackageCount:1}),
|
||||
loadTransferSourceCartons:async()=>{}, listRelabelHistoricalOrders:async()=>[{id:'1234567890123456789'}],
|
||||
ElMessage:{error(message){throw Error(message)}} }
|
||||
const select = new Function(...Object.keys(ctx), 'let transferSourceRequest=0;'+code+'; return selectTransferInventory')(...Object.values(ctx))
|
||||
return {ctx,select}
|
||||
}
|
||||
test('inventory source populates full immutable cargo counts without mixing other inbound orders',async()=>{
|
||||
const {ctx,select}=setup(); await select('IN')
|
||||
assert.equal(ctx.transferDestinationType.value,'FBA')
|
||||
assert.equal(ctx.cargoRows.value.length,1)
|
||||
assert.equal(ctx.cargoRows.value[0].expectedPackageCount,5)
|
||||
assert.equal(ctx.cargoRows.value[0].quantity,5)
|
||||
assert.deepEqual(ctx.selectedTransferSourceOrderIds.value,['1234567890123456789'])
|
||||
await select('')
|
||||
assert.equal(ctx.form.inboundNo,'')
|
||||
assert.deepEqual(ctx.selectedTransferSourceOrderIds.value,[])
|
||||
assert.deepEqual(ctx.transferSourceCartons.value,[])
|
||||
})
|
||||
test('inventory view hides inbound fields and editing actions and shows original carton destination',()=>{
|
||||
assert.match(view,/v-if="props.service === 'transfer' && !inventoryTransfer"[^>]*><span><i>\*<\/i>入仓方式/)
|
||||
assert.match(view,/<el-radio-button v-if="!inventoryTransfer" value="NONE">/)
|
||||
const panel=view.slice(view.indexOf('<section v-if="inventoryTransfer"'),view.indexOf('</section>',view.indexOf('<section v-if="inventoryTransfer"')))
|
||||
assert.match(panel,/box.cartonMark/); assert.match(panel,/box.destinationWarehouseCode/)
|
||||
assert.doesNotMatch(panel,/v-model|addCargoRow|removeCargoRow|清空/)
|
||||
assert.match(view,/!inventoryTransfer\.value && \(!form.warehouse/)
|
||||
assert.match(view,/estimatedArrivalAt: inventoryTransfer.value \? undefined : form.estimatedArrivalAt/)
|
||||
})
|
||||
Reference in New Issue
Block a user