From edc102b82539c2ac92ad3f8dd4cedaa6984444c5 Mon Sep 17 00:00:00 2001 From: can1357 Date: Tue, 12 May 2026 11:35:12 +0200 Subject: [PATCH] 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. --- packages/tui/test/markdown.test.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/tui/test/markdown.test.ts b/packages/tui/test/markdown.test.ts index aa3bdfb3e..2eba2bc9e 100644 --- a/packages/tui/test/markdown.test.ts +++ b/packages/tui/test/markdown.test.ts @@ -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);