authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-09-05 22:32:35-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-09-05 22:32:35-07:00
logb972f1c1dfc827c2fb074af92f52a9f8fc1fcda5
tree2e735f20b2e3eb30f35cfee6991e216a5206b65d
parentfc7ad2edaeedabebcbe1ad6d2f1a4780f0516310
signature Signed by PGP key B5690EEEBB952194

test(web): keep Markdown gutter styling private (#10306)


2 files changed, 1 insertions(+), 43 deletions(-)

apps/web/src/components/ChatMarkdown.test.tsx-42
...@@ -60,7 +60,6 @@ vi.mock("~/lib/openPullRequestLink", () => ({...@@ -60,7 +60,6 @@ vi.mock("~/lib/openPullRequestLink", () => ({
60import ChatMarkdown, {60import ChatMarkdown, {
61 canUseMarkdownFileShellActions,61 canUseMarkdownFileShellActions,
62 hasMarkdownFilePrimaryAction,62 hasMarkdownFilePrimaryAction,
63 orderedListGutterStyle,
64 shouldUseMarkdownFileBrowserPrimaryAction,63 shouldUseMarkdownFileBrowserPrimaryAction,
65} from "./ChatMarkdown";64} from "./ChatMarkdown";
6665
...@@ -640,47 +639,6 @@ describe("shouldUseMarkdownFileBrowserPrimaryAction", () => {...@@ -640,47 +639,6 @@ describe("shouldUseMarkdownFileBrowserPrimaryAction", () => {
640 });639 });
641});640});
642641
643describe("orderedListGutterStyle", () => {
644 it("leaves the default gutter alone for single-digit lists", () => {
645 expect(orderedListGutterStyle(9, undefined)).toBeUndefined();
646 });
647
648 it("widens the gutter for two-digit lists", () => {
649 expect(orderedListGutterStyle(99, undefined)).toEqual({ "--list-gutter": "3ch" });
650 });
651
652 it("widens the gutter for a two-digit list that starts above 1", () => {
653 // start=50 + 49 items => last marker is "98", still two digits.
654 expect(orderedListGutterStyle(49, 50)).toEqual({ "--list-gutter": "3ch" });
655 });
656
657 it("widens the gutter once the last marker reaches three digits", () => {
658 // item 100 is the bug from #6512: a 100-item list starting at 1.
659 expect(orderedListGutterStyle(100, undefined)).toEqual({ "--list-gutter": "4ch" });
660 });
661
662 it("accounts for a non-default start attribute", () => {
663 // start=95 + 9 items => last marker is "103", three digits.
664 expect(orderedListGutterStyle(9, 95)).toEqual({ "--list-gutter": "4ch" });
665 expect(orderedListGutterStyle(5, "999995")).toEqual({ "--list-gutter": "7ch" });
666 });
667
668 it("scales further for four-digit markers", () => {
669 expect(orderedListGutterStyle(1000, undefined)).toEqual({ "--list-gutter": "5ch" });
670 });
671
672 it("uses the widest marker and includes a negative start's minus sign", () => {
673 expect(orderedListGutterStyle(1001, -1000)).toEqual({ "--list-gutter": "6ch" });
674 expect(orderedListGutterStyle(3, -15)).toEqual({ "--list-gutter": "4ch" });
675 expect(orderedListGutterStyle(3, -5)).toEqual({ "--list-gutter": "3ch" });
676 });
677
678 it("treats a missing/zero item count as a single item", () => {
679 expect(orderedListGutterStyle(0, undefined)).toBeUndefined();
680 expect(orderedListGutterStyle(0, 100)).toEqual({ "--list-gutter": "4ch" });
681 });
682});
683
684describe("ChatMarkdown Windows file links", () => {642describe("ChatMarkdown Windows file links", () => {
685 const environmentId = EnvironmentId.make("env-windows");643 const environmentId = EnvironmentId.make("env-windows");
686644
apps/web/src/components/ChatMarkdown.tsx+1-1
...@@ -340,7 +340,7 @@ function findTaskListMarkerOffset(markdown: string, listItemStart: number): numb...@@ -340,7 +340,7 @@ function findTaskListMarkerOffset(markdown: string, listItemStart: number): numb
340 * message's overflow. Widen the gutter to fit the widest marker, including a340 * message's overflow. Widen the gutter to fit the widest marker, including a
341 * negative marker's minus sign.341 * negative marker's minus sign.
342 */342 */
343export function orderedListGutterStyle(343function orderedListGutterStyle(
344 itemCount: number,344 itemCount: number,
345 start: unknown,345 start: unknown,
346): { "--list-gutter": string } | undefined {346): { "--list-gutter": string } | undefined {