补客户端更新"校验失败不得当成功"的回归用例
Project CI / AI game creator shell Rust crates (push) Failing after 1m15s
Project CI / AI game creator shell Rust smoke (push) Successful in 1m58s
Project CI / Frontend tests (push) Has been cancelled
Project CI / Backend tests (push) Has been cancelled
Project CI / Repository checks (push) Has been cancelled
Project CI / AI game creator shell web tests (push) Has been cancelled
Project CI / AI game creator shell Rust lane 1/2 (push) Has been cancelled
Project CI / AI game creator shell Rust lane 2/2 (push) Has been cancelled
Project CI / Native shell tests (push) Has been cancelled

- appUpdate.test:新增「签名校验失败时拒绝安装、不重启进程,并保留待装更新供重试」——插件抛 signature verification failed 时断言错误原样上抛、restart_agc_app 未被调用、重试仍走安装链路并在成功后重启
- 变异验证:把 restartAppAfterUpdate() 挪到 await downloadAndInstall 之前,该用例立即以 expected "spy" to not be called with arguments: [ 'restart_agc_app' ] 变红;还原后 7 passed
- 客户端更新里程碑补记该覆盖与剩余边界(真机安装闭环与插件侧临时文件清理需真实设备与已发布包);pitfalls 记录"重启必须排在安装成功之后"
This commit is contained in:
kdletters
2026-09-29 00:02:17 +08:00
parent 8b305162c1
commit f6ccabf425
3 changed files with 35 additions and 1 deletions
@@ -118,6 +118,33 @@ describe('AGC 客户端更新', () => {
resetAppUpdateCheckForTests();
});
it('签名校验失败时拒绝安装、不重启进程,并保留待装更新供重试', async () => {
vi.stubEnv('VITE_AGC_ENABLE_APP_UPDATE_CHECK', '1');
vi.resetModules();
const invoke = stubTauriWindow();
const update = fakeUpdate();
// 官方插件在原生侧校验签名;校验不过时它拒绝安装并抛错。客户端不得把这次失败
// 当成安装成功(更不能重启进程把坏包"坐实"),同时要保留待装更新让重试仍走同一条链路。
update.downloadAndInstall.mockRejectedValueOnce(
new Error('signature verification failed: invalid minisign signature'),
);
checkMock.mockResolvedValue(update as never);
const { checkForAppUpdate, installAppUpdate, resetAppUpdateCheckForTests } =
await import('../src/services/appUpdate');
await checkForAppUpdate();
await expect(installAppUpdate()).rejects.toThrow(
'signature verification failed',
);
expect(invoke).not.toHaveBeenCalledWith('restart_agc_app');
// 待装更新仍在:重试会再次走安装链路,成功后才会重启。
await installAppUpdate();
expect(update.downloadAndInstall).toHaveBeenCalledTimes(2);
expect(invoke).toHaveBeenCalledWith('restart_agc_app');
resetAppUpdateCheckForTests();
});
it('下载失败后仍可重试安装', async () => {
vi.stubEnv('VITE_AGC_ENABLE_APP_UPDATE_CHECK', '1');
vi.resetModules();