fix(gsd): address QA round 4
- Add unitType/unitId round-trip test for paused-session metadata. - Add backward-compatibility test for legacy metadata without unitType/unitId fields.
This commit is contained in:
parent
690bcbd79c
commit
3b9b109a4e
1 changed files with 35 additions and 1 deletions
|
|
@ -103,12 +103,14 @@ function writePausedSession(
|
|||
milestoneId = "M001",
|
||||
stepMode = false,
|
||||
worktreePath?: string,
|
||||
unitType?: string,
|
||||
unitId?: string,
|
||||
): void {
|
||||
const runtimeDir = join(base, ".gsd", "runtime");
|
||||
mkdirSync(runtimeDir, { recursive: true });
|
||||
writeFileSync(
|
||||
join(runtimeDir, "paused-session.json"),
|
||||
JSON.stringify({ milestoneId, originalBasePath: base, stepMode, worktreePath }, null, 2),
|
||||
JSON.stringify({ milestoneId, originalBasePath: base, stepMode, worktreePath, unitType, unitId }, null, 2),
|
||||
"utf-8",
|
||||
);
|
||||
}
|
||||
|
|
@ -168,6 +170,38 @@ test("readPausedSessionMetadata reads paused-session metadata when present", ()
|
|||
}
|
||||
});
|
||||
|
||||
test("readPausedSessionMetadata preserves unitType and unitId through round-trip", () => {
|
||||
const base = makeTmpBase();
|
||||
try {
|
||||
writePausedSession(base, "M001", false, undefined, "execute-task", "M001/S01/T02");
|
||||
const meta = readPausedSessionMetadata(base);
|
||||
assert.equal(meta?.unitType, "execute-task");
|
||||
assert.equal(meta?.unitId, "M001/S01/T02");
|
||||
} finally {
|
||||
cleanup(base);
|
||||
}
|
||||
});
|
||||
|
||||
test("readPausedSessionMetadata handles legacy metadata without unitType/unitId", () => {
|
||||
const base = makeTmpBase();
|
||||
try {
|
||||
// Write metadata without unitType/unitId (simulates older version)
|
||||
const runtimeDir = join(base, ".gsd", "runtime");
|
||||
mkdirSync(runtimeDir, { recursive: true });
|
||||
writeFileSync(
|
||||
join(runtimeDir, "paused-session.json"),
|
||||
JSON.stringify({ milestoneId: "M001", originalBasePath: base }),
|
||||
"utf-8",
|
||||
);
|
||||
const meta = readPausedSessionMetadata(base);
|
||||
assert.equal(meta?.milestoneId, "M001");
|
||||
assert.equal(meta?.unitType, undefined);
|
||||
assert.equal(meta?.unitId, undefined);
|
||||
} finally {
|
||||
cleanup(base);
|
||||
}
|
||||
});
|
||||
|
||||
test("assessInterruptedSession returns none when no lock and no paused session exist", async () => {
|
||||
const base = makeTmpBase();
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue