46 lines
1.7 KiB
JavaScript
46 lines
1.7 KiB
JavaScript
import assert from 'node:assert/strict'
|
|||
|
|
import test from 'node:test'
|
||
|
|
|
||
|
|
import { planA0LocationIsolation } from '../admin-test-env-acceptance.mjs'
|
||
|
|
|
||
|
|
function locations(count) {
|
||
|
|
return Array.from({ length: count }, (_, index) => ({
|
||
|
|
id: String(index + 1), locationCode: `L-${String(index + 1).padStart(4, '0')}`,
|
||
|
|
sharedOverflow: false, version: 0,
|
||
|
|
}))
|
||
|
|
}
|
||
|
|
|
||
|
|
test('large warehouse is never selected for default mass disable', () => {
|
||
|
|
const plan = planA0LocationIsolation(locations(614), 1)
|
||
|
|
assert.equal(plan.enabled, false)
|
||
|
|
assert.equal(plan.mutationsRequired, 614)
|
||
|
|
assert.deepEqual(plan.targets, [])
|
||
|
|
})
|
||
|
|
|
||
|
|
test('minimum mutations leave fewer normal locations than required pallets', () => {
|
||
|
|
const plan = planA0LocationIsolation(locations(3), 3)
|
||
|
|
assert.equal(plan.enabled, true)
|
||
|
|
assert.equal(plan.mutationsRequired, 1)
|
||
|
|
assert.equal(plan.targets.length, 1)
|
||
|
|
assert.equal(plan.expectedRemainingNormal, 2)
|
||
|
|
assert.ok(plan.expectedRemainingNormal < plan.requiredSlots)
|
||
|
|
})
|
||
|
|
|
||
|
|
test('natural shortage proves A0 fallback without any location mutation', () => {
|
||
|
|
const plan = planA0LocationIsolation(locations(1), 2)
|
||
|
|
assert.equal(plan.enabled, true)
|
||
|
|
assert.equal(plan.mutationsRequired, 0)
|
||
|
|
assert.deepEqual(plan.targets, [])
|
||
|
|
assert.ok(plan.normalCount < plan.requiredSlots)
|
||
|
|
})
|
||
|
|
|
||
|
|
test('shared A0 and duplicate rows never inflate the normal location plan', () => {
|
||
|
|
const normal = locations(2)
|
||
|
|
const plan = planA0LocationIsolation([
|
||
|
|
...normal, normal[0], { id: 'A0', locationCode: 'A0', sharedOverflow: true, version: 0 },
|
||
|
|
], 2)
|
||
|
|
assert.equal(plan.normalCount, 2)
|
||
|
|
assert.equal(plan.mutationsRequired, 1)
|
||
|
|
assert.deepEqual(plan.targets.map((item) => item.id), ['1'])
|
||
|
|
})
|