mirror of
https://github.com/morluto/rea.git
synced 2026-12-06 14:59:05 +00:00
test(pi): share empty-environment registration reads (#16893)
This commit is contained in:
1 parent
9f8a5633b0
commit
09b2812cf3
1 file changed
+34
-95
@@ -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",
|
||||
|
||||
Reference in new issue
Block a user