import { test, expect } from '@playwright/test';
import { LoginPage } from './LoginPage';
import { DashboardPage } from './DashboardPage';
import { CreateEventPage } from './CreateEventPage';
import { TEST_USERS } from '../data/test-users';
import { TEST_EVENTS } from '../data/test-events';

test.describe('Simple Create Event Test', () => {
    test('Create basic event', async ({ page }) => {
        const loginPage = new LoginPage(page);
        const dashboardPage = new DashboardPage(page);
        const createEventPage = new CreateEventPage(page);
        const trainer = TEST_USERS.trainer;
        
        // Login
        await loginPage.navigateToLogin();
        await loginPage.login(trainer.username, trainer.password);
        
        // Navigate to create event
        await dashboardPage.clickCreateEvent();
        
        // Wait for form to load
        await page.waitForLoadState('networkidle');
        
        // Fill minimal event details
        await page.fill('input[name="post_title"]', 'Test Event');
        await page.fill('#content', 'Test event description');
        await page.fill('#EventStartDate', '6/1/2025');
        await page.fill('#EventEndDate', '6/1/2025');
        
        // Submit
        await page.click('input[value="Submit Event"]');
        
        // Wait for navigation
        await page.waitForLoadState('networkidle');
        
        console.log(`Final URL: ${page.url()}`);
        
        // Take screenshot
        await page.screenshot({ path: 'simple-create-event-result.png', fullPage: true });
    });
});