System Designmedium
Test complex React components and integration flows
Describe a testing strategy for a React SaaS feature such as a policy editor or access review page. Include unit tests, component tests, integration tests, E2E tests, mocks, accessibility, and CI trade-offs.
Asked at PlainID
Answer
Interview framing: For complex enterprise UI, tests should protect workflows and business rules without locking the implementation in place.
Testing layers:
- Unit tests:
- Policy validation helpers.
- Permission/capability mapping.
- Data formatters and reducers.
- Edge cases around missing attributes or conflicting rules.
- Component tests:
- Render policy forms and interact with them as a user.
- Assert visible behavior: validation messages, disabled publish button, warning banners, result summaries.
- Prefer role/label queries over test IDs when possible.
- Integration tests:
- Mock API boundaries with realistic fixtures.
- Test loading, success, empty, 401/403, validation error, and server error states.
- Verify stale request handling for search/simulation flows.
- E2E tests:
- Cover a few critical paths: create draft, simulate decision, publish, audit entry visible.
- Keep them stable and focused; avoid duplicating all component cases.
- Accessibility:
- Automated checks for labels, roles, keyboard access, and color-independent status.
- Manual keyboard checks for custom dropdowns/rule builders.
CI trade-offs:
- Fast unit/component tests on every PR.
- E2E smoke tests in CI or preview environments.
- More expensive suites can run nightly or before release.
Good closing: "I want confidence in user-visible behavior and security-sensitive rules, not brittle snapshots of every markup detail."
Source: PlainID senior frontend job description