Skip to content

Conversation

VetteIT
Copy link

@VetteIT VetteIT commented Sep 27, 2025

Description

Adds a comprehensive unit test suite for the GlobalModal component using Vitest + React Testing Library.
Covers portal rendering to #modal-container (with fallback to document.body), state-driven modal selection, and rerender behavior.

Closes #112


What change does this PR introduce?

  • Bug fix
  • New feature
  • Breaking change
  • CI/CD
  • Documentation update
  • Chore (tests)

What is the proposed approach?

  • Mocked useGlobalModal via a hoisted state to avoid mocking order issues and enable clear assertions.
  • Stubbed LoginModal and ErrorModal with lightweight test doubles (data-testid hooks).
  • Verified portal targets by DOM queries (container vs. body) following RTL best practices.
  • Asserted priority behavior (error > login) and rerender transition (login → error).

Checklist:

  • The commit message follows our adopted guidelines
  • Testing has been done for the change(s) added
  • Relevant comments/docs have been added/updated (N/A — tests only)

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.

[Task] Add unit test cases for GlobalModal component
1 participant