Skip to content

Commit c31c41c

Browse files
authored
feat(ui): add initializing explorer logic (#5941)
1 parent ea12834 commit c31c41c

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

packages/ui/client/components/explorer/Explorer.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ useResizeObserver(testExplorerRef, (entries) => {
121121
</div>
122122
<div class="scrolls" flex-auto py-1 @scroll.passive="hideAllPoppers">
123123
<DetailsPanel>
124-
<template #summary>
124+
<template v-if="initialized" #summary>
125125
<div grid="~ items-center gap-x-1 cols-[auto_min-content_auto] rows-[min-content_min-content]">
126126
<span text-red5>
127127
FAIL ({{ testsTotal.failed }})
@@ -141,7 +141,7 @@ useResizeObserver(testExplorerRef, (entries) => {
141141
</template>
142142
<!-- empty-state -->
143143
<template v-if="(isFiltered || isFilteredByStatus) && uiEntries.length === 0">
144-
<div v-show="initialized" flex="~ col" items-center p="x4 y4" font-light>
144+
<div v-if="initialized" flex="~ col" items-center p="x4 y4" font-light>
145145
<div op30>
146146
No matched test
147147
</div>
@@ -186,6 +186,12 @@ useResizeObserver(testExplorerRef, (entries) => {
186186
Clear All
187187
</button>
188188
</div>
189+
<div v-else flex="~ col" items-center p="x4 y4" font-light>
190+
<div class="i-carbon:circle-dash animate-spin" />
191+
<div op30>
192+
Loading...
193+
</div>
194+
</div>
189195
</template>
190196
<template v-else>
191197
<RecycleScroller

packages/ui/client/composables/explorer/collector.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ import {
1313
isRunningTestNode,
1414
} from '~/composables/explorer/utils'
1515
import { isSuite } from '~/utils/task'
16-
import { openedTreeItems, treeFilter, uiEntries, uiFiles } from '~/composables/explorer/state'
16+
import {
17+
initialized,
18+
openedTreeItems,
19+
treeFilter,
20+
uiEntries,
21+
uiFiles,
22+
} from '~/composables/explorer/state'
1723
import { explorerTree } from '~/composables/explorer/index'
1824
import { expandNodesOnEndRun } from '~/composables/explorer/expand'
1925

@@ -161,8 +167,6 @@ function doRunFilter(
161167
filter: Filter,
162168
end = false,
163169
) {
164-
// refresh explorer
165-
166170
const expandAll = treeFilter.value.expandAll
167171
const resetExpandAll = expandAll !== true
168172
const ids = new Set(openedTreeItems.value)
@@ -173,6 +177,15 @@ function doRunFilter(
173177
refreshExplorer(search, filter, end)
174178
})
175179

180+
// initialize the explorer
181+
if (!initialized.value) {
182+
queueMicrotask(() => {
183+
if (uiEntries.value.length || end) {
184+
initialized.value = true
185+
}
186+
})
187+
}
188+
176189
if (applyExpandNodes) {
177190
// expand all nodes
178191
queueMicrotask(() => {

packages/ui/client/composables/explorer/search.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,6 @@ export function useSearch(searchBox: Ref<HTMLDivElement | undefined>) {
8585
}
8686
}, { flush: 'post' })
8787

88-
onMounted(() => {
89-
nextTick(() => (initialized.value = true))
90-
})
91-
9288
return {
9389
initialized,
9490
filter,

0 commit comments

Comments
 (0)