import { test, expect } from "@playwright/test"; import { channelStage, generateReport, pathExists, resetData, } from "./helpers"; test("cancels a running pipeline job from the channel page", async ({ page }) => { await resetData("slow-pipeline-channel"); await generateReport(page, "slow-channel"); await page.goto(channelStage("slow-channel", "playlist")); await page.getByRole("button", { name: "Sync" }).click(); await expect(page.getByLabel("Sync output")).toContainText("test-slow", { timeout: 15_000, }); await page.getByRole("button", { name: "Cancel Sync" }).click(); // Cancel button gone; run button re-enabled. await expect( page.getByRole("button", { name: "Cancel Sync" }), ).not.toBeVisible({ timeout: 15_000 }); const syncButton = page.getByRole("button", { name: /^Sync$/ }); await expect(syncButton).toBeEnabled(); // No data dir was written. expect( await pathExists("test-transcripts/channels/slow-channel/data"), ).toBe(false); }); test("cancels a running job from the jobs list", async ({ page }) => { await resetData("slow-pipeline-channel"); await generateReport(page, "slow-channel"); await page.goto(channelStage("slow-channel", "playlist")); await page.getByRole("button", { name: "Sync" }).click(); await expect(page.getByLabel("Sync output")).toContainText("test-slow", { timeout: 15_000, }); await page.goto("/jobs"); const runningRow = page .getByRole("row") .filter({ hasText: "slow-channel" }) .first(); await expect(runningRow).toContainText("running"); await runningRow.getByRole("button", { name: /cancel/i }).click(); await expect(runningRow).toContainText("cancelled", { timeout: 15_000 }); });