fix(web): 清理测试运行警告
This commit is contained in:
6 files changed
+18
-7
No files matched your search
@@ -5,7 +5,7 @@ import type { ApiClient } from './client'
|
||||
export const apiClientKey: InjectionKey<ApiClient> = Symbol('api-client')
|
||||
|
||||
export function useApiClient(): ApiClient {
|
||||
const client = inject(apiClientKey)
|
||||
const client = inject(apiClientKey, null)
|
||||
if (!client) throw new Error('API_CLIENT_NOT_PROVIDED')
|
||||
return client
|
||||
}
|
||||
@@ -107,7 +107,7 @@ const healthErrorMessage = computed(() =>
|
||||
<span>{{
|
||||
t('home.revision', { revision: healthQuery.data.value.snapshot_revision })
|
||||
}}</span>
|
||||
<i18n-t keypath="home.observedAt" tag="span">
|
||||
<i18n-t keypath="home.observedAt" scope="global" tag="span">
|
||||
<template #time>
|
||||
<AppDateTime :instant="healthQuery.data.value.observed_at" :locale="locale" />
|
||||
</template>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { QueryClient, VueQueryPlugin } from '@tanstack/vue-query'
|
||||
import { flushPromises, mount } from '@vue/test-utils'
|
||||
import { createMemoryHistory } from 'vue-router'
|
||||
import { computed } from 'vue'
|
||||
import { createMemoryHistory, matchedRouteKey } from 'vue-router'
|
||||
|
||||
import type { ApiClient } from '@/api/client'
|
||||
import { apiClientKey } from '@/api/client-context'
|
||||
@@ -53,6 +54,7 @@ async function mountImport(
|
||||
const router = createAppRouter({ hasCredential: () => true }, createMemoryHistory())
|
||||
await router.push('/import')
|
||||
await router.isReady()
|
||||
const activeRouteRecord = computed(() => router.currentRoute.value.matched.at(-1))
|
||||
const importRecovery = recovery()
|
||||
const operationOwner = createImportOperationOwner()
|
||||
const wrapper = mount(NewGroupImport, {
|
||||
@@ -69,6 +71,7 @@ async function mountImport(
|
||||
[importRecoveryKey as symbol]: importRecovery,
|
||||
[importOperationOwnerKey as symbol]: operationOwner,
|
||||
[unsavedChangesKey as symbol]: createUnsavedChangesController(),
|
||||
[matchedRouteKey as symbol]: activeRouteRecord,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -104,6 +104,12 @@ function accessKeyLabel(log: RequestLogItemDto): string {
|
||||
return `#${log.access_key.id}`
|
||||
}
|
||||
|
||||
function protocolLabel(log: RequestLogItemDto): string {
|
||||
return log.protocol
|
||||
? t(`common.protocols.${log.protocol}`)
|
||||
: t('monitor.logs.drawer.usage.unknown')
|
||||
}
|
||||
|
||||
function usageStateLabel(log: RequestLogItemDto): string {
|
||||
return t(`monitor.logs.drawer.usage.state.${log.usage_state}`)
|
||||
}
|
||||
@@ -189,7 +195,7 @@ function estimatedCost(log: RequestLogItemDto): string {
|
||||
</div>
|
||||
<div>
|
||||
<dt>{{ t('monitor.logs.drawer.protocol') }}</dt>
|
||||
<dd>{{ t(`common.protocols.${log.protocol}`) }}</dd>
|
||||
<dd>{{ protocolLabel(log) }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>{{ t('monitor.logs.drawer.accessKey') }}</dt>
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { AppI18n } from './index'
|
||||
export const appI18nKey: InjectionKey<AppI18n> = Symbol('app-i18n')
|
||||
|
||||
export function useAppI18n(): AppI18n {
|
||||
const appI18n = inject(appI18nKey)
|
||||
const appI18n = inject(appI18nKey, null)
|
||||
if (!appI18n) throw new Error('APP_I18N_NOT_PROVIDED')
|
||||
return appI18n
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { VueQueryPlugin, type QueryClient } from '@tanstack/vue-query'
|
||||
import { mount, type ComponentMountingOptions } from '@vue/test-utils'
|
||||
import type { Component } from 'vue'
|
||||
import { createMemoryHistory } from 'vue-router'
|
||||
import { computed, type Component } from 'vue'
|
||||
import { createMemoryHistory, matchedRouteKey } from 'vue-router'
|
||||
|
||||
import type { ApiClient } from '@/api/client'
|
||||
import { apiClientKey } from '@/api/client-context'
|
||||
@@ -35,6 +35,7 @@ export async function mountApp(
|
||||
const router = createAppRouter({ hasCredential: () => true }, createMemoryHistory())
|
||||
await router.push(options.path ?? '/')
|
||||
await router.isReady()
|
||||
const activeRouteRecord = computed(() => router.currentRoute.value.matched.at(-1))
|
||||
const appI18n = createTestAppI18n(undefined, options.locale ?? 'zh-CN')
|
||||
const recovery =
|
||||
options.recovery ??
|
||||
@@ -55,6 +56,7 @@ export async function mountApp(
|
||||
[importRecoveryKey as symbol]: recovery,
|
||||
[importOperationOwnerKey as symbol]: options.operationOwner ?? createImportOperationOwner(),
|
||||
[unsavedChangesKey as symbol]: createUnsavedChangesController(),
|
||||
[matchedRouteKey as symbol]: activeRouteRecord,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user