// "ARCHIVE THIS ACCOUNT" FROM A LIBRARY ASKS X NOTHING, NOW OR LATER (lane // x-trending-publish, review 1 M1). The channel it makes has a URL and has // never synced: the most overdue channel the scheduler knows. So it is made // with its priority tier `paused`, and this pins that every automatic door // honours that one switch: the sync scheduler (selectDueChannels and the // schedule view), Sync all's skip, and the four lanes. And that an X SEARCH // channel's lead is archived exactly as before. // // Run with: pnpm --filter yt-dlp-transcript-common exec tsx --test jobs/xLeadSyncOff.test.ts import { test } from "node:test"; import assert from "node:assert/strict"; import type { ChannelConfig } from "../lib/channelConfig"; import { channelsForOperation, isChannelPaused, PRIORITY_OPERATIONS, sanitizeChannelPriority } from "../lib/channelPriority"; import { defaultSyncScheduler } from "../lib/settings"; import { xLeadArchiveMode, xLeadChannelFields, xLeadChannelSlug, xLeadSyncOffSentence } from "../lib/xSearch/leads"; import { buildScheduleView, selectDueChannels } from "./syncScheduler"; import { emptySchedulerState } from "./syncSchedulerState"; const NOW = Date.parse("2026-11-18T12:00:00.000Z"); const scheduler = { ...defaultSyncScheduler(), enabled: true, defaultIntervalMinutes: 60, quietHoursStart: null, quietHoursEnd: null }; // The channel as "Archive this account" makes it: the lead's own fields, never synced. const slug = xLeadChannelSlug("saucer_fan"); const fields = xLeadChannelFields({ handle: "saucer_fan" }); const config = { handling: "transcribe", name: fields.name, url: fields.url, platform: "twitter", sourceKind: "social", postFetcher: fields.postFetcher, socialHandle: fields.socialHandle } as ChannelConfig; const channels = [{ slug, config }]; const due = (priority: ReturnType) => selectDueChannels({ channels, scheduler, state: emptySchedulerState(), activeSlugs: new Set(), now: NOW, priority }).due; test("the mode: from a library nothing is fetched and sync is off unless fetch is asked; from a search channel nothing changed", () => { assert.deepEqual(xLeadArchiveMode({ library: true }), { fetchNow: false, syncOff: true }); assert.deepEqual(xLeadArchiveMode({ library: true, fetch: false }), { fetchNow: false, syncOff: true }); assert.deepEqual(xLeadArchiveMode({ library: true, fetch: true }), { fetchNow: true, syncOff: false }); // AN X SEARCH CHANNEL'S LEAD, AS IT ALWAYS WAS: the first fetch starts unless `fetch: false`; sync is never touched. assert.deepEqual(xLeadArchiveMode({ library: false }), { fetchNow: true, syncOff: false }); assert.deepEqual(xLeadArchiveMode({ library: false, fetch: true }), { fetchNow: true, syncOff: false }); assert.deepEqual(xLeadArchiveMode({ library: false, fetch: false }), { fetchNow: false, syncOff: false }); }); test("WITHOUT the switch the new channel is fetched at the scheduler's next tick: a never-synced channel with a URL is due at once", () => { assert.deepEqual(due(sanitizeChannelPriority({ channels: {} })), [slug]); }); test("with its tier paused it is not due, not eligible, skipped by Sync all's question, and in no lane", () => { const priority = sanitizeChannelPriority({ channels: { [slug]: { tier: "paused" } } }); // The sync scheduler. assert.deepEqual(due(priority), []); const view = buildScheduleView({ channels, scheduler, state: emptySchedulerState(), now: NOW, priority }); assert.equal(view[0].autoSyncEligible, false); // Sync all asks exactly this (editor channels/actions.ts syncAllChannelsAction: "paused for sync"). assert.equal(isChannelPaused(priority, slug, "sync"), true); // The four lanes, and sync: every operation there is. for (const op of PRIORITY_OPERATIONS) { assert.equal(isChannelPaused(priority, slug, op), true, op); assert.deepEqual(channelsForOperation(priority, [slug], op), [], op); } // Turned on again (tier normal): due, as any channel. assert.deepEqual(due(sanitizeChannelPriority({ channels: { [slug]: { tier: "normal" } } })), [slug]); }); test("the sentence says the three things: sync off, nothing asked of X, and how to turn sync on and run the first fetch", () => { assert.equal( xLeadSyncOffSentence("saucer_fan-x", "@saucer_fan"), `Made the channel "saucer_fan-x" for @saucer_fan, on no site, with sync off (its priority is paused): nothing was asked of X, and nothing will be until you say so. ` + `To turn sync on, set its priority to normal on /channels (pnpm ops channel-priority --json '{"slugs":["saucer_fan-x"],"tier":"normal"}'). ` + `Its first fetch is Fetch posts on its page (pnpm ops fetch-posts --json '{"slug":"saucer_fan-x"}').`, ); });