Skip to content

Commit af2ff4e

Browse files
committed
Add readonly indicator and widget tests to tui-indicators.test
1 parent 55f20e2 commit af2ff4e

1 file changed

Lines changed: 38 additions & 1 deletion

File tree

tests/unit/tui-indicators.test.ts

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import test from "node:test";
22
import assert from "node:assert/strict";
33
import { createState } from "../../state.js";
4-
import { updateIndicators, STATUS_KEY_TOPIC } from "../../tui.js";
4+
import { updateIndicators, STATUS_KEY_TOPIC, STATUS_KEY_READONLY } from "../../tui.js";
55
import { makeTUICtx } from "./helpers.js";
66

77
test("updateIndicators sets context usage status with correct color tone", () => {
@@ -89,6 +89,43 @@ test("updateIndicators shows active notebook topic when set", () => {
8989
assert.equal(record.statuses.get(STATUS_KEY_TOPIC), "🧭 oauth");
9090
});
9191

92+
test("updateIndicators shows readonly indicator when enabled", () => {
93+
const state = createState();
94+
state.readonlyEnabled = true;
95+
const record = { statuses: new Map<string, string | undefined>(), widgets: new Map<string, string[] | undefined>() };
96+
const ctx = makeTUICtx({ percent: null, record });
97+
98+
updateIndicators(ctx, state);
99+
const s = record.statuses.get(STATUS_KEY_READONLY);
100+
assert.ok(s?.includes("\u{1F512}"), "readonly indicator should show lock emoji when enabled");
101+
assert.ok(s?.includes("readonly"), "readonly indicator should show 'readonly' text when enabled");
102+
});
103+
104+
test("updateIndicators hides readonly indicator when disabled", () => {
105+
const state = createState();
106+
state.readonlyEnabled = false;
107+
const record = { statuses: new Map<string, string | undefined>(), widgets: new Map<string, string[] | undefined>() };
108+
const ctx = makeTUICtx({ percent: null, record });
109+
110+
updateIndicators(ctx, state);
111+
assert.equal(record.statuses.get(STATUS_KEY_READONLY), undefined, "readonly indicator should be undefined when disabled");
112+
});
113+
114+
test("updateIndicators shows readonly-specific warning widget at 70%+ context", () => {
115+
const state = createState();
116+
state.readonlyEnabled = true;
117+
const record = { statuses: new Map<string, string | undefined>(), widgets: new Map<string, string[] | undefined>() };
118+
const ctx = makeTUICtx({ percent: 85, record });
119+
120+
updateIndicators(ctx, state);
121+
const w = record.widgets.get("agenticoding-warning");
122+
assert.ok(w, "warning widget should be present at 85%");
123+
assert.ok(w[0].includes("readonly"), "widget should mention readonly");
124+
assert.ok(w[0].includes("spawn"), "widget should mention spawn");
125+
assert.ok(w[0].includes("handoff"), "widget should mention handoff");
126+
assert.ok(w[0].includes("resumes readonly"), "widget should mention readonly resumption");
127+
});
128+
92129
test("updateIndicators hides widget below 70% context", () => {
93130
const state = createState();
94131
const record = { statuses: new Map<string, string | undefined>(), widgets: new Map<string, string[] | undefined>() };

0 commit comments

Comments
 (0)