diff --git a/frontend/src/components/Chat.test.tsx b/frontend/src/components/Chat.test.tsx index 6ebf89d..cecf20b 100644 --- a/frontend/src/components/Chat.test.tsx +++ b/frontend/src/components/Chat.test.tsx @@ -1097,9 +1097,13 @@ describe("Remove bubble styling from streaming messages (Story 163)", () => { ]); }); - // findByText returns the styled div itself for user messages (text is direct child) - const userStyledDiv = await screen.findByText("I am a user message"); - const styleAttr = userStyledDiv.getAttribute("style") ?? ""; + // findByText finds the text element; traverse up to the styled bubble div + const userText = await screen.findByText("I am a user message"); + // User messages are rendered via markdown, so text is inside a
inside .user-markdown-body
+ // Walk up to find the styled bubble container
+ const bubbleDiv = userText.closest("[style*='padding: 10px 16px']");
+ expect(bubbleDiv).toBeTruthy();
+ const styleAttr = bubbleDiv?.getAttribute("style") ?? "";
// User messages retain bubble: distinct background, padding, rounded corners
expect(styleAttr).toContain("padding: 10px 16px");
expect(styleAttr).toContain("border-radius: 20px");
diff --git a/frontend/src/components/MessageItem.test.tsx b/frontend/src/components/MessageItem.test.tsx
index 85e4638..036d685 100644
--- a/frontend/src/components/MessageItem.test.tsx
+++ b/frontend/src/components/MessageItem.test.tsx
@@ -71,3 +71,45 @@ describe("MessageItem component (Story 178 AC3)", () => {
expect(typeofStr).toContain("memo");
});
});
+
+describe("MessageItem user message code fence rendering (Story 196)", () => {
+ it("renders code fences in user messages as code blocks", () => {
+ const { container } = render(
+