Files
Hotel-Booking/Frontend/src/pages/admin/__tests__/InvoiceManagementPage.test.tsx
Iliyan Angelov cf97df9aeb updates
2025-11-28 20:24:58 +02:00

39 lines
1.2 KiB
TypeScript

import { describe, it, expect, vi, beforeEach } from 'vitest';
import { screen, waitFor } from '../../../test/utils/test-utils';
import { renderWithRouter } from '../../../test/utils/test-utils';
import InvoiceManagementPage from '../InvoiceManagementPage';
describe('Admin InvoiceManagementPage', () => {
beforeEach(() => {
vi.clearAllMocks();
});
it('should render the page', async () => {
renderWithRouter(<InvoiceManagementPage />);
// Wait for loading to finish
await waitFor(() => {
expect(screen.queryByText(/Loading/i)).not.toBeInTheDocument();
}, { timeout: 5000 });
// Check if page content is displayed (use more specific query)
await waitFor(() => {
const pageTitle = screen.queryByRole('heading', { name: /Invoice Management/i });
expect(pageTitle).toBeInTheDocument();
});
});
it('should fetch and display invoices', async () => {
renderWithRouter(<InvoiceManagementPage />);
await waitFor(() => {
// Check if invoices are displayed
const invoicesSection = screen.queryByText(/Invoices/i);
if (invoicesSection) {
expect(invoicesSection).toBeInTheDocument();
}
}, { timeout: 5000 });
});
});