import { test } from "node:test"; import assert from "node:assert/strict"; import { readdir, readFile } from "node:fs/promises"; import path from "node:path"; import { fileURLToPath } from "node:url"; // Run with: // pnpm --filter yt-dlp-transcript-common exec tsx --test lib/storedText.grep.test.ts // // THE STORED-TEXT GATE (lane text-compress). The raw live chat may be on disk // as `transcript.live_chat.json.zst` (lib/storedText.ts). A reader that opens, // stats, lists or deletes the plain name directly sees that file as ABSENT — // for the chat that is a fetch of the whole replay again, or (a deleter) an // older stored copy brought back as the file. So every line of app code that // names the raw chat must go through the stored-text helpers. A context-blind // grep, like architecture.test.ts: each line naming it (by its constant or the // literal) must also name a sanctioned READER or DELETER within the same // statement (the line or the two before it), or interpolate the name into a // message (a log line, an error), or be inside an import, or be one of the // definitions below, or be an ALLOWED line (each with its reason). // // The second gate below is the one REVIEW-1 F2 asked for: every yt-dlp argv // that can WRITE the chat, and every caller of its builder, is pinned — a new // one fails until it asks the disk for the stored form first and says so here. // // WHAT THESE GATES CANNOT SEE: a channel's own `ytdlpExtraArgs` (appended to // every spawn; a `--sub-langs` there would win over the narrowing — no channel // sets one today); a flag spelled at run time (built from a variable, or inside // one shell string); a spawn in a language they do not read (shell, Python); // yt-dlp's own config files (the builders pass `--ignore-config`); and a read // of the chat through a path built from a variable that holds the name. const COMMON = path.dirname(path.dirname(fileURLToPath(import.meta.url))); const REPO = path.dirname(COMMON); const ROOTS = ["common", "editor/app", "editor/lib", "mcp/src", "umtool", "export/scripts", "export/lib", "export/app", "scripts", "docker"]; const SKIP_DIRS = new Set(["node_modules", ".next", "out", "out-private", "public", "e2e", "dist", ".turbo"]); // Every dot-directory under these roots is build or test output, never source // (umtool's alternate dist dirs `.next-*`, `.e2e-song`, …, all gitignored): a // checkout that has run a build holds its compiled chunks, which name the same // files as the source they were built from — and the source is what is gated. // The names of the raw chat in code: the two constants, the stored one, the // literal (but not its `.part`, its `.zst` spelled out in a comment, or the // derived `live_chat.cues.json`). const NAMES = /\bLIVE_CHAT_(?:MEDIA_|STORED_)?FILENAME\b|transcript\.live_chat\.json(?![.\w])/; // The read path, the existence checks, and the writers that know both forms. // Readers and deleters only: a name helper (`storedNameOf`) or the tier hook // (`tierMediaFile`) makes no read safe — those lines are in ALLOWED. const SANCTIONED = /\b(?:listingHas|storedFormsIn|logicalEntries|readdirLogical|storedTextExists|storedTextForms|storedTextMtimeMs|statStoredText|readStoredText|storedTextLogicalSize|removeStoredText|removeStoredTextForm|compressStoredText|restoreStoredText|verifyStoredText|setAsideStoredText|putBackKeptCapture|keepPlainAsCapture|hasStoredTextLeftover)\b/; // Lines that name the raw chat for a reason that is neither a read nor a // delete, each with it: `file` and a pattern of the code on the line. const ALLOWED: { file: string; code: RegExp; why: string }[] = [ { file: "common/controller/compressText.ts", code: /sizeOf\(path\.join\(videoDir, (?:LIVE_CHAT_FILENAME|storedNameOf\(LIVE_CHAT_FILENAME\))\)\)|const zp = path\.join\(videoDir, storedNameOf\(LIVE_CHAT_FILENAME\)\)/, why: "the migration's own survey: each form's PHYSICAL size, after storedFormsIn said which are there", }, { file: "common/controller/compressText.ts", code: /if \(kind === "live-chat"\) return \[LIVE_CHAT_FILENAME\];/, why: "the migration's kind → declared names table; every read of the name it returns is the survey's storedFormsIn or the compressor's", }, { file: "common/controller/normalizeLiveChat.ts", code: /^\s*`Failed to parse \$\{LIVE_CHAT_FILENAME\} for /, why: "a message (its path.basename is the video id, not a path to the chat)", }, { file: "common/controller/normalizeLiveChat.ts", code: /await tierMediaFile\(opts\.videoDir, LIVE_CHAT_(?:STORED_)?FILENAME, \{ onLog \}\)/, why: "the tier hook moves whichever form it is given and never reads it", }, { file: "common/controller/fetchLiveChat.ts", code: /const landed = !partial && \(await stat\(path\.join\(videoDir, LIVE_CHAT_FILENAME\)\)|const fetched = measureChat\(await readFile\(path\.join\(videoDir, LIVE_CHAT_FILENAME\)\)\)/, why: "the replace's look at what the pass wrote: the PLAIN file only (the stored capture was set aside first)", }, { file: "scripts/archilyzer-ops.mjs", code: /^\s*['"`][^'"`]*transcript\.live_chat\.json[^'"`]*['"`],?\s*$/, why: "a line of the ops help text (a string literal alone on its line)", }, ]; // Where the names are DEFINED or are the rules themselves. const DEFINITIONS = new Set([ "common/lib/videoStatus.ts", "common/lib/mediaTier.ts", "common/lib/storedText.ts", "common/lib/storedText-server.ts", "common/lib/storedText-write-server.ts", "common/lib/storedText-read.mjs", ]); async function walk(dir: string, out: string[]): Promise { let entries; try { entries = await readdir(dir, { withFileTypes: true }); } catch { return; } for (const e of entries) { if (SKIP_DIRS.has(e.name)) continue; const p = path.join(dir, e.name); if (e.isDirectory()) { if (!e.name.startsWith(".")) await walk(p, out); } else if (/\.(?:ts|tsx|mjs|js)$/.test(e.name) && !/\.(?:test|spec|unit)\.|\.d\.m?ts$/.test(e.name)) out.push(p); } } // Every walked file's lines, read once for both gates. let corpusOnce: Promise<{ rel: string; lines: string[] }[]> | undefined; function appFiles(): Promise<{ rel: string; lines: string[] }[]> { return (corpusOnce ??= (async () => { const files: string[] = []; for (const r of ROOTS) await walk(path.join(REPO, r), files); return Promise.all( files.map(async (f) => ({ rel: path.relative(REPO, f), lines: (await readFile(f, "utf8")).split("\n") })), ); })()); } function codeOnly(line: string): string { const t = line.trim(); if (t.startsWith("//") || t.startsWith("*") || t.startsWith("/*")) return ""; // A trailing comment is not code. return line.replace(/\s\/\/.*$/, ""); } test("every app line naming the raw live chat goes through the stored-text helpers", async () => { const files = await appFiles(); assert.ok(files.length > 200, `walked ${files.length} files`); const offenders: string[] = []; for (const { rel, lines } of files) { if (DEFINITIONS.has(rel)) continue; let inImport = false; for (let i = 0; i < lines.length; i++) { const code = codeOnly(lines[i]); // Inside a multi-line `import { … } from` / `export { … } from` list — // and only there: a bare constant on a line of its own elsewhere (a // prettier-wrapped `rm(path.join(\n dir,\n NAME,\n))`) is a use. if (/^\s*(?:import|export)\b[^;]*\{[^}]*$/.test(code)) { inImport = true; continue; } if (inImport) { if (/\}/.test(code)) inImport = false; continue; } if (!NAMES.test(code)) continue; // A one-line import or re-export. if (/^\s*(?:import\b|export\s*\{)/.test(code)) continue; // Interpolated into a MESSAGE — a log line, an error, a refusal — and // never into a path (a template with a "/" or a path.* call is a path). if ( /\$\{LIVE_CHAT_(?:MEDIA_|STORED_)?FILENAME\}/.test(code) && !/\/\$\{LIVE_CHAT|\$\{LIVE_CHAT_(?:MEDIA_|STORED_)?FILENAME\}\/|path\.|join\(/.test(code) ) { continue; } if (ALLOWED.some((a) => a.file === rel && a.code.test(code))) continue; // UI copy naming the file. if (/transcript\.live_chat\.json<\/code>/.test(code)) continue; const statement = [lines[i - 2] ?? "", lines[i - 1] ?? "", code].map(codeOnly).join("\n"); if (SANCTIONED.test(statement)) continue; offenders.push(`${rel}:${i + 1}: ${lines[i].trim()}`); } } assert.deepEqual( offenders, [], "read, list, stat or delete the raw live chat through lib/storedText(-server|-write-server).ts — it may be stored as .zst", ); }); // ── THE SECOND GATE: EVERY yt-dlp ARGV THAT CAN WRITE THE CHAT (REVIEW-1 F2) ── // // yt-dlp's own "already present" skip sees only the plain // `transcript.live_chat.json`: a pass that may write subtitles over a chat // stored as `.zst` fetches the whole replay again and lands a second copy // beside it. The first gate cannot see such a site — it names no file, only a // flag. So every code line carrying a subtitle-writing flag (or `live_chat` // as an argv value) must be inside a builder pinned here, and every builder's // callers are pinned by count, each with the guard that asks the disk first // and the behavioural test that proves it. A new site, or a new caller of a // builder, fails until it is listed — with its guard and its test. // A flag as an argv element: `"--write-subs"`, `'--sub-langs'`, or a joined // `--sub-langs=…` in any quote; or `"live_chat"` alone as an argv value. // (Prose that names a flag in backticks is not an argv.) const SUB_FLAGS = /(["'])--(?:sub-langs?|all-subs|write-subs|write-auto-subs|write-automatic-subs)\1|["'`]--(?:sub-langs?)=|^\s*["'`]live_chat["'`],?\s*$/; // CAPTIONS TOO (lane text-compress-captions): a caption track stored as // `transcript..vtt.zst` is fetched again by any pass that asks for it. // The missing-subs pass (`--no-overwrites`, where main skipped a present // track) excludes the stored tracks by code; the managed download (no // `--no-overwrites`, where main replaced it) fetches them and settles each // after the pass. Both take the stored tracks from the PHYSICAL listing. const CHAT_WRITERS: Record = { youtubeHandlingArgs: { file: "common/ytdlp/downloadOneManaged.ts", guard: "chatStored (storedFormsIn === \"zst\"): the chat left out of --sub-langs; a stored caption IS fetched " + "again (main's re-download rule) and its caller settles it after the pass (settleRefetchedCaptions)", test: "controller/storedText.chat.test.ts (youtubeHandlingArgs); ytdlp/captionsRefetch.test.ts", }, liveChatOnlyArgs: { file: "common/ytdlp/downloadOneManaged.ts", guard: "the chat-only pass: hasLiveChatOnDisk first; fetch-chat: liveChatPlan, or `replace` with the stored capture kept first", test: "ytdlp/chatOnlyStored.test.ts; controller/fetchLiveChat.test.ts (replace)", }, downloadSubsForUrl: { file: "common/ytdlp/runYtdlp.ts", guard: "subLangsForVideo: the chat left out of --sub-langs for a stored chat, each stored caption excluded by code", test: "controller/storedText.chat.test.ts (subLangsForVideo); controller/storedText.captions.test.ts (subLangsForVideo)", }, }; // Every call of each builder, by file (the definition not counted). A caller // is where the guard has to be. const CALLERS: Record> = { youtubeHandlingArgs: { "common/ytdlp/downloadOneManaged.ts": 1 }, liveChatOnlyArgs: { "common/ytdlp/downloadOneManaged.ts": 1, "common/controller/fetchLiveChat.ts": 1 }, downloadSubsForUrl: { "common/ytdlp/runYtdlp.ts": 1 }, }; // yt-dlp's OPTION TABLES (lane network-exits): every option the installed // yt-dlp's parser accepts, and a person's class of each — pure data, outside // any function, read only by lib/networkExits.ts to RESOLVE a listing's argv // as yt-dlp would (resolveLongOption, argvOptions). Nothing builds an argv // from them, so a row naming a subtitle flag writes nothing. Only a table ROW // outside every function passes: an argv element in these files, or a row // moved into a function, is a site like any other. const OPTION_TABLES: { file: string; row: RegExp; why: string }[] = [ { file: "common/lib/ytdlpOptions.ts", row: /^\s*\[(?:null|"[^"]+"), "--[a-z0-9-]+", (?:true|false)\],$/, why: "YTDLP_OPTIONS: [short, long, takes a value], generated from yt-dlp's parser", }, { file: "common/lib/ytdlpOptionClasses.ts", row: /^\s*"--[a-z0-9-]+": "(?:cookie|login|header|config|proxy|none)",$/, why: "YTDLP_OPTION_CLASSES: the network-exit class of each long name", }, ]; const BUILDER_RES = Object.keys(CHAT_WRITERS).map((name) => ({ name, call: new RegExp(`\\b${name}\\s*\\(`, "g"), def: new RegExp(`\\bfunction\\s+${name}\\s*\\(`), })); // The enclosing named function of line `i`: the nearest `function NAME(` // above it. Good enough for argv builders, which are named functions. function enclosingFunction(lines: string[], i: number): string | null { for (let j = i; j >= 0; j--) { const m = /\bfunction\s+([A-Za-z0-9_$]+)\s*[(<]/.exec(codeOnly(lines[j])); if (m) return m[1]; } return null; } test("every yt-dlp argv that can write the raw chat is a pinned builder, and every caller of one is pinned", async () => { const sites: string[] = []; const calls: Record> = {}; const tableRows = new Set(); for (const { rel, lines } of await appFiles()) { for (let i = 0; i < lines.length; i++) { const code = codeOnly(lines[i]); if (SUB_FLAGS.test(code)) { const fn = enclosingFunction(lines, i); const pinned = fn ? CHAT_WRITERS[fn] : undefined; const table = fn === null ? OPTION_TABLES.find((t) => t.file === rel && t.row.test(code)) : undefined; if (table) tableRows.add(table.file); else if (!pinned || pinned.file !== rel) sites.push(`${rel}:${i + 1} (in ${fn ?? "no function"}): ${lines[i].trim()}`); } for (const { name, call, def } of BUILDER_RES) { if (!code.includes(name)) continue; const n = (code.match(call) ?? []).length - (def.test(code) ? 1 : 0); if (n > 0) (calls[name] ??= {})[rel] = (calls[name]?.[rel] ?? 0) + n; } } } assert.deepEqual( sites, [], "a yt-dlp argv that can write subtitles (the chat among them) outside a pinned builder: it must ask the disk " + "for the stored chat first (listingHas / storedFormsIn), have a test that the fake yt-dlp is not asked for it, " + "and be listed in CHAT_WRITERS", ); // The table exemption cannot rot, and holds only while the tables are read // by the one argv RESOLVER: a new importer of either could build from them. for (const t of OPTION_TABLES) assert.ok(tableRows.has(t.file), `${t.file} has no subtitle-flag row any more: drop it from OPTION_TABLES`); const importers = new Set(); for (const { rel, lines } of await appFiles()) { if (lines.some((l) => /\bfrom\s+["'][^"']*\/ytdlpOption(?:s|Classes)(?:\.[jt]s)?["']/.test(codeOnly(l)))) importers.add(rel); } assert.deepEqual([...importers], ["common/lib/networkExits.ts"], "yt-dlp's option tables are read by lib/networkExits.ts alone"); assert.deepEqual( calls, CALLERS, "a new caller of a chat-writing argv builder: it must guard against a stored chat (see CHAT_WRITERS' guards), " + "be tested, and be counted in CALLERS", ); }); // ── THE THIRD GATE: CAPTIONS (lane text-compress-captions) ───────────────── // // A caption track may be on disk as `transcript..vtt.zst`. A raw read, // stat or delete of a caption NAME (its constants, a `transcript..vtt` // literal, a record's `ytVttFile` / `vttFile` / `picked.filename`) outside the // stored-text helpers sees a compressed track as ABSENT — and the three // misses that cost the most are a re-fetch of the URL (destinationExists), an // audio download and a transcription for a video that has captions // (hasAnyTranscriptOnDisk), and a purge that leaves the `.zst` (the captions // come back). Two tripwires, like the first gate: // // 1. A LINE THAT CALLS A RAW FS READ, STAT OR DELETE and names a caption in // the same statement (the line or the two before it) must also name a // sanctioned reader or deleter there, or be ALLOWED_CAPTION with its // reason. Writes are not gated: every writer writes the plain name, which // is the truth (lib/storedText.ts). // 2. A FILE THAT APPLIES A CAPTION RULE to a listing (`englishVttsByPreference`, // `resolvePrimaryVtt`, `captionInputs`, `listTranscriptVtts`, …) must take // a LOGICAL listing somewhere in it (`readVideoFiles`, `logicalEntries`, // `readdirLogical`, `logicalFileNames`, the umtool twin) — a raw readdir // fed to the rule loses every stored track — or be a RULE_ONLY file with // its reason (it is handed a logical listing by its callers). // // WHAT THEY CANNOT SEE: a variable holding a caption name read far from where // it was named; a listing passed through a parameter from a raw readdir in // another file; a shell or Python reader. const CAPTION_NAMES = /\b(?:VTT_FILENAME|ORIG_VTT_FILENAME|CANONICAL_VTT|EN_ORIG_TRACK)\b|transcript\.[A-Za-z-]*\.vtt(?![.\w])|\.ytVttFile\b|\bvttFile\b|picked\.filename\b/; const RAW_FS = /\b(?:readFile|readFileSync|stat|statSync|lstat|lstatSync|open|openSync|createReadStream|rm|rmSync|unlink|unlinkSync|copyFile|rename|access|existsSync|removeMediaFile|renameMediaFile)\s*\(/; const CAPTION_SANCTIONED = /\b(?:readStoredText|readStoredTextHead|statStoredText|storedTextMtimeMs|storedTextExists|storedTextForms|storedTextLogicalSize|removeStoredText|removeStoredTextForm|compressStoredText|restoreStoredText|verifyStoredText|decodeStoredBytes|captionBytes|readEnglishVttCues|readEnglishVttTracks|readVttProvenance|resolveVttProvenance)\b/; const ALLOWED_CAPTION: { file: string; code: RegExp; why: string }[] = [ { file: "common/lib/localMediaCommit-server.ts", code: /const current = await lstat\(target\);/, why: "the new record's DIRECTORY, checked before each link of a commit that made it (mkdir, EEXIST refused): no stored form can be in it", }, ]; // The caption rules, and the files that define them. const CAPTION_RULES = /\b(?:englishVttsByPreference|resolvePrimaryVtt|captionInputs|listTranscriptVtts|readEnglishVttCues|readEnglishVttTracks|mayHaveAltTracks|resolveCaptionsProvenance)\s*\(/; const LOGICAL_LISTING = /\b(?:readVideoFiles|logicalEntries|readdirLogical|logicalFileNames)\b/; const RULE_ONLY: Record = { "common/lib/videoStatus.ts": "the rules themselves (readEnglishVttCues makes its listing logical)", }; test("every app line that reads, stats or deletes a caption track goes through the stored-text helpers", async () => { const offenders: string[] = []; for (const { rel, lines } of await appFiles()) { if (DEFINITIONS.has(rel)) continue; for (let i = 0; i < lines.length; i++) { const code = codeOnly(lines[i]); if (!RAW_FS.test(code)) continue; const statement = [lines[i - 2] ?? "", lines[i - 1] ?? "", code].map(codeOnly).join("\n"); if (!CAPTION_NAMES.test(statement)) continue; if (CAPTION_SANCTIONED.test(statement)) continue; if (ALLOWED_CAPTION.some((a) => a.file === rel && a.code.test(code))) continue; offenders.push(`${rel}:${i + 1}: ${lines[i].trim()}`); } } assert.deepEqual( offenders, [], "read, stat or delete a caption track through lib/storedText(-server|-write-server).ts — it may be stored as .zst", ); }); test("every file that applies a caption rule to a listing takes a logical listing", async () => { const offenders: string[] = []; for (const { rel, lines } of await appFiles()) { if (DEFINITIONS.has(rel) || RULE_ONLY[rel]) continue; const code = lines.map(codeOnly); const uses = code.findIndex((l) => CAPTION_RULES.test(l) && !/^\s*(?:export\s+)?(?:async\s+)?function\b/.test(l)); if (uses < 0) continue; if (code.some((l) => LOGICAL_LISTING.test(l))) continue; offenders.push(`${rel}:${uses + 1}: ${lines[uses].trim()}`); } assert.deepEqual( offenders, [], "a caption rule fed a raw readdir loses every track stored as .zst: list with readVideoFiles / readdirLogical / logicalEntries", ); }); // ── THE CAPTIONS GATES, TIGHTER (REVIEW-1 N8 of the captions lane) ───────── // // 5. In a file that applies a caption rule, EVERY readdir of a video dir is // logical (wrapped in logicalEntries / readdirLogical on its line or the // next) or listed below with why: a raw listing fed to the rule loses every // stored track. A listing of a channel's or the index's own dirs (not a // video dir) is not asked. // 6. A caption PARSE (`parseVtt`, `hasWordTiming`, `vttWordStarts`, // `sniffVttProvenance`) fed by a raw `readFile` in the same statement: // the bytes of a stored track are zstd, not text. // 7. The managed download's subtitle pass fetches stored captions again // (main's rule): the file that calls its argv builder must settle them. const NOT_A_VIDEO_DIR = /readdir\(\s*(?:channelsDir|dataDir|paths\.|\w*OutDir\b|\w*ChannelDir\b|channelDir\b|summariesOut\b|transcriptsOutDir)/; const RAW_VIDEO_READDIR: { file: string; code: RegExp; why: string }[] = [ { file: "common/controller/channelSnapshot.ts", code: /entries = await readdir\(dir\);/, why: "dirFileBytes: the clips/ cache's files, never a caption" }, { file: "common/controller/copiesLane.ts", code: /readdir: \(p\) => readdir\(p\)/, why: "the io seam; signatureOf makes the listing logical" }, { file: "common/controller/findClips.ts", code: /const entries = await readdir\(videoDir\)/, why: "media and sidecar names; the transcript pick wraps it in logicalEntries" }, { file: "editor/app/channels/[slug]/lib/fixIncompleteTranscript.ts", code: /const entries = await readdir\(videoDir\)\.catch/, why: "the audio files only (isRealAudioFile)" }, { file: "editor/app/channels/[slug]/videos/[id]/videoActions.ts", code: /const (?:firstEntries|entries) = await readdir\((?:videoDir|resolved)\)/, why: "audio and containers; the captions check wraps it in logicalEntries" }, ]; const PARSE = /\b(?:parseVtt|hasWordTiming|vttWordStarts|sniffVttProvenance)\s*\(/; const PARSE_RAW_ALLOWED: { file: string; code: RegExp; why: string }[] = [ { file: "common/controller/copiesLane.ts", code: /for \(const cue of parseVtt\(text\)\)/, why: "text from io.readCaption (readStoredText); io.readFile only in a test's seam" }, ]; test("in a file that applies a caption rule, every readdir of a video dir is logical", async () => { const offenders: string[] = []; for (const { rel, lines } of await appFiles()) { if (DEFINITIONS.has(rel) || RULE_ONLY[rel]) continue; const code = lines.map(codeOnly); if (!code.some((l) => CAPTION_RULES.test(l) || /\b(?:isTranscriptVtt|isEnglishVtt|isTranscriptVttName)\s*\(/.test(l))) continue; code.forEach((l, i) => { if (!/\breaddir\s*\(/.test(l) || NOT_A_VIDEO_DIR.test(l)) return; if (/logicalEntries\(|readdirLogical/.test(l + (code[i + 1] ?? ""))) return; if (RAW_VIDEO_READDIR.some((a) => a.file === rel && a.code.test(l))) return; offenders.push(`${rel}:${i + 1}: ${lines[i].trim()}`); }); } assert.deepEqual(offenders, [], "a raw readdir beside a caption rule: make it logical (readdirLogical / logicalEntries) or list it with why"); }); test("no caption parse is fed a raw readFile", async () => { const offenders: string[] = []; for (const { rel, lines } of await appFiles()) { if (DEFINITIONS.has(rel) || rel === "common/lib/vtt.ts") continue; const code = lines.map(codeOnly); code.forEach((l, i) => { if (!PARSE.test(l)) return; const st = [code[i - 2] ?? "", code[i - 1] ?? "", l].join("\n"); if (!/\breadFile(?:Sync)?\s*\(/.test(st)) return; if (PARSE_RAW_ALLOWED.some((a) => a.file === rel && a.code.test(l))) return; offenders.push(`${rel}:${i + 1}: ${lines[i].trim()}`); }); } assert.deepEqual(offenders, [], "parse a caption read through readStoredText — its bytes may be zstd"); }); test("the file that builds the managed download's subtitle argv settles stored captions after the pass", async () => { for (const { rel, lines } of await appFiles()) { const text = lines.map(codeOnly).join("\n"); if (!/\byoutubeHandlingArgs\s*\(/.test(text.replace(/export function youtubeHandlingArgs\s*\(/, ""))) continue; assert.match(text, /\bsettleRefetchedCaptions\s*\(/, `${rel}: calls youtubeHandlingArgs without settleRefetchedCaptions`); assert.match(text, /\bstoredOnlyCaptionTracks\s*\(/, `${rel}: settles without the PHYSICAL listing's stored tracks`); } });