From fdaf644ed1e181e768fdbab190671c0a1af94a71 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Fri, 4 Dec 2026 01:37:06 +0800 Subject: [PATCH] test(config): share Cursor JSON client fixtures (#16417) --- tests/boundary/filesystem/setupConfig.test.ts | 110 +++++------------- 1 file changed, 26 insertions(+), 84 deletions(-) diff --git a/tests/boundary/filesystem/setupConfig.test.ts b/tests/boundary/filesystem/setupConfig.test.ts index 2a812b0d06a..92e372359db 100644 --- a/tests/boundary/filesystem/setupConfig.test.ts +++ b/tests/boundary/filesystem/setupConfig.test.ts @@ -30,6 +30,14 @@ import { CURRENT_ENTRYPOINT_PATH } from "../../../src/process/CurrentEntrypointP const registrationCommand = currentClientRegistrationCommand(); +const cursorJsonClient = (configPath: string) => + ({ + name: "cursor", + registrationProfile: supportedClientRegistrationProfile("cursor"), + configPath, + format: "json", + }) as const; + it.skipIf(process.platform === "win32")( "preserves an aligned caller launcher alias without writes or a backup", async () => { @@ -266,12 +274,9 @@ describe("JSON client configuration transaction: writing configuration through s const original = '{"theme":"dark","mcpServers":{"other":{"command":"other"}}}\n'; await writeFile(configPath, original); - const result = await configureClientConfiguration({ - name: "cursor", - registrationProfile: supportedClientRegistrationProfile("cursor"), - configPath, - format: "json", - }); + const result = await configureClientConfiguration( + cursorJsonClient(configPath), + ); expect(result.status).toBe("configured"); expect(await readFile(`${configPath}.rea.backup`, "utf8")).toBe(original); expect(JSON.parse(await readFile(configPath, "utf8"))).toMatchObject({ @@ -295,12 +300,7 @@ describe("JSON client configuration transaction: writing configuration through s await symlink(targetPath, configPath); expect( - await configureClientConfiguration({ - name: "cursor", - registrationProfile: supportedClientRegistrationProfile("cursor"), - configPath, - format: "json", - }), + await configureClientConfiguration(cursorJsonClient(configPath)), ).toMatchObject({ status: "configured" }); expect((await lstat(configPath)).isSymbolicLink()).toBe(true); expect(await readFile(`${configPath}.rea.backup`, "utf8")).toBe(original); @@ -314,12 +314,7 @@ describe("JSON client configuration transaction: writing configuration through s }, }); expect( - await configureClientConfiguration({ - name: "cursor", - registrationProfile: supportedClientRegistrationProfile("cursor"), - configPath, - format: "json", - }), + await configureClientConfiguration(cursorJsonClient(configPath)), ).toEqual({ status: "unchanged", }); @@ -331,12 +326,7 @@ describe("JSON client configuration transaction: writing configuration through s await symlink(join(directory, "missing.json"), configPath); expect( - await configureClientConfiguration({ - name: "cursor", - registrationProfile: supportedClientRegistrationProfile("cursor"), - configPath, - format: "json", - }), + await configureClientConfiguration(cursorJsonClient(configPath)), ).toEqual({ status: "failed", reason: "path", @@ -357,12 +347,7 @@ describe("JSON client configuration transaction: keeping matching configuration `${JSON.stringify({ mcpServers: { rea: { command: registrationCommand[0], args: registrationCommand.slice(1) } } })}\n`, ); expect( - await configureClientConfiguration({ - name: "cursor", - registrationProfile: supportedClientRegistrationProfile("cursor"), - configPath, - format: "json", - }), + await configureClientConfiguration(cursorJsonClient(configPath)), ).toEqual({ status: "unchanged", }); @@ -391,18 +376,10 @@ describe("JSON client configuration transaction: keeping matching configuration ); expect( - await configureClientConfiguration( - { - name: "cursor", - registrationProfile: supportedClientRegistrationProfile("cursor"), - configPath, - format: "json", - }, - { - GHIDRA_INSTALL_DIR: "/opt/ghidra", - JAVA_HOME: "/usr/lib/jvm/jdk-21", - }, - ), + await configureClientConfiguration(cursorJsonClient(configPath), { + GHIDRA_INSTALL_DIR: "/opt/ghidra", + JAVA_HOME: "/usr/lib/jvm/jdk-21", + }), ).toEqual({ status: "unchanged" }); await expect( readFile(`${configPath}.rea.backup`, "utf8"), @@ -419,12 +396,7 @@ describe("JSON client configuration migration and provider paths", () => { await writeFile(configPath, original); expect( - await configureClientConfiguration({ - name: "cursor", - registrationProfile: supportedClientRegistrationProfile("cursor"), - configPath, - format: "json", - }), + await configureClientConfiguration(cursorJsonClient(configPath)), ).toEqual(expect.objectContaining({ status: "configured" })); expect(JSON.parse(await readFile(configPath, "utf8"))).toEqual({ @@ -444,12 +416,7 @@ describe("JSON client configuration migration and provider paths", () => { const directory = await createTestTempDirectory("rea-setup-"); const configPath = join(directory, "mcp.json"); const hopperPath = "/Applications/Hopper v6.app/Contents/MacOS/hopper"; - const client = { - name: "cursor", - registrationProfile: supportedClientRegistrationProfile("cursor"), - configPath, - format: "json", - } as const; + const client = cursorJsonClient(configPath); const original = "{}\n"; await writeFile(configPath, original); expect( @@ -486,12 +453,7 @@ describe("JSON client configuration migration and provider paths", () => { it("adds exact BYO Ghidra and Java paths without installing dependencies", async () => { const directory = await createTestTempDirectory("rea-setup-"); const configPath = join(directory, "mcp.json"); - const client = { - name: "cursor", - registrationProfile: supportedClientRegistrationProfile("cursor"), - configPath, - format: "json", - } as const; + const client = cursorJsonClient(configPath); const environment = { GHIDRA_INSTALL_DIR: "/opt/ghidra_12.1.4_PUBLIC", JAVA_HOME: "/usr/lib/jvm/jdk-21", @@ -524,12 +486,7 @@ describe("invalid JSON client configuration preservation", () => { const configPath = join(directory, "mcp.json"); await writeFile(configPath, "not-json"); expect( - await configureClientConfiguration({ - name: "cursor", - registrationProfile: supportedClientRegistrationProfile("cursor"), - configPath, - format: "json", - }), + await configureClientConfiguration(cursorJsonClient(configPath)), ).toEqual({ status: "failed", reason: "readback", @@ -543,12 +500,7 @@ describe("invalid JSON client configuration preservation", () => { const configPath = join(directory, "mcp.json"); await writeFile(configPath, original); expect( - await configureClientConfiguration({ - name: "cursor", - registrationProfile: supportedClientRegistrationProfile("cursor"), - configPath, - format: "json", - }), + await configureClientConfiguration(cursorJsonClient(configPath)), ).toEqual({ status: "failed", reason: "readback", @@ -566,12 +518,7 @@ describe("invalid JSON client configuration preservation", () => { const original = `{"mcpServers":${servers}}`; await writeFile(configPath, original); expect( - await configureClientConfiguration({ - name: "cursor", - registrationProfile: supportedClientRegistrationProfile("cursor"), - configPath, - format: "json", - }), + await configureClientConfiguration(cursorJsonClient(configPath)), ).toEqual({ status: "failed", reason: "readback", @@ -662,12 +609,7 @@ describe("JSON client configuration shape diagnostics", () => { async (original, problem) => { const directory = await createTestTempDirectory("rea-setup-shape-"); const configPath = join(directory, "mcp.json"); - const client = { - name: "cursor", - registrationProfile: supportedClientRegistrationProfile("cursor"), - configPath, - format: "json" as const, - }; + const client = cursorJsonClient(configPath); await writeFile(configPath, original); const read = await readConfigurationFile(configPath, "json"); if (read.ok) throw new Error("expected malformed configuration");