50 lines
2.9 KiB
JavaScript
50 lines
2.9 KiB
JavaScript
import test from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import { readFile } from 'node:fs/promises'
|
|
|
|
const api = await readFile(new URL('../src/api/relabel.js', import.meta.url), 'utf8')
|
|
const page = await readFile(new URL('../src/pages/relabel/relabel.vue', import.meta.url), 'utf8')
|
|
const palletWork = await readFile(new URL('../src/components/RelabelPalletWork.vue', import.meta.url), 'utf8')
|
|
|
|
test('PDA exposes the approved return bulk SKU completion endpoint', () => {
|
|
assert.match(api, /completeReturnRelabelSkuTotal/)
|
|
assert.match(api, /\/return-skus\/complete-total/)
|
|
})
|
|
|
|
test('return relabel pallet binding validates pieces while binding physical carton marks', () => {
|
|
assert.match(palletWork, /isReturnBulk\(\).*RETURN_BULK_SKU_LABEL/)
|
|
assert.match(palletWork, /count === packages && this\.completedItems\(\)\.length === this\.eligibleItems\.length && this\.marks\.length === this\.eligibleItems\.length/)
|
|
assert.match(palletWork, /this\.isReturnBulk \? this\.eligibleItems : this\.eligibleItems\.slice\(0, count\)/)
|
|
assert.match(page, /requiredMarks[\s\S]*some\(\(mark\) => !marks\.has\(mark\)\)/)
|
|
})
|
|
|
|
test('return relabel mode works by SKU remaining quantity without carton-mark scanning', () => {
|
|
assert.match(page, /current\?\.operationType === 'RETURN_BULK_SKU_LABEL'/)
|
|
assert.match(page, /退货贴标 SKU 明细/)
|
|
assert.match(page, /name="returnSku"[\s\S]*@submit="verifyReturnSku"/)
|
|
assert.match(page, /activeTarget === 'return-sku'[\s\S]*this\.verifyReturnSku\(value\)/)
|
|
assert.match(page, /verifiedReturnSkuKey !== group\.key/)
|
|
assert.match(page, /Number\.isSafeInteger\(quantity\)[\s\S]*quantity > group\.remaining/)
|
|
assert.match(page, /returnBulkSkuGroups/)
|
|
assert.match(page, /来源托盘拆箱数量/)
|
|
assert.match(page, /登记本次贴标.*group\.remaining/)
|
|
assert.match(page, /completeReturnRelabelSkuTotal/)
|
|
assert.match(page, /taskTab === 'carton' && !isReturnBulk/)
|
|
})
|
|
|
|
test('new relabel pallet is immediately copied into the target scan field', () => {
|
|
assert.match(palletWork, /this\.targetCode = this\.newPallet\.palletCode \|\| ''/)
|
|
assert.match(palletWork, /退货换标无需扫描箱唛/)
|
|
})
|
|
|
|
test('return relabel distinguishes a whole pallet from a partial unpack', () => {
|
|
assert.match(palletWork, /wholeSource\(\).*plannedPackages === Number\(this\.selectedSource\.stockPackages/)
|
|
assert.match(palletWork, /eligibleItems\(\).*this\.isReturnBulk \? this\.sourceItems\(\) : this\.completedItems\(\)/)
|
|
assert.match(palletWork, /this\.selectedDestination = this\.sourceItems\(\)\[0\]/)
|
|
assert.match(palletWork, /this\.completedItems\(\)\.length !== this\.eligibleItems\.length/)
|
|
assert.match(palletWork, /贴标数量等于本托盘全部/)
|
|
assert.match(palletWork, /贴标数量少于本托盘库存/)
|
|
assert.match(palletWork, /v-if="!isReturnBulk"[\s\S]*name="relabel-source"/)
|
|
assert.match(palletWork, /await this\.run\(async \(\) => \{ const value = await resolvePallet\(row\.palletCode\)/)
|
|
})
|