import { chromium } from "@playwright/test";

(async () => {
  const b = await chromium.launch();
  const p = await b.newPage();
  
  try {
    await p.goto("http://localhost:5265/login");
    
    // Fill and submit
    await p.fill("input[name=\"username\"]", "admin");
    await p.fill("input[name=\"password\"]", "admin");
    await p.click("button[type=\"submit\"]");
    
    // Wait for response/error
    await new Promise(r => setTimeout(r, 3000));
    
    // Get error message
    const alertDiv = await p.$(".alert");
    if (alertDiv) {
      const alertText = await p.textContent(".alert");
      console.log("Alert message: " + alertText);
    }
    
    // Take screenshot to see the state
    await p.screenshot({ path: "./error-state.png", fullPage: true });
    console.log("Screenshot saved: error-state.png");
    
  } catch (e) {
    console.error(e.message);
  }
  
  await b.close();
})();
