From 12b2f0ac3b69eaaedd6565d99c5ebf7e606a17a5 Mon Sep 17 00:00:00 2001 From: Joel Date: Mon, 20 Apr 2026 09:06:44 +0800 Subject: [PATCH] chore: tip i18n --- .../__tests__/form-fields.spec.tsx | 26 +++++++++++++++++++ .../config-var/config-modal/form-fields.tsx | 18 ++++++++++++- web/i18n/en-US/app-debug.json | 2 +- web/i18n/zh-Hans/app-debug.json | 2 +- 4 files changed, 45 insertions(+), 3 deletions(-) diff --git a/web/app/components/app/configuration/config-var/config-modal/__tests__/form-fields.spec.tsx b/web/app/components/app/configuration/config-var/config-modal/__tests__/form-fields.spec.tsx index 91fc828c2f..277ff32059 100644 --- a/web/app/components/app/configuration/config-var/config-modal/__tests__/form-fields.spec.tsx +++ b/web/app/components/app/configuration/config-var/config-modal/__tests__/form-fields.spec.tsx @@ -4,6 +4,29 @@ import { fireEvent, render, screen } from '@testing-library/react' import { InputVarType } from '@/app/components/workflow/types' import ConfigModalFormFields from '../form-fields' +vi.mock('react-i18next', async () => { + const React = await import('react') + return { + useTranslation: () => ({ + t: (key: string, options?: Record) => { + const ns = options?.ns as string | undefined + return ns ? `${ns}.${key}` : key + }, + i18n: { language: 'en', changeLanguage: vi.fn() }, + }), + Trans: ({ i18nKey, components }: { i18nKey: string, components?: Record }) => ( + + {i18nKey} + {components?.docLink} + + ), + } +}) + +vi.mock('@/context/i18n', () => ({ + useDocLink: () => (path?: string) => `https://docs.example.com${path || ''}`, +})) + vi.mock('@/app/components/base/file-uploader', () => ({ FileUploaderInAttachmentWrapper: ({ onChange }: { onChange: (files: Array>) => void }) => (