Skip to content

Phase 1.5: Establish Test Coverage Baseline#26

Merged
AccessiT3ch merged 36 commits intomainfrom
test/phase1.5-test-coverage
Feb 1, 2026
Merged

Phase 1.5: Establish Test Coverage Baseline#26
AccessiT3ch merged 36 commits intomainfrom
test/phase1.5-test-coverage

Conversation

@AccessiT3ch
Copy link
Copy Markdown
Contributor

@AccessiT3ch AccessiT3ch commented Feb 1, 2026

This pull request significantly improves the test coverage and robustness of the application by adding comprehensive tests for the Header, ResourceModal, and ErrorBoundary components. It also introduces new coverage reporting for tests and fixes a minor typo in the ResourceModal share button props. The most important changes are grouped below.

Test Coverage and Robustness Improvements

  • Added extensive tests for the Header component covering custom titles, translation toggle, scan button behavior, install prompt handling, and share button interactions, including error and success cases. [1] [2]
  • Added a full test suite for the ResourceModal component, verifying rendering logic, link/button variations, footer source, navigation on close, and share button presence.
  • Enhanced ErrorBoundary tests to cover edge cases when reporting issues with missing error message, stack, or component stack, ensuring robust error reporting. [1] [2]

Developer Experience

  • Added a new test:coverage script to package.json for running tests with coverage reporting, making it easier to track test completeness.

Bug Fixes

  • Fixed a typo in the ResourceModal share button props (shareTiteshareTitle) to ensure correct sharing behavior.

- 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
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ShareButton and ResourceModal to cover previously untested branches.
  • Expanded Header and ResourceBtn test 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.

Comment thread src/Components/Share/ShareButton.test.jsx
Comment thread src/Components/Resources/ResourceModal.test.jsx Outdated
Comment thread src/Components/Resources/ResourceModal.test.jsx Outdated
Comment thread src/Components/Header/header.test.jsx Outdated
Comment thread src/Components/Header/header.test.jsx
Comment thread src/Components/Header/header.test.jsx Outdated
Comment thread src/Components/Header/header.test.jsx
Comment thread src/Components/Header/header.test.jsx
Comment thread src/Components/Header/header.test.jsx Outdated
Comment thread src/Components/Header/header.test.jsx Outdated
AccessiT3ch and others added 7 commits February 1, 2026 12:03
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>
Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 1, 2026

@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.

Copilot AI and others added 3 commits February 1, 2026 20:11
Co-authored-by: AccessiT3ch <95449364+AccessiT3ch@users.noreply.github.com>
Fix shareTitle prop typo in ShareButton component
Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 1, 2026

@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.

Copilot AI and others added 3 commits February 1, 2026 20:19
Co-authored-by: AccessiT3ch <95449364+AccessiT3ch@users.noreply.github.com>
Fix Element.prototype.scrollIntoView mock leaking into other tests
Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 1, 2026

@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.

Copilot AI and others added 3 commits February 1, 2026 20:24
…leaks

Co-authored-by: AccessiT3ch <95449364+AccessiT3ch@users.noreply.github.com>
Fix window.matchMedia mock cleanup in header tests
Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 1, 2026

@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.

Copilot AI and others added 6 commits February 1, 2026 20:34
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
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/Components/Resources/resources.test.jsx
Comment thread src/Components/Resources/resources.test.jsx
Comment thread .vscode/settings.json Outdated
Comment thread src/Components/Rights/rights.test.jsx
Comment thread src/Components/Rights/rights.test.jsx Outdated
Comment thread src/Components/Rights/rights.test.jsx
Comment thread src/Components/Rights/rights.test.jsx Outdated
Comment thread src/Components/Resources/resources.test.jsx Outdated
Comment thread src/Components/Resources/resources.test.jsx
Comment thread src/Components/Rights/rights.test.jsx Outdated
@AccessiT3ch
Copy link
Copy Markdown
Contributor Author

@copilot open a new pull request to apply changes based on the comments in this thread

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 1, 2026

@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.

Copilot AI and others added 8 commits February 1, 2026 21:03
…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).
@AccessiT3ch AccessiT3ch merged commit 157fe51 into main Feb 1, 2026
1 check passed
@AccessiT3ch AccessiT3ch deleted the test/phase1.5-test-coverage branch February 1, 2026 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants