import assert from 'node:assert/strict'; import { test } from 'node:test'; import { fromGraph } from '../src/platforms/instagram.ts'; import { findMetaMedia, mediaFromMetaNode } from '../src/platforms/meta-media.ts'; import { fixture } from './helpers.ts'; test('a carousel becomes one media entry per child, in order', () => { const scraped = fromGraph(fixture('instagram/carousel.json')); assert.ok(scraped.media.length > 1, 'expected a carousel'); assert.ok(scraped.media.every((m) => m.kind === 'image')); assert.ok(scraped.media.every((m) => m.url.startsWith('https://'))); // The CDN 403s anything arriving without a referrer, so every entry has // to carry the headers the proxy will replay. assert.ok(scraped.media.every((m) => m.fetchHeaders?.['Referer'] === 'https://www.instagram.com/')); assert.ok(scraped.text); }); test('a reel becomes a progressive video with its cover frame as the poster', () => { const scraped = fromGraph(fixture('instagram/reel.json')); assert.equal(scraped.media.length, 1); const [item] = scraped.media; assert.equal(item?.kind, 'video'); assert.ok(item?.kind === 'video' && item.poster, 'expected a poster'); // Not a blob: or an HLS manifest — the native player needs a real file. assert.match(item?.url ?? '', /^https:\/\//); assert.ok(!item?.url.includes('.m3u8')); assert.ok(item?.width && item.height, 'expected dimensions for the aspect ratio'); }); test('a reel whose embed only ships a cover frame still finds its video on the post page', () => { // The captioned embed stopped shipping a reel's `video_url` and never draws // a logged-out `