@@ -6,9 +6,14 @@ import { hasFailedSnapshot } from '@vitest/ws-client'
6
6
import type { CollectFilteredTests , CollectorInfo , Filter , FilteredTests } from '~/composables/explorer/types'
7
7
import { client , findById } from '~/composables/client'
8
8
import { runFilter , testMatcher } from '~/composables/explorer/filter'
9
- import { createOrUpdateFileNode , createOrUpdateNodeTask , createOrUpdateSuiteTask } from '~/composables/explorer/utils'
9
+ import {
10
+ createOrUpdateFileNode ,
11
+ createOrUpdateNodeTask ,
12
+ createOrUpdateSuiteTask ,
13
+ isRunningTestNode ,
14
+ } from '~/composables/explorer/utils'
10
15
import { isSuite } from '~/utils/task'
11
- import { openedTreeItems , treeFilter , uiFiles } from '~/composables/explorer/state'
16
+ import { openedTreeItems , treeFilter , uiEntries , uiFiles } from '~/composables/explorer/state'
12
17
import { explorerTree } from '~/composables/explorer/index'
13
18
import { expandNodesOnEndRun } from '~/composables/explorer/expand'
14
19
@@ -91,6 +96,25 @@ export function runCollect(
91
96
} )
92
97
}
93
98
99
+ function * collectRunningTodoTests ( ) {
100
+ yield * uiEntries . value . filter ( isRunningTestNode )
101
+ }
102
+
103
+ function updateRunningTodoTests ( ) {
104
+ const idMap = client . state . idMap
105
+ let task : Task | undefined
106
+ for ( const test of collectRunningTodoTests ( ) ) {
107
+ // lookup the parent
108
+ task = idMap . get ( test . parentId )
109
+ if ( task && isSuite ( task ) && task . mode === 'todo' ) {
110
+ task = idMap . get ( test . id )
111
+ if ( task ) {
112
+ task . mode = 'todo'
113
+ }
114
+ }
115
+ }
116
+ }
117
+
94
118
function traverseFiles ( collect : boolean ) {
95
119
const rootTasks = explorerTree . root . tasks
96
120
// collect remote children
@@ -146,7 +170,7 @@ function doRunFilter(
146
170
147
171
// refresh explorer
148
172
queueMicrotask ( ( ) => {
149
- runFilter ( search , filter )
173
+ refreshExplorer ( search , filter , end )
150
174
} )
151
175
152
176
if ( applyExpandNodes ) {
@@ -158,10 +182,18 @@ function doRunFilter(
158
182
}
159
183
} )
160
184
// refresh explorer
161
- queueMicrotask ( ( ) => runFilter ( search , filter ) )
185
+ queueMicrotask ( ( ) => {
186
+ refreshExplorer ( search , filter , end )
187
+ } )
162
188
}
163
189
}
164
190
191
+ function refreshExplorer ( search : string , filter : Filter , end : boolean ) {
192
+ runFilter ( search , filter )
193
+ // update only at the end
194
+ end && updateRunningTodoTests ( )
195
+ }
196
+
165
197
function createOrUpdateEntry ( tasks : Task [ ] ) {
166
198
let task : Task
167
199
for ( let i = 0 ; i < tasks . length ; i ++ ) {
0 commit comments