Files
rea/tests/acceptance/setup/repeatedClientSetup.test.ts
T
Afloat c012015ae8 fix(setup): deduplicate selected clients before planning (#3919)
Normalize client identities once in the shared workflow while preserving first-selected order. Keep planning, readiness, default skill selection and configuration application on the same unique list.

Cover duplicate selections in direct workflow tests and an isolated compiled CLI preview/apply/rerun journey. Refs morluto/rea#3847.
2026-10-16 23:59:15 +08:00

82 lines
2.3 KiB
TypeScript

import { access, readFile } from "node:fs/promises";
import { join } from "node:path";
import { expect } from "vitest";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
import { cliTest } from "../../support/cli/cliFixture.js";
cliTest(
"repeated client flags plan and configure each selected client once",
async ({ cli }) => {
const directory = await createTestTempDirectory("rea-repeated-clients-");
const arguments_ = [
"setup",
"--client",
"cursor",
"--client",
"codex",
"--client",
"cursor",
"--skill=false",
"--json",
];
const run = (mode: string) =>
cli.run({
arguments: [...arguments_, mode],
cwd: directory,
environment: {
HOME: directory,
USERPROFILE: directory,
TMPDIR: directory,
},
});
const configurations = [
join(directory, ".cursor/mcp.json"),
join(directory, ".codex/config.toml"),
];
const preview = await run("--dry-run");
expect(preview.exitCode, preview.stdout).toBe(0);
expect(preview.json).toMatchObject({
status: "planned",
plannedActions: [
{ id: "configure_client:cursor" },
{ id: "configure_client:codex" },
],
appliedActions: [],
});
for (const path of configurations)
await expect(access(path)).rejects.toMatchObject({ code: "ENOENT" });
const applied = await run("--yes");
expect(applied.exitCode, applied.stdout).toBe(0);
expect(applied.json).toMatchObject({
status: "ready",
plannedActions: [
{ id: "configure_client:cursor" },
{ id: "configure_client:codex" },
],
appliedActions: ["configured_cursor", "configured_codex"],
clients: {
cursor: { status: "configured" },
codex: { status: "configured" },
},
});
const configured = await Promise.all(
configurations.map((path) => readFile(path, "utf8")),
);
const repeated = await run("--yes");
expect(repeated.exitCode, repeated.stdout).toBe(0);
expect(repeated.json).toMatchObject({
status: "ready",
plannedActions: [],
appliedActions: [],
});
expect(
await Promise.all(configurations.map((path) => readFile(path, "utf8"))),
).toEqual(configured);
},
);