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

vi.mock('axios', () => ({ default: { get: vi.fn().mockResolvedValue({ data: [] }) } }));
vi.mock('@inertiajs/react', async () => ({
  ...(await vi.importActual<any>('@inertiajs/react')),
  Head: () => null,
}));
// The layout shell (sidebar + header) pulls in theme/page-prop providers that
// aren't relevant to this page's own behaviour — stub them out, like other
// page tests stub their layout wrappers.
vi.mock('@/components/Sidebar/AppSidebar', () => ({ AppSidebar: () => null }));
vi.mock('@/components/Header/AppPageHeader', () => ({ AppPageHeader: () => null }));
// The page calls useTranslation(); stub it so t() echoes its key (like other page tests).
vi.mock('@/contexts/LanguageContext', () => ({
  useTranslation: () => ({ t: (s: string) => s, isRtl: false, locale: 'en' }),
}));

import Index from './Index';

const auth = { user: { id: 1, name: 'A', email: 'a@b.c' } } as any;

describe('Github/Index', () => {
  it('renders the connect action', async () => {
    render(<Index auth={auth} />);
    expect(await screen.findByRole('button', { name: /connect github/i })).toBeInTheDocument();
  });
});
