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')