test(setup): exercise the MSIX registration regression in Windows CI (#13189)

test(setup): run the MSIX registration regression in Windows CI
This commit is contained in:
morluto authored and GitHub committed 2026-11-21 14:33:59 -05:00
1 parent b3dfd5305d
commit c806ba8ed7
2 files changed
+76 -74

No files matched your search

@@ -1,7 +1,6 @@
import { currentClientRegistrationCommand } from "../../../src/application/ClientRegistrationIdentity.js";
import { mkdir, readFile, writeFile } from "node:fs/promises";
import { delimiter, dirname, join, resolve } from "node:path";
import { pathToFileURL } from "node:url";
import { delimiter, join, resolve } from "node:path";
import { expect } from "vitest";
import { z } from "zod";
@@ -16,77 +15,6 @@ const ompConfigurationSchema = z.object({
}),
});
cliTest.skipIf(process.platform !== "win32")(
"mcp add blocks an implicit MSIX-private launcher before writing client files",
async ({ processes }) => {
const home = await createTestTempDirectory("rea-msix-mcp-add-");
const environment = await registrationEnvironment(home, {
CLAUDE_CONFIG_DIR: home,
});
const isolatedConfig = join(home, ".claude.json");
const installed = join(home, "installed", "rea.mjs");
const privateEntry = join(
home,
"localappdata",
"Packages",
"Fixture_123",
"LocalCache",
"rea.mjs",
);
const original = '{"mcpServers":{"other":{"command":"unchanged"}}}\n';
const launcher = `import ${JSON.stringify(pathToFileURL(resolve("scripts/rea.mjs")).href)};\n`;
for (const entry of [installed, privateEntry]) {
await mkdir(dirname(entry), { recursive: true });
await writeFile(entry, launcher);
}
await writeFile(isolatedConfig, original);
const run = (entry: string, args: readonly string[] = []) =>
processes.run(
process.execPath,
[entry, "mcp", "add", "--agent", "claude-code", "--json", ...args],
{
cwd: home,
env: environment,
},
);
const blocked = await run(privateEntry);
expect(blocked.exitCode, blocked.stderr).toBe(1);
expect(JSON.parse(blocked.stdout)).toMatchObject({
code: "VALIDATION_ERROR",
message: expect.stringContaining(
"inside the private storage of MSIX package Fixture_123",
),
fieldErrors: [expect.objectContaining({ path: "command" })],
});
expect(await readFile(isolatedConfig, "utf8")).toBe(original);
await expect(
readFile(`${isolatedConfig}.rea.backup`, "utf8"),
).rejects.toMatchObject({ code: "ENOENT" });
const allowed = await run(installed);
expect(allowed.exitCode, allowed.stderr).toBe(0);
expect(JSON.parse(await readFile(isolatedConfig, "utf8"))).toMatchObject({
mcpServers: {
rea: { command: process.execPath, args: [installed, "mcp"] },
other: { command: "unchanged" },
},
});
expect(await readFile(`${isolatedConfig}.rea.backup`, "utf8")).toBe(
original,
);
const explicit = await run(privateEntry, [
"--command",
'"custom executable" mcp',
]);
expect(explicit.exitCode, explicit.stderr).toBe(0);
expect(JSON.parse(await readFile(isolatedConfig, "utf8"))).toMatchObject({
mcpServers: { rea: { command: "custom executable", args: ["mcp"] } },
});
},
);
const controlledRunnerFixture = async (home: string) => {
const bin = join(home, "bin");
const script = join(home, "runner-fixture.cjs");
@@ -1,5 +1,6 @@
import { mkdir, readFile, writeFile } from "node:fs/promises";
import { join, isAbsolute } from "node:path";
import { dirname, isAbsolute, join, resolve } from "node:path";
import { pathToFileURL } from "node:url";
import { Client } from "@modelcontextprotocol/client";
import {
StdioClientTransport,
@@ -15,6 +16,8 @@ import { PRODUCT_IDENTITY } from "../../../src/identity.js";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
import { supportedClientRegistrationProfile } from "../../fixtures/clientRegistrationProfile.js";
import { createMcpSchemaValidation } from "../../fixtures/mcpSchemaValidation.js";
import { registrationEnvironment } from "../../support/cli/registrationEnvironment.js";
import { processTest } from "../../support/process/processFixture.js";
// These writer tests model setup running from REA's actual entrypoint, not Vitest's worker.
vi.mock(
@@ -239,3 +242,74 @@ it.skipIf(process.platform !== "win32")(
}
},
);
processTest.skipIf(process.platform !== "win32")(
"mcp add blocks an implicit MSIX-private launcher before writing client files",
async ({ processes }) => {
const home = await createTestTempDirectory("rea-msix-mcp-add-");
const environment = await registrationEnvironment(home, {
CLAUDE_CONFIG_DIR: home,
});
const isolatedConfig = join(home, ".claude.json");
const installed = join(home, "installed", "rea.mjs");
const privateEntry = join(
home,
"localappdata",
"Packages",
"Fixture_123",
"LocalCache",
"rea.mjs",
);
const original = '{"mcpServers":{"other":{"command":"unchanged"}}}\n';
const launcher = `import ${JSON.stringify(pathToFileURL(resolve("scripts/rea.mjs")).href)};\n`;
for (const entry of [installed, privateEntry]) {
await mkdir(dirname(entry), { recursive: true });
await writeFile(entry, launcher);
}
await writeFile(isolatedConfig, original);
const run = (entry: string, args: readonly string[] = []) =>
processes.run(
process.execPath,
[entry, "mcp", "add", "--agent", "claude-code", "--json", ...args],
{
cwd: home,
env: environment,
},
);
const blocked = await run(privateEntry);
expect(blocked.exitCode, blocked.stderr).toBe(1);
expect(JSON.parse(blocked.stdout)).toMatchObject({
code: "VALIDATION_ERROR",
message: expect.stringContaining(
"inside the private storage of MSIX package Fixture_123",
),
fieldErrors: [expect.objectContaining({ path: "command" })],
});
expect(await readFile(isolatedConfig, "utf8")).toBe(original);
await expect(
readFile(`${isolatedConfig}.rea.backup`, "utf8"),
).rejects.toMatchObject({ code: "ENOENT" });
const allowed = await run(installed);
expect(allowed.exitCode, allowed.stderr).toBe(0);
expect(JSON.parse(await readFile(isolatedConfig, "utf8"))).toMatchObject({
mcpServers: {
rea: { command: process.execPath, args: [installed, "mcp"] },
other: { command: "unchanged" },
},
});
expect(await readFile(`${isolatedConfig}.rea.backup`, "utf8")).toBe(
original,
);
const explicit = await run(privateEntry, [
"--command",
'"custom executable" mcp',
]);
expect(explicit.exitCode, explicit.stderr).toBe(0);
expect(JSON.parse(await readFile(isolatedConfig, "utf8"))).toMatchObject({
mcpServers: { rea: { command: "custom executable", args: ["mcp"] } },
});
},
);