Skip to content

fix(#943): wrap Statistics in ErrorBoundary with retry fallback#1067

Merged
hman38705 merged 1 commit into
solutions-plug:mainfrom
Coredevjay:fix/943-statistics-error-boundary
Jun 30, 2026
Merged

fix(#943): wrap Statistics in ErrorBoundary with retry fallback#1067
hman38705 merged 1 commit into
solutions-plug:mainfrom
Coredevjay:fix/943-statistics-error-boundary

Conversation

@Coredevjay

Copy link
Copy Markdown
Contributor

Summary

Closes #943.

The Statistics component had no error isolation — any unhandled rendering exception propagated straight to the page root, causing a full blank-screen crash. This PR wires up the existing ErrorBoundary around Statistics in LandingPage and improves the fallback UI with a retry affordance.


Changes

frontend/src/components/LandingPage.tsx

  • The ErrorBoundary wrapper that already existed around <Statistics /> had a fallback <section> with no way for the user to recover.
  • Added a Retry button (aria-label="Retry loading statistics") inside that fallback, using the pre-existing .retry-button CSS class from Statistics.css.
  • Clicking the button calls window.location.reload(), giving users a clear escape route when the component crashes rather than staring at a static error message.

frontend/src/components/__tests__/Statistics.test.tsx

  • Imported ErrorBoundary from ../ErrorBoundary.
  • Added a new describe('Statistics wrapped in ErrorBoundary') block with three focused unit tests:
    1. Catches a rendering exception — mounts <ErrorBoundary><ThrowingStatistics /></ErrorBoundary> and asserts the fallback heading, alert role, and message are rendered.
    2. Retry button is present — asserts getByRole('button', { name: /retry loading statistics/i }) is in the fallback.
    3. Statistics content is absent — asserts none of the normal stat labels ("Total Markets", "Total Volume", "Active Users") appear when the boundary has caught an error.
  • Added a ThrowingStatistics helper component that unconditionally throws to simulate a runtime rendering exception.
  • console.error is suppressed per test to keep output clean; restored via afterEach.

frontend/src/components/__tests__/LandingPage.error-boundary.test.tsx

  • Extended the existing 'should render error fallback when Statistics throws' test to also assert that the retry button is rendered, keeping the integration test in sync with the new fallback UI.

Acceptance Criteria

Criterion Status
Statistics wrapped in ErrorBoundary from src/components/ErrorBoundary.tsx ✅ Already in place via LandingPage.tsx; this PR adds the missing retry affordance
Fallback UI shows a placeholder stats card with a retry button ✅ Done
Test that throws inside Statistics and verifies ErrorBoundary catches it and renders the fallback ✅ Three tests added in Statistics.test.tsx

Testing

No new dependencies. Tests are in Jest + React Testing Library (already set up in the project).

cd frontend
npm test -- --testPathPattern="Statistics|LandingPage.error-boundary"

…fallback

- Add retry button to the ErrorBoundary fallback in LandingPage.tsx wrapping
  Statistics, using the existing .retry-button CSS class and aria-label
  'Retry loading statistics' for accessibility
- Add ErrorBoundary import to Statistics.test.tsx
- Add 'Statistics wrapped in ErrorBoundary' describe block with three tests:
  - catches a rendering exception and renders the fallback
  - renders a retry button in the fallback when Statistics throws
  - does not render Statistics content when an error is thrown
- Update LandingPage.error-boundary.test.tsx to assert the retry button
  is present in the fallback

Closes solutions-plug#943
@drips-wave

drips-wave Bot commented Jun 30, 2026

Copy link
Copy Markdown

@Coredevjay Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@hman38705 hman38705 merged commit 814cc40 into solutions-plug:main Jun 30, 2026
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.

Statistics component has no error boundary — unhandled errors crash the whole page

2 participants