Skip to content

test(react-toast): add hook regression tests for useToast, useToastBody, useToastTitle#36044

Open
dmytrokirpa wants to merge 5 commits intomicrosoft:masterfrom
dmytrokirpa:test/react-toast-hook-regression-tests
Open

test(react-toast): add hook regression tests for useToast, useToastBody, useToastTitle#36044
dmytrokirpa wants to merge 5 commits intomicrosoft:masterfrom
dmytrokirpa:test/react-toast-hook-regression-tests

Conversation

@dmytrokirpa
Copy link
Copy Markdown
Contributor

@dmytrokirpa dmytrokirpa commented Apr 25, 2026

Summary

Adds unit tests that lock down the hook-level behaviors of useToast_unstable, useToastBody_unstable, and useToastTitle_unstable before #35914 lands.

These tests act as a regression safety net: once #35914 refactors each hook to delegate to a *Base_unstable variant, CI must still pass all 37 of these cases — which verifies that the base-hook delegation produces identical output to the current implementation.

useToast_unstable (8 tests)

  • backgroundAppearance maps directly from props.appearance (undefined / 'inverted' / 'brand')
  • intent is read from ToastContainerContext
  • components shape and root slot presence
  • Extra div props spread through to root

useToastBody_unstable (10 tests)

  • backgroundAppearance comes from BackgroundAppearanceContext (not from props)
  • root.id is wired to bodyId from ToastContainerContext
  • subtitle is absent when not provided, present when provided
  • components shape and root slot presence

useToastTitle_unstable (19 tests — highest regression risk)

  • backgroundAppearance from BackgroundAppearanceContext
  • intent and titleId from ToastContainerContext; root.id applied
  • Media slot default-icon injection: undefined without intent; correct icon (CheckmarkCircleFilled / DiamondDismissFilled / WarningFilled / InfoFilled) per intent
  • User-provided media.children override: explicit children must win over the default icon
  • renderByDefault behavior: media slot present whenever intent is set, even without a media prop
  • Fallback to default icon: media prop without children still receives the intent icon

…oastBody, useToastTitle

Tests lock down the exact behaviors that PR microsoft#35914 refactors — backgroundAppearance
mapping, context reads (intent, bodyId, titleId), and the media slot default-icon
injection by intent — so any regression introduced by the base-hooks refactor will
be caught immediately.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@dmytrokirpa dmytrokirpa requested a review from a team as a code owner April 25, 2026 16:40
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 25, 2026

📊 Bundle size report

✅ No changes found

@github-actions
Copy link
Copy Markdown

Pull request demo site: URL

@dmytrokirpa dmytrokirpa marked this pull request as draft April 25, 2026 18:08
…sertions

The `components` property is deprecated but these tests intentionally verify
its shape as a regression guard while the API contract still exists.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant