test: add regression test for stale pending auto-start cleanup

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Tibsfox 2026-04-06 22:27:04 -07:00
parent 7e9434dec1
commit 2e4c19eb16

View file

@ -0,0 +1,41 @@
/**
* clear-stale-autostart.test.ts #3667
*
* Verify that guided-flow.ts adds a createdAt timestamp to pending auto-start
* entries and implements a staleness check (30s age guard) so that /clear
* interrupted discussions don't permanently block future /gsd invocations.
*/
import { describe, test } from "node:test";
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { join, dirname } from "node:path";
import { fileURLToPath } from "node:url";
const __dirname = dirname(fileURLToPath(import.meta.url));
const sourceFile = join(__dirname, "..", "guided-flow.ts");
describe("clear stale pending auto-start (#3667)", () => {
const source = readFileSync(sourceFile, "utf-8");
test("PendingAutoStartEntry interface includes createdAt field", () => {
assert.match(source, /createdAt:\s*number/);
});
test("setPendingAutoStart defaults createdAt to Date.now()", () => {
assert.match(source, /createdAt:\s*Date\.now\(\)/);
});
test("staleness check uses 30_000ms threshold", () => {
assert.match(source, /30[_]?000/);
});
test("stale entry detection checks manifest and context files", () => {
assert.match(source, /DISCUSSION-MANIFEST\.json/);
assert.match(source, /CONTEXT\.md/);
});
test("stale entries are deleted from the map", () => {
assert.match(source, /pendingAutoStartMap\.delete\(basePath\)/);
});
});