const { chromium } = require("C:/Users/ramez/AppData/Roaming/npm/node_modules/playwright");

(async () => {
  console.log("Testing Workspace Guide and Auto-Load Examples...");
  const browser = await chromium.launch({ headless: true });
  const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });

  await page.goto("http://localhost:3008", { waitUntil: "domcontentloaded" });
  await page.waitForTimeout(1500);

  // 1. Select example "Chiller flooded" from dropdown
  console.log("Selecting Chiller flooded example...");
  await page.selectOption("select[title*='Exemple']", "chiller_flooded_4port_watercooled.json");
  await page.waitForTimeout(1500);

  // Take screenshot of loaded example on canvas
  const screenshotPath1 = "C:/Users/ramez/.gemini/antigravity-ide/brain/e16f5552-47ce-4483-9b25-8266bb395491/example_flooded_chiller_loaded.png";
  await page.screenshot({ path: screenshotPath1 });
  console.log(`Saved screenshot 1 to ${screenshotPath1}`);

  // 2. Click Guide button
  console.log("Clicking Guide button...");
  await page.click("button:has-text('Guide')");
  await page.waitForTimeout(1000);

  // Take screenshot of Workspace Help Modal
  const screenshotPath2 = "C:/Users/ramez/.gemini/antigravity-ide/brain/e16f5552-47ce-4483-9b25-8266bb395491/workspace_guide_modal.png";
  await page.screenshot({ path: screenshotPath2 });
  console.log(`Saved screenshot 2 to ${screenshotPath2}`);

  await browser.close();
})();
