import { test } from "node:test"; import assert from "node:assert/strict"; import { collectTimelineTweets, graphqlOpOf, mediaSummaryOf, parseTrendingCapture, type TrendingCaptureLine, } from "./xTrendingParse"; import { FIXTURE_FIRST_PAGE, FIXTURE_TIMELINE_OP, FIXTURE_TOP_TIMELINE, FIXTURE_TREND_OP, fixtureTimelineBody, fixtureTrendingResponses, } from "./__fixtures__/xTrendingCapture"; function linesOf(responses: Array<{ url: string; status: number; body?: unknown }>): TrendingCaptureLine[] { return responses .filter((r) => graphqlOpOf(r.url)) .map((r, i) => ({ n: i + 1, at: "2026-11-17T10:00:00.000Z", op: graphqlOpOf(r.url)!, status: r.status, url: r.url, bytes: JSON.stringify(r.body ?? null).length, body: r.body, })); } test("an operation is named by the GraphQL URL's path; nothing else is one", () => { assert.equal(graphqlOpOf("https://x.com/i/api/graphql/abc123/ExampleTrendTimeline?variables=%7B%7D"), "ExampleTrendTimeline"); assert.equal(graphqlOpOf("https://api.x.com/i/api/graphql/abc/Op"), "Op"); assert.equal(graphqlOpOf("https://x.com/i/api/1.1/example.json"), null); assert.equal(graphqlOpOf("https://x.com.example.test/i/api/graphql/abc/Op"), null); assert.equal(graphqlOpOf("https://example.test/i/api/graphql/abc/Op"), null); }); test("the walk lists the page's posts once each, in order: no promoted entry, no quoted post", () => { const tweets = collectTimelineTweets(fixtureTimelineBody(FIXTURE_FIRST_PAGE)); assert.deepEqual( tweets.map((t) => t.rest_id), ["1900000000000001001", "1900000000000001002", "1900000000000001004"], ); // The quoted post rides on the post quoting it. assert.equal((tweets[1].quoted as { rest_id: string }).rest_id, "1900000000000000900"); // Names under user.core are read as names under user.legacy are. assert.deepEqual(tweets[2].user, { name: "spout_clips", nick: "Spout Clips" }); }); test("media is counted by kind from the answer", () => { const [first, , video] = collectTimelineTweets(fixtureTimelineBody(FIXTURE_FIRST_PAGE)); assert.deepEqual(mediaSummaryOf(first), { count: 2, kinds: ["image"] }); assert.deepEqual(mediaSummaryOf(video), { count: 1, kinds: ["video"] }); assert.equal(mediaSummaryOf({ full_text: "no media" }), undefined); // A type that is a property of every object is no kind. assert.deepEqual( mediaSummaryOf({ extended_entities: { media: [{ type: "constructor" }, { type: "toString" }, { type: "photo" }] } }), { count: 3, kinds: ["image"] }, ); }); test("a capture parses to posts, their media and the operations' names and sizes", () => { const f = fixtureTrendingResponses(); const parsed = parseTrendingCapture(linesOf([...f.load, ...f.scrolls.flat()]), "trending"); assert.deepEqual( parsed.posts.map((p) => [p.id, p.author, p.channelSlug]), [ ["1900000000000001001", "teapot_news", "trending"], ["1900000000000001002", "saucer_fan", "trending"], ["1900000000000001004", "spout_clips", "trending"], ["1900000000000001005", "lid_watch", "trending"], ], ); const quoting = parsed.posts[1]; assert.equal(quoting.quoted?.id, "1900000000000000900"); assert.equal(quoting.quoted?.author, "kettle_org"); assert.equal(parsed.posts[3].isReply, true); assert.equal(parsed.posts[3].replyTo?.id, "1900000000000001001"); assert.equal(parsed.posts[0].url, "https://x.com/teapot_news/status/1900000000000001001"); assert.deepEqual(parsed.media, { "1900000000000001001": { count: 2, kinds: ["image"] }, "1900000000000001004": { count: 1, kinds: ["video"] }, "1900000000000001005": { count: 1, kinds: ["gif"] }, }); // Another surface's answer is counted, and its posts are not the page's. assert.deepEqual( parsed.operations.map((o) => [o.op, o.responses, o.tweets]), [ [FIXTURE_TREND_OP, 1, 0], [FIXTURE_TIMELINE_OP, 2, 5], ["HomeTimeline", 1, 0], ], ); assert.equal(parsed.responses, 4); assert.ok(parsed.posts.every((p) => p.author !== "home_only" && p.author !== "advert_co")); }); test("an answer that failed, or whose body was not kept, yields nothing", () => { const body = fixtureTimelineBody(FIXTURE_FIRST_PAGE); const line = (over: Partial): TrendingCaptureLine => ({ n: 1, at: "2026-11-17T10:00:00.000Z", op: FIXTURE_TIMELINE_OP, status: 200, url: "https://x.com/i/api/graphql/q/ExampleTrendTimeline", bytes: 10, body, ...over, }); assert.equal(parseTrendingCapture([line({ status: 429 })], "t").posts.length, 0); assert.equal(parseTrendingCapture([line({ body: undefined, skipped: "too-large" })], "t").posts.length, 0); assert.equal(parseTrendingCapture([line({})], "t").posts.length, 3); assert.equal(parseTrendingCapture([line({ body: { data: {} } })], "t").posts.length, 0); }); // Lane x-trending-2: where the CDN serves a post's media, read from the answer. test("media sources: a picture at its original size, a video's highest-bitrate mp4, X's two hosts only", async () => { const { mediaSourcesOf, mediaSourcesInCapture, xMediaCdnUrl } = await import("./xTrendingParse"); const { fixtureTweetResult } = await import("./__fixtures__/xTrendingCapture"); const { collectTimelineTweets } = await import("./xTrendingParse"); const raw = (t: Parameters[0]) => collectTimelineTweets({ result: fixtureTweetResult(t) })[0]; assert.deepEqual(mediaSourcesOf(raw({ id: "1900000000000002001", handle: "a", text: "t", media: ["photo", "video", "animated_gif"] })), [ { kind: "image", url: "https://pbs.twimg.com/media/Fixture20010.jpg", fetchUrl: "https://pbs.twimg.com/media/Fixture20010?format=jpg&name=orig", ext: "jpg", }, { kind: "video", url: "https://video.twimg.com/ext_tw_video/19000000000000020011/vid/1280x720/high.mp4", fetchUrl: "https://video.twimg.com/ext_tw_video/19000000000000020011/vid/1280x720/high.mp4", ext: "mp4", bitrate: 2176000, }, { kind: "gif", url: "https://video.twimg.com/ext_tw_video/19000000000000020012/vid/1280x720/high.mp4", fetchUrl: "https://video.twimg.com/ext_tw_video/19000000000000020012/vid/1280x720/high.mp4", ext: "mp4", bitrate: 2176000, }, ]); assert.deepEqual(mediaSourcesOf(raw({ id: "1900000000000002002", handle: "a", text: "no media" })), []); // An address on another host, or not https, is no media source. const elsewhere = { id_str: "1", full_text: "t", extended_entities: { media: [ { type: "photo", media_url_https: "https://pbs.twimg.com.example.test/media/x.jpg" }, { type: "photo", media_url_https: "http://pbs.twimg.com/media/x.jpg" }, { type: "photo", media_url_https: "https://user:pw@pbs.twimg.com/media/x.jpg" }, { type: "video", video_info: { variants: [{ content_type: "video/mp4", bitrate: 1, url: "https://example.test/v.mp4" }] } }, { type: "video", video_info: { variants: [{ content_type: "application/x-mpegURL", url: "https://video.twimg.com/x/pl/list.m3u8" }] } }, { type: "constructor", media_url_https: "https://pbs.twimg.com/media/y.jpg" }, ], }, }; assert.deepEqual(mediaSourcesOf(elsewhere as never), []); assert.equal(xMediaCdnUrl("https://video.twimg.com/a.mp4")?.hostname, "video.twimg.com"); assert.equal(xMediaCdnUrl("https://pbs.twimg.com:8443/a.jpg"), null); assert.equal(xMediaCdnUrl(42), null); // A capture's sources by post id: ignored operations and failed answers give none. const body = { data: { list: [fixtureTweetResult({ id: "1900000000000002003", handle: "a", text: "t", media: ["photo"] })] } }; const line = (op: string, status: number) => ({ n: 1, at: "x", op, status, url: "u", bytes: 1, body }); assert.deepEqual([...mediaSourcesInCapture([line("ExampleTrendTimeline", 200)]).keys()], ["1900000000000002003"]); assert.equal(mediaSourcesInCapture([line("HomeTimeline", 200), line("ExampleTrendTimeline", 500)]).size, 0); }); // Review 1 S2, review 2 N4. test("S2/N4: a capture shows the page's end only when the bottom-cursor continuation brought nothing new and no answer failed", async () => { const { parseTrendingCapture, requestCursorOf, timelineShapeOf } = await import("./xTrendingParse"); const { fixtureTimelineBody, FIXTURE_BOTTOM_CURSOR } = await import("./__fixtures__/xTrendingCapture"); type Line = import("./xTrendingParse").TrendingCaptureLine; const t = (id: string) => ({ id, handle: "a", text: `post ${id}` }); let n = 0; const url = (op: string, cursor?: string) => `https://x.com/i/api/graphql/q/${op}?variables=${encodeURIComponent(JSON.stringify({ rest_id: "1", ...(cursor ? { cursor } : {}) }))}`; const line = (op: string, status: number, body?: unknown, cursor?: string): Line => ({ n: ++n, at: "x", op, status, url: url(op, cursor), bytes: 1, ...(body === undefined ? {} : { body }) }); // The first page (no cursor), and a continuation from the bottom. const first = (ids: string[]) => line("ExampleTrendTimeline", 200, fixtureTimelineBody(ids.map(t))); const more = (ids: string[], cursor: string = FIXTURE_BOTTOM_CURSOR) => line("ExampleTrendTimeline", 200, fixtureTimelineBody(ids.map(t)), cursor); const end = (lines: Line[]) => parseTrendingCapture(lines, "lib").pageEnd; assert.equal(requestCursorOf(url("Op", "abc")), "abc"); assert.equal(requestCursorOf(url("Op")), undefined); assert.equal(requestCursorOf("not a url"), undefined); assert.deepEqual(timelineShapeOf(fixtureTimelineBody([])), { instructions: true, bottom: FIXTURE_BOTTOM_CURSOR }); assert.deepEqual(timelineShapeOf({ data: {} }), { instructions: false }); // Posts, then the continuation from the bottom with none: the end. assert.equal(end([first(["1", "2"]), more([])]), true); // ...or with only posts already seen. assert.equal(end([first(["1", "2"]), more(["2"])]), true); // The continuation still brought a new post: nothing says there was no more. assert.equal(end([first(["1", "2"]), more(["3"])]), false); assert.equal(end([first(["1", "2"])]), false); // N4: an answer with nothing new that is NOT the bottom continuation says nothing about the bottom — // a refresh from the top (no cursor), or another cursor. assert.equal(end([first(["1", "2"]), first(["1", "2"])]), false); assert.equal(end([first(["1", "2"]), first([])]), false); assert.equal(end([first(["1", "2"]), more([], "some-top-cursor")]), false); // The answer before it named no bottom cursor: the capture cannot tell. const noCursor = line("ExampleTrendTimeline", 200, { data: { timeline: { instructions: [{ type: "TimelineAddEntries", entries: [{ entryId: "tweet-1", content: { itemContent: { tweet_results: { result: { __typename: "Tweet", rest_id: "1", legacy: { id_str: "1", full_text: "x" } } } } } }] }] } } }); assert.equal(end([noCursor, more([])]), false); // An answer that failed, or whose body was not kept: the capture cannot tell. assert.equal(end([first(["1"]), line("ExampleTrendTimeline", 500), more([])]), false); assert.equal(end([first(["1"]), { ...more([]), body: undefined, skipped: "too-large" as const }]), false); assert.equal(end([first(["1"]), more([]), line("ExampleTrendPage", 429)]), false); // N4: a 200 that carries GraphQL errors, or no timeline instructions, is a failed answer. assert.equal(end([first(["1"]), line("ExampleTrendTimeline", 200, { ...fixtureTimelineBody([]), errors: [{ message: "Timeout: Unspecified" }] }, FIXTURE_BOTTOM_CURSOR)]), false); assert.equal(end([first(["1"]), line("ExampleTrendTimeline", 200, { data: {} }, FIXTURE_BOTTOM_CURSOR)]), false); assert.equal(end([first(["1"]), more([]), line("ExampleTrendPage", 200, { data: {}, errors: [{ message: "x" }] })]), false); // Another surface's failure is not the page's. assert.equal(end([first(["1"]), more([]), line("HomeTimeline", 500)]), true); // No post at all: no page to have an end. assert.equal(end([line("ExampleTrendPage", 200, { data: {} })]), false); }); // ── the real page's shape (lane x-followups) ─────────────────────────────── test("the real shape: the page's title, summary, last update and tabs are read from the page's own answer", async () => { const { trendPageOf } = await import("./xTrendingParse"); const real = await import("./__fixtures__/xTrendingRealShape"); assert.deepEqual(trendPageOf(real.realPageBody()), { title: real.INVENTED_TITLE, summary: real.INVENTED_SUMMARY, lastUpdatedAt: new Date(real.INVENTED_LAST_UPDATED_MS).toISOString(), tabs: [ { label: "Top", timelineId: real.INVENTED_TOP_TIMELINE }, { label: "Latest", timelineId: real.INVENTED_LATEST_TIMELINE }, ], }); // The accounts answer shares the page's `data` key and carries no page. assert.equal(trendPageOf(real.realRelevantUsers().body), undefined); assert.equal(trendPageOf(real.realStoryTopics().body), undefined); assert.equal(trendPageOf(real.realFirstPage(real.INVENTED_FIRST).body), undefined); assert.equal(trendPageOf({ data: null }), undefined); assert.equal(trendPageOf("no"), undefined); // Words are one line; a title that is not text, a tab with no id and a date that is no number are left out. assert.deepEqual( trendPageOf({ data: { any_key: { result: { page: { article: { title: " Two\n lines ", article_text: { text: 7 } }, last_updated_at_ms: "soon", post_timelines: [{ label: "Top" }, { label: "Latest", post_timeline: { id: "t2" } }, { label: "Again", post_timeline: { id: "t2" } }] } } } } }), { title: "Two lines", tabs: [{ label: "Latest", timelineId: "t2" }] }, ); }); test("the real shape: a capture parses to the page's posts once each, the page, and which tab showed them", async () => { const real = await import("./__fixtures__/xTrendingRealShape"); const parsed = parseTrendingCapture(linesOf(real.realCaptureResponses()), "lib"); // Six posts: the quoted post rides on the post quoting it, the accounts of the module are no posts. assert.deepEqual(parsed.posts.map((p) => p.id), ["1900000000000003001", "1900000000000003002", "1900000000000003003", "1900000000000003004", "1900000000000003005", "1900000000000003006"]); assert.equal(parsed.posts[1].quoted?.id, "1900000000000002900"); assert.equal(parsed.page?.title, real.INVENTED_TITLE); assert.equal(parsed.page?.summary, real.INVENTED_SUMMARY); assert.deepEqual(parsed.timelines, [{ timelineId: real.INVENTED_TOP_TIMELINE, tab: "Top", posts: 6, postIds: parsed.posts.map((p) => p.id), pageEnd: false }]); assert.deepEqual(new Set(Object.values(parsed.tabs)), new Set(["Top"])); assert.equal(Object.keys(parsed.tabs).length, 6); assert.deepEqual( parsed.operations.map((o) => [o.op, o.responses, o.tweets]), [["AiTrendByRestId", 1, 0], ["DataSaverMode", 1, 0], ["GenericTimelineById", 3, 6], ["TrendRelevantUsers", 1, 0], ["useStoryTopicQuery", 1, 0], ["ViewerBadgeCounts", 1, 0]], ); assert.deepEqual(parsed.media, { "1900000000000003001": { count: 1, kinds: ["image"] }, "1900000000000003003": { count: 1, kinds: ["video"] }, "1900000000000003004": { count: 1, kinds: ["gif"] }, }); // A capture with no page answer: posts all the same, no page, a timeline that is no known tab. const bare = parseTrendingCapture(linesOf([real.realFirstPage(real.INVENTED_FIRST)]), "lib"); assert.equal(bare.page, undefined); assert.deepEqual(bare.timelines.map((t) => [t.timelineId, t.tab, t.posts, t.pageEnd]), [[real.INVENTED_TOP_TIMELINE, undefined, 3, false]]); assert.deepEqual(bare.tabs, {}); // The old fixture names no timeline: one untagged timeline. assert.deepEqual(parseTrendingCapture(linesOf(fixtureTrendingResponses().load), "lib").timelines.map((t) => t.timelineId), [FIXTURE_TOP_TIMELINE]); }); test("the real shape: the bottom cursor is read from a cursor entry AND from TimelineReplaceEntry", async () => { const { timelineShapeOf, requestVariablesOf } = await import("./xTrendingParse"); const real = await import("./__fixtures__/xTrendingRealShape"); // The first answer: a cursor entry (the top cursor beside it is not the bottom's). assert.deepEqual(timelineShapeOf(real.realFirstPage(real.INVENTED_FIRST).body), { instructions: true, bottom: real.realBottomCursor(1) }); // A later answer: no cursor entry, two replacements. const later = real.realContinuation(real.INVENTED_SECOND, { n: 2 }); assert.deepEqual(timelineShapeOf(later.body), { instructions: true, bottom: real.realBottomCursor(2) }); assert.deepEqual(requestVariablesOf(later.url), { cursor: real.realBottomCursor(1), timelineId: real.INVENTED_TOP_TIMELINE }); assert.deepEqual(requestVariablesOf(real.realFirstPage([]).url), { timelineId: real.INVENTED_TOP_TIMELINE }); // A replacement named only by the entry it replaces (no cursorType on the new entry) is still the bottom's. assert.deepEqual( timelineShapeOf({ instructions: [{ type: "TimelineReplaceEntry", entry_id_to_replace: "cursor-bottom-1", entry: { entryId: "x", content: { value: "next" } } }] }), { instructions: true, bottom: "next" }, ); // A replacement of the TOP cursor alone names no bottom. assert.deepEqual( timelineShapeOf({ instructions: [{ type: "TimelineReplaceEntry", entry_id_to_replace: "cursor-top-9", entry: { entryId: "cursor-top-9", content: { cursorType: "Top", value: "up" } } }] }), { instructions: true }, ); // The accounts answer has instructions and no cursor. assert.deepEqual(timelineShapeOf(real.realRelevantUsers().body), { instructions: true }); }); test("the real shape: a capped read asserts nothing; the bottom continuation that brings nothing new is the end; a failed last answer asserts nothing", async () => { const real = await import("./__fixtures__/xTrendingRealShape"); const end = (responses: Array<{ url: string; status: number; body?: unknown }>) => parseTrendingCapture(linesOf(responses), "lib").pageEnd; // A CAPPED READ (what the first real read was: it stopped at its post cap): every continuation brought new posts. assert.equal(end(real.realCaptureResponses()), false); assert.equal(end(real.realCaptureResponses({ later: [] })), false); // The continuation from the last bottom cursor (carried by a TimelineReplaceEntry) brings no post… assert.equal(end([...real.realCaptureResponses(), real.realContinuation([], { n: 4 })]), true); // …or only posts already shown. assert.equal(end([...real.realCaptureResponses(), real.realContinuation(real.INVENTED_THIRD, { n: 4 })]), true); // It must continue from the bottom cursor of the answer BEFORE it: the first answer's (an entry) is stale by then. assert.equal(end([...real.realCaptureResponses(), real.realContinuation([], { n: 4, asked: real.realBottomCursor(1) })]), false); assert.equal(end([...real.realCaptureResponses(), real.realContinuation([], { n: 4, asked: real.realTopCursor(3) })]), false); // A FAILED LAST ANSWER: a 429, a body not kept, GraphQL errors, no instructions. const last = real.realContinuation([], { n: 4 }); assert.equal(end([...real.realCaptureResponses(), { ...last, status: 429 }]), false); assert.equal(end([...real.realCaptureResponses(), { url: last.url, status: 200 }]), false); assert.equal(end([...real.realCaptureResponses(), { ...last, body: { ...(last.body as object), errors: [{ message: "Timeout" }] } }]), false); assert.equal(end([...real.realCaptureResponses(), { ...last, body: { data: { timeline: {} } } }]), false); // A failed answer BEFORE the end, then a clean end: the capture still cannot tell. assert.equal(end([...real.realCaptureResponses(), { ...last, status: 500 }, last]), false); // One of the page's small answers failing is the page's failure too. assert.equal(end([...real.realCaptureResponses(), last, { url: real.realStoryTopics().url, status: 500 }]), false); }); test("the real shape: two tabs in one capture show no end, and each post is the tab's that showed it first", async () => { const real = await import("./__fixtures__/xTrendingRealShape"); const latest = { timelineId: real.INVENTED_LATEST_TIMELINE }; const responses = [ ...real.realCaptureResponses({ later: [] }), real.realContinuation([], { n: 2 }), // The other tab: a post of its own and one the first tab showed. real.realFirstPage([real.INVENTED_SECOND[0], real.INVENTED_FIRST[0]], { ...latest, bottom: "latest-1" }), real.realContinuation([], { ...latest, asked: "latest-1", bottom: "latest-2" }), ]; const parsed = parseTrendingCapture(linesOf(responses), "lib"); assert.equal(parsed.pageEnd, false); // PER TIMELINE: each tab's own posts in its own order (a post both show is in both), and each tab's own end. assert.deepEqual(parsed.timelines, [ { timelineId: real.INVENTED_TOP_TIMELINE, tab: "Top", posts: 3, postIds: ["1900000000000003001", "1900000000000003002", "1900000000000003003"], pageEnd: true }, { timelineId: real.INVENTED_LATEST_TIMELINE, tab: "Latest", posts: 1, postIds: ["1900000000000003004", "1900000000000003001"], pageEnd: true }, ]); // One tab at its end and the other capped: said of each by itself. const capped = parseTrendingCapture(linesOf(responses.slice(0, -1)), "lib"); assert.deepEqual(capped.timelines.map((t) => [t.tab, t.pageEnd]), [["Top", true], ["Latest", false]]); // A continuation that brings only posts the OTHER tab showed is not this tab's end: they are new to it. const borrowed = [...responses.slice(0, -1), real.realContinuation([real.INVENTED_FIRST[1]], { ...latest, asked: "latest-1", bottom: "latest-2" })]; assert.deepEqual(parseTrendingCapture(linesOf(borrowed), "lib").timelines.map((t) => [t.tab, t.pageEnd]), [["Top", true], ["Latest", false]]); // A failed answer anywhere: neither tab shows an end. const failed = [...responses, { url: real.realStoryTopics().url, status: 500 }]; assert.deepEqual(parseTrendingCapture(linesOf(failed), "lib").timelines.map((t) => t.pageEnd), [false, false]); assert.equal(parsed.tabs["1900000000000003001"], "Top"); assert.equal(parsed.tabs["1900000000000003004"], "Latest"); // Each tab alone, read to its end, shows it: the continuation is its own timeline's. assert.equal(parseTrendingCapture(linesOf(responses.slice(0, -2)), "lib").pageEnd, true); // A continuation carrying ANOTHER timeline's bottom cursor is not this one's. const crossed = [real.realFirstPage(real.INVENTED_FIRST), real.realContinuation([], { ...latest, asked: real.realBottomCursor(1) })]; assert.equal(parseTrendingCapture(linesOf(crossed), "lib").pageEnd, false); }); // Review 3 S8: THE PARSER'S OP FILTER. Every answer of an operation not in // X_TRENDING_IGNORED_OPS that lists posts is the page's — so after a press // took the page elsewhere, another page's timeline would be read as this // topic's. `pageTabsOnly` (the controller sets it when a tab was abandoned, // "the page changed") ingests only the timelines the trend answer names as // its own tabs; the other answers stay counted in the capture, unread. test("review 3 S8: after the page changed, only the trend answer's own timelines are ingested; the others stay in the capture", async () => { const real = await import("./__fixtures__/xTrendingRealShape"); const stray: typeof real.INVENTED_SECOND = [{ id: "1900000000000003901", handle: "elsewhere", text: "A post of another page." }]; const responses = [ real.realPageAnswer(), real.realFirstPage(real.INVENTED_FIRST), // Another trend's timeline, and a home-like answer naming no timeline. real.realFirstPage(stray, { timelineId: "VGltZWxpbmU6Zml4dHVyZS1lbHNld2hlcmU=" }), { ...real.realFirstPage([{ id: "1900000000000003902", handle: "home", text: "A home post." }]), url: "https://x.com/i/api/graphql/abc/HomeLatestTimeline?variables=%7B%22count%22%3A20%7D" }, ]; const all = parseTrendingCapture(linesOf(responses), "lib"); assert.ok(all.posts.some((p) => p.id === "1900000000000003901"), "without the option every listing answer is read (the filter is by operation only)"); const own = parseTrendingCapture(linesOf(responses), "lib", { pageTabsOnly: true }); const ids = own.posts.map((p) => p.id); assert.ok(!ids.includes("1900000000000003901") && !ids.includes("1900000000000003902"), ids.join(",")); assert.ok(ids.includes(real.INVENTED_FIRST[0].id)); assert.deepEqual(own.timelines.map((t) => t.timelineId), [real.INVENTED_TOP_TIMELINE]); // The capture still says what it holds: every answer counted. assert.equal(own.responses, all.responses); assert.deepEqual(own.operations.map((o) => [o.op, o.responses]), all.operations.map((o) => [o.op, o.responses])); // With no trend answer to name the tabs, nothing is the page's own: nothing is ingested. const none = parseTrendingCapture(linesOf(responses.slice(1)), "lib", { pageTabsOnly: true }); assert.equal(none.posts.length, 0); });