Skip to content

Commit 048e4e4

Browse files
test: align setup expectations after automation merge
1 parent aec895f commit 048e4e4

2 files changed

Lines changed: 15 additions & 35 deletions

File tree

test/cli.test.ts

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,9 @@ describe("registerCommands", () => {
229229
const help = program.helpInformation();
230230

231231
expect(help).toMatch(/Setup:[\s\S]*agents\s+list supported AI agent providers and readiness/);
232-
expect(help).toMatch(/Setup:[\s\S]*config\s+read and write codealmanac settings/);
232+
expect(help).toMatch(/Setup:[\s\S]*config\s+read and write Almanac settings/);
233233
expect(help).toContain("Deprecated:");
234-
expect(help).toMatch(/set <key> \[value\.\.\.\]\s+configure codealmanac defaults/);
234+
expect(help).toMatch(/set <key> \[value\.\.\.\]\s+configure Almanac defaults/);
235235
expect(help).toMatch(/ps \[options\]\s+deprecated alias for jobs/);
236236
});
237237
});
@@ -374,42 +374,22 @@ describe("run() — codealmanac-setup shortcut routing", () => {
374374
});
375375
});
376376

377-
it("does NOT shortcut when the binary name is `almanac`", async () => {
378-
// `almanac --yes` without a subcommand isn't a setup invocation —
379-
// it's a commander error ("unknown option '--yes'"). We verify
380-
// runSetup was NOT called. Commander will write to stderr;
381-
// capture + silence it.
377+
it("routes bare `almanac --yes` to setup", async () => {
382378
const setupMock = vi
383379
.fn<(opts?: unknown) => Promise<SetupResult>>()
384380
.mockResolvedValue({ stdout: "", stderr: "", exitCode: 0 });
385381

386-
// Commander prints to stderr + throws via `exitOverride` or process.exit;
387-
// we swallow either to keep the test surface clean.
388-
const origErr = process.stderr.write.bind(process.stderr);
389-
process.stderr.write = (() => true) as typeof process.stderr.write;
390-
const origExit = process.exit;
391-
process.exit = ((code?: number): never => {
392-
throw new Error(`process.exit called with ${code}`);
393-
}) as typeof process.exit;
394-
395-
try {
396-
await run(
397-
["/abs/node", "/abs/path/almanac", "--yes"],
398-
{
399-
runSetup: setupMock as never,
400-
announceUpdate: () => {},
401-
scheduleUpdateCheck: () => {},
402-
runInternalUpdateCheck: async () => {},
403-
},
404-
).catch(() => {
405-
// Swallow — commander's unknown-option error bubbles here.
406-
});
407-
} finally {
408-
process.stderr.write = origErr;
409-
process.exit = origExit;
410-
}
382+
await run(
383+
["/abs/node", "/abs/path/almanac", "--yes"],
384+
{
385+
runSetup: setupMock as never,
386+
announceUpdate: () => {},
387+
scheduleUpdateCheck: () => {},
388+
runInternalUpdateCheck: async () => {},
389+
},
390+
);
411391

412-
expect(setupMock).not.toHaveBeenCalled();
392+
expect(setupMock).toHaveBeenCalledWith({ yes: true });
413393
});
414394

415395
it("does NOT shortcut for `codealmanac doctor`", async () => {

test/setup.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ describe("codealmanac setup", () => {
226226
});
227227
});
228228

229-
it("reports auth status without blocking setup", async () => {
229+
it("does not block setup when the selected agent is ready", async () => {
230230
await withTempHome(async (home) => {
231231
const env = await scaffold(home);
232232
const res = await runSetup({
@@ -241,7 +241,7 @@ describe("codealmanac setup", () => {
241241
});
242242

243243
expect(res.exitCode).toBe(0);
244-
expect(env.stdout()).toMatch(/not signed in/);
244+
expect(env.stdout()).toMatch(/Agent:/);
245245
expect(existsSync(env.plistPath)).toBe(true);
246246
});
247247
});

0 commit comments

Comments
 (0)