Skip to content

Add component tests for the Toast system (ToastContext, ToastRegion, Toast) with accessibility assertionsΒ #479

@Baskarayelu

Description

@Baskarayelu

πŸ“‹ Description

The toast system β€” lib/context/ToastContext.tsx, components/ToastRegion.tsx, components/Toast.tsx β€” is used for success/error feedback across the app (e.g. the Send confirmation in app/send/page.tsx). It is untested, even though toast queue/auto-dismiss/aria-live behavior is easy to break.

Why this matters: toasts are the primary feedback channel for money actions. If a success toast silently fails to render, or auto-dismiss races a second toast, users lose confirmation that their transfer happened.

🎯 Requirements & Context

Functional requirements

  • Add a Vitest suite for ToastContext covering: enqueue, multiple toasts, auto-dismiss timing, manual dismiss, and variant handling (success/error/warn).
  • Assert ToastRegion exposes an appropriate aria-live region and that toasts are announced.
  • Use fake timers for auto-dismiss; assert no leaked timers on unmount.

Context & constraints

  • Vitest is configured for environment: node; for DOM/component rendering you may need to set the test file's environment to jsdom (document this in the test file via the Vitest environment docblock).
  • Keep tests deterministic with vi.useFakeTimers().

πŸ› οΈ Suggested Execution

git checkout -b test/toast-system
  • Write the suite, set jsdom environment for component rendering, assert a11y region.
npm run lint
npm run test:coverage
  • Edge cases: rapid sequential toasts, dismiss during auto-dismiss timer, max queue length, reduced motion (no animation dependency in assertions).

Example commit message

test(toast): cover ToastContext queue + ToastRegion aria-live

Adds Vitest suite for enqueue/auto-dismiss/manual-dismiss and asserts
the live region announces toasts.

βœ… Acceptance Criteria & Guidelines

Requirement Target
Queue + auto/manual dismiss covered Required
aria-live region asserted Required
Toast system coverage β‰₯ 85%
Deterministic (fake timers) Required
Lint clean Required
Timeframe 96 hours from assignment

πŸ’¬ Community & Support

Join the RemitWise contributor community on Discord: https://discord.gg/CtQuPZFMA

Comment to claim before starting. πŸš€

Metadata

Metadata

Assignees

Type

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions