From 95ece25c3744dce5dfc217c3b66420d74c434c4f Mon Sep 17 00:00:00 2001 From: mesalogo Date: Thu, 8 Oct 2026 09:40:38 +0800 Subject: [PATCH] test: reject calls after confirmed storage loss --- src/main/desktop-storage-electron-fixture.ts | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/main/desktop-storage-electron-fixture.ts b/src/main/desktop-storage-electron-fixture.ts index d1bd6114..1d599771 100644 --- a/src/main/desktop-storage-electron-fixture.ts +++ b/src/main/desktop-storage-electron-fixture.ts @@ -205,22 +205,14 @@ async function run(): Promise { await lostFiles.attachments.outputCreate('crashed-call', abandoned) await lostFiles.attachments.outputAppend('crashed-call', abandoned, Buffer.from('orphan')) await lostFiles.attachments.outputFinish('crashed-call', abandoned, 6) - const internal = lost as unknown as { transport: { child: { kill(): boolean; postMessage(message: unknown): void } } } - const post = internal.transport.child.postMessage.bind(internal.transport.child) - let killed = false - internal.transport.child.postMessage = message => { - post(message) - if (!killed && (message as { type: string }).type === 'call') { - killed = true - assert.ok(internal.transport.child.kill()) - } - } + const internal = lost as unknown as { transport: { child: { kill(): boolean } } } const neverReplayId = randomUUID() const neverReplayMessages = histories.map(message => ({ ...message, id: randomUUID() })) + assert.ok(internal.transport.child.kill()) + while (Reflect.get(lost, 'state') !== 'failed') await new Promise(resolve => setImmediate(resolve)) await assert.rejects(lost.call('assistant', 'saveLocalConversations', [[{ header: { id: neverReplayId, title: 'Never replay', updatedAt: 123 }, messages: neverReplayMessages }]]), error => error?.code === 'STORAGE_UNCONFIRMED' || error?.message === 'Storage is not ready') - while (Reflect.get(lost, 'state') !== 'failed') await new Promise(resolve => setImmediate(resolve)) await assert.rejects(lost.call('assistant', 'listProjects', []), /not ready/) await lost.retry() await lost.ready