fix(tests): invalidate both state and path caches before assertions expecting fresh disk state
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
e739c4cab7
commit
8a64a1c1da
2 changed files with 6 additions and 2 deletions
|
|
@ -4,6 +4,7 @@ import { tmpdir } from "node:os";
|
|||
import { fileURLToPath } from "node:url";
|
||||
import { createTestContext } from './test-helpers.ts';
|
||||
import { clearPathCache } from '../paths.ts';
|
||||
import { invalidateStateCache } from '../state.ts';
|
||||
|
||||
// loadPrompt reads from ~/.gsd/agent/extensions/gsd/prompts/ (main checkout).
|
||||
// In a worktree the file may not exist there yet, so we resolve prompts
|
||||
|
|
@ -147,7 +148,7 @@ async function main(): Promise<void> {
|
|||
// ─── deriveState integration: completing-milestone dispatches correctly ─
|
||||
console.log("\n=== deriveState completing-milestone integration ===");
|
||||
{
|
||||
const { deriveState, isMilestoneComplete } = await import("../state.ts");
|
||||
const { deriveState, isMilestoneComplete, invalidateStateCache } = await import("../state.ts");
|
||||
const { parseRoadmap } = await import("../files.ts");
|
||||
|
||||
const base = createFixtureBase();
|
||||
|
|
@ -181,6 +182,7 @@ async function main(): Promise<void> {
|
|||
// Now add the summary and verify it transitions to complete
|
||||
writeMilestoneSummary(base, "M001", "# M001 Summary\n\nDone.");
|
||||
clearPathCache();
|
||||
invalidateStateCache();
|
||||
const stateAfter = await deriveState(base);
|
||||
assertEq(stateAfter.phase, "complete", "deriveState returns complete after summary exists");
|
||||
assertEq(stateAfter.registry[0]?.status, "complete", "registry shows complete status");
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { mkdtempSync, mkdirSync, rmSync, writeFileSync, existsSync } from "node:
|
|||
import { join } from "node:path";
|
||||
import { tmpdir } from "node:os";
|
||||
|
||||
import { deriveState } from "../state.js";
|
||||
import { deriveState, invalidateStateCache } from "../state.js";
|
||||
import { resolveMilestoneFile, clearPathCache } from "../paths.js";
|
||||
|
||||
let passed = 0;
|
||||
|
|
@ -41,6 +41,7 @@ const contextPath = join(gsd, "milestones", "M001", "M001-CONTEXT.md");
|
|||
writeFileSync(contextPath, "# M001: Full Context\n\nDeep discussion output.\n");
|
||||
|
||||
clearPathCache();
|
||||
invalidateStateCache();
|
||||
const state2 = await deriveState(tmpBase);
|
||||
assert(
|
||||
state2.phase === "pre-planning",
|
||||
|
|
@ -67,6 +68,7 @@ assert(
|
|||
|
||||
// Step 4: After cleanup, state is still pre-planning (CONTEXT.md exists)
|
||||
clearPathCache();
|
||||
invalidateStateCache();
|
||||
const state3 = await deriveState(tmpBase);
|
||||
assert(
|
||||
state3.phase === "pre-planning",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue