From 1d2eac1b4e0c504699eb33759a393cef8df13e7c Mon Sep 17 00:00:00 2001 From: CodingOnStar Date: Mon, 29 Dec 2025 17:50:13 +0800 Subject: [PATCH] test: enhance translation function in plugin detail panel tests to support namespace handling --- .../subscription-list/create/common-modal.spec.tsx | 6 +++++- .../subscription-list/create/oauth-client.spec.tsx | 6 +++++- .../subscription-list/edit/index.spec.tsx | 8 +++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/web/app/components/plugins/plugin-detail-panel/subscription-list/create/common-modal.spec.tsx b/web/app/components/plugins/plugin-detail-panel/subscription-list/create/common-modal.spec.tsx index 8bf154e26e..33cb93013d 100644 --- a/web/app/components/plugins/plugin-detail-panel/subscription-list/create/common-modal.spec.tsx +++ b/web/app/components/plugins/plugin-detail-panel/subscription-list/create/common-modal.spec.tsx @@ -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, diff --git a/web/app/components/plugins/plugin-detail-panel/subscription-list/create/oauth-client.spec.tsx b/web/app/components/plugins/plugin-detail-panel/subscription-list/create/oauth-client.spec.tsx index 8c2a4109c6..74599a13c5 100644 --- a/web/app/components/plugins/plugin-detail-panel/subscription-list/create/oauth-client.spec.tsx +++ b/web/app/components/plugins/plugin-detail-panel/subscription-list/create/oauth-client.spec.tsx @@ -68,7 +68,11 @@ function createMockSubscriptionBuilder(overrides: Partial 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, diff --git a/web/app/components/plugins/plugin-detail-panel/subscription-list/edit/index.spec.tsx b/web/app/components/plugins/plugin-detail-panel/subscription-list/edit/index.spec.tsx index e814774621..4ce1841b05 100644 --- a/web/app/components/plugins/plugin-detail-panel/subscription-list/edit/index.spec.tsx +++ b/web/app/components/plugins/plugin-detail-panel/subscription-list/edit/index.spec.tsx @@ -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()