From 504cb0a8230cb9f314f53a8b1ab25dd102d8acf7 Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Wed, 24 Jul 2024 15:53:52 +0200 Subject: [PATCH] fix: run updateList before determining what tests changed --- packages/trace-viewer/src/ui/uiModeView.tsx | 11 ++++++++--- tests/playwright-test/ui-mode-test-watch.spec.ts | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/trace-viewer/src/ui/uiModeView.tsx b/packages/trace-viewer/src/ui/uiModeView.tsx index 3362f6bc31..9674de2e7e 100644 --- a/packages/trace-viewer/src/ui/uiModeView.tsx +++ b/packages/trace-viewer/src/ui/uiModeView.tsx @@ -314,9 +314,14 @@ export const UIModeView: React.FC<{}> = ({ // Watch implementation. React.useEffect(() => { - if (!testServerConnection) + if (!testServerConnection || !teleSuiteUpdater) return; - const disposable = testServerConnection.onTestFilesChanged(params => { + const disposable = testServerConnection.onTestFilesChanged(async params => { + await updateList(); + + const testModel = teleSuiteUpdater.asModel(); + const testTree = new TestTree('', testModel.rootSuite, testModel.loadErrors, projectFilters, pathSeparator); + const testIds: string[] = []; const set = new Set(params.testFiles); if (watchAll) { @@ -339,7 +344,7 @@ export const UIModeView: React.FC<{}> = ({ runTests('queue-if-busy', new Set(testIds)); }); return () => disposable.dispose(); - }, [runTests, testServerConnection, testTree, watchAll, watchedTreeIds]); + }, [runTests, updateList, testServerConnection, watchAll, watchedTreeIds, teleSuiteUpdater, projectFilters]); // Shortcuts. React.useEffect(() => { diff --git a/tests/playwright-test/ui-mode-test-watch.spec.ts b/tests/playwright-test/ui-mode-test-watch.spec.ts index d4b8d98dce..bd04750a1f 100644 --- a/tests/playwright-test/ui-mode-test-watch.spec.ts +++ b/tests/playwright-test/ui-mode-test-watch.spec.ts @@ -245,7 +245,7 @@ test('should run added test in watched file', async ({ runUITest, writeFiles }) }); await expect.poll(dumpTestTree(page)).toBe(` - ▼ ◯ a.test.ts 👁 <= + ▼ ✅ a.test.ts 👁 <= ✅ foo ✅ bar `);