- Added markdown prose tests to verify maskNonProse preserves plain prose and masks fenced/tilde blocks. - Added keyword-in-prose tests that enforced lowercase token matching and ignored code spans, fences, XML, and comments. - Added highlight-mode tests ensuring only prose keywords are ANSI-highlighted and inline/fenced/XML regions stay unmodified. - Added workflow/orchestrate assertions that uppercase or path-like forms remain unchanged while lowercase token boundaries are handled correctly.
37 lines
1.4 KiB
TypeScript
37 lines
1.4 KiB
TypeScript
import { beforeAll, describe, expect, it } from "bun:test";
|
|
import { UserMessageComponent } from "../../../src/modes/components/user-message";
|
|
import { initTheme } from "../../../src/modes/theme/theme";
|
|
|
|
beforeAll(async () => {
|
|
await initTheme(false);
|
|
});
|
|
|
|
function render(text: string): string {
|
|
return new UserMessageComponent(text).render(80).join("\n");
|
|
}
|
|
|
|
describe("UserMessageComponent magic-keyword highlighting", () => {
|
|
it("gradient-paints a magic keyword in the rendered (sent) message bubble", () => {
|
|
const raw = render("please orchestrate the rollout");
|
|
// Visible text is preserved.
|
|
expect(Bun.stripANSI(raw)).toContain("please orchestrate the rollout");
|
|
// The keyword is gradient-painted: a per-character foreground sequence is emitted,
|
|
// and the word no longer survives as a contiguous run in the rendered bytes.
|
|
expect(raw).toContain("\x1b[38");
|
|
expect(raw).not.toContain("orchestrate");
|
|
});
|
|
|
|
it("does not paint a keyword inside an inline code span", () => {
|
|
const raw = render("ship the `orchestrate` helper");
|
|
expect(Bun.stripANSI(raw)).toContain("orchestrate");
|
|
// Code spans render through the code style as a single run — the word stays intact.
|
|
expect(raw).toContain("orchestrate");
|
|
});
|
|
|
|
it("does not paint a keyword inside a fenced code block", () => {
|
|
const raw = render("intro\n```\norchestrate\n```");
|
|
expect(Bun.stripANSI(raw)).toContain("orchestrate");
|
|
expect(raw).toContain("orchestrate");
|
|
});
|
|
});
|