diff --git a/tests/boundary/filesystem/piClientConfiguration.test.ts b/tests/boundary/filesystem/piClientConfiguration.test.ts index 73b187934b8..5ba9f4e0fb2 100644 --- a/tests/boundary/filesystem/piClientConfiguration.test.ts +++ b/tests/boundary/filesystem/piClientConfiguration.test.ts @@ -26,6 +26,12 @@ afterEach(() => { vi.restoreAllMocks(); }); +const readStatusesWithEmptyEnvironment = (home: string) => + readClientRegistrationStatuses(home, undefined, { + platform: HOST_PLATFORM.platform, + environment: {}, + }); + const piPath = ( home: string, platform: NodeJS.Platform, @@ -190,12 +196,9 @@ describe("Pi registration semantics", () => { }); expect(await readFile(client.configPath, "utf8")).toBe(configured); expect( - ( - await readClientRegistrationStatuses(home, undefined, { - platform: HOST_PLATFORM.platform, - environment: {}, - }) - ).find(({ client: name }) => name === "pi"), + (await readStatusesWithEmptyEnvironment(home)).find( + ({ client: name }) => name === "pi", + ), ).toMatchObject({ state: "aligned" }); expect((await systemUninstallHost(home).removeClient(client)).status).toBe( "removed", @@ -235,10 +238,7 @@ describe("Pi registration semantics", () => { enabledServers: ["rea"], }), ); - const statuses = await readClientRegistrationStatuses(home, undefined, { - platform: HOST_PLATFORM.platform, - environment: {}, - }); + const statuses = await readStatusesWithEmptyEnvironment(home); expect(statuses.find(({ client: name }) => name === "pi")).toMatchObject({ state, }); @@ -281,12 +281,9 @@ describe("Pi strict JSON parsing", () => { readFile(`${client.configPath}.rea.backup`), ).rejects.toMatchObject({ code: "ENOENT" }); expect( - ( - await readClientRegistrationStatuses(home, undefined, { - platform: HOST_PLATFORM.platform, - environment: {}, - }) - ).find(({ client: name }) => name === "pi"), + (await readStatusesWithEmptyEnvironment(home)).find( + ({ client: name }) => name === "pi", + ), ).toMatchObject({ state: "invalid" }); expect( await systemUninstallHost(home).removeClient(client), @@ -332,12 +329,9 @@ describe("Pi strict JSON parsing", () => { }); expect(await readFile(client.configPath, "utf8")).toBe(created); expect( - ( - await readClientRegistrationStatuses(home, undefined, { - platform: HOST_PLATFORM.platform, - environment: {}, - }) - ).find(({ client: name }) => name === "pi"), + (await readStatusesWithEmptyEnvironment(home)).find( + ({ client: name }) => name === "pi", + ), ).toMatchObject({ state: "aligned" }); expect(await systemUninstallHost(home).removeClient(client)).toMatchObject({ name: "pi", @@ -380,10 +374,7 @@ describe("Pi project-scoped discovery and overrides", () => { const projectConfigPath = resolve(projectConfigDir, "mcp.json"); await writePiRegistration(projectConfigPath, command); - const statuses = await readClientRegistrationStatuses(home, undefined, { - platform: HOST_PLATFORM.platform, - environment: {}, - }); + const statuses = await readStatusesWithEmptyEnvironment(home); const piStatus = statuses.find(({ client }) => client === "pi"); expect(piStatus).toMatchObject({ client: "pi", @@ -417,10 +408,7 @@ describe("Pi project-scoped discovery and overrides", () => { const projectConfigPath = resolve(projectConfigDir, "mcp.json"); await writePiRegistration(projectConfigPath, command); - const statuses = await readClientRegistrationStatuses(home, undefined, { - platform: HOST_PLATFORM.platform, - environment: {}, - }); + const statuses = await readStatusesWithEmptyEnvironment(home); const piStatus = statuses.find(({ client }) => client === "pi"); expect(piStatus).toMatchObject({ client: "pi", @@ -458,10 +446,7 @@ describe("Pi project-scoped discovery and overrides", () => { const projectConfigPath = resolve(projectConfigDir, "mcp.json"); await writePiRegistration(projectConfigPath, command); - const statuses = await readClientRegistrationStatuses(home, undefined, { - platform: HOST_PLATFORM.platform, - environment: {}, - }); + const statuses = await readStatusesWithEmptyEnvironment(home); const piStatus = statuses.find(({ client: c }) => c === "pi"); expect(piStatus).toMatchObject({ client: "pi", @@ -522,10 +507,7 @@ describe("Pi project-scoped partial overrides", () => { }), ); - const statuses = await readClientRegistrationStatuses(home, undefined, { - platform: HOST_PLATFORM.platform, - environment: {}, - }); + const statuses = await readStatusesWithEmptyEnvironment(home); const piStatus = statuses.find(({ client }) => client === "pi"); expect(piStatus).toMatchObject({ client: "pi", @@ -573,10 +555,7 @@ describe("Pi project-scoped partial overrides", () => { }), ); - const statuses = await readClientRegistrationStatuses(home, undefined, { - platform: HOST_PLATFORM.platform, - environment: {}, - }); + const statuses = await readStatusesWithEmptyEnvironment(home); const piStatus = statuses.find(({ client }) => client === "pi"); expect(piStatus).toMatchObject({ client: "pi", @@ -629,10 +608,7 @@ describe("Pi project-scoped inherited environment validation", () => { }), ); - const statuses = await readClientRegistrationStatuses(home, undefined, { - platform: HOST_PLATFORM.platform, - environment: {}, - }); + const statuses = await readStatusesWithEmptyEnvironment(home); const piStatus = statuses.find(({ client: c }) => c === "pi"); expect(piStatus).toMatchObject({ client: "pi", @@ -683,10 +659,7 @@ describe("Pi project-scoped inherited environment validation", () => { }), ); - const statuses = await readClientRegistrationStatuses(home, undefined, { - platform: HOST_PLATFORM.platform, - environment: {}, - }); + const statuses = await readStatusesWithEmptyEnvironment(home); const piStatus = statuses.find(({ client: c }) => c === "pi"); expect(piStatus).toMatchObject({ client: "pi", @@ -731,10 +704,7 @@ it.each(["user", "project"] as const)( }), ); - const statuses = await readClientRegistrationStatuses(home, undefined, { - platform: HOST_PLATFORM.platform, - environment: {}, - }); + const statuses = await readStatusesWithEmptyEnvironment(home); const expectedPath = scope === "user" ? client.configPath : projectPath; const status = statuses.find(({ client: name }) => name === "pi"); expect(status).toMatchObject({ @@ -796,10 +766,7 @@ describe("Pi standalone partial override validation", () => { }), ); - const statuses = await readClientRegistrationStatuses(home, undefined, { - platform: HOST_PLATFORM.platform, - environment: {}, - }); + const statuses = await readStatusesWithEmptyEnvironment(home); const piStatus = statuses.find(({ client }) => client === "pi"); expect(piStatus).toMatchObject({ client: "pi", @@ -838,10 +805,7 @@ describe("Pi project-scoped launcher provenance and fallback", () => { }), ); - const statuses = await readClientRegistrationStatuses(home, undefined, { - platform: HOST_PLATFORM.platform, - environment: {}, - }); + const statuses = await readStatusesWithEmptyEnvironment(home); const piStatus = statuses.find(({ client }) => client === "pi"); expect(piStatus).toMatchObject({ client: "pi", @@ -886,10 +850,7 @@ describe("Pi project-scoped launcher provenance and fallback", () => { }), ); - const statuses = await readClientRegistrationStatuses(home, undefined, { - platform: HOST_PLATFORM.platform, - environment: {}, - }); + const statuses = await readStatusesWithEmptyEnvironment(home); const piStatus = statuses.find(({ client }) => client === "pi"); expect(piStatus).toMatchObject({ client: "pi", @@ -940,10 +901,7 @@ describe("Pi project-scoped package launcher repair", () => { }), ); - const statuses = await readClientRegistrationStatuses(home, undefined, { - platform: HOST_PLATFORM.platform, - environment: {}, - }); + const statuses = await readStatusesWithEmptyEnvironment(home); const piStatus = statuses.find(({ client }) => client === "pi"); expect(piStatus).toMatchObject({ client: "pi", @@ -969,10 +927,7 @@ describe("Pi project-scoped package launcher repair", () => { }, }), ); - const migrated = await readClientRegistrationStatuses(home, undefined, { - platform: HOST_PLATFORM.platform, - environment: {}, - }); + const migrated = await readStatusesWithEmptyEnvironment(home); expect(migrated.find(({ client }) => client === "pi")).toMatchObject({ state: "aligned", scope: "project", @@ -1004,10 +959,7 @@ describe("Pi project-scoped fallback on sibling servers", () => { }), ); - const statuses = await readClientRegistrationStatuses(home, undefined, { - platform: HOST_PLATFORM.platform, - environment: {}, - }); + const statuses = await readStatusesWithEmptyEnvironment(home); const piStatus = statuses.find(({ client }) => client === "pi"); const client = supportedClients(home, HOST_PLATFORM.platform).find( ({ name }) => name === "pi", @@ -1047,10 +999,7 @@ describe("Pi project trust enforcement", () => { ); // Without trust decision in trust.json or settings.json, project is untrusted - const statuses = await readClientRegistrationStatuses(home, undefined, { - platform: HOST_PLATFORM.platform, - environment: {}, - }); + const statuses = await readStatusesWithEmptyEnvironment(home); const piStatus = statuses.find(({ client: c }) => c === "pi"); expect(piStatus).toMatchObject({ client: "pi", @@ -1061,11 +1010,7 @@ describe("Pi project trust enforcement", () => { // Now trust the project and verify project configuration is selected await trustPiProject(home, projectDir); - const trustedStatuses = await readClientRegistrationStatuses( - home, - undefined, - { platform: HOST_PLATFORM.platform, environment: {} }, - ); + const trustedStatuses = await readStatusesWithEmptyEnvironment(home); const trustedPiStatus = trustedStatuses.find(({ client: c }) => c === "pi"); expect(trustedPiStatus).toMatchObject({ client: "pi", @@ -1094,10 +1039,7 @@ describe("Pi project trust error handling", () => { vi.spyOn(process, "cwd").mockReturnValue(projectDir); - const statuses = await readClientRegistrationStatuses(home, undefined, { - platform: HOST_PLATFORM.platform, - environment: {}, - }); + const statuses = await readStatusesWithEmptyEnvironment(home); const piStatus = statuses.find(({ client: c }) => c === "pi"); expect(piStatus).toMatchObject({ client: "pi", @@ -1135,10 +1077,7 @@ describe("Pi project trust error handling", () => { vi.spyOn(process, "cwd").mockReturnValue(projectDir); - const statuses = await readClientRegistrationStatuses(home, undefined, { - platform: HOST_PLATFORM.platform, - environment: {}, - }); + const statuses = await readStatusesWithEmptyEnvironment(home); const piStatus = statuses.find(({ client: c }) => c === "pi"); expect(piStatus).toMatchObject({ client: "pi",