Changeset 3bbf73d in Klonkt for test/thread.test.js
- Timestamp:
- 08/10/2026 02:43:16 PM (4 weeks ago)
- Branches:
- main
- Children:
- f0a33e1
- Parents:
- f549cf5
- File:
-
- 1 edited
-
test/thread.test.js (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
test/thread.test.js
rf549cf5 r3bbf73d 55 55 // een ECHT verzoek aan een testserver op localhost, en dat mag de stub niet 56 56 // beantwoorden met zijn 404. 57 const echteFetch = globalThis.fetch;57 const realFetch = globalThis.fetch; 58 58 59 59 globalThis.fetch = async (url) => { … … 171 171 t.after(() => server.close()); 172 172 await new Promise((r) => server.once('listening', r)); 173 const haal = async () => (await (await echteFetch(173 const get = async () => (await (await realFetch( 174 174 `http://127.0.0.1:${server.address().port}/ap/users/kind/thread?object=${encodeURIComponent(BRON)}`, 175 175 { headers: { Authorization: `Bearer ${bearer}` } })).json()); 176 176 177 const doc = await haal();177 const doc = await get(); 178 178 assert.ok(!JSON.stringify(doc).includes('"shaer:author":'), 'geen dialect meer op deze leg'); 179 const vanTante= doc.orderedItems.find((n) => n.id.endsWith('/replies/2'));180 assert.equal( vanTante.attributedTo.name, 'tante', 'de byline zit in attributedTo');181 assert.equal( vanTante.attributedTo.preferredUsername, 'tante');182 assert.ok(( vanTante.tag || []).some((x) => x.type === 'Emoji'), 'open poort: de emoji van het antwoord blijft');179 const fromAunt = doc.orderedItems.find((n) => n.id.endsWith('/replies/2')); 180 assert.equal(fromAunt.attributedTo.name, 'tante', 'de byline zit in attributedTo'); 181 assert.equal(fromAunt.attributedTo.preferredUsername, 'tante'); 182 assert.ok((fromAunt.tag || []).some((x) => x.type === 'Emoji'), 'open poort: de emoji van het antwoord blijft'); 183 183 184 184 // Poort dicht: FEP-9098 zit in de tag van de ingesloten actor, dus daar … … 188 188 db.prepare("INSERT INTO ap_guardianships (slug, other_uri, role, status) VALUES ('kind', ?, 'guardian', 'accepted')") 189 189 .run('https://203.0.113.20/users/tante'); 190 const dicht = await haal();191 const na = dicht.orderedItems.find((n) => n.id.endsWith('/replies/2'));192 assert.ok(!( na.tag || []).some((x) => x.type === 'Emoji'), 'dichte poort: geen emoji meer');193 assert.ok(! na.attributedTo.tag, 'ook niet in de byline');190 const closed = await get(); 191 const after = closed.orderedItems.find((n) => n.id.endsWith('/replies/2')); 192 assert.ok(!(after.tag || []).some((x) => x.type === 'Emoji'), 'dichte poort: geen emoji meer'); 193 assert.ok(!after.attributedTo.tag, 'ook niet in de byline'); 194 194 }); 195 195 … … 217 217 const vorige = globalThis.fetch; 218 218 t.after(() => { globalThis.fetch = vorige; }); 219 const vraag= async (uri) => {220 const r = await echteFetch(219 const ask = async (uri) => { 220 const r = await realFetch( 221 221 `http://127.0.0.1:${server.address().port}/ap/users/kind/thread?object=${encodeURIComponent(uri)}`, 222 222 { headers: { Authorization: `Bearer ${bearer}` } }); … … 226 226 // De bron zegt nee -- precies wat boiert.eu doet met een friends-only post 227 227 // voor iemand die de auteur niet (meer) volgt. 228 const DICHT = 'https://203.0.113.50/notes/dicht';228 const SHUT = 'https://203.0.113.50/notes/dicht'; 229 229 globalThis.fetch = async () => new Response('nope', { status: 404 }); 230 const nee = await vraag(DICHT);231 assert.equal( nee.status, 404);232 assert.equal( nee.body.error, 'not shared by source');233 assert.equal( nee.body.sourceStatus, 404);230 const refused = await ask(SHUT); 231 assert.equal(refused.status, 404); 232 assert.equal(refused.body.error, 'not shared by source'); 233 assert.equal(refused.body.sourceStatus, 404); 234 234 235 235 // De bron ligt eruit. Dezelfde lege uitkomst, een andere waarheid. 236 const STUK= 'https://203.0.113.51/notes/stuk';236 const BROKEN = 'https://203.0.113.51/notes/stuk'; 237 237 globalThis.fetch = async () => new Response('boem', { status: 500 }); 238 const stuk = await vraag(STUK);239 assert.equal( stuk.status, 502);240 assert.equal( stuk.body.error, 'source unreachable');241 }); 238 const broken = await ask(BROKEN); 239 assert.equal(broken.status, 502); 240 assert.equal(broken.body.error, 'source unreachable'); 241 });
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)