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

test('App Verification', async ({ page }) => {
    // 1. Navigate to the app
    console.log('Navigating to app...');
    await page.goto('http://localhost:3000');

    // 2. Verified Page Title/Header
    console.log('Verifying Header...');
    await expect(page.getByRole('heading', { name: 'Second Brain' }).first()).toBeVisible();

    // 3. User & Auth
    console.log('Verifying User Profile...');
    // Force click the avatar group just in case to show the menu (though we just check existence first)
    const avatar = page.locator('img[alt="User Profile Avatar"]');
    await expect(avatar).toBeVisible();

    // 4. Sidebar Elements
    console.log('Verifying Sidebar...');

    // Check for "New Note" button (since New Chat is also there)
    await expect(page.getByText('New Note')).toBeVisible();

    // Check for NEW "History" section
    await expect(page.getByText('History')).toBeVisible();

    // Check for "Recents" section
    await expect(page.getByText('Recents')).toBeVisible();

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

    // 6. Test Model Selector presence (simple check)
    await expect(page.locator('select')).toBeVisible();

    console.log('All checks passed!');

    // Take a screenshot
    await page.screenshot({ path: 'verification_result.png', fullPage: true });
});
