import test from 'node:test' import assert from 'node:assert/strict' import { readFileSync } from 'node:fs' const page = readFileSync(new URL('../pages/picking/picking.vue', import.meta.url), 'utf8') test('ordinary partially picked items retain full and partial picking actions, but not skip', () => { assert.match(page, /v-else-if="!isSealedPalletItem\(item\) && \[ITEM_STATUS.PENDING, ITEM_STATUS.PARTIAL\].includes\(itemState\(item\)\)"/) assert.match(page, /v-if="itemState\(item\) === ITEM_STATUS.PENDING" class="pick-btn pick-btn-skip"/) assert.match(page, /const remaining = Number\(item\?\.qty \|\| 0\) - Number\(item\?\.pickedPackageCount \|\| 0\)/) assert.match(page, /'PICK', \{ pickedPackageCount: remaining, source \}/) }) test('partial quantity is a cumulative total and cannot erase boxes already picked', () => { const body = page.match(/partialInputValid\(\) \{([\s\S]*?)\n\t\t\t\},/)[1] const valid = new Function(body) const context = { partialTargetItem: { qty: 20, pickedPackageCount: 3 }, availablePickQuantity: () => 20 } for (const [input, expected] of [['2', false], ['3', true], ['12', true], ['20', false]]) { assert.equal(valid.call({ ...context, partialInput: input }), expected, input) } assert.match(page, /this.partialInput = Number\(item\?\.pickedPackageCount \|\| 0\) > 0 \? String\(item.pickedPackageCount\) : ''/) })