- Timestamp:
- 07/28/2026 08:37:08 AM (6 weeks ago)
- Branches:
- main
- Children:
- 3f32994
- Parents:
- 0101d0a
- File:
-
- 1 edited
-
test/embed-resolver.test.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
test/embed-resolver.test.js
r0101d0a rc52dc82 52 52 }); 53 53 54 test('a known provider beats oEmbed but loses to AP', async () => { 54 // Regression: a hardcoded provider list used to short-circuit here and return a 55 // card with no title and no thumbnail, so a YouTube link ended up storing 56 // nothing at all. There is no provider list any more; every non-fediverse URL 57 // takes the generic path, which is exactly what gives it a thumbnail. 58 test('a video host is not special-cased and still gets a real card', async () => { 55 59 const r = await resolveEmbed('https://youtu.be/abcdefghijk', io({ 56 provider: () => ({ provider: 'youtube', id: 'abcdefghijk' }), 60 provider: () => ({ provider: 'youtube', id: 'abcdefghijk' }), // ignored on purpose 57 61 getPage: async () => OEMBED_PAGE, 58 62 getJSON: async () => OEMBED_JSON, 59 63 })); 60 assert.equal(r.kind, 'provider'); 61 assert.equal(r.provider, 'youtube'); 64 assert.equal(r.kind, 'oembed'); 65 assert.equal(r.title, 'A talk'); 66 assert.ok(r.media[0].url, 'and it has a thumbnail, which the old path never produced'); 62 67 }); 63 68 … … 115 120 }; 116 121 const io = liveIO({ safeFetch: fakeFetch, detectProvider: () => null }); 117 assert.equal(await io.getPage('https://x/huge'), null, 'oversized body refused'); 122 // A JSON payload must parse whole, so an oversized one is refused outright. 123 assert.equal(await io.getJSON('https://x/huge'), null, 'oversized JSON refused'); 118 124 assert.equal(await io.getAP('https://x/boom'), null, 'a refused fetch is not an error'); 119 125 assert.deepEqual(await io.getAP('https://x/ok'), { type: 'Note', id: 'https://s/1' }); … … 163 169 assert.equal(r.url, 'https://lg.example/artikel'); 164 170 }); 171 172 // Regression, the one that kept YouTube blank: a page is read from the START and 173 // cut off, never refused for being large. Refusing it meant no thumbnail at all 174 // for exactly the sites people share most. 175 test('a huge page is truncated, not rejected', async () => { 176 const { liveIO } = await import('../src/services/EmbedResolver.js'); 177 const big = '<html><head>' + 'x'.repeat(5000) + '<meta property="og:title" content="T">' 178 + '<meta property="og:image" content="https://x/i.png"></head></html>'; 179 const fakeFetch = async () => ({ ok: true, headers: { get: () => String(9_000_000) }, text: async () => big }); 180 const io = liveIO({ safeFetch: fakeFetch, detectProvider: () => null }); 181 const page = await io.getPage('https://x/huge'); 182 assert.ok(page && page.includes('og:image'), 'the head survives the cap'); 183 });
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)