Test the ToastProvider context, auto-dismiss timer, and useToast guard
Description
src/components/ToastProvider.tsx provides app-wide toasts (used by the layout) with a 4s auto-dismiss and a useToast hook that throws outside the provider — none of which is tested. The role="alert" vs role="status" distinction for error/info toasts is a meaningful a11y behaviour worth locking down. This issue adds coverage.
Requirements and context
- Repository scope:
Agentpay-Org/Agentpay-frontend only.
- Render a consumer that calls
push, assert the message appears, error toasts use role="alert" and info toasts role="status", and the toast disappears after advancing fake timers by 4000 ms.
- Assert
useToast() throws the documented error when rendered outside <ToastProvider>.
- Use
jest.useFakeTimers() and act for the timer assertions.
Suggested execution
- Fork the repo and create a branch
git checkout -b test/testing-18-toastprovider
- Implement changes
- Write comprehensive tests in: create
src/components/__tests__/ToastProvider.test.tsx.
- Add documentation: none beyond test descriptions.
- Validate the live region container (
aria-live="polite") is present.
- Test and commit
Test and commit
- Run
npm run lint, npm run typecheck, and npm test.
- Cover edge cases: multiple stacked toasts, default level (
info), and the outside-provider throw.
- Include the
npm test output and coverage for the component.
Example commit message
test(components): cover ToastProvider dismiss timer and useToast guard
Guidelines
- Minimum 95 percent test coverage for
ToastProvider.tsx.
- Clear, reviewer-focused documentation.
- Timeframe: 96 hours.
Community & contribution rewards
- 💬 Join the AgentPay community on Discord for questions, reviews, and faster merges: https://discord.gg/eXvRKkgcv
- ⭐ This is a GrantFox OSS / Official Campaign task and may be rewarded. When your PR is merged you'll be prompted to rate the project — if this issue and the maintainers helped you ship, we'd be grateful for a 5-star rating. Clear questions in Discord and tidy, well-tested PRs are the fastest path to a merge and a reward.
Test the ToastProvider context, auto-dismiss timer, and useToast guard
Description
src/components/ToastProvider.tsxprovides app-wide toasts (used by the layout) with a 4s auto-dismiss and auseToasthook that throws outside the provider — none of which is tested. Therole="alert"vsrole="status"distinction for error/info toasts is a meaningful a11y behaviour worth locking down. This issue adds coverage.Requirements and context
Agentpay-Org/Agentpay-frontendonly.push, assert the message appears, error toasts userole="alert"and info toastsrole="status", and the toast disappears after advancing fake timers by 4000 ms.useToast()throws the documented error when rendered outside<ToastProvider>.jest.useFakeTimers()andactfor the timer assertions.Suggested execution
git checkout -b test/testing-18-toastprovidersrc/components/__tests__/ToastProvider.test.tsx.aria-live="polite") is present.Test and commit
npm run lint,npm run typecheck, andnpm test.info), and the outside-provider throw.npm testoutput and coverage for the component.Example commit message
test(components): cover ToastProvider dismiss timer and useToast guardGuidelines
ToastProvider.tsx.Community & contribution rewards