storkit: merge 454_story_deduplicate_work_item_display_in_web_ui_story_panel

This commit is contained in:
dave
2026-04-02 10:57:18 +00:00
parent f7f4e8f95b
commit f8d7438eec
3 changed files with 142 additions and 14 deletions
@@ -69,7 +69,7 @@ afterEach(() => {
});
describe("WorkItemDetailPanel", () => {
it("renders the story name in the header", async () => {
it("renders the story name in the header with type and ID prefix", async () => {
render(
<WorkItemDetailPanel
storyId="237_bug_test"
@@ -79,7 +79,7 @@ describe("WorkItemDetailPanel", () => {
);
await waitFor(() => {
expect(screen.getByTestId("detail-panel-title")).toHaveTextContent(
"Big Title Story",
"Bug 237: Big Title Story",
);
});
});
@@ -110,6 +110,10 @@ describe("WorkItemDetailPanel", () => {
});
it("renders markdown headings with constrained inline font size", async () => {
mockedGetWorkItemContent.mockResolvedValue({
...DEFAULT_CONTENT,
content: "# Title Heading\n\n## Section Heading\n\nSome content.",
});
render(
<WorkItemDetailPanel
storyId="237_bug_test"
@@ -119,11 +123,95 @@ describe("WorkItemDetailPanel", () => {
);
await waitFor(() => {
const content = screen.getByTestId("detail-panel-content");
const h1 = content.querySelector("h1");
expect(h1).not.toBeNull();
expect(h1?.style.fontSize).toBeTruthy();
// H1 is stripped by stripDisplayContent; h2 should be constrained
const h2 = content.querySelector("h2");
expect(h2).not.toBeNull();
expect(h2?.style.fontSize).toBeTruthy();
});
});
it("strips YAML front matter so 'name' is not shown as a prefix in content", async () => {
mockedGetWorkItemContent.mockResolvedValue({
content:
'---\nname: "My Story Name"\n---\n\n# Story 42: My Story Name\n\n## User Story\n\nAs a user...',
stage: "current",
name: "My Story Name",
agent: null,
});
render(
<WorkItemDetailPanel
storyId="42_story_test"
pipelineVersion={0}
onClose={() => {}}
/>,
);
const content = await screen.findByTestId("detail-panel-content");
expect(content.textContent).not.toMatch(/name:/i);
});
it("strips the first H1 heading so the story title is not shown twice", async () => {
mockedGetWorkItemContent.mockResolvedValue({
content:
'---\nname: "My Story Name"\n---\n\n# Story 42: My Story Name\n\n## User Story\n\nAs a user...',
stage: "current",
name: "My Story Name",
agent: null,
});
render(
<WorkItemDetailPanel
storyId="42_story_test"
pipelineVersion={0}
onClose={() => {}}
/>,
);
const content = await screen.findByTestId("detail-panel-content");
expect(content.querySelector("h1")).toBeNull();
});
it("shows 'Type N: Name' format in the panel header title (story ID/title left-justified)", async () => {
mockedGetWorkItemContent.mockResolvedValue({
content: "## User Story\n\nAs a user...",
stage: "current",
name: "My Story Name",
agent: null,
});
render(
<WorkItemDetailPanel
storyId="42_story_test"
pipelineVersion={0}
onClose={() => {}}
/>,
);
await waitFor(() => {
expect(screen.getByTestId("detail-panel-title")).toHaveTextContent(
"Story 42: My Story Name",
);
});
});
it("does not show the work item type label twice when front matter and H1 are stripped", async () => {
mockedGetWorkItemContent.mockResolvedValue({
content:
'---\nname: "My Story Name"\n---\n\n# Story 42: My Story Name\n\n## User Story\n\nContent.',
stage: "current",
name: "My Story Name",
agent: null,
});
render(
<WorkItemDetailPanel
storyId="42_story_test"
pipelineVersion={0}
onClose={() => {}}
/>,
);
await screen.findByTestId("detail-panel-content");
// "Story" type label appears exactly once — in the panel header title
const title = screen.getByTestId("detail-panel-title");
expect(title.textContent).toContain("Story 42:");
// The content body should not contain an H1 repeating the type + title
const content = screen.getByTestId("detail-panel-content");
expect(content.querySelector("h1")).toBeNull();
});
});
describe("WorkItemDetailPanel - Agent Logs", () => {