Skip to content

Commit 7b0e4be

Browse files
committed
🤖 fix(test): use exact button names in ToggleGroup test to avoid theme toggle collision
The StorybookThemeToggle button text contains 'Dark' and 'Light' (e.g., '🌙 Dark'), which was causing 'Found multiple elements' errors when the test used regex matching /dark/i and /light/i. Using exact name matching ('Dark' vs '🌙 Dark') avoids the collision while keeping the test focused on the actual ToggleGroup component. Fixes: ToggleGroup:Two Options dark/light test failures
1 parent f51df19 commit 7b0e4be

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

‎src/browser/components/ToggleGroup.stories.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ export const TwoOptions: Story = {
5656
play: async ({ canvasElement }) => {
5757
const canvas = within(canvasElement);
5858

59-
// Find all buttons
60-
const lightButton = canvas.getByRole("button", { name: /light/i });
61-
const darkButton = canvas.getByRole("button", { name: /dark/i });
59+
// Find all buttons - use exact match to avoid collision with theme toggle button
60+
const lightButton = canvas.getByRole("button", { name: "Light" });
61+
const darkButton = canvas.getByRole("button", { name: "Dark" });
6262

6363
// Initial state - dark should be active
6464
await expect(darkButton).toHaveAttribute("aria-pressed", "true");

0 commit comments

Comments
 (0)