From 628bba09376f871697a1634d17c4ddbef5f9e83c Mon Sep 17 00:00:00 2001 From: Dave Date: Sat, 28 Feb 2026 09:18:50 +0000 Subject: [PATCH] story-kit: merge 237_bug_work_item_titles_render_too_large_in_expanded_view --- .../components/WorkItemDetailPanel.test.tsx | 49 +++++++++++++++++++ .../src/components/WorkItemDetailPanel.tsx | 19 ++++++- 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 frontend/src/components/WorkItemDetailPanel.test.tsx diff --git a/frontend/src/components/WorkItemDetailPanel.test.tsx b/frontend/src/components/WorkItemDetailPanel.test.tsx new file mode 100644 index 0000000..faac353 --- /dev/null +++ b/frontend/src/components/WorkItemDetailPanel.test.tsx @@ -0,0 +1,49 @@ +import { render, screen, waitFor } from "@testing-library/react"; +import { describe, expect, it, vi } from "vitest"; +import { WorkItemDetailPanel } from "./WorkItemDetailPanel"; + +vi.mock("../api/client", () => ({ + api: { + getWorkItemContent: vi.fn().mockResolvedValue({ + content: "# Big Title\n\nSome content here.", + stage: "current", + name: "Big Title Story", + }), + }, +})); + +describe("WorkItemDetailPanel", () => { + it("renders the story name in the header", async () => { + render( {}} />); + await waitFor(() => { + expect(screen.getByTestId("detail-panel-title")).toHaveTextContent( + "Big Title Story", + ); + }); + }); + + it("shows loading state initially", () => { + render( {}} />); + expect(screen.getByTestId("detail-panel-loading")).toBeInTheDocument(); + }); + + it("calls onClose when close button is clicked", async () => { + const onClose = vi.fn(); + render(); + const closeButton = screen.getByTestId("detail-panel-close"); + closeButton.click(); + expect(onClose).toHaveBeenCalledTimes(1); + }); + + it("renders markdown headings with constrained inline font size", async () => { + render( {}} />); + await waitFor(() => { + const content = screen.getByTestId("detail-panel-content"); + const h1 = content.querySelector("h1"); + expect(h1).not.toBeNull(); + // Headings must have a constrained fontSize inline style + // Browser-default 2em is too large for the work item detail panel + expect(h1?.style.fontSize).toBeTruthy(); + }); + }); +}); diff --git a/frontend/src/components/WorkItemDetailPanel.tsx b/frontend/src/components/WorkItemDetailPanel.tsx index 1e58611..99d9aa9 100644 --- a/frontend/src/components/WorkItemDetailPanel.tsx +++ b/frontend/src/components/WorkItemDetailPanel.tsx @@ -166,7 +166,24 @@ export function WorkItemDetailPanel({ className="markdown-body" style={{ fontSize: "0.9em", lineHeight: 1.6 }} > - {content} + ( +

{children}

+ ), + // biome-ignore lint/suspicious/noExplicitAny: react-markdown requires any for component props + h2: ({ children }: any) => ( +

{children}

+ ), + // biome-ignore lint/suspicious/noExplicitAny: react-markdown requires any for component props + h3: ({ children }: any) => ( +

{children}

+ ), + }} + > + {content} +
)}