Phase 1.5: Establish Test Coverage Baseline#26
Conversation
- Add tests for custom title/lead and default values - Add tests for Translate component visibility - Add tests for Scan button (scroll behavior, missing QR section) - Add tests for Save button (PWA install flow, alerts, state management) - Add tests for Share button (shareHandler integration, success/error callbacks) - Increase Header.jsx coverage from 43.24% to near 100% - Use container queries to avoid DOM accumulation issues - Add cleanup between tests for test isolation Part of Phase 1.5
- Add tests for rendering with and without props - Add tests for default and custom titles (shareAlt) - Add tests for shareHandler integration with various prop combinations - Add tests for click event handling and preventDefault - Add tests for styling and accessibility (aria-hidden) - Increase ShareButton.jsx coverage from 41.66% to 100% Part of Phase 1.5
- Add tests for external link behavior (no modal navigation) - Add tests for modal navigation when links property present - Add tests for preventDefault and click event handling - Add tests for styling classes - Add tests for graceful handling of missing data - Mock useNavigate to test routing logic - Increase ResourceBtn.jsx coverage from 67.74% to ~100% Part of Phase 1.5
- Add tests for modal show/hide behavior - Add tests for title and description rendering - Add tests for all link rendering branches (with/without description, descriptionLink) - Add tests for button text rendering (btnText vs title, titleCase conversion) - Add tests for multiple links - Add tests for footer source link - Add tests for modal close navigation - Add tests for ShareButton integration - Significantly improve ResourceModal branch coverage from 12.5% Part of Phase 1.5
- Set minimum thresholds: 85% for lines, functions, branches, statements - Prevents future regressions in test coverage - Current coverage exceeds all thresholds: * Statements: 98.97% * Branches: 86.89% * Functions: 100% * Lines: 98.97% Part of Phase 1.5
There was a problem hiding this comment.
Pull request overview
Establishes a higher-confidence automated testing baseline for the RedCards app by adding new component tests, expanding existing test suites, and enforcing minimum coverage thresholds in Vitest.
Changes:
- Added new test suites for
ShareButtonandResourceModalto cover previously untested branches. - Expanded
HeaderandResourceBtntest coverage (PWA install, sharing flow, navigation, rendering behaviors). - Added Vitest coverage thresholds (85% minimum across key metrics).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
vitest.config.js |
Adds coverage thresholds to prevent coverage regressions. |
src/Components/Share/ShareButton.test.jsx |
New unit tests for ShareButton rendering and click behavior. |
src/Components/Resources/resourceBtn.test.jsx |
Expands tests for routing vs external-link behavior and styling. |
src/Components/Resources/ResourceModal.test.jsx |
New tests covering modal rendering branches, link variants, and navigation on close. |
src/Components/Header/header.test.jsx |
Adds tests for title/lead rendering, Scan/Save/Share flows, and PWA install prompt behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@AccessiT3ch I've opened a new pull request, #27, to work on those changes. Once the pull request is ready, I'll request review from you. |
Co-authored-by: AccessiT3ch <95449364+AccessiT3ch@users.noreply.github.com>
Fix shareTitle prop typo in ShareButton component
|
@AccessiT3ch I've opened a new pull request, #28, to work on those changes. Once the pull request is ready, I'll request review from you. |
Co-authored-by: AccessiT3ch <95449364+AccessiT3ch@users.noreply.github.com>
Fix Element.prototype.scrollIntoView mock leaking into other tests
|
@AccessiT3ch I've opened a new pull request, #29, to work on those changes. Once the pull request is ready, I'll request review from you. |
…leaks Co-authored-by: AccessiT3ch <95449364+AccessiT3ch@users.noreply.github.com>
Fix window.matchMedia mock cleanup in header tests
|
@AccessiT3ch I've opened a new pull request, #30, to work on those changes. Once the pull request is ready, I'll request review from you. |
Co-authored-by: AccessiT3ch <95449364+AccessiT3ch@users.noreply.github.com>
Fix global.alert test leak in Header component tests
Introduce a new npm script `test:coverage` that runs `vitest --root src/ --coverage`. This provides a convenient way to execute tests with coverage collection for the project's src directory, complementing the existing `test` script.
- Added 8 new tests for Rights component - Tests now cover useEffect branches with route param changes - Uses MemoryRouter and programmatic navigation to test id changes - Tests cover modal show/hide based on URL routing - Coverage improved: Rights.jsx 44.44% → 100% branches - Overall coverage: 86.89% → 90.54% branches
- Added 9 new tests for Resources component - Tests cover hideDigitals and hidePrintables props - Tests cover useEffect branches with route param changes - Tests cover modal display for digital and printable resources - Tests cover invalid resource IDs and empty routes - Coverage improved: Resources.jsx 25% → 100% branches - Overall coverage: 90.54% → 94.87% branches
- Added 3 new tests for ErrorBoundary edge cases
- Tests cover missing error.message ("Unknown error" fallback)
- Tests cover missing error.stack ("No stack trace" fallback)
- Tests cover missing errorInfo.componentStack ("No component stack" fallback)
- Coverage improved: ErrorBoundary.jsx 76.47% → 100% branches
- Overall coverage: 94.87% → 97.43% branches
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated 19 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot open a new pull request to apply changes based on the comments in this thread |
|
@AccessiT3ch I've opened a new pull request, #31, to work on those changes. Once the pull request is ready, I'll request review from you. |
…Null and fix window.open mocking Co-authored-by: AccessiT3ch <95449364+AccessiT3ch@users.noreply.github.com>
…undant test Co-authored-by: AccessiT3ch <95449364+AccessiT3ch@users.noreply.github.com>
Fix test assertions and mock cleanup per code review
Add .vscode/ to .gitignore to prevent committing local VS Code workspace settings and metadata. .vscode-test was already ignored; this change ensures typical editor configs remain untracked.
- Increased waitFor timeout from 200ms to 500ms - Fixes race condition in watch mode vs run-once mode - Tests now pass reliably in both modes
- Increased waitFor timeout from 500ms to 1000ms - Increased navigation delay from 100ms to 150ms - Fixes flaky tests in watch mode with modal animations - Applied to both Resources and Rights component tests
Extend the waitFor timeout from 1000ms to 10000ms in src/Components/Resources/resources.test.jsx to reduce flakiness when waiting for the modal to appear/disappear (accommodates slower CI or async timing).
This pull request significantly improves the test coverage and robustness of the application by adding comprehensive tests for the
Header,ResourceModal, andErrorBoundarycomponents. It also introduces new coverage reporting for tests and fixes a minor typo in theResourceModalshare button props. The most important changes are grouped below.Test Coverage and Robustness Improvements
Headercomponent covering custom titles, translation toggle, scan button behavior, install prompt handling, and share button interactions, including error and success cases. [1] [2]ResourceModalcomponent, verifying rendering logic, link/button variations, footer source, navigation on close, and share button presence.ErrorBoundarytests to cover edge cases when reporting issues with missing error message, stack, or component stack, ensuring robust error reporting. [1] [2]Developer Experience
test:coveragescript topackage.jsonfor running tests with coverage reporting, making it easier to track test completeness.Bug Fixes
ResourceModalshare button props (shareTite→shareTitle) to ensure correct sharing behavior.