feat(FN-4313): complete Step 1 — add central default project setting

Fusion-Task-Id: FN-4313
Fusion-Task-Lineage: 36b8aad3-20f4-475b-9b0f-63e5458d1b91
This commit is contained in:
Fusion
2026-05-13 22:24:27 -07:00
committed by gsxdsm
parent 8722d0bc2c
commit 611aca71ed
3 changed files with 102 additions and 1 deletions

View File

@@ -2378,6 +2378,58 @@ describe("CentralCore", () => {
});
});
describe("default project setting", () => {
beforeEach(async () => {
await central.init();
});
it("should be undefined by default", async () => {
await expect(central.getDefaultProjectId()).resolves.toBeUndefined();
});
it("should set/get and clear default project id", async () => {
const projectPath = join(tempDir, "default-project");
mkdirSync(projectPath);
projectPaths.push(projectPath);
const project = await central.registerProject({
name: "Default Project",
path: projectPath,
});
await central.setDefaultProjectId(project.id);
await expect(central.getDefaultProjectId()).resolves.toBe(project.id);
await central.setDefaultProjectId(null);
await expect(central.getDefaultProjectId()).resolves.toBeUndefined();
});
it("should reject unknown project id", async () => {
await expect(central.setDefaultProjectId("missing-project-id")).rejects.toThrow(
"Cannot set default project: project not found: missing-project-id",
);
});
it("should persist setting across reopen", async () => {
const projectPath = join(tempDir, "persisted-default-project");
mkdirSync(projectPath);
projectPaths.push(projectPath);
const project = await central.registerProject({
name: "Persisted Default Project",
path: projectPath,
});
await central.setDefaultProjectId(project.id);
await central.close();
central = new CentralCore(tempDir);
await central.init();
await expect(central.getDefaultProjectId()).resolves.toBe(project.id);
});
});
describe("global concurrency", () => {
beforeEach(async () => {
await central.init();