From e2edcdb0cf78b05f785cb41c47c72aeea4981cfd Mon Sep 17 00:00:00 2001 From: CodingOnStar Date: Fri, 19 Dec 2025 13:45:52 +0800 Subject: [PATCH] fix(tests): normalize path handling in useDocLink mock for document processing tests - Updated the mock implementation of useDocLink to strip leading slashes from paths, aligning with actual implementation behavior. - This change ensures that the generated documentation URLs are consistent and accurate, improving the reliability of tests that depend on this mock. These adjustments enhance the overall stability and correctness of the testing suite for document processing components. --- .../create-from-pipeline/processing/index.spec.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/web/app/components/datasets/documents/create-from-pipeline/processing/index.spec.tsx b/web/app/components/datasets/documents/create-from-pipeline/processing/index.spec.tsx index 0312dae61e..7a051ad325 100644 --- a/web/app/components/datasets/documents/create-from-pipeline/processing/index.spec.tsx +++ b/web/app/components/datasets/documents/create-from-pipeline/processing/index.spec.tsx @@ -17,8 +17,12 @@ jest.mock('react-i18next', () => ({ })) // Mock useDocLink - returns a function that generates doc URLs +// Strips leading slash from path to match actual implementation behavior jest.mock('@/context/i18n', () => ({ - useDocLink: () => (path?: string) => `https://docs.dify.ai/en-US/${path || ''}`, + useDocLink: () => (path?: string) => { + const normalizedPath = path?.startsWith('/') ? path.slice(1) : (path || '') + return `https://docs.dify.ai/en-US/${normalizedPath}` + }, })) // Mock dataset detail context