2.8 KiB
2.8 KiB
Frontend Testing Strategy
This document is a granulated shard from the main "5-front-end-architecture.md" focusing on "Frontend Testing Strategy".
This section elaborates on the overall testing strategy defined in architecture.txt, focusing on frontend specifics.
- Link to Main Testing Strategy:
docs/architecture.md#overall-testing-strategy(anddocs/architecture.md#coding-standardsfor test file colocation).
Component Testing
- Scope: Testing individual React components in isolation, primarily focusing on UI rendering based on props and basic interactions.
- Tools: Jest (test runner, assertion library, mocking) and React Testing Library (RTL) (for user-centric component querying and interaction).
- Focus:
- Correct rendering based on props.
- User interactions (e.g., button clicks triggering callbacks).
- Conditional rendering logic.
- Accessibility attributes.
- Location: Test files (
*.test.tsxor*.spec.tsx) will be co-located with the component files (e.g.,app/components/core/NewsletterCard.test.tsx). - Example Guideline: "A
NewsletterCardcomponent should render the title and date passed as props. Clicking the card should navigate (mocked) or call anonClickprop."
UI Integration/Flow Testing
- Scope: Testing interactions between multiple components that compose a piece of UI or a small user flow, potentially with mocked Supabase client responses or Zustand store states.
- Tools: Jest and React Testing Library.
- Focus:
- Data flow between a parent and its child components.
- State updates in a Zustand store affecting multiple components.
- Rendering of a sequence of UI elements in a simple flow (e.g., selecting an item from a list and seeing details appear).
- Example Guideline: "The
NewsletterListPageshould correctly render multipleNewsletterCardcomponents when provided with mock newsletter data. Clicking a card should correctly invoke navigation logic."
End-to-End UI Testing Tools & Scope
- Tools: Playwright.
- Scope (Frontend Focus):
- Verify the "Viewing a Newsletter" user flow:
- Navigate to the newsletter list page.
- Verify newsletters are listed.
- Click on a newsletter.
- Verify the newsletter detail page loads with content.
- Verify the podcast player is present if a podcast URL exists.
- Verify the download button is present.
- Verify the "Back to List" button works.
- Basic mobile responsiveness checks for key pages (list and detail).
- Verify the "Viewing a Newsletter" user flow:
- Test Data Management for UI: E2E tests will rely on data populated in the development Supabase instance or use mocked API responses if targeting isolated frontend tests with Playwright's network interception. For true E2E against a live dev environment, pre-seeded data in Supabase dev instance will be used.