// COOKIE REFRESH ALERTS (plans/cookie-refresh-alerts.md), end to end. // // The 2026-10-21 case in miniature: a fetch-windows batch on Rumble whose // embeds 403 (the browser's Cloudflare clearance cookie had gone stale). The // fake yt-dlp answers `embed403` URLs with the real RumbleEmbed 403 line until // the spec drops `fake-ytdlp.fresh-cookies` in the channel dir — the operator // opening rumble.com in the browser. Two different videos refused in a row // raise the banner; Recheck (one metadata request) clears it once the fake // answers; "Re-run stopped jobs" retries the batch it stopped. // // Same token as /api/ops/* (WORKER_TOKEN=test-worker-token on the test server). import { mkdir, readFile, utimes, writeFile } from "node:fs/promises"; import { test, expect, type APIRequestContext } from "@playwright/test"; import { resetData, resolvePath, testPaths, writeSettings } from "./helpers"; import { baseUrl } from "./baseUrl"; const AUTH = { authorization: "Bearer test-worker-token" }; const SLUG = "test-youtube"; const channelRel = (p: string) => `${testPaths().transcriptsDir}/channels/${SLUG}/${p}`; async function jobStatus(request: APIRequestContext, jobId: string): Promise { const r = await request.get(`${baseUrl}/api/ops/job/${jobId}`, { headers: AUTH }); const body = (await r.json()) as { job?: { status?: string } }; return body.job?.status ?? ""; } async function waitJob(request: APIRequestContext, jobId: string, timeout = 90_000): Promise { let status = ""; await expect .poll( async () => { status = await jobStatus(request, jobId); return status; }, { timeout }, ) .not.toMatch(/^(queued|running|)$/); return status; } test.beforeEach(async () => { await resetData("youtube-with-playlist"); await writeSettings({ minFreeDiskGB: 0 }); }); test("two Rumble embeds refused raise the banner; Recheck with fresh cookies clears it; the stopped batch re-runs", async ({ page, request, }) => { test.setTimeout(180_000); const items = [ { slug: SLUG, id: "embed403a", webpageUrl: "https://rumble.com/vembed403a-first.html", from: 5, to: 10, clipId: "c01" }, { slug: SLUG, id: "embed403b", webpageUrl: "https://rumble.com/vembed403b-second.html", from: 5, to: 10, clipId: "c02" }, ]; const post = await request.post(`${baseUrl}/api/ops/fetch-windows`, { headers: AUTH, // The remote seek's refusal is what this pins; Rumble's default (the whole // recording, settings.clips) is a persist's download, not a window's. data: { requestedBy: "umtool", manifest: "cookie-alerts", items, wholeRecording: false }, }); expect(post.status()).toBe(200); const body = (await post.json()) as { jobs: { platform: string; jobId: string }[] }; expect(body.jobs).toHaveLength(1); expect(body.jobs[0].platform).toBe("rumble"); const batchId = body.jobs[0].jobId; expect(await waitJob(request, batchId)).toBe("failed"); // The stopping job's log names the cause and the fix. const log = await readFile(resolvePath(`${testPaths().transcriptsDir}/.jobs/${batchId}.log`), "utf8"); expect(log).toMatch(/a removed video does this too; a second video refused in a row raises the cookie alert/); expect(log).toMatch(/stopped: Rumble cookies look stale — open rumble\.com in .*, then Recheck on the dashboard\./); // The read side says the same. const services = await request.get(`${baseUrl}/api/ops/services`, { headers: AUTH }); expect(services.status()).toBe(200); const s = (await services.json()) as { alerts: { service: string; state: string; stoppedJobs: { id: string }[] }[] }; expect(s.alerts.map((a) => [a.service, a.state])).toEqual([["rumble", "stale"]]); // The banner, top of the dashboard. await page.goto(`${baseUrl}/`); const banner = page.getByRole("alert", { name: "Rumble cookies" }); await expect(banner).toContainText("Rumble needs fresh cookies: open rumble.com in"); await expect(banner).toContainText("2 embed 403s on different videos"); // Recheck while the cookies are still stale: it stays. await banner.getByRole("button", { name: "Recheck" }).click(); await expect(page.getByRole("status", { name: "Rumble cookies result" })).toContainText("still refused", { timeout: 30_000, }); await expect(banner).toHaveAttribute("data-state", "stale"); // The operator opens rumble.com in the browser; Recheck clears it. await writeFile(resolvePath(channelRel("fake-ytdlp.fresh-cookies")), "fresh"); await banner.getByRole("button", { name: "Recheck" }).click(); await expect(banner).toHaveAttribute("data-state", "ok-again", { timeout: 30_000 }); await expect(banner).toContainText("Rumble cookies OK again — re-run the 1 job it stopped"); const invocations = await readFile(resolvePath(channelRel("fake-ytdlp.invocations")), "utf8"); expect(invocations).toContain("recheck:https://rumble.com/vembed403b-second.html"); // Re-run the batch it stopped: the windows fetch now. await banner.getByRole("button", { name: "Re-run stopped jobs" }).click(); await expect(page.getByRole("status", { name: "Rumble cookies result" })).toContainText("Re-ran 1 job", { timeout: 30_000, }); const after = (await (await request.get(`${baseUrl}/api/ops/services`, { headers: AUTH })).json()) as { alerts: { service: string; rerunJobIds?: string[] }[]; }; const rerun = after.alerts.find((a) => a.service === "rumble")?.rerunJobIds ?? []; expect(rerun).toHaveLength(1); const rerunStatus = await waitJob(request, rerun[0]); const tail = await request.get(`${baseUrl}/api/ops/job/${rerun[0]}?tail=40`, { headers: AUTH }); expect(rerunStatus, ((await tail.json()) as { tail?: string[] }).tail?.join("\n")).toBe("done"); }); test("ops: get services is behind the token; recheck-service refuses a name that is not a service", async ({ request }) => { expect((await request.get(`${baseUrl}/api/ops/services`)).status()).toBe(401); const empty = await request.get(`${baseUrl}/api/ops/services`, { headers: AUTH }); expect(empty.status()).toBe(200); expect(await empty.json()).toMatchObject({ ok: true, alerts: [], pending: [] }); const bad = await request.post(`${baseUrl}/api/ops/recheck-service`, { headers: AUTH, data: { service: "you tube/../x" }, }); expect(bad.status()).toBe(400); const nothing = await request.post(`${baseUrl}/api/ops/recheck-service`, { headers: AUTH, data: { service: "odysee" }, }); // Nothing recorded for Odysee: the probe has nothing to ask, and says so. expect(nothing.status()).toBe(200); expect(await nothing.json()).toMatchObject({ ok: true, result: "failed" }); const dismiss = await request.post(`${baseUrl}/api/ops/dismiss-service`, { headers: AUTH, data: { service: "youtube" }, }); expect(await dismiss.json()).toMatchObject({ ok: true, message: "YouTube had no cookie alert to dismiss." }); }); // ── X (plans/pacing-guard.md) ───────────────────────────────────────────── // // The 2026-10-23 case: fetch-posts for 13 X accounts in one loop, a 16-day-old // cookie jar, X answering with a Cloudflare challenge that gallery-dl printed // as a WARNING and exited 0 on. Now the jar's age refuses the fetch, the // challenge fails the job and raises the X alert, and every X job is refused // while it is up. The fake gallery-dl answers `challenged_user` with the // challenge; the jar is written by hand (no X, no browser). The test server // turns the built-in age limit off (E2E_X_MAX_COOKIE_AGE_MINUTES=0), so this // spec sets its own. async function xChannel(slug: string, handle: string): Promise { const dir = resolvePath(`${testPaths().transcriptsDir}/channels/${slug}`); await mkdir(dir, { recursive: true }); await writeFile( `${dir}/config.json`, JSON.stringify({ name: `${handle} (X)`, handling: "transcribe", sourceKind: "social", postFetcher: "x-gallery-dl", platform: "twitter", socialHandle: handle, url: `https://x.com/${handle}`, }), ); } async function xJar(ageMs: number): Promise { const dir = resolvePath(`${testPaths().transcriptsDir}/.x-session`); await mkdir(`${dir}/profile`, { recursive: true }); await writeFile(`${dir}/cookies.txt`, "# Netscape HTTP Cookie File\n.x.com\tTRUE\t/\tTRUE\t0\tauth_token\tfake\n"); const t = new Date(Date.now() - ageMs); await utimes(`${dir}/cookies.txt`, t, t); } async function fetchPosts(request: APIRequestContext, slug: string, extra: Record = {}) { const res = await request.post(`${baseUrl}/api/ops/fetch-posts`, { headers: AUTH, data: { slug, ...extra } }); return { status: res.status(), body: (await res.json()) as { ok: boolean; jobId?: string; error?: string } }; } test("X: a stale jar refuses Fetch posts; \"\" is refused; a challenge fails the job, raises the X banner and refuses the next fetch; Recheck asks X nothing", async ({ page, request, }) => { test.setTimeout(120_000); await writeSettings({ minFreeDiskGB: 0, social: { x: { cookieSource: "profile", maxCookieAgeMinutes: 60 } } }); await xChannel("x-challenged", "challenged_user"); await xChannel("x-other", "faketester"); // A 16-day-old jar: refused before any job exists. await xJar(16 * 24 * 60 * 60_000); const stale = await fetchPosts(request, "x-other"); expect(stale.status).toBe(400); expect(stale.body.error).toBe( "X cookies were last refreshed 16 days ago (limit 60 min): press Refresh cookies (or Connect X account) on /cookies, then fetch again.", ); // A fresh jar; an unqueued fetch is still refused. await xJar(60_000); const unqueued = await fetchPosts(request, "x-other", { queueKey: "" }); expect(unqueued.status).toBe(400); expect(unqueued.body.error).toMatch(/never runs unqueued: the queue override "" \(immediate\) is refused/); // X answers with a challenge (a warning, exit 0): the job FAILS. const challenged = await fetchPosts(request, "x-challenged"); expect(challenged.body.ok).toBe(true); expect(await waitJob(request, challenged.body.jobId!)).toBe("failed"); const log = await readFile(resolvePath(`${testPaths().transcriptsDir}/.jobs/${challenged.body.jobId}.log`), "utf8"); expect(log).toContain("[twitter][warning] Cloudflare challenge"); expect(log).toMatch(/X answered with a challenge or a login wall/); // The next X fetch is refused with the alert's sentence. const after = await fetchPosts(request, "x-other"); expect(after.status).toBe(400); expect(after.body.error).toMatch(/^X answered with a challenge at \d\d:\d\d UTC .*its cookie alert is up, so no X job starts/); // The banner. await page.goto(`${baseUrl}/`); const banner = page.getByRole("alert", { name: "X cookies" }); await expect(banner).toContainText("X needs fresh cookies: pass X's check by hand"); await expect(banner).toHaveAttribute("data-state", "stale"); // Recheck before the jar is refreshed: stale, and no request was made. await banner.getByRole("button", { name: "Recheck" }).click(); await expect(page.getByRole("status", { name: "X cookies result" })).toContainText("Recheck sends X no request", { timeout: 30_000, }); await expect(banner).toHaveAttribute("data-state", "stale"); // The operator refreshes the jar (Refresh cookies on /cookies); Recheck clears it. await xJar(0); await banner.getByRole("button", { name: "Recheck" }).click(); await expect(banner).toHaveAttribute("data-state", "ok-again", { timeout: 30_000 }); const ok = await fetchPosts(request, "x-other"); expect(ok.body.ok).toBe(true); expect(await waitJob(request, ok.body.jobId!)).toBe("done"); }); // ── X's cookie banner like Rumble's (2026-10-31) ────────────────────────── // // Operator: "add banner cookie refresh indicator for X like we have for // Rumble". The fresh-jar rule's refusal raises X's banner (kind jar-age) with // the jar's age read from disk; Recheck re-reads it (no request to X); a // refreshed jar makes it "OK again". A logged-out timeline (gallery-dl's // AuthRequired) raises a login-failure alert; the 429 wait before it does not. type ServicesBody = { alerts: { service: string; state: string; kind: string; headline: string }[]; x?: { source: string; ageMinutes: number | null; maxAgeMinutes: number; fresh: boolean; summary: string }; timer?: { intervalMinutes: number; armed: boolean }; }; async function services(request: APIRequestContext): Promise { return (await (await request.get(`${baseUrl}/api/ops/services`, { headers: AUTH })).json()) as ServicesBody; } test("X: a fetch refused for an old jar raises the X banner with the jar's age; Recheck re-reads it; a refreshed jar is OK again", async ({ page, request, }, testInfo) => { test.setTimeout(120_000); await writeSettings({ minFreeDiskGB: 0, social: { x: { cookieSource: "profile", maxCookieAgeMinutes: 60 } } }); await xChannel("x-other", "faketester"); // No alert yet: get services still says how fresh X's jar is. await xJar(5 * 60_000); const before = await services(request); expect(before.alerts).toEqual([]); expect(before.x).toMatchObject({ source: "profile", maxAgeMinutes: 60, fresh: true }); // The timer is not armed on the test server; its setting is reported. expect(before.timer).toMatchObject({ intervalMinutes: 180, armed: false }); await xJar(3 * 60 * 60_000); const refused = await fetchPosts(request, "x-other"); expect(refused.status).toBe(400); expect(refused.body.error).toMatch(/^X cookies were last refreshed 3 h ago \(limit 60 min\)/); const s = await services(request); expect(s.alerts.map((a) => [a.service, a.state, a.kind])).toEqual([["x", "stale", "jar-age"]]); expect(s.x).toMatchObject({ fresh: false, ageMinutes: 180 }); await page.goto(`${baseUrl}/`); const banner = page.getByRole("alert", { name: "X cookies" }); // Three short lines, no lead paragraph: the age, the one action, the job it refused. await expect(banner.locator("p").first()).toHaveText("X cookies are 3 h old (limit 60 min)"); await expect(banner.getByLabel("X cookies action")).toHaveText( "Refresh cookies (or Connect X account) on /cookies — then Recheck.", ); await expect(banner).toContainText("Refused an X job on x-other."); await expect(banner.locator("code")).toHaveCount(0); await expect(banner).not.toContainText("X cookies were last refreshed"); await banner.screenshot({ path: testInfo.outputPath("x-cookie-banner.png") }); await page.screenshot({ path: testInfo.outputPath("x-cookie-banner-page.png"), fullPage: false }); // Recheck on the old jar: stale, and X was asked nothing. await banner.getByRole("button", { name: "Recheck" }).click(); await expect(page.getByRole("status", { name: "X cookies result" })).toContainText("Recheck sends X no request", { timeout: 30_000, }); await expect(banner).toHaveAttribute("data-state", "stale"); // The operator refreshes the jar; Recheck: OK again, and the next fetch runs. await xJar(0); await banner.getByRole("button", { name: "Recheck" }).click(); await expect(banner).toHaveAttribute("data-state", "ok-again", { timeout: 30_000 }); await expect(banner).toContainText("X cookies OK again"); expect((await services(request)).x).toMatchObject({ fresh: true }); const ok = await fetchPosts(request, "x-other"); expect(ok.body.ok).toBe(true); expect(await waitJob(request, ok.body.jobId!)).toBe("done"); }); test("X: a logged-out timeline (AuthRequired) fails the fetch and raises a login-failure alert that refuses the next X fetch; the 429 wait before it is not counted", async ({ page, request, }) => { test.setTimeout(120_000); await writeSettings({ minFreeDiskGB: 0, social: { x: { cookieSource: "profile", maxCookieAgeMinutes: 60 } } }); await xChannel("x-logged-out", "logged_out_user"); await xChannel("x-other", "faketester"); await xJar(60_000); const res = await fetchPosts(request, "x-logged-out"); expect(res.body.ok).toBe(true); expect(await waitJob(request, res.body.jobId!)).toBe("failed"); const log = await readFile(resolvePath(`${testPaths().transcriptsDir}/.jobs/${res.body.jobId}.log`), "utf8"); expect(log).toContain("AuthRequired: authenticated cookies needed to access this timeline"); expect(log).toMatch(/X answered with a challenge or a login wall \(\[twitter\]\[error\] AuthRequired/); const s = await services(request); expect(s.alerts.map((a) => [a.service, a.state, a.kind])).toEqual([["x", "stale", "auth-failure"]]); const next = await fetchPosts(request, "x-other"); expect(next.status).toBe(400); expect(next.body.error).toMatch(/^X answered with a login failure at \d\d:\d\d UTC .*no X job starts/); await page.goto(`${baseUrl}/`); const banner = page.getByRole("alert", { name: "X cookies" }); await expect(banner).toContainText("X needs fresh cookies: pass X's check by hand"); await expect(banner).toContainText("1 login failure since"); });