refactor: deduplicate shared helpers and test setup

This commit is contained in:
Peter Steinberger
2026-02-23 20:40:38 +00:00
parent 1f5e6444ee
commit 75423a00d6
33 changed files with 999 additions and 1112 deletions

View File

@@ -76,6 +76,19 @@ describe("runBootOnce", () => {
});
};
const expectMainSessionRestored = (params: {
storePath: string;
sessionKey: string;
expectedSessionId?: string;
}) => {
const restored = loadSessionStore(params.storePath, { skipCache: true });
if (params.expectedSessionId === undefined) {
expect(restored[params.sessionKey]).toBeUndefined();
return;
}
expect(restored[params.sessionKey]?.sessionId).toBe(params.expectedSessionId);
};
it("skips when BOOT.md is missing", async () => {
await withBootWorkspace({}, async (workspaceDir) => {
await expect(runBootOnce({ cfg: {}, deps: makeDeps(), workspaceDir })).resolves.toEqual({
@@ -226,8 +239,7 @@ describe("runBootOnce", () => {
status: "ran",
});
const restored = loadSessionStore(storePath, { skipCache: true });
expect(restored[sessionKey]?.sessionId).toBe(existingSessionId);
expectMainSessionRestored({ storePath, sessionKey, expectedSessionId: existingSessionId });
});
});
@@ -242,8 +254,7 @@ describe("runBootOnce", () => {
status: "ran",
});
const restored = loadSessionStore(storePath, { skipCache: true });
expect(restored[sessionKey]).toBeUndefined();
expectMainSessionRestored({ storePath, sessionKey });
});
});
});