sadpandajoe opened a new pull request, #35918:
URL: https://github.com/apache/superset/pull/35918

   ## SUMMARY
   
   Fixed race conditions in `useThemeMenuItems` test suite by adding `await` to 
all 20 unawaited `userEvent` calls (16 hover + 4 click). This prevents 
intermittent test failures caused by queries executing before async user 
interactions complete.
   
   - Awaited all `userEvent.hover()` calls (16 occurrences)
   - Awaited all `userEvent.click()` calls (4 occurrences)
   - Follows established pattern from commit 4932f3522f (DatasourceControl fix)
   - Aligns with React Testing Library best practices
   
   ## BEFORE/AFTER
   
   **Before:**
   ```typescript
   userEvent.hover(await screen.findByRole('menuitem'));
   const menu = await findMenuWithText('Light');
   ```
   
   **After:**
   ```typescript
   await userEvent.hover(await screen.findByRole('menuitem'));
   const menu = await findMenuWithText('Light');
   ```
   
   ## TESTING INSTRUCTIONS
   
   Run the test suite multiple times to verify consistency:
   
   ```bash
   npm run test -- useThemeMenuItems.test.tsx
   npm run test -- useThemeMenuItems.test.tsx
   npm run test -- useThemeMenuItems.test.tsx
   ```
   
   **Expected result:** All 20 tests pass consistently across multiple runs 
with no race condition warnings.
   
   **Validation performed:**
   - ✅ 4 consecutive test runs: 20/20 tests passing each time
   - ✅ No "unmounted component" warnings
   - ✅ All pre-commit hooks passing
   
   ## ADDITIONAL INFORMATION
   
   This fix addresses potential flakiness by ensuring that async hover and 
click actions complete before subsequent queries and assertions execute. The 
@testing-library/user-event library returns Promises for all user interactions, 
which must be awaited to prevent race conditions.
   
   Similar fixes have been applied across the codebase (28+ test files properly 
await userEvent calls). This change brings useThemeMenuItems.test.tsx in line 
with established testing patterns.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to