aboutsummaryrefslogtreecommitdiffstats
path: root/tools/live-reactions-test.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-10-18 23:46:18 -0700
committerAdam Soltys <[email protected]>2026-10-18 23:46:18 -0700
commitaa3fecd4f0dc39550c6ad44a19736f820201d0a3 (patch)
treefac2819d695f881fbeb73264907445aed1e3e596 /tools/live-reactions-test.js
parent1f0b1cd2af2c2391d6706f6194bdb65c85f14ca6 (diff)
downloadcoinosv3-aa3fecd4f0dc39550c6ad44a19736f820201d0a3.tar.gz
coinosv3-aa3fecd4f0dc39550c6ad44a19736f820201d0a3.zip
A stream's chat is the app's chat: each comment is a bubble like a DM's or a group's — tap for the emoji row, reply, zap or copy; reactions (kind 7, tagged with the stream and the comment, one per person, deletable) and zap totals show on the comment for every viewer; the zap goes to the commenter, for that comment, on that stream. The composer is the one the other chats use (drafts kept per stream). A reaction no relay took is taken back. (Begun by Codex; finished here.)
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013ZDf1cyCQLkfjftYhymZAg
Diffstat (limited to 'tools/live-reactions-test.js')
-rw-r--r--tools/live-reactions-test.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/tools/live-reactions-test.js b/tools/live-reactions-test.js
new file mode 100644
index 0000000..b142528
--- /dev/null
+++ b/tools/live-reactions-test.js
@@ -0,0 +1,13 @@
+import assert from 'node:assert/strict';
+import { liveReactions } from '../src/live.js';
+const one = {kind:7,id:'one',pubkey:'alice',created_at:1,content:'❤️',tags:[['e','parent'],['e','comment']]};
+const two = {...one,id:'two',created_at:2,content:'👍'};
+const other = {...one,id:'other',pubkey:'bob'};
+const del = {kind:5,id:'delete',pubkey:'alice',created_at:3,tags:[['e','one'],['e','two']]};
+assert.equal(liveReactions([two, one]).get('comment').get('alice').content,'👍');
+assert.equal(liveReactions([one, one, other]).get('comment').size,2);
+assert.equal(liveReactions([del, two, one, other]).get('comment').size,1);
+assert.equal(liveReactions([{...del,pubkey:'mallory'},two]).get('comment').size,1);
+assert.equal(liveReactions([one,two,{...del,tags:[['e','one']]}]).get('comment').get('alice').id,'two');
+assert.equal(liveReactions([two,{...two,id:'zzz'}]).get('comment').get('alice').id,'zzz');
+console.log('✓ Live reaction deduplication, replacement, out-of-order deletion and author validation');