test(tui): force hyperlinks capability for markdown OSC 8 assertions

CI runs without TERM_PROGRAM/TERM, resolving TERMINAL_ID to "base" which
has hyperlinks disabled. The Links suite asserts on OSC 8 sequences, so
flip TERMINAL.hyperlinks for the duration of that describe block. The
render cache keys on hyperlinks state, so the toggle invalidates stale
entries automatically.
This commit is contained in:
can1357
2026-05-12 11:35:12 +02:00
parent 64e89b12b5
commit edc102b825
+14 -1
View File
@@ -1,7 +1,8 @@
import { describe, expect, it } from "bun:test";
import { afterAll, beforeAll, describe, expect, it } from "bun:test";
import type { Terminal as XtermTerminalType } from "@xterm/headless";
import { Chalk } from "chalk";
import { Markdown, renderInlineMarkdown } from "../src/components/markdown.js";
import { TERMINAL } from "../src/terminal-capabilities.js";
import { type Component, TUI } from "../src/tui.js";
import { defaultMarkdownTheme } from "./test-themes.js";
import { VirtualTerminal } from "./virtual-terminal.js";
@@ -1025,6 +1026,18 @@ bar`,
line.replace(/\x1b\]8;;[^\x07]*\x07/g, "").replace(/\x1b\[[0-9;]*m/g, "");
describe("Links", () => {
// CI environments often resolve to the "base" terminal which has hyperlinks
// disabled; force them on so OSC 8 assertions are deterministic. The render
// cache keys on TERMINAL.hyperlinks, so flipping the bit invalidates entries.
const terminalState = TERMINAL as unknown as { hyperlinks: boolean };
const originalHyperlinks = terminalState.hyperlinks;
beforeAll(() => {
terminalState.hyperlinks = true;
});
afterAll(() => {
terminalState.hyperlinks = originalHyperlinks;
});
it("should not duplicate URL for autolinked emails", () => {
const markdown = new Markdown("Contact user@example.com for help", 0, 0, defaultMarkdownTheme);