From e75fe015cf7715ed0141ff1654d09177fb5e204d Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Mon, 20 Mar 2023 21:25:55 -0700 Subject: [PATCH] cherry-pick(#21830): chore(ui): use test backlog when chaining --- packages/trace-viewer/src/ui/watchMode.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/trace-viewer/src/ui/watchMode.tsx b/packages/trace-viewer/src/ui/watchMode.tsx index 38fb1ffe63..816da62ade 100644 --- a/packages/trace-viewer/src/ui/watchMode.tsx +++ b/packages/trace-viewer/src/ui/watchMode.tsx @@ -75,6 +75,7 @@ export const WatchModeView: React.FC<{}> = ({ const [watchAll, setWatchAll] = useSetting('watch-all', false); const [watchedTreeIds, setWatchedTreeIds] = React.useState<{ value: Set }>({ value: new Set() }); const runTestPromiseChain = React.useRef(Promise.resolve()); + const runTestBacklog = React.useRef>(new Set()); const inputRef = React.useRef(null); @@ -117,7 +118,13 @@ export const WatchModeView: React.FC<{}> = ({ if (mode === 'bounce-if-busy' && runningState) return; + runTestBacklog.current = new Set([...runTestBacklog.current, ...testIds]); runTestPromiseChain.current = runTestPromiseChain.current.then(async () => { + const testIds = runTestBacklog.current; + runTestBacklog.current = new Set(); + if (!testIds.size) + return; + // Clear test results. { for (const test of testModel.rootSuite?.allTests() || []) {