import React from 'react';
import { describe, expect, it, vi } from 'vitest';
import { render, screen } from '@testing-library/react';

const navigateMock = vi.fn();

vi.mock('react-router-dom', () => ({
  useNavigate: () => navigateMock,
}));

vi.mock('react-i18next', () => ({
  useTranslation: () => ({
    t: (key: string, fallback?: string | Record<string, unknown>) => {
      if (typeof fallback === 'string') {
        return fallback;
      }
      if (fallback && typeof fallback === 'object' && typeof fallback.defaultValue === 'string') {
        return fallback.defaultValue;
      }
      return key;
    },
  }),
}));

vi.mock('../../auth/context', () => ({
  useAuth: () => ({ status: 'loading' }),
}));

vi.mock('../../lib/returnTo', () => ({
  decodeReturnTo: () => null,
  resolveReturnTarget: () => ({ finalTarget: '/event-admin/mobile/dashboard' }),
}));

vi.mock('@tamagui/card', () => ({
  Card: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}));

vi.mock('@tamagui/stacks', () => ({
  YStack: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}));

vi.mock('@tamagui/text', () => ({
  SizableText: ({ children }: { children: React.ReactNode }) => <span>{children}</span>,
}));

vi.mock('tamagui', () => ({
  Spinner: () => <div>spinner</div>,
}));

vi.mock('../theme', () => ({
  useAdminTheme: () => ({
    textStrong: '#111827',
    muted: '#6b7280',
    border: '#e5e7eb',
    surface: '#ffffff',
    shadow: 'rgba(15,23,42,0.12)',
    appBackground: 'linear-gradient(180deg, #fff, #f8fafc)',
  }),
}));

import AuthCallbackPage from '../AuthCallbackPage';

describe('AuthCallbackPage', () => {
  it('renders the processing message', () => {
    render(<AuthCallbackPage />);

    expect(screen.getByText('Signing you in …')).toBeInTheDocument();
  });
});
