@@ -8,7 +8,7 @@ import type {
88 UITaskTreeNode ,
99} from '~/composables/explorer/types'
1010import { isTestCase } from '@vitest/runner/utils'
11- import { client } from '~/composables/client'
11+ import { client , config } from '~/composables/client'
1212import { explorerTree } from '~/composables/explorer/index'
1313import { openedTreeItemsSet } from '~/composables/explorer/state'
1414import { getBadgeNameColor , isSuite as isTaskSuite } from '~/utils/task'
@@ -33,6 +33,20 @@ export function isParentNode(node: UITaskTreeNode): node is FileTreeNode | Suite
3333 return node . type === 'file' || node . type === 'suite'
3434}
3535
36+ export function isSlowTestTask ( task : Task ) {
37+ if ( task . type !== 'test' ) {
38+ return false
39+ }
40+
41+ const duration = task . result ?. duration
42+ if ( typeof duration !== 'number' ) {
43+ return false
44+ }
45+
46+ const treshold = config . value . slowTestThreshold
47+ return typeof treshold === 'number' && duration > treshold
48+ }
49+
3650export function getSortedRootTasks ( sort : SortUIType , tasks = explorerTree . root . tasks ) {
3751 const sorted = [ ...tasks ]
3852
@@ -73,6 +87,7 @@ export function createOrUpdateFileNode(
7387 fileNode . state = file . result ?. state
7488 fileNode . mode = file . mode
7589 fileNode . duration = typeof file . result ?. duration === 'number' ? Math . round ( file . result . duration ) : undefined
90+ fileNode . slow = false
7691 fileNode . collectDuration = file . collectDuration
7792 fileNode . setupDuration = file . setupDuration
7893 fileNode . environmentLoad = file . environmentLoad
@@ -93,6 +108,7 @@ export function createOrUpdateFileNode(
93108 typecheck : ! ! file . meta && 'typecheck' in file . meta ,
94109 indent : 0 ,
95110 duration : typeof file . result ?. duration === 'number' ? Math . round ( file . result . duration ) : undefined ,
111+ slow : false ,
96112 filepath : file . filepath ,
97113 projectName : file . projectName || '' ,
98114 projectNameColor : explorerTree . colors . get ( file . projectName || '' ) || getBadgeNameColor ( file . projectName ) ,
@@ -169,6 +185,7 @@ export function createOrUpdateNode(
169185 taskNode . name = task . name
170186 taskNode . mode = task . mode
171187 taskNode . duration = duration
188+ taskNode . slow = isSlowTestTask ( task )
172189 taskNode . state = task . result ?. state
173190 }
174191 else {
@@ -184,6 +201,7 @@ export function createOrUpdateNode(
184201 expanded : false ,
185202 indent : node . indent + 1 ,
186203 duration,
204+ slow : isSlowTestTask ( task ) ,
187205 state : task . result ?. state ,
188206 } as TestTreeNode
189207 }
@@ -202,6 +220,7 @@ export function createOrUpdateNode(
202220 tasks : [ ] ,
203221 indent : node . indent + 1 ,
204222 duration,
223+ slow : false ,
205224 state : task . result ?. state ,
206225 } as SuiteTreeNode
207226 }
0 commit comments