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

(async () => {
  console.log("Launching browser for Module Editor 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);

  // 2. Click on "Éditer" for BaseChiller
  console.log("Clicking Éditer on BaseChiller...");
  const editBtn = page.locator("button:has-text('Éditer')").first();
  await editBtn.click();
  await page.waitForTimeout(1200);

  const screenshotPath = "C:/Users/ramez/.gemini/antigravity-ide/brain/e16f5552-47ce-4483-9b25-8266bb395491/3_module_editor_view.png";
  await page.screenshot({ path: screenshotPath });
  console.log(`Module editor screenshot saved to ${screenshotPath}`);
  await browser.close();
})();
