test: enhance translation function in plugin detail panel tests to support namespace handling

This commit is contained in:
CodingOnStar 2025-12-29 17:50:13 +08:00
parent 23a8bebb62
commit 1d2eac1b4e
3 changed files with 17 additions and 3 deletions

View File

@ -78,7 +78,11 @@ function createMockLogData(logs: TriggerLogEntity[] = []): { logs: TriggerLogEnt
// Mock Setup
// ============================================================================
const mockTranslate = vi.fn((key: string) => key)
const mockTranslate = vi.fn((key: string, options?: { ns?: string }) => {
// Build full key with namespace prefix if provided
const fullKey = options?.ns ? `${options.ns}.${key}` : key
return fullKey
})
vi.mock('react-i18next', () => ({
useTranslation: () => ({
t: mockTranslate,

View File

@ -68,7 +68,11 @@ function createMockSubscriptionBuilder(overrides: Partial<TriggerSubscriptionBui
// Mock Setup
// ============================================================================
const mockTranslate = vi.fn((key: string) => key)
const mockTranslate = vi.fn((key: string, options?: { ns?: string }) => {
// Build full key with namespace prefix if provided
const fullKey = options?.ns ? `${options.ns}.${key}` : key
return fullKey
})
vi.mock('react-i18next', () => ({
useTranslation: () => ({
t: mockTranslate,

View File

@ -13,7 +13,13 @@ import { OAuthEditModal } from './oauth-edit-modal'
// ==================== Mock Setup ====================
vi.mock('react-i18next', () => ({
useTranslation: () => ({ t: (key: string) => key }),
useTranslation: () => ({
t: (key: string, options?: { ns?: string }) => {
// Build full key with namespace prefix if provided
const fullKey = options?.ns ? `${options.ns}.${key}` : key
return fullKey
},
}),
}))
const mockToastNotify = vi.fn()