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,
  useLocation: () => ({ search: '' }),
}));

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('@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 LoginStartPage from '../LoginStartPage';

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

    expect(screen.getByText('Redirecting to login …')).toBeInTheDocument();
  });
});
