mirror of
https://github.com/langgenius/dify.git
synced 2025-12-19 14:19:28 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user