rusackas commented on code in PR #45751:
URL: https://github.com/apache/superset/pull/45751#discussion_r4385059509
##########
superset-frontend/src/components/Datasource/DatasourceModal/DatasourceModal.pendingEdits.test.tsx:
##########
@@ -53,13 +53,20 @@ type AceNode = HTMLElement & {
};
};
-/** Flushes the real controls' debounces while leaving their callbacks intact.
*/
-async function settleInputs() {
- await act(async () => {
- await new Promise(resolve =>
- setTimeout(resolve, Math.max(Constants.FAST_DEBOUNCE, 300) + 25),
- );
+// Controls debounce their onChange by FAST_DEBOUNCE (SQL controls use an
+// explicit 300ms, see DatasourceEditor.tsx), via a real setTimeout. Faking
+// timers just long enough to advance past that, mirroring the sibling
+// DatasourceModal.test.tsx / CollectionTable.debounce.test.tsx pattern,
+// settles the same callback deterministically and without the wall-clock
+// wait — real timers resume immediately after so userEvent's own internal
+// timing is unaffected.
+/** Flushes the real controls' debounces without burning real wall-clock time.
*/
+function flushDebounce() {
+ jest.useFakeTimers();
Review Comment:
Good catch, you are right that already-scheduled native timeouts never move
into the fake clock. Went back to the real-timer `settleInputs()` wait (about
1s total) and kept the 30s timeout. Description said 40s; the code is 30s, so
that is the number to trust.
--
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]