import { render, type RenderOptions } from '@testing-library/react';
import { SessionProvider } from 'next-auth/react';
import type { ReactElement } from 'react';

const mockSession = {
  user: { name: 'Test User', email: 'test@example.com' },
  accessToken: 'mock-access-token',
  expires: '2099-01-01T00:00:00.000Z',
};

function AllProviders({ children }: { children: React.ReactNode }) {
  return <SessionProvider session={mockSession as never}>{children}</SessionProvider>;
}

function customRender(ui: ReactElement, options?: Omit<RenderOptions, 'wrapper'>) {
  return render(ui, { wrapper: AllProviders, ...options });
}

export { customRender as render };
export { default as userEvent } from '@testing-library/user-event';
