feat(mobile-expo): TextRenderer section component#323
Conversation
Replace the Text stub with a real renderer that displays heading (sized by headingLevel h1-h6), subtitle, and content text with default/lead/small variant styling. Resolves #308 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
WalkthroughReplace the TextStub placeholder with a fully-featured TextRenderer component that displays rich text content blocks with dynamic heading levels (h1–h6), optional subtitle, variant support (default, lead, small), and comprehensive unit tests. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
# Conflicts: # mobile/expo/src/components/sections/index.ts
Test results (b092243)
No changes needed. Ready to merge. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
mobile/expo/src/components/sections/TextRenderer.test.tsx (1)
18-22: Consider using render-based tests for better coverage.
createElementonly creates a React element object; it doesn't invoke the render function. Runtime errors insideTextRenderer(e.g., style computation, conditional rendering bugs) won't be caught.Using
renderfrom@testing-library/react-nativewould actually mount the component and exercise the render path, providing stronger guarantees.♻️ Example using React Native Testing Library
-import { createElement } from "react" +import { render, screen } from "@testing-library/react-native" import type { TextSection } from "../../lib/sectionModels" import { TextRenderer } from "./TextRenderer" // ... describe("TextRenderer", () => { it("renders without throwing with all fields", () => { - expect(() => - createElement(TextRenderer, { section: baseSection }), - ).not.toThrow() + render(<TextRenderer section={baseSection} />) + expect(screen.getByText("The Real Easter Story")).toBeTruthy() })🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@mobile/expo/src/components/sections/TextRenderer.test.tsx` around lines 18 - 22, The test currently uses createElement(TextRenderer, { section: baseSection }) which only constructs a React element and won't exercise rendering logic; replace the createElement assertion with mounting via render from `@testing-library/react-native` (import render) and call render(<TextRenderer section={baseSection} />) then assert that rendering does not throw and/or query for expected output; update the test case name if desired and keep references to TextRenderer and baseSection so the rendered component is actually mounted instead of just created.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@mobile/expo/src/components/sections/TextRenderer.test.tsx`:
- Around line 18-22: The test currently uses createElement(TextRenderer, {
section: baseSection }) which only constructs a React element and won't exercise
rendering logic; replace the createElement assertion with mounting via render
from `@testing-library/react-native` (import render) and call render(<TextRenderer
section={baseSection} />) then assert that rendering does not throw and/or query
for expected output; update the test case name if desired and keep references to
TextRenderer and baseSection so the rendered component is actually mounted
instead of just created.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5aa85e49-4fa2-491a-a79e-fb98657fdc65
📒 Files selected for processing (5)
mobile/expo/src/components/sections/SectionDispatcher.tsxmobile/expo/src/components/sections/TextRenderer.test.tsxmobile/expo/src/components/sections/TextRenderer.tsxmobile/expo/src/components/sections/TextStub.tsxmobile/expo/src/components/sections/index.ts
💤 Files with no reviewable changes (1)
- mobile/expo/src/components/sections/TextStub.tsx
Summary
headingLevel(h1=32px through h6=16px), defaults to h2lead(larger/prominent),small(compact),default(standard)Contracts Changed
No
Regeneration Required
No
Validation
pnpm --filter @forge/expo lint— passes with 0 warningspnpm --filter @forge/expo test -- --testPathPattern=TextRenderer— 10/10 tests passpnpm --filter @forge/expo test -- --testPathPattern=SectionDispatcher— 11/11 tests pass (no regressions)Resolves #308
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Tests