feat(tests): fix unit tests and ts linting
This commit is contained in:
parent
c78fa4c8be
commit
16daadc3e7
|
|
@ -591,8 +591,8 @@ const DocumentsPage: React.FC = () => {
|
||||||
}}>
|
}}>
|
||||||
<Typography variant="body2" sx={{ flexGrow: 1, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
<Typography variant="body2" sx={{ flexGrow: 1, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||||
{t('documents.selection.count', {
|
{t('documents.selection.count', {
|
||||||
count: selectedDocuments.size > 999 ? `${Math.floor(selectedDocuments.size/1000)}K` : selectedDocuments.size,
|
count: selectedDocuments.size,
|
||||||
total: sortedDocuments.length > 999 ? `${Math.floor(sortedDocuments.length/1000)}K` : sortedDocuments.length
|
total: sortedDocuments.length
|
||||||
})}
|
})}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Button
|
<Button
|
||||||
|
|
@ -612,7 +612,7 @@ const DocumentsPage: React.FC = () => {
|
||||||
size="small"
|
size="small"
|
||||||
color="error"
|
color="error"
|
||||||
>
|
>
|
||||||
{t('documents.selection.deleteSelected', { count: selectedDocuments.size > 999 ? `${Math.floor(selectedDocuments.size/1000)}K` : selectedDocuments.size })}
|
{t('documents.selection.deleteSelected', { count: selectedDocuments.size })}
|
||||||
</Button>
|
</Button>
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,32 @@ import React from 'react'
|
||||||
import { render, RenderOptions } from '@testing-library/react'
|
import { render, RenderOptions } from '@testing-library/react'
|
||||||
import { BrowserRouter } from 'react-router-dom'
|
import { BrowserRouter } from 'react-router-dom'
|
||||||
import { vi } from 'vitest'
|
import { vi } from 'vitest'
|
||||||
|
import { I18nextProvider } from 'react-i18next'
|
||||||
|
import i18n from 'i18next'
|
||||||
|
import { initReactI18next } from 'react-i18next'
|
||||||
import { NotificationProvider } from '../contexts/NotificationContext'
|
import { NotificationProvider } from '../contexts/NotificationContext'
|
||||||
|
|
||||||
|
// Initialize i18n for tests
|
||||||
|
i18n
|
||||||
|
.use(initReactI18next)
|
||||||
|
.init({
|
||||||
|
lng: 'en',
|
||||||
|
fallbackLng: 'en',
|
||||||
|
ns: ['translation'],
|
||||||
|
defaultNS: 'translation',
|
||||||
|
resources: {
|
||||||
|
en: {
|
||||||
|
translation: require('../../public/locales/en/translation.json')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
interpolation: {
|
||||||
|
escapeValue: false
|
||||||
|
},
|
||||||
|
react: {
|
||||||
|
useSuspense: false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
interface User {
|
interface User {
|
||||||
id: string
|
id: string
|
||||||
username: string
|
username: string
|
||||||
|
|
@ -147,23 +171,25 @@ export const MockAuthProvider = ({
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enhanced provider wrapper with theme and notification contexts
|
// Enhanced provider wrapper with theme and notification contexts
|
||||||
const AllTheProviders = ({
|
const AllTheProviders = ({
|
||||||
children,
|
children,
|
||||||
authValues,
|
authValues,
|
||||||
routerProps = {}
|
routerProps = {}
|
||||||
}: {
|
}: {
|
||||||
children: React.ReactNode
|
children: React.ReactNode
|
||||||
authValues?: Partial<MockAuthContextType>
|
authValues?: Partial<MockAuthContextType>
|
||||||
routerProps?: any
|
routerProps?: any
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<BrowserRouter {...routerProps}>
|
<I18nextProvider i18n={i18n}>
|
||||||
<NotificationProvider>
|
<BrowserRouter {...routerProps}>
|
||||||
<MockAuthProvider mockValues={authValues}>
|
<NotificationProvider>
|
||||||
{children}
|
<MockAuthProvider mockValues={authValues}>
|
||||||
</MockAuthProvider>
|
{children}
|
||||||
</NotificationProvider>
|
</MockAuthProvider>
|
||||||
</BrowserRouter>
|
</NotificationProvider>
|
||||||
|
</BrowserRouter>
|
||||||
|
</I18nextProvider>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue