// Cancel one job on the LIVE /jobs page through its own Cancel button (the existing surface). import { chromium } from "/home/user/Projects/yt-dlp-transcript-browser/node_modules/.pnpm/@playwright+test@1.59.1/node_modules/@playwright/test/index.mjs"; const id = process.argv[2]; const base = process.env.EDITOR_URL ?? "http://localhost:3001"; const browser = await chromium.launch(); const page = await browser.newPage(); page.setDefaultTimeout(120_000); await page.goto(`${base}/jobs`, { waitUntil: "domcontentloaded" }); let row = page.locator(`[data-job-id="${id}"]`); if ((await row.count()) === 0) row = page.locator(`a[href*="${id}"]`).first().locator("xpath=ancestor::*[self::li or self::tr or self::article][1]"); console.log("rows matched:", await row.count()); const text = (await row.first().innerText()).replace(/\s+/g, " ").slice(0, 160); console.log("row:", text); const btn = row.first().getByRole("button", { name: /cancel/i }); console.log("cancel buttons:", await btn.count(), await btn.count() ? await btn.first().getAttribute("aria-label") ?? await btn.first().innerText() : ""); if (await btn.count()) { await btn.first().click(); console.log("clicked"); await page.waitForTimeout(3000); } await browser.close();