Changeset b258a79 in Klonkt for test/external-embeds.test.js
- Timestamp:
- 07/28/2026 07:53:36 AM (6 weeks ago)
- Branches:
- main
- Children:
- 0101d0a
- Parents:
- fc40410
- File:
-
- 1 edited
-
test/external-embeds.test.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
test/external-embeds.test.js
rfc40410 rb258a79 43 43 assert.equal(timelineEmbed('{"title":"no url"}'), undefined, 'a card without a url is not a card'); 44 44 }); 45 46 // FEP-044f emit side: quoting a fediverse object must federate as a quote AND 47 // tell the quoted author. This is the mirror of the ingest we already had. 48 const { applyQuoteProps } = await import('../src/services/ActivityPubService.js'); 49 50 test('a quote is emitted in all three shapes the network reads', () => { 51 const note = { to: ['https://www.w3.org/ns/activitystreams#Public'], cc: [], tag: [{ type: 'Hashtag', name: '#x' }] }; 52 applyQuoteProps(note, 'https://s/objects/9', 'https://s/users/alice'); 53 assert.equal(note.quote, 'https://s/objects/9', 'the FEP property'); 54 assert.equal(note.quoteUrl, 'https://s/objects/9', 'the as: alias Mastodon reads'); 55 assert.equal(note._misskey_quote, 'https://s/objects/9', 'the misskey alias'); 56 const link = note.tag.find((t) => t.type === 'Link'); 57 assert.ok(link, 'and an FEP-e232 Link tag'); 58 assert.equal(link.href, 'https://s/objects/9'); 59 assert.ok(link.mediaType.includes('activitystreams')); 60 assert.ok(note.tag.some((t) => t.type === 'Hashtag'), 'existing tags survive'); 61 }); 62 63 test('the quoted author is addressed, so being quoted is not a surprise', () => { 64 const note = { cc: ['https://s/users/me/followers'] }; 65 applyQuoteProps(note, 'https://s/objects/9', 'https://s/users/alice'); 66 assert.ok(note.cc.includes('https://s/users/alice')); 67 assert.ok(note.cc.includes('https://s/users/me/followers'), 'without dropping the followers'); 68 }); 69 70 test('no quote, or a junk one, changes nothing', () => { 71 const a = { cc: [], tag: [] }; 72 applyQuoteProps(a, null, null); 73 assert.equal(a.quote, undefined); 74 assert.equal(a.tag.length, 0); 75 const b = { cc: [], tag: [] }; 76 applyQuoteProps(b, 'javascript:alert(1)', 'https://s/users/alice'); 77 assert.equal(b.quote, undefined, 'a non-http quote uri is refused'); 78 const c = { cc: [], tag: [] }; 79 applyQuoteProps(c, 'https://s/objects/9', 'not-a-url'); 80 assert.equal(c.quote, 'https://s/objects/9'); 81 assert.equal(c.cc.length, 0, 'a junk actor is simply not addressed'); 82 }); 83 84 test('a hostile oEmbed title is stored as plain text, not markup', async () => { 85 const { resolveExternalEmbed } = await import('../src/services/ActivityPubService.js'); 86 // No network in the test env, so the resolver bails and returns null; the 87 // point here is the contract: whatever comes back is never raw provider HTML. 88 const out = await resolveExternalEmbed('<p><a href="https://v.example/1">x</a></p>'); 89 assert.ok(out === null || !/<script/i.test(out), 'never stores executable markup'); 90 });
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)