This commit is contained in:
2026-09-20 14:22:14 +08:00
parent afd722a7e2
commit 117431a4fb
5 changed files with 51 additions and 7 deletions
+13
View File
@@ -31,6 +31,19 @@ test('online update supports mandatory APK and wgt installation flows', async ()
assert.match(updater, /if \(retry\) await runUpdate\(update\)/)
})
test('update manifest rejects a different AppID and incompatible WGT base', async () => {
const updater = await read('../utils/app-update.js')
const body = updater.match(/function normalizeUpdate\(payload, runtime\) \{[\s\S]*?\n\}/)?.[0]
assert.ok(body)
const normalize = new Function(`${body}; return normalizeUpdate`)()
const runtime = { appid: 'domestic-app', appVersionCode: 3 }
const manifest = { update: true, appid: 'domestic-app', packageType: 'wgt', downloadUrl: 'https://example.com/app.wgt', versionName: '1.0.4', minAppVersionCode: 3 }
assert.equal(normalize(manifest, runtime).minAppVersionCode, 3)
assert.throws(() => normalize({ ...manifest, appid: 'overseas-app' }, runtime), /不匹配/)
assert.throws(() => normalize({ ...manifest, minAppVersionCode: 4 }, runtime), /新版 APK/)
assert.throws(() => normalize({ ...manifest, minAppVersionCode: undefined }, runtime), /新版 APK/)
})
test('profile exposes manual App update checking and the runtime version', async () => {
const profile = await read('../pages/profile/profile.vue')
+22
View File
@@ -0,0 +1,22 @@
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\) : ''/)
})