- Timestamp:
- 07/29/2026 12:36:50 PM (6 weeks ago)
- Branches:
- main
- Children:
- 7a93fcf
- Parents:
- 6100ce9
- File:
-
- 1 edited
-
test/gated-settings.test.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
test/gated-settings.test.js
r6100ce9 rd56d471 147 147 assert.equal(database.prepare('SELECT external_embeds FROM sites WHERE slug = ?').get('kid9').external_embeds, 1, 148 148 'two of three agreed, so the ward may see link previews'); 149 150 // And the loop CLOSES: the ward's server answers the Offer that opened the 151 // decision, back to the proposer. Without this the proposer's screen can 152 // only ever say "waiting", forever, whatever actually happened: the tally is 153 // the ward server's private ledger and nobody else may read it. 154 const answer = sent.find((x) => x.to === A && (x.act.type === 'Accept' || x.act.type === 'Reject')); 155 assert.ok(answer, 'the proposer is told the outcome'); 156 assert.equal(answer.act.type, 'Accept', 'it settled on what A proposed'); 157 assert.equal(answer.act.actor, WARD, 'and only the ward may say so'); 158 assert.equal(answer.act.object, 'https://a.test/gated/1', 'referencing the offer it answers'); 159 }); 160 161 test("the proposer's own book: sent, answered, or honestly expired", async () => { 162 const dbMod3 = await import('../src/config/database.js'); 163 const database = dbMod3.default; 164 const G = await import('../src/services/guardianship/index.js'); 165 const WARD = 'https://kids.example/ap/users/maan'; 166 const ME = 'https://test.example/ap/users/oma1'; 167 database.prepare('INSERT OR IGNORE INTO users (id, username, email, password_hash, role) VALUES (?,?,?,?,?)').run('u11', 'u11', 'u11@t', 'x', 'god'); 168 database.prepare('INSERT OR IGNORE INTO sites (id, slug, title, owner_id, is_primary) VALUES (?,?,?,?,0)').run('s11', 'oma1', 'oma1', 'u11'); 169 database.prepare("INSERT OR IGNORE INTO ap_guardianships (slug, role, other_uri, status, offer_id) VALUES ('oma1','guardian',?, 'accepted','o')").run(WARD); 170 const site = database.prepare('SELECT * FROM sites WHERE slug = ?').get('oma1'); 171 172 // The route records what it sent; here we do what the route does. 173 G.gated.recordSent(`${ME}/gated/p1`, 'oma1', WARD, 'shaer:externalPlayback', true); 174 assert.equal(G.gated.sentStatus(G.gated.recallSent(`${ME}/gated/p1`), Date.now()), 'open'); 175 176 // A stranger claiming an outcome is not one: only the ward's voice counts. 177 assert.equal(await G.handleGuardianshipInbox(site, { type: 'Accept', actor: 'https://evil.test/u/x', object: `${ME}/gated/p1` }), false); 178 assert.equal(G.gated.recallSent(`${ME}/gated/p1`).status, 'open', 'still open: a stranger cannot close our books'); 179 180 // The ward's server answers: the row settles. 181 assert.equal(await G.handleGuardianshipInbox(site, { type: 'Accept', actor: WARD, object: `${ME}/gated/p1` }), true); 182 assert.equal(G.gated.recallSent(`${ME}/gated/p1`).status, 'accepted'); 183 assert.equal(G.gated.sentStatus(G.gated.recallSent(`${ME}/gated/p1`), Date.now()), 'accepted'); 184 185 // A Reject is an answer too, and lands as one. 186 G.gated.recordSent(`${ME}/gated/p2`, 'oma1', WARD, 'shaer:externalEmbeds', false); 187 assert.equal(await G.handleGuardianshipInbox(site, { type: 'Reject', actor: WARD, object: `${ME}/gated/p2` }), true); 188 assert.equal(G.gated.sentStatus(G.gated.recallSent(`${ME}/gated/p2`), Date.now()), 'rejected'); 189 190 // Silence past the window is not "still running": it is over, and the 191 // screen must say so instead of promising forever. 192 G.gated.recordSent(`${ME}/gated/p3`, 'oma1', WARD, 'shaer:externalEmbeds', true); 193 const row = G.gated.recallSent(`${ME}/gated/p3`); 194 assert.equal(G.gated.sentStatus(row, Date.now()), 'open'); 195 assert.equal(G.gated.sentStatus(row, Date.now() + 25 * 60 * 60 * 1000), 'expired'); 149 196 }); 150 197
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)