From 7900f9f89c6a37928df9ea1ae473e526883d6d43 Mon Sep 17 00:00:00 2001 From: Vladimir Date: Fri, 31 May 2024 21:33:31 +0200 Subject: [PATCH] feat(ui): render tests in a tree (#5807) --- packages/ui/client/auto-imports.d.ts | 1 + packages/ui/client/components.d.ts | 2 +- packages/ui/client/components/FileDetails.vue | 4 + packages/ui/client/components/IconAction.vue | 15 ++++ packages/ui/client/components/Navigation.vue | 34 ++++++++- packages/ui/client/components/Suites.vue | 45 ----------- packages/ui/client/components/TaskItem.vue | 74 ++++++++++++++----- packages/ui/client/components/TaskTree.vue | 46 ++++++++++-- packages/ui/client/components/TasksList.vue | 11 +++ packages/ui/client/composables/navigation.ts | 1 + packages/ui/client/pages/index.vue | 9 +-- packages/ui/client/utils/task.ts | 14 ++++ packages/ui/vite.config.ts | 16 ++-- test/ui/test/html-report.spec.ts | 9 ++- test/ui/test/ui.spec.ts | 13 +++- 15 files changed, 200 insertions(+), 94 deletions(-) create mode 100644 packages/ui/client/components/IconAction.vue delete mode 100644 packages/ui/client/components/Suites.vue diff --git a/packages/ui/client/auto-imports.d.ts b/packages/ui/client/auto-imports.d.ts index 1ae5d56efcd3..f2cbcae93687 100644 --- a/packages/ui/client/auto-imports.d.ts +++ b/packages/ui/client/auto-imports.d.ts @@ -89,6 +89,7 @@ declare global { const onUnmounted: typeof import('vue')['onUnmounted'] const onUpdated: typeof import('vue')['onUpdated'] const openInEditor: typeof import('./composables/error')['openInEditor'] + const openedTreeItems: typeof import('./composables/navigation')['openedTreeItems'] const params: typeof import('./composables/params')['params'] const parseError: typeof import('./composables/error')['parseError'] const pausableWatch: typeof import('@vueuse/core')['pausableWatch'] diff --git a/packages/ui/client/components.d.ts b/packages/ui/client/components.d.ts index 2cbf34ccdfa9..b80951f9c47f 100644 --- a/packages/ui/client/components.d.ts +++ b/packages/ui/client/components.d.ts @@ -15,6 +15,7 @@ declare module 'vue' { DetailsPanel: typeof import('./components/DetailsPanel.vue')['default'] ErrorEntry: typeof import('./components/dashboard/ErrorEntry.vue')['default'] FileDetails: typeof import('./components/FileDetails.vue')['default'] + IconAction: typeof import('./components/IconAction.vue')['default'] IconButton: typeof import('./components/IconButton.vue')['default'] Modal: typeof import('./components/Modal.vue')['default'] ModuleTransformResultView: typeof import('./components/ModuleTransformResultView.vue')['default'] @@ -23,7 +24,6 @@ declare module 'vue' { RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] StatusIcon: typeof import('./components/StatusIcon.vue')['default'] - Suites: typeof import('./components/Suites.vue')['default'] TaskItem: typeof import('./components/TaskItem.vue')['default'] TasksList: typeof import('./components/TasksList.vue')['default'] TaskTree: typeof import('./components/TaskTree.vue')['default'] diff --git a/packages/ui/client/components/FileDetails.vue b/packages/ui/client/components/FileDetails.vue index 1bbe4a9ef286..653d97db7c9a 100644 --- a/packages/ui/client/components/FileDetails.vue +++ b/packages/ui/client/components/FileDetails.vue @@ -5,6 +5,7 @@ import type { Params } from '~/composables/params' import { viewMode } from '~/composables/params' import type { ModuleGraph } from '~/composables/module-graph' import { getModuleGraph } from '~/composables/module-graph' +import { getProjectNameColor } from '~/utils/task'; const data = ref({ externalized: [], graph: {}, inlined: [] }) const graph = ref({ nodes: [], links: [] }) @@ -49,6 +50,9 @@ function onDraft(value: boolean) {
+
+ [{{ current?.file.projectName || '' }}] +
{{ current?.filepath }}
diff --git a/packages/ui/client/components/IconAction.vue b/packages/ui/client/components/IconAction.vue new file mode 100644 index 000000000000..9d3243332907 --- /dev/null +++ b/packages/ui/client/components/IconAction.vue @@ -0,0 +1,15 @@ + + + \ No newline at end of file diff --git a/packages/ui/client/components/Navigation.vue b/packages/ui/client/components/Navigation.vue index 489cad5e3c69..95070726a8ec 100644 --- a/packages/ui/client/components/Navigation.vue +++ b/packages/ui/client/components/Navigation.vue @@ -16,6 +16,7 @@ import { client, findById } from '../composables/client' import { isDark, toggleDark } from '~/composables' import { files, isReport, runAll } from '~/composables/client' import { activeFileId } from '~/composables/params' +import { openedTreeItems } from '~/composables/navigation' const failedSnapshot = computed(() => files.value && hasFailedSnapshot(files.value)) function updateSnapshot() { @@ -25,8 +26,8 @@ function updateSnapshot() { const toggleMode = computed(() => isDark.value ? 'light' : 'dark') function onItemClick(task: Task) { - activeFileId.value = task.id - currentModule.value = findById(task.id) + activeFileId.value = task.file.id + currentModule.value = findById(task.file.id) showDashboard(false) } @@ -41,14 +42,41 @@ async function onRunAll(files?: File[]) { } await runAll(files) } + +function collapseTests() { + openedTreeItems.value = [] +} + +function expandTests() { + files.value.forEach(file => { + if (!openedTreeItems.value.includes(file.id)) { + openedTreeItems.value.push(file.id) + } + }) +}