Skip to content

Commit 0640e3b

Browse files
committed
test(permissions): expect /yolo off hint on default-source skip warning
1 parent b167db3 commit 0640e3b

3 files changed

Lines changed: 37 additions & 8 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { describe, expect, test } from "bun:test";
2+
import { globalSettingsPath } from "../config/settings.js";
3+
import { savedSkipPermissionsWarning } from "./saved-skip-warning.js";
4+
5+
describe("savedSkipPermissionsWarning", () => {
6+
test("default machine-wide source appends the /yolo off hint", () => {
7+
const source = globalSettingsPath();
8+
9+
const warning = savedSkipPermissionsWarning(source);
10+
11+
expect(warning).toContain(source);
12+
expect(warning).toContain("edit that file to re-enable");
13+
expect(warning).toContain("/yolo off");
14+
});
15+
16+
test("custom source keeps file-path wording with no false provenance", () => {
17+
const warning = savedSkipPermissionsWarning(
18+
"/tmp/custom-corbits-settings.json",
19+
);
20+
21+
expect(warning).toContain("/tmp/custom-corbits-settings.json");
22+
expect(warning).toContain("edit that file to re-enable");
23+
expect(warning).not.toMatch(/machine-wide|saved default|\/yolo off/i);
24+
});
25+
});

‎src/tui/runner/wiring.skip-permissions-warning.test.ts‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { describe, expect, test } from "bun:test";
2+
import { globalSettingsPath } from "../../config/settings.js";
23
import { createAppShell } from "../shell/index.js";
34
import { shellInternals } from "../shell/internals.js";
45
import { withTestRenderer } from "../harness.js";
@@ -34,12 +35,12 @@ describe("saved skip-permissions startup warning", () => {
3435
expect(warning).not.toMatch(/machine-wide|saved default|\/yolo off/i);
3536
});
3637

37-
test("identifies the default settings path", async () => {
38-
const warning = await surfacedWarning(
39-
"/home/operator/.corbits/settings.json",
40-
);
38+
test("appends the /yolo off hint for the default settings path", async () => {
39+
const source = globalSettingsPath();
40+
const warning = await surfacedWarning(source);
4141

42-
expect(warning).toContain("/home/operator/.corbits/settings.json");
42+
expect(warning).toContain(source);
4343
expect(warning).toContain("edit that file to re-enable");
44+
expect(warning).toContain("/yolo off");
4445
});
4546
});

‎tests/unit/exec/runner.test.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,11 @@ describe("runExec", () => {
470470
async () => {
471471
const { runExec: runExecUnderMock } =
472472
await import("../../../src/exec/runner.js");
473-
const defaultSettingsPath = join(home, "settings.json");
473+
const defaultSettingsPath = join(
474+
home,
475+
".corbits",
476+
"settings.json",
477+
);
474478
const result = await runExecUnderMock({
475479
...bareConfig("do the thing"),
476480
cwd,
@@ -487,9 +491,8 @@ describe("runExec", () => {
487491
);
488492
const stderrOutput = stderrChunks.join("");
489493
expect(stderrOutput).toContain(
490-
`Warning: permission prompts are disabled by saved settings at ${defaultSettingsPath}; edit that file to re-enable.\n`,
494+
`Warning: permission prompts are disabled by saved settings at ${defaultSettingsPath}; edit that file to re-enable (/yolo off to re-enable).\n`,
491495
);
492-
expect(stderrOutput).not.toContain("/yolo");
493496
expect(stderrOutput).toMatch(/runtime dispose failed/i);
494497
expect(disposeCalls).toBe(1);
495498
expect(getActiveDisposeHost()).toBeNull();

0 commit comments

Comments
 (0)