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.
This commit is contained in:
CodingOnStar
2025-12-19 13:45:52 +08:00
parent d0ba785645
commit e2edcdb0cf

View File

@@ -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