import { describe, it, expect, vi, beforeEach } from 'vitest';
import { screen, waitFor } from '../../../test/utils/test-utils';
import { renderWithRouter } from '../../../test/utils/test-utils';
import BookingManagementPage from '../BookingManagementPage';

// Mock components that might cause issues
vi.mock('../../../components/shared/CreateBookingModal', () => ({
  default: ({ isOpen }: any) => isOpen ? <div data-testid="create-booking-modal">Create Booking Modal</div> : null,
}));

describe('Admin BookingManagementPage', () => {
  beforeEach(() => {
    vi.clearAllMocks();
  });

  it('should render loading state initially', () => {
    renderWithRouter(<BookingManagementPage />);
    // Component should render (might be in loading state)
    const loadingOrContent = screen.queryByText(/Loading/i) || screen.queryByText(/Booking/i);
    expect(loadingOrContent).toBeInTheDocument();
  });

  it('should fetch and display bookings', async () => {
    renderWithRouter(<BookingManagementPage />);

    await waitFor(() => {
      // Check if bookings table or list is displayed
      const bookingsSection = screen.queryByText(/Bookings/i);
      if (bookingsSection) {
        expect(bookingsSection).toBeInTheDocument();
      }
    }, { timeout: 5000 });
  });
});

