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

/**
 * Seed test for Open Core Business Suite
 *
 * This test sets up the environment for AI agents to explore the application.
 * It establishes a logged-in session that other tests can use as a starting point.
 *
 * Demo Credentials:
 * - Admin: admin@demo.com / password123
 * - HR: hr@demo.com / password123
 * - Employee: employee@demo.com / password123
 */
test.describe('Environment Setup', () => {
  test('seed - login as admin and navigate to dashboard', async ({ page }) => {
    // Navigate to login page
    await page.goto('/auth/login', { waitUntil: 'networkidle' });

    // Verify login page loaded
    await expect(page.locator('#formAuthentication')).toBeVisible();
    await expect(page.locator('#email')).toBeVisible();

    // Fill in admin credentials
    await page.locator('#email').fill('admin@demo.com');
    await page.locator('#password').fill('password123');

    // Submit the form
    await page.locator('button[type="submit"]').click();

    // Wait for navigation to complete
    await page.waitForLoadState('networkidle');
    await page.waitForURL('**/dashboard', { timeout: 30000 });

    // Verify dashboard loaded
    await expect(page.locator('.layout-wrapper')).toBeVisible();

    // Verify user is logged in (check for navbar)
    await expect(page.locator('.layout-navbar')).toBeVisible();
  });
});
