Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/ui/client/components/FilterStatus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function toggle() {

<template>
<label
class="font-light text-sm checkbox flex items-center py-1 text-sm w-full gap-y-1 mb-1px"
class="font-light text-sm checkbox flex items-center py-1 w-full gap-y-1 mb-1px"
:class="disabled ? 'cursor-not-allowed op50' : 'cursor-pointer'"
v-bind="$attrs"
@click.prevent="toggle"
Expand All @@ -26,6 +26,7 @@ function toggle() {
modelValue ? 'i-carbon:checkbox-checked-filled' : 'i-carbon:checkbox',
]"
text-lg
flex-shrink-0
aria-hidden="true"
/>
<input
Expand All @@ -34,7 +35,7 @@ function toggle() {
:disabled="disabled"
sr-only
>
<span flex-1 ms-2 select-none>{{ label }}</span>
<span flex-1 ms-2 select-none whitespace-nowrap>{{ label }}</span>
</label>
</template>

Expand Down
18 changes: 17 additions & 1 deletion packages/ui/client/components/dashboard/TestsEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import { explorerTree } from '~/composables/explorer'
import { filter } from '~/composables/explorer/state'
import DashboardEntry from './DashboardEntry.vue'

function toggleFilter(type: 'success' | 'failed' | 'skipped' | 'total') {
function toggleFilter(type: 'success' | 'failed' | 'skipped' | 'slow' | 'total') {
// Reset all filters first
filter.success = false
filter.failed = false
filter.skipped = false
filter.slow = false

if (type === 'total') {
return
Expand Down Expand Up @@ -74,6 +75,21 @@ function toggleFilter(type: 'success' | 'failed' | 'skipped' | 'total') {
{{ explorerTree.summary.testsSkipped }}
</template>
</DashboardEntry>
<DashboardEntry
v-if="explorerTree.summary.testsSlow"
text-yellow5
data-testid="slow-entry"
cursor-pointer
hover="op80"
@click="toggleFilter('slow')"
>
<template #header>
Slow
</template>
<template #body>
{{ explorerTree.summary.testsSlow }}
</template>
</DashboardEntry>
<DashboardEntry
v-if="explorerTree.summary.testsTodo"
op50
Expand Down
16 changes: 13 additions & 3 deletions packages/ui/client/components/explorer/Explorer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,21 @@ const filterHeaderClass = ref<string>('grid-col-span-2')

const testExplorerRef = ref<HTMLElement | undefined>()
useResizeObserver(() => testExplorerRef.value, ([{ contentRect }]) => {
if (contentRect.width < 420) {
if (contentRect.width < 220) {
filterClass.value = 'grid-cols-1'
filterHeaderClass.value = 'grid-col-span-1'
}
else if (contentRect.width < 340) {
filterClass.value = 'grid-cols-2'
filterHeaderClass.value = 'grid-col-span-2'
}
else if (contentRect.width < 540) {
filterClass.value = 'grid-cols-3'
filterHeaderClass.value = 'grid-col-span-3'
}
else {
filterClass.value = 'grid-cols-4'
filterHeaderClass.value = 'grid-col-span-4'
filterClass.value = 'grid-cols-5'
filterHeaderClass.value = 'grid-col-span-5'
}
})
</script>
Expand Down Expand Up @@ -242,6 +250,7 @@ useResizeObserver(() => testExplorerRef.value, ([{ contentRect }]) => {
<FilterStatus v-model="filter.success" label="Pass" />
<FilterStatus v-model="filter.skipped" label="Skip" />
<FilterStatus v-model="filter.onlyTests" label="Only Tests" />
<FilterStatus v-model="filter.slow" label="Slow" />
</div>
</div>
<div class="scrolls" flex-auto py-1 @scroll.passive="hideAllPoppers">
Expand Down Expand Up @@ -343,6 +352,7 @@ useResizeObserver(() => testExplorerRef.value, ([{ contentRect }]) => {
:project-name-color="item.projectNameColor ?? ''"
:state="item.state"
:duration="item.duration"
:slow="item.slow === true"
:opened="item.expanded"
:disable-task-location="!includeTaskLocation"
:class="selectedTest === item.id || (!selectedTest && activeFileId === item.id) ? 'bg-active' : ''"
Expand Down
9 changes: 8 additions & 1 deletion packages/ui/client/components/explorer/ExplorerItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const {
indent,
name,
duration,
slow,
current,
opened,
expandable,
Expand All @@ -35,6 +36,7 @@ const {
indent: number
typecheck?: boolean
duration?: number
slow?: boolean
state?: TaskState
current: boolean
type: TaskTreeNodeType
Expand Down Expand Up @@ -220,7 +222,12 @@ const tagsBgGradient = computed(() => {
</span>
<span :text="state === 'fail' ? 'red-500' : ''" v-html="highlighted" />
</span>
<span v-if="typeof duration === 'number'" text="xs" op20 style="white-space: nowrap">
<span
v-if="typeof duration === 'number'"
text="xs"
:class="slow ? 'text-yellow5 op80' : 'op20'"
style="white-space: nowrap"
>
{{ duration > 0 ? duration : '< 1' }}ms
</span>
</div>
Expand Down
11 changes: 11 additions & 0 deletions packages/ui/client/composables/explorer/collector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
createOrUpdateNodeTask,
createOrUpdateSuiteTask,
isRunningTestNode,
isSlowTestTask,
} from '~/composables/explorer/utils'
import { isSuite } from '~/utils/task'
import { hasFailedSnapshot } from '../../../../vitest/src/utils/tasks'
Expand All @@ -41,6 +42,7 @@ export function runLoadFiles(
failed: filter.failed,
success: filter.success,
skipped: filter.skipped,
slow: filter.slow,
onlyTests: filter.onlyTests,
})
}
Expand Down Expand Up @@ -294,6 +296,7 @@ export function resetCollectorInfo(summary: CollectorInfo) {
summary.testsSkipped = 0
summary.testsTodo = 0
summary.testsExpectedFail = 0
summary.testsSlow = 0
summary.totalTests = 0
summary.failedSnapshotEnabled = false
}
Expand Down Expand Up @@ -321,6 +324,7 @@ function collectData(
testsSkipped: 0,
testsTodo: 0,
testsExpectedFail: 0,
testsSlow: 0,
totalTests: 0,
failedSnapshot: false,
failedSnapshotEnabled: false,
Expand Down Expand Up @@ -356,6 +360,7 @@ function collectData(
ignored,
todo,
expectedFail,
slow,
} = collectTests(f)

data.totalTests += total
Expand All @@ -364,6 +369,7 @@ function collectData(
data.testsSkipped += skipped
data.testsTodo += todo
data.testsExpectedFail += expectedFail
data.testsSlow += slow
data.testsIgnore += ignored
}

Expand All @@ -379,6 +385,7 @@ function collectData(
summary.testsSuccess = data.testsSuccess
summary.testsTodo = data.testsTodo
summary.testsExpectedFail = data.testsExpectedFail
summary.testsSlow = data.testsSlow
summary.testsIgnore = data.testsIgnore
summary.testsSkipped = data.testsSkipped
summary.totalTests = data.totalTests
Expand All @@ -394,11 +401,15 @@ function collectTests(file: File, search: SearchMatcher = () => true, filter?: F
ignored: 0,
todo: 0,
expectedFail: 0,
slow: 0,
} satisfies CollectFilteredTests

for (const t of testsCollector(file)) {
if (!filter || testMatcher(t, search, filter)) {
data.total++
if (isSlowTestTask(t)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I don't like with this check is that total number is not a sum of all other states anymore.

Copy link
Copy Markdown
Member

@userquin userquin Feb 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right, checking logic, thx Vlad

Copy link
Copy Markdown
Member

@userquin userquin Feb 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how to solve this, we'll need 2 filters (split testMatcher/matchState at collector.ts and matcher at filter.ts) to collect totals and filtering nodes.

Using a new flag (filterSlow = true) at testMatcher/matchState, collectTests will use false:

image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check 94b0c07 not sure if this is ok

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it is fine since we only show files/suites containing filtered tests, since we're filtering the ui with forceSlow = true shouldn't be a problem, we're changing the way we collect the totals (forceSlow = false; files or individual tests, PASS (15) is the number of files, if we check Tests Only will display the tests PASSING, slow or not)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arggg, so it is test/core with threads project only, reverting changes; will check the sum/count

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also 200 files don't add up to Pass 198 + Fail 1 🤔

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arggg, something is wrong also at default reporter:

image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing running test fixed here cc73597

Missing running test running test running test mode
Missing running test fixed once main merged here running test fixed

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is anything missing? The failing tests is not related to the changes, right?

data.slow++
}
if (t.result?.state === 'fail') {
data.failed++
}
Expand Down
14 changes: 12 additions & 2 deletions packages/ui/client/composables/explorer/filter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Task } from '@vitest/runner'
import type { FileTreeNode, Filter, FilterResult, ParentTreeNode, SearchMatcher, UITaskTreeNode } from '~/composables/explorer/types'
import { client, findById } from '~/composables/client'
import { client, config, findById } from '~/composables/client'
import { explorerTree } from '~/composables/explorer/index'
import { currentProjectName, filteredFiles, projectSort, uiEntries } from '~/composables/explorer/state'
import {
Expand Down Expand Up @@ -220,6 +220,15 @@ function* filterParents(
}

function matchState(task: Task, filter: Filter) {
if (filter.slow) {
if (task.type === 'test') {
const threshold = config.value.slowTestThreshold
if (typeof threshold === 'number' && typeof task.result?.duration === 'number' && task.result.duration > threshold) {
return true
}
}
}

if (filter.success || filter.failed) {
if ('result' in task) {
if (filter.success && task.result?.state === 'pass') {
Expand All @@ -245,7 +254,8 @@ function matchTask(
) {
// search and filter will apply together
if (search(task)) {
if (filter.success || filter.failed || filter.skipped) {
const hasStatusFilter = filter.success || filter.failed || filter.skipped || filter.slow
if (hasStatusFilter) {
if (matchState(task, filter)) {
return true
}
Expand Down
7 changes: 6 additions & 1 deletion packages/ui/client/composables/explorer/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export function useSearch(
filter.failed = false
filter.success = false
filter.skipped = false
filter.slow = false
filter.onlyTests = false
if (focus) {
searchBox.value?.focus()
Expand Down Expand Up @@ -94,6 +95,7 @@ export function useSearch(
failedValue: boolean,
successValue: boolean,
skippedValue: boolean,
slowValue: boolean,
onlyTestsValue: boolean,
projectValue: string,
projectSortValue: SortUIType,
Expand All @@ -106,6 +108,7 @@ export function useSearch(
treeFilter.value.failed = failedValue
treeFilter.value.success = successValue
treeFilter.value.skipped = skippedValue
treeFilter.value.slow = slowValue
treeFilter.value.onlyTests = onlyTestsValue
treeFilter.value.project = projectValue
treeFilter.value.projectSort = projectSortValue === 'default' ? undefined : projectSortValue
Expand All @@ -117,16 +120,18 @@ export function useSearch(
filter.failed,
filter.success,
filter.skipped,
filter.slow,
filter.onlyTests,
currentProject.value,
projectSort.value,
] as const,
([search, failed, success, skipped, onlyTests, project, projectSort]) => {
([search, failed, success, skipped, slow, onlyTests, project, projectSort]) => {
updateFilterStorage(
search,
failed,
success,
skipped,
slow,
onlyTests,
project,
projectSort,
Expand Down
6 changes: 6 additions & 0 deletions packages/ui/client/composables/explorer/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const treeFilter = useLocalStorage<TreeFilterState>(
failed: false,
success: false,
skipped: false,
slow: false,
onlyTests: false,
search: '',
project: ALL_PROJECTS,
Expand Down Expand Up @@ -92,6 +93,7 @@ export const filter = reactive<Filter>({
failed: treeFilter.value.failed,
success: treeFilter.value.success,
skipped: treeFilter.value.skipped,
slow: treeFilter.value.slow,
onlyTests: treeFilter.value.onlyTests,
})
export const isFilteredByStatus = computed(() => {
Expand All @@ -107,6 +109,10 @@ export const isFilteredByStatus = computed(() => {
return true
}

if (filter.slow) {
return true
}

return false
})
export const filteredFiles = shallowRef<File[]>([])
Expand Down
8 changes: 8 additions & 0 deletions packages/ui/client/composables/explorer/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export class ExplorerTree {
testsSkipped: 0,
testsTodo: 0,
testsExpectedFail: 0,
testsSlow: 0,
totalTests: 0,
failedSnapshot: false,
failedSnapshotEnabled: false,
Expand All @@ -73,6 +74,7 @@ export class ExplorerTree {
failed: filter.failed,
success: filter.success,
skipped: filter.skipped,
slow: filter.slow,
onlyTests: filter.onlyTests,
},
)
Expand Down Expand Up @@ -127,6 +129,7 @@ export class ExplorerTree {
failed: filter.failed,
success: filter.success,
skipped: filter.skipped,
slow: filter.slow,
onlyTests: filter.onlyTests,
},
end ? this.executionTime : performance.now() - this.startTime,
Expand All @@ -143,6 +146,7 @@ export class ExplorerTree {
failed: filter.failed,
success: filter.success,
skipped: filter.skipped,
slow: filter.slow,
onlyTests: filter.onlyTests,
},
end ? this.executionTime : performance.now() - this.startTime,
Expand All @@ -160,6 +164,7 @@ export class ExplorerTree {
failed: filter.failed,
success: filter.success,
skipped: filter.skipped,
slow: filter.slow,
onlyTests: filter.onlyTests,
})
}
Expand All @@ -176,6 +181,7 @@ export class ExplorerTree {
failed: filter.failed,
success: filter.success,
skipped: filter.skipped,
slow: filter.slow,
onlyTests: filter.onlyTests,
})
})
Expand All @@ -193,6 +199,7 @@ export class ExplorerTree {
failed: filter.failed,
success: filter.success,
skipped: filter.skipped,
slow: filter.slow,
onlyTests: filter.onlyTests,
})
})
Expand All @@ -204,6 +211,7 @@ export class ExplorerTree {
failed: filter.failed,
success: filter.success,
skipped: filter.skipped,
slow: filter.slow,
onlyTests: filter.onlyTests,
})
})
Expand Down
Loading