From 16daadc3e75ace5ab94429ba48d03b5e7c97edf3 Mon Sep 17 00:00:00 2001 From: perf3ct Date: Sat, 4 Oct 2025 14:20:27 -0700 Subject: [PATCH] feat(tests): fix unit tests and ts linting --- frontend/src/pages/DocumentsPage.tsx | 6 ++-- frontend/src/test/test-utils.tsx | 46 ++++++++++++++++++++++------ 2 files changed, 39 insertions(+), 13 deletions(-) diff --git a/frontend/src/pages/DocumentsPage.tsx b/frontend/src/pages/DocumentsPage.tsx index e50746d..66b64f2 100644 --- a/frontend/src/pages/DocumentsPage.tsx +++ b/frontend/src/pages/DocumentsPage.tsx @@ -591,8 +591,8 @@ const DocumentsPage: React.FC = () => { }}> {t('documents.selection.count', { - count: selectedDocuments.size > 999 ? `${Math.floor(selectedDocuments.size/1000)}K` : selectedDocuments.size, - total: sortedDocuments.length > 999 ? `${Math.floor(sortedDocuments.length/1000)}K` : sortedDocuments.length + count: selectedDocuments.size, + total: sortedDocuments.length })} )} diff --git a/frontend/src/test/test-utils.tsx b/frontend/src/test/test-utils.tsx index 643e21f..0bb3879 100644 --- a/frontend/src/test/test-utils.tsx +++ b/frontend/src/test/test-utils.tsx @@ -2,8 +2,32 @@ import React from 'react' import { render, RenderOptions } from '@testing-library/react' import { BrowserRouter } from 'react-router-dom' import { vi } from 'vitest' +import { I18nextProvider } from 'react-i18next' +import i18n from 'i18next' +import { initReactI18next } from 'react-i18next' 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 { id: string username: string @@ -147,23 +171,25 @@ export const MockAuthProvider = ({ } // Enhanced provider wrapper with theme and notification contexts -const AllTheProviders = ({ - children, +const AllTheProviders = ({ + children, authValues, routerProps = {} -}: { +}: { children: React.ReactNode authValues?: Partial routerProps?: any }) => { return ( - - - - {children} - - - + + + + + {children} + + + + ) }