SEPURI-SAI-KRISHNA opened a new issue, #44946:
URL: https://github.com/apache/superset/issues/44946

   ### Bug description
   
   #43512 bumped `@testing-library/user-event` from 12.8.3 to 14.6.5, which 
made every `userEvent` API return a promise. #44315, #44323, #44335 and #44799 
awaited the call sites that existed at the time. **46 un-awaited calls are on 
master again**, across 7 files:
   
   | file | calls |
   |---|---|
   | 
`src/explore/components/controls/DndColumnSelectControl/ColumnSelectPopover.test.tsx`
 | 18 |
   | 
`src/dashboard/components/nativeFilters/FilterBar/FilterControls/GroupByFilterCard.test.tsx`
 | 11 |
   | 
`src/explore/components/controls/DndColumnSelectControl/DndColumnSelect.test.tsx`
 | 10 |
   | `src/dashboard/components/Header/Header.test.tsx` | 2 |
   | 
`src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent/AdhocFilterEditPopoverSimpleTabContent.test.tsx`
 | 2 |
   | 
`src/explore/components/controls/MetricControl/AdhocMetricEditPopover/AdhocMetricEditPopover.test.tsx`
 | 2 |
   | `src/components/Chart/ChartContextMenu/ChartContextMenu.test.tsx` | 1 |
   
   All 46 sit inside `async` functions, so each needs only an `await`:
   
   ```tsx
   // GroupByFilterCard.test.tsx
   const combobox = await screen.findByRole('combobox');
   userEvent.click(combobox);                       // not awaited
   expect(await screen.findByText('Orders State')).toBeInTheDocument();
   ```
   
   An un-awaited call is fire-and-forget: its pointer events are still being 
dispatched across `delay: 0` timer yields when the next query runs. That either 
charges the dispatch time to a following `waitFor`/`findBy*` budget — the 
default is 1000 ms — or lets an assertion observe the state from before the 
interaction. Both are the latent race that #44314, #44322, #44334 and #44791 
each turned into a real sharded-jest-tests failure.
   
   ### The sweep keeps having to be repeated
   
   This is the third time these have accumulated, which is the actual problem. 
Open PR #43736 **adds three more** un-awaited `userEvent.click` calls to 
`GroupByFilterCard.test.tsx`; nothing in the toolchain objects.
   
   Nothing can object today:
   
   - oxlint, the enforcing frontend linter, has no `testing-library` plugin, so 
`testing-library/await-async-events` is unavailable.
   - `eslint-plugin-testing-library` *is* a devDependency, but the only ESLint 
config that loads custom plugins is `eslint.config.minimal.js`, and that is 
consumed solely by `tech-debt.yml` for metrics — it gates nothing.
   
   `superset-frontend/scripts/check-custom-rules.js` is the Babel-AST checker 
that already holds the Superset-specific rules oxlint cannot express, and it 
runs from the `custom-rules-frontend` pre-commit hook, which CI enforces over 
changed files. A "userEvent calls must be awaited" rule belongs there, and 
would have caught every one of these 46 as it was written.
   
   ### How to reproduce the bug
   
   A scan of all 1,400 test files on master (`549508b3`) matching 
`userEvent.<method>(...)` used as an expression statement — not an 
`AwaitExpression` — whose nearest enclosing function is `async`:
   
   ```
   ColumnSelectPopover.test.tsx                     18
   GroupByFilterCard.test.tsx                       11
   DndColumnSelect.test.tsx                         10
   Header.test.tsx                                   2
   AdhocFilterEditPopoverSimpleTabContent.test.tsx   2
   AdhocMetricEditPopover.test.tsx                   2
   ChartContextMenu.test.tsx                         1
   TOTAL                                            46
   ```
   
   ### Screenshots/recordings
   
   _No response_
   
   ### Superset version
   
   master / latest-dev
   
   ### Python version
   
   N/A (frontend tests)
   
   ### Node version
   
   18 or greater (CI: 24.16.0)
   
   ### Browser
   
   Not applicable
   
   ### Additional context
   
   `userEvent.setup()` is correctly exempt from any such rule: it is 
synchronous and returns a session object rather than a promise. It appears 
three times on master, always assigned to a variable, never as a bare statement.
   
   ### Checklist
   
   - [x] I have searched Superset docs and Slack and didn't find a solution to 
my problem.
   - [x] I have searched the GitHub issue tracker and didn't find a similar bug 
report.
   - [x] I have checked Superset's logs for errors and if I found a relevant 
Python stacktrace, I included it here as text in the "additional context" 
section.
   


-- 
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