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

(async () => {
  console.log("Launching browser for Module UI test...");
  const browser = await chromium.launch({ headless: true });
  const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });

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

  // 1. Click on Bibliothèque tab
  console.log("Clicking Bibliothèque tab...");
  await page.click("button:has-text('Bibliothèque')");
  await page.waitForTimeout(800);
  await page.screenshot({ path: "C:/Users/ramez/.gemini/antigravity-ide/brain/e16f5552-47ce-4483-9b25-8266bb395491/1_library_tab.png" });

  // 2. Click on "Save as Module" button in Toolbar
  console.log("Clicking Save as Module button...");
  await page.click("button:has-text('Save as Module')");
  await page.waitForTimeout(600);
  await page.screenshot({ path: "C:/Users/ramez/.gemini/antigravity-ide/brain/e16f5552-47ce-4483-9b25-8266bb395491/2_save_module_modal.png" });

  console.log("Screenshots captured successfully.");
  await browser.close();
})();
