fix(tests): resolve FailedOcrPage frontend unit test, part 2

This commit is contained in:
perf3ct 2025-06-24 22:02:48 +00:00
parent 2a8ba554ce
commit 115c3649b0
1 changed files with 16 additions and 10 deletions

View File

@ -1,5 +1,5 @@
import { describe, test, expect, vi, beforeEach } from 'vitest'; import { describe, test, expect, vi, beforeEach } from 'vitest';
import { render, screen } from '@testing-library/react'; import { render, screen, waitFor } from '@testing-library/react';
import { BrowserRouter } from 'react-router-dom'; import { BrowserRouter } from 'react-router-dom';
import FailedOcrPage from '../FailedOcrPage'; import FailedOcrPage from '../FailedOcrPage';
@ -46,37 +46,43 @@ describe('FailedOcrPage', () => {
expect(document.body).toBeInTheDocument(); expect(document.body).toBeInTheDocument();
}); });
test('renders page title', () => { test('renders page title', async () => {
render( render(
<FailedOcrPageWrapper> <FailedOcrPageWrapper>
<FailedOcrPage /> <FailedOcrPage />
</FailedOcrPageWrapper> </FailedOcrPageWrapper>
); );
// Check for page title // Wait for the page to load and show the title
expect(screen.getByText('Failed OCR & Duplicates')).toBeInTheDocument(); await waitFor(() => {
expect(screen.getByText('Failed OCR & Duplicates')).toBeInTheDocument();
});
}); });
test('renders refresh button', () => { test('renders refresh button', async () => {
render( render(
<FailedOcrPageWrapper> <FailedOcrPageWrapper>
<FailedOcrPage /> <FailedOcrPage />
</FailedOcrPageWrapper> </FailedOcrPageWrapper>
); );
expect(screen.getByText('Refresh')).toBeInTheDocument(); await waitFor(() => {
expect(screen.getByText('Refresh')).toBeInTheDocument();
});
}); });
test('renders tabs structure', () => { test('renders tabs structure', async () => {
render( render(
<FailedOcrPageWrapper> <FailedOcrPageWrapper>
<FailedOcrPage /> <FailedOcrPage />
</FailedOcrPageWrapper> </FailedOcrPageWrapper>
); );
// Check for tab structure // Wait for tabs to appear
const tabs = screen.getByRole('tablist'); await waitFor(() => {
expect(tabs).toBeInTheDocument(); const tabs = screen.getByRole('tablist');
expect(tabs).toBeInTheDocument();
});
}); });
// DISABLED - Complex async behavior tests that require more sophisticated mocking // DISABLED - Complex async behavior tests that require more sophisticated mocking