/
Suites.vue
44 lines (41 loc) · 1.43 KB
/
Suites.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<script setup lang="ts">
import { hasFailedSnapshot } from '@vitest/ws-client'
import { coverageEnabled, disableCoverage } from '../composables/navigation'
import { client, current, isReport, runCurrent } from '~/composables/client'
const name = computed(() => current.value?.name.split(/\//g).pop())
const failedSnapshot = computed(() => current.value?.tasks && hasFailedSnapshot(current.value?.tasks))
function updateSnapshot() {
return current.value && client.rpc.updateSnapshot(current.value)
}
async function onRunCurrent() {
if (coverageEnabled.value) {
disableCoverage.value = true
await nextTick()
}
await runCurrent()
}
</script>
<template>
<div v-if="current" h-full>
<TasksList :tasks="current.tasks" :nested="true">
<template #header>
<StatusIcon mx-1 :task="current" />
<span data-testid="filenames" font-bold text-sm flex-auto ws-nowrap overflow-hidden truncate>{{ name }}</span>
<div class="flex text-lg">
<IconButton
v-if="(failedSnapshot && !isReport)"
v-tooltip.bottom="`Update failed snapshot(s) of ${current.name}`"
icon="i-carbon-result-old"
@click="updateSnapshot()"
/>
<IconButton
v-if="!isReport"
v-tooltip.bottom="'Rerun file'"
icon="i-carbon-play"
@click="onRunCurrent()"
/>
</div>
</template>
</TasksList>
</div>
</template>