Skip to content

Commit c839ee4

Browse files
committed
test(daemon): assert the durable close event survives a failed close-time save
Review feedback on #1392 (thymikee), final P2 item: the previous commit removed the actions rollback because there's no surviving session to duplicate the close action on, but nothing actually asserted the durable events.ndjson action.recorded:close event stays put. Flush and read it back so a future rollback or event-order change can't silently recreate the in-memory/durable mismatch the removed rollback used to paper over asymmetrically.
1 parent 3eb6e9d commit c839ee4

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

src/daemon/handlers/__tests__/session-device-claims.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,4 +307,20 @@ test('#1391: a close-time script save failure still clears the advisory claim an
307307
assert.equal(store.get('close-save-script-failure'), undefined);
308308
assert.deepEqual(inspectDeviceClaims({ serial: android.id }), []);
309309
assert.equal(fs.readFileSync(targetPath, 'utf8'), 'pre-existing\n');
310+
311+
// No rollback: the durable `action.recorded: close` event this close wrote
312+
// to events.ndjson (before the script write failed) survives — teardown
313+
// never withholds it, since there is no surviving session for a later
314+
// write to duplicate it against. Guards against a future rollback or
315+
// event-order change silently recreating the in-memory/durable mismatch
316+
// this test's own name warns about.
317+
await store.flushEvents('close-save-script-failure');
318+
const events = store.readEvents('close-save-script-failure').events;
319+
const closeEvent = events.find(
320+
(event) => event.kind === 'action.recorded' && event.command === 'close',
321+
);
322+
assert.ok(
323+
closeEvent,
324+
'expected a durable action.recorded:close event to survive the failed save',
325+
);
310326
});

0 commit comments

Comments
 (0)