import { render, screen } from '@testing-library/react';
import { describe, it, expect, vi } from 'vitest';

vi.mock('@/Layouts/Web/WebLayout', () => ({ default: ({ children }) => <>{children}</> }));

import Index from '@/Pages/Web/Index';

describe('Web/Index page', () => {
    it('renders without crashing', () => {
        render(<Index />);
    });

    it('sets the correct page title', () => {
        render(<Index />);
        expect(document.title).toBe('Upepo POS — Inventory & Point of Sale for African Business');
    });

    it('displays main headline', () => {
        render(<Index />);
        expect(screen.getByText(/point of sale/i)).toBeInTheDocument();
    });

    it('renders link to /register', () => {
        render(<Index />);
        const links = screen.getAllByRole('link');
        const hrefs = links.map((l) => l.getAttribute('href'));
        expect(hrefs).toContain('/register');
    });
});
