Changeset feced2c in Klonkt for test/rich-reply.test.js
- Timestamp:
- 07/19/2026 05:25:26 PM (7 weeks ago)
- Branches:
- main
- Children:
- 5190152
- Parents:
- 33e1dbd
- git-author:
- Robin <roboburr@…> (07/19/2026 05:24:58 PM)
- git-committer:
- Robin <roboburr@…> (07/19/2026 05:25:26 PM)
- File:
-
- 1 edited
-
test/rich-reply.test.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
test/rich-reply.test.js
r33e1dbd rfeced2c 80 80 assert.equal(row.language, null); 81 81 }); 82 83 test('attachments: own /media/ urls stored, note carries typed absolute attachments', async () => { 84 const r = await AP.deliverReply(site, { 85 postId: 'p1', postSlug: 'hallo', parent, text: 'met media', html: '', 86 attachments: [ 87 { url: '/media/reply-media/a.webp', mediaType: 'image/webp', name: 'foto' }, 88 { url: '/media/reply-media/b.mp3', mediaType: 'audio/mpeg', name: 'liedje' }, 89 { url: 'https://evil.example/x.png', mediaType: 'image/png', name: 'remote' }, // rejected: not ours 90 { url: '/media/reply-media/c.pdf', mediaType: 'application/pdf', name: 'doc' }, // rejected: type 91 ], 92 }); 93 const row = db.prepare('SELECT * FROM ap_outbox WHERE id = ?').get(r.id); 94 const stored = JSON.parse(row.attachments); 95 assert.equal(stored.length, 2); 96 assert.deepEqual(stored.map((a) => a.url), ['/media/reply-media/a.webp', '/media/reply-media/b.mp3']); 97 98 const note = AP.buildReplyNote('https://klonkt.test', site, row); 99 assert.equal(note.attachment.length, 2); 100 assert.deepEqual(note.attachment.map((a) => a.type), ['Image', 'Audio']); 101 assert.equal(note.attachment[0].url, 'https://klonkt.test/media/reply-media/a.webp'); 102 }); 103 104 test('a media-only reply (no text) is delivered', async () => { 105 const r = await AP.deliverReply(site, { 106 postId: 'p1', postSlug: 'hallo', parent, text: '', html: '', 107 attachments: [{ url: '/media/reply-media/solo.webp', mediaType: 'image/webp', name: '' }], 108 }); 109 assert.ok(r && r.id); 110 const row = db.prepare('SELECT * FROM ap_outbox WHERE id = ?').get(r.id); 111 assert.match(row.content, /^<p><a /); // just the mention paragraph 112 assert.equal(JSON.parse(row.attachments).length, 1); 113 }); 114 115 test('only foreign/invalid attachments and no text -> rejected', async () => { 116 const r = await AP.deliverReply(site, { 117 postId: 'p1', postSlug: 'hallo', parent, text: '', html: '', 118 attachments: [{ url: 'https://evil.example/x.png', mediaType: 'image/png' }], 119 }); 120 assert.equal(r, null); 121 });
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)