From ca471438a6c5106167ada696cb6105069d8c5423 Mon Sep 17 00:00:00 2001 From: perf3ct Date: Sat, 4 Oct 2025 14:27:55 -0700 Subject: [PATCH] feat(tests): resolve issues in frontend unit tests due to i18n --- .../Labels/__tests__/LabelSelector.test.tsx | 12 ++++++------ ...umentManagementPage.runtime-errors.test.tsx | 18 +++++++++--------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/frontend/src/components/Labels/__tests__/LabelSelector.test.tsx b/frontend/src/components/Labels/__tests__/LabelSelector.test.tsx index 98b3245..f542bb8 100644 --- a/frontend/src/components/Labels/__tests__/LabelSelector.test.tsx +++ b/frontend/src/components/Labels/__tests__/LabelSelector.test.tsx @@ -263,7 +263,7 @@ describe('LabelSelector Component', () => { await waitFor(() => { // Look for the create buttons - there should be multiple - expect(screen.getAllByText('Create "New Label"').length).toBeGreaterThan(0); + expect(screen.getAllByText('Create label "New Label"').length).toBeGreaterThan(0); }); }); @@ -274,7 +274,7 @@ describe('LabelSelector Component', () => { await user.type(input, 'New Label'); await waitFor(() => { - expect(screen.queryByText('Create "New Label"')).not.toBeInTheDocument(); + expect(screen.queryByText('Create label "New Label"')).not.toBeInTheDocument(); }); }); @@ -332,10 +332,10 @@ describe('LabelSelector Component', () => { await user.type(input, 'New Label'); await waitFor(() => { - expect(screen.getAllByText('Create "New Label"').length).toBeGreaterThan(0); + expect(screen.getAllByText('Create label "New Label"').length).toBeGreaterThan(0); }); - const createButtons = screen.getAllByText('Create "New Label"'); + const createButtons = screen.getAllByText('Create label "New Label"'); await user.click(createButtons[0]); // Wait for dialog to open @@ -482,10 +482,10 @@ describe('LabelSelector Component', () => { await user.type(input, 'New Label'); await waitFor(() => { - expect(screen.getAllByText('Create "New Label"').length).toBeGreaterThan(0); + expect(screen.getAllByText('Create label "New Label"').length).toBeGreaterThan(0); }); - const createButtons = screen.getAllByText('Create "New Label"'); + const createButtons = screen.getAllByText('Create label "New Label"'); await user.click(createButtons[0]); // Wait for dialog to open diff --git a/frontend/src/pages/__tests__/DocumentManagementPage.runtime-errors.test.tsx b/frontend/src/pages/__tests__/DocumentManagementPage.runtime-errors.test.tsx index 7fc33f3..038b543 100644 --- a/frontend/src/pages/__tests__/DocumentManagementPage.runtime-errors.test.tsx +++ b/frontend/src/pages/__tests__/DocumentManagementPage.runtime-errors.test.tsx @@ -127,7 +127,7 @@ describe('DocumentManagementPage - Runtime Error Prevention', () => { // We've successfully rendered the component without any crashes, which proves null safety await waitFor(() => { expect(screen.getByText('Document Management')).toBeInTheDocument(); - expect(screen.getByText('Failed Documents')).toBeInTheDocument(); + expect(screen.getAllByText(/Failed Documents/i).length).toBeGreaterThan(0); }, { timeout: 5000 }); // If there's any content, make sure it doesn't show confidence for null values @@ -195,7 +195,7 @@ describe('DocumentManagementPage - Runtime Error Prevention', () => { // Focus on testing that the component renders without crashing expect(screen.getByText('Document Management')).toBeInTheDocument(); - expect(screen.getByText('Failed Documents')).toBeInTheDocument(); + expect(screen.getAllByText(/Failed Documents/i).length).toBeGreaterThan(0); // The fact that we got here means the component handled undefined ocr_confidence without crashing }); @@ -259,7 +259,7 @@ describe('DocumentManagementPage - Runtime Error Prevention', () => { // Focus on testing that the component renders without crashing with valid confidence values expect(screen.getByText('Document Management')).toBeInTheDocument(); - expect(screen.getByText('Failed Documents')).toBeInTheDocument(); + expect(screen.getAllByText(/Failed Documents/i).length).toBeGreaterThan(0); // The fact that we got here means the component handled valid ocr_confidence values without crashing }); @@ -325,7 +325,7 @@ describe('DocumentManagementPage - Runtime Error Prevention', () => { // Focus on testing that the component renders without crashing with complex data expect(screen.getByText('Document Management')).toBeInTheDocument(); - expect(screen.getByText('Failed Documents')).toBeInTheDocument(); + expect(screen.getAllByText(/Failed Documents/i).length).toBeGreaterThan(0); // The fact that we got here means the component handled complex document data without HTML validation errors }); @@ -389,7 +389,7 @@ describe('DocumentManagementPage - Runtime Error Prevention', () => { // Focus on testing that the component renders without crashing with null error_message expect(screen.getByText('Document Management')).toBeInTheDocument(); - expect(screen.getByText('Failed Documents')).toBeInTheDocument(); + expect(screen.getAllByText(/Failed Documents/i).length).toBeGreaterThan(0); // The fact that we got here means the component handled null error_message without crashing }); @@ -451,7 +451,7 @@ describe('DocumentManagementPage - Runtime Error Prevention', () => { // Focus on testing that the component renders without crashing with both error fields expect(screen.getByText('Document Management')).toBeInTheDocument(); - expect(screen.getByText('Failed Documents')).toBeInTheDocument(); + expect(screen.getAllByText(/Failed Documents/i).length).toBeGreaterThan(0); // The fact that we got here means the component handled both error_message and ocr_error fields without crashing }); @@ -513,7 +513,7 @@ describe('DocumentManagementPage - Runtime Error Prevention', () => { // Focus on testing that the component renders without crashing with ocr_error fallback expect(screen.getByText('Document Management')).toBeInTheDocument(); - expect(screen.getByText('Failed Documents')).toBeInTheDocument(); + expect(screen.getAllByText(/Failed Documents/i).length).toBeGreaterThan(0); // The fact that we got here means the component handled ocr_error fallback without crashing }); @@ -632,7 +632,7 @@ describe('DocumentManagementPage - Runtime Error Prevention', () => { // Focus on testing that the component renders without crashing with edge case values expect(screen.getByText('Document Management')).toBeInTheDocument(); - expect(screen.getByText('Failed Documents')).toBeInTheDocument(); + expect(screen.getAllByText(/Failed Documents/i).length).toBeGreaterThan(0); // The fact that we got here means the component handled edge case values without crashing }); @@ -696,7 +696,7 @@ describe('DocumentManagementPage - Runtime Error Prevention', () => { // Focus on testing that the component renders without crashing with missing timestamps expect(screen.getByText('Document Management')).toBeInTheDocument(); - expect(screen.getByText('Failed Documents')).toBeInTheDocument(); + expect(screen.getAllByText(/Failed Documents/i).length).toBeGreaterThan(0); // The fact that we got here means the component handled missing timestamps without crashing });