Files
reverse-engineering-anything/tests/boundary/filesystem/clientRegistrationRefresh.test.ts
Ysopwnableandgensokyo-dev b3cf255894 test(setup): remove PATH assumptions from launcher fixtures (#15282)
Use a shared package-owned launcher in setup and uninstall fixtures.
Exercise publication, recovery, and policy under an isolated PATH.

Follow-up to #15046.

Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing)
Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-12-01 01:44:05 +08:00

48 lines
2.1 KiB
TypeScript

import { parse as parseToml } from "smol-toml";
import { readFile, writeFile } from "node:fs/promises";
import { join } from "node:path";
import { expect, it } from "vitest";
import { configureClientConfiguration } from "../../../src/application/SetupClientConfiguration.js";
import {
ownedPackageCommand,
ownedPackageRegistration,
} from "../../fixtures/ownedPackageRegistration.js";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
import { supportedClientRegistrationProfile } from "../../fixtures/clientRegistrationProfile.js";
it.each([90, 120])(
"preserves caller-selected Grok startup timeout %s when refreshing its launcher",
async (timeout) => {
const directory = await createTestTempDirectory("rea-grok-refresh-");
const configPath = join(directory, "config.toml");
const source = `[mcp_servers.rea]\ncommand = "npx"\nargs = ["-y", "rea-agents@6.1.0", "mcp"]\nstartup_timeout_sec = ${timeout}\ncustom_policy = "caller"\n\n[mcp_servers.rea.env]\nPATH = "/caller/bin:/usr/bin"\nCUSTOM = "preserved"\n`;
await writeFile(configPath, source);
const client = {
name: "grok_build",
registrationProfile: supportedClientRegistrationProfile("grok_build"),
configPath,
format: "grok",
} as const;
expect(
await configureClientConfiguration(client, {}, ownedPackageCommand),
).toMatchObject({ status: "configured" });
const refreshed = await readFile(configPath, "utf8");
expect(parseToml(refreshed, { integersAsBigInt: true })).toMatchObject({
mcp_servers: {
rea: {
...ownedPackageRegistration,
startup_timeout_sec: BigInt(timeout),
custom_policy: "caller",
env: { PATH: "/caller/bin:/usr/bin", CUSTOM: "preserved" },
},
},
});
expect(await readFile(`${configPath}.rea.backup`, "utf8")).toBe(source);
expect(
await configureClientConfiguration(client, {}, ownedPackageCommand),
).toEqual({ status: "unchanged" });
expect(await readFile(configPath, "utf8")).toBe(refreshed);
expect(await readFile(`${configPath}.rea.backup`, "utf8")).toBe(source);
},
);