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

(async () => {
  console.log("Testing DualCircuit opening in Module Editor...");
  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);

  // Click Bibliothèque tab
  console.log("Clicking Bibliothèque tab...");
  await page.click("button:has-text('Bibliothèque')");
  await page.waitForTimeout(1000);

  // Click "Éditer" specifically on DualCircuit card
  console.log("Clicking Éditer on DualCircuit card...");
  const editBtn = page.locator("div.group:has(h4:has-text('DualCircuit')) button:has-text('Éditer')").first();
  await editBtn.click();
  await page.waitForTimeout(2000);

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

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