From 7ec298eb37f314a61ac7e747a497c9225e26e841 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20S=C3=A1nchez?= Date: Thu, 27 Jun 2024 14:47:31 +0200 Subject: [PATCH] feat(ui): add action to explorer item to show the test/suite line in the source code tab (#5948) Co-authored-by: Anjorin Damilare --- docs/config/index.md | 4 + packages/ui/client/auto-imports.d.ts | 5 ++ packages/ui/client/components.d.ts | 2 +- ...CodeMirror.vue => CodeMirrorContainer.vue} | 16 ++-- packages/ui/client/components/FileDetails.vue | 1 - .../components/ModuleTransformResultView.vue | 6 +- packages/ui/client/components/Navigation.vue | 15 +--- .../client/components/explorer/Explorer.vue | 6 +- .../components/explorer/ExplorerItem.vue | 82 +++++++++++++++---- .../ui/client/components/views/ViewEditor.vue | 59 +++++++++---- .../ui/client/composables/client/static.ts | 14 ++-- packages/ui/client/composables/codemirror.ts | 12 +++ packages/ui/client/composables/navigation.ts | 20 ++++- packages/ui/client/composables/params.ts | 3 + packages/ui/node/reporter.ts | 13 +++ packages/vitest/src/node/config.ts | 22 +++++ .../tests/__snapshots__/html.test.ts.snap | 36 ++++++++ 17 files changed, 248 insertions(+), 68 deletions(-) rename packages/ui/client/components/{CodeMirror.vue => CodeMirrorContainer.vue} (75%) diff --git a/docs/config/index.md b/docs/config/index.md index 5749c8af7..26f052934 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -2297,6 +2297,10 @@ Should `location` property be included when Vitest API receives tasks in [report The `location` property has `column` and `line` values that correspond to the `test` or `describe` position in the original file. +This option will be auto-enabled if you don't disable it explicitly, and you are running Vitest with: +- [Vitest UI](/guide/ui) +- or using the [Browser Mode](/guide/browser) without [headless](/guide/browser#headless) mode + ::: tip This option has no effect if you do not use custom code that relies on this. ::: diff --git a/packages/ui/client/auto-imports.d.ts b/packages/ui/client/auto-imports.d.ts index b9f6880e6..34c081840 100644 --- a/packages/ui/client/auto-imports.d.ts +++ b/packages/ui/client/auto-imports.d.ts @@ -10,6 +10,7 @@ declare global { const asyncComputed: typeof import('@vueuse/core')['asyncComputed'] const autoResetRef: typeof import('@vueuse/core')['autoResetRef'] const calcExternalLabels: typeof import('./composables/module-graph')['calcExternalLabels'] + const codemirrorRef: typeof import('./composables/codemirror')['codemirrorRef'] const computed: typeof import('vue')['computed'] const computedAsync: typeof import('@vueuse/core')['computedAsync'] const computedEager: typeof import('@vueuse/core')['computedEager'] @@ -61,8 +62,10 @@ declare global { const isReactive: typeof import('vue')['isReactive'] const isReadonly: typeof import('vue')['isReadonly'] const isRef: typeof import('vue')['isRef'] + const lineNumber: typeof import('./composables/params')['lineNumber'] const makeDestructurable: typeof import('@vueuse/core')['makeDestructurable'] const markRaw: typeof import('vue')['markRaw'] + const navigateTo: typeof import('./composables/navigation')['navigateTo'] const nextTick: typeof import('vue')['nextTick'] const onActivated: typeof import('vue')['onActivated'] const onBeforeMount: typeof import('vue')['onBeforeMount'] @@ -117,6 +120,8 @@ declare global { const shouldOpenInEditor: typeof import('./composables/error')['shouldOpenInEditor'] const showCoverage: typeof import('./composables/navigation')['showCoverage'] const showDashboard: typeof import('./composables/navigation')['showDashboard'] + const showLine: typeof import('./composables/codemirror')['showLine'] + const showSource: typeof import('./composables/codemirror')['showSource'] const syncRef: typeof import('@vueuse/core')['syncRef'] const syncRefs: typeof import('@vueuse/core')['syncRefs'] const templateRef: typeof import('@vueuse/core')['templateRef'] diff --git a/packages/ui/client/components.d.ts b/packages/ui/client/components.d.ts index de49b1ec7..a7a4abf43 100644 --- a/packages/ui/client/components.d.ts +++ b/packages/ui/client/components.d.ts @@ -8,7 +8,7 @@ export {} declare module 'vue' { export interface GlobalComponents { BrowserIframe: typeof import('./components/BrowserIframe.vue')['default'] - CodeMirror: typeof import('./components/CodeMirror.vue')['default'] + CodeMirrorContainer: typeof import('./components/CodeMirrorContainer.vue')['default'] ConnectionOverlay: typeof import('./components/ConnectionOverlay.vue')['default'] Coverage: typeof import('./components/Coverage.vue')['default'] Dashboard: typeof import('./components/Dashboard.vue')['default'] diff --git a/packages/ui/client/components/CodeMirror.vue b/packages/ui/client/components/CodeMirrorContainer.vue similarity index 75% rename from packages/ui/client/components/CodeMirror.vue rename to packages/ui/client/components/CodeMirrorContainer.vue index d76a3227c..83ee34dc4 100644 --- a/packages/ui/client/components/CodeMirror.vue +++ b/packages/ui/client/components/CodeMirrorContainer.vue @@ -1,5 +1,5 @@ diff --git a/packages/ui/client/components/FileDetails.vue b/packages/ui/client/components/FileDetails.vue index 9184b1978..5bfe490c5 100644 --- a/packages/ui/client/components/FileDetails.vue +++ b/packages/ui/client/components/FileDetails.vue @@ -174,7 +174,6 @@ debouncedWatch( Module Graph