import { STAGING_URL, PATHS, TIMEOUTS } from './config/staging-config';
import { test, expect } from '@playwright/test';

test.describe('HVAC Dashboard Content Verification', () => {
  test('verify the plugin appears in admin sidebar', async ({ page }) => {
    // Navigate to the admin page
    await page.goto('https://upskill-staging.measurequick.com/wp-admin/');
    
    // Login as admin
    await page.fill('#user_login', 'admin');
    await page.fill('#user_pass', 'password');
    await page.click('#wp-submit');
    
    // Wait for admin dashboard to load
    await page.waitForSelector('#adminmenu');
    
    // Check if the HVAC Community Events menu is present
    const menuExists = await page.isVisible('text=HVAC Community Events');
    expect(menuExists).toBeTruthy();
    
    console.log('Plugin menu is visible in the admin sidebar');
  });
  
  test('verify dashboard page content', async ({ page }) => {
    // Navigate to the dashboard page
    await page.goto('https://upskill-staging.measurequick.com/hvac-dashboard/');
    
    // Check if the dashboard content is present
    const dashboardTitle = await page.isVisible('h1:has-text("Trainer Dashboard")');
    expect(dashboardTitle).toBeTruthy();
    
    // Check for stat cards
    const totalEventsCard = await page.isVisible('h3:has-text("Total Events")');
    expect(totalEventsCard).toBeTruthy();
    
    const upcomingEventsCard = await page.isVisible('h3:has-text("Upcoming Events")');
    expect(upcomingEventsCard).toBeTruthy();
    
    console.log('Dashboard page content is rendered correctly');
  });
  
  test('verify login page content', async ({ page }) => {
    // Navigate to the login page
    await page.goto('https://upskill-staging.measurequick.com/community-login/');
    
    // Check if the login form is present
    const loginTitle = await page.isVisible('h2:has-text("Trainer Login")');
    expect(loginTitle).toBeTruthy();
    
    // Check for form elements
    const usernameField = await page.isVisible('#user_login');
    expect(usernameField).toBeTruthy();
    
    const passwordField = await page.isVisible('#user_pass');
    expect(passwordField).toBeTruthy();
    
    const loginButton = await page.isVisible('#wp-submit');
    expect(loginButton).toBeTruthy();
    
    console.log('Login page content is rendered correctly');
  });
});