From c095794e4cb36be2e0af050da6844f2c4770f0a6 Mon Sep 17 00:00:00 2001 From: userquin Date: Fri, 21 Jun 2024 00:54:55 +0200 Subject: [PATCH 1/9] feat(ui): add action to explorer item to show the test/suite line in the source code tab --- docs/config/index.md | 2 + packages/ui/client/auto-imports.d.ts | 4 + packages/ui/client/components/CodeMirror.vue | 16 ++-- packages/ui/client/components/Navigation.vue | 15 +--- .../client/components/explorer/Explorer.vue | 6 +- .../components/explorer/ExplorerItem.vue | 76 +++++++++++++++---- .../ui/client/components/views/ViewEditor.vue | 11 +-- packages/ui/client/composables/codemirror.ts | 26 +++++++ packages/ui/client/composables/navigation.ts | 15 +++- packages/vitest/src/node/config.ts | 10 +++ 10 files changed, 139 insertions(+), 42 deletions(-) diff --git a/docs/config/index.md b/docs/config/index.md index 94d4a34e7706..d5313286e781 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -2285,6 +2285,8 @@ The `location` property has `column` and `line` values that correspond to the `t ::: tip This option has no effect if you do not use custom code that relies on this. + +This option is enabled by default in [Vitest UI](/guide/ui). ::: ### snapshotEnvironment {#snapshotEnvironment} diff --git a/packages/ui/client/auto-imports.d.ts b/packages/ui/client/auto-imports.d.ts index b9f6880e6219..2c1a81fc0b82 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'] @@ -63,6 +64,7 @@ declare global { const isRef: typeof import('vue')['isRef'] 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 +119,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/CodeMirror.vue b/packages/ui/client/components/CodeMirror.vue index d76a3227c159..83ee34dc4a83 100644 --- a/packages/ui/client/components/CodeMirror.vue +++ b/packages/ui/client/components/CodeMirror.vue @@ -1,5 +1,5 @@ diff --git a/packages/ui/client/components/Navigation.vue b/packages/ui/client/components/Navigation.vue index 55f21c9a5580..73353d9a6a13 100644 --- a/packages/ui/client/components/Navigation.vue +++ b/packages/ui/client/components/Navigation.vue @@ -1,19 +1,18 @@