import { test, expect } from '@playwright/test';

test('Production Site Verification - ai.dffm.it', async ({ page }) => {
    console.log('Navigating to production site...');
    await page.goto('https://ai.dffm.it', { waitUntil: 'networkidle', timeout: 30000 });

    console.log('Page loaded, taking initial screenshot...');
    await page.screenshot({ path: 'prod_initial.png', fullPage: true });

    console.log('Verifying Header...');
    await expect(page.getByRole('heading', { name: 'Second Brain' }).first()).toBeVisible({ timeout: 10000 });

    console.log('Verifying Sidebar elements...');
    await expect(page.getByText('New Chat')).toBeVisible();
    await expect(page.getByText('History')).toBeVisible();
    await expect(page.getByText('Recents')).toBeVisible();

    console.log('Verifying Chat Interface...');
    await expect(page.getByPlaceholder('Ask your brain anything...')).toBeVisible();

    console.log('Checking User Profile...');
    const profileDropdown = page.locator('.group.relative.cursor-pointer').first();
    await expect(profileDropdown).toBeVisible();

    console.log('Hovering over profile to check dropdown...');
    await profileDropdown.hover();
    await page.waitForTimeout(500);

    const signOutButton = page.getByRole('button', { name: /sign out/i });
    await expect(signOutButton).toBeVisible();

    console.log('Taking final screenshot...');
    await page.screenshot({ path: 'prod_final.png', fullPage: true });

    console.log('✅ All production checks passed!');
    console.log('Current URL:', page.url());
});
