From 0182439b5567d259807058827f96db19f1849851 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Thu, 14 May 2026 08:43:52 -0400 Subject: [PATCH] fix NestViewModelTest for sender-grouped reaction aggregator onReactionEventGroupsByTargetAndEvictsOnTick asserted the pre-change targetPubkey grouping (recentReactions.value[bob]); the aggregator now groups by sourcePubkey so the chip rises from the reactor's avatar. Renamed to ...GroupsBySender and assert under alice's key. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../amethyst/commons/viewmodels/NestViewModelTest.kt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/viewmodels/NestViewModelTest.kt b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/viewmodels/NestViewModelTest.kt index 59b7a91ca..18fd08dbf 100644 --- a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/viewmodels/NestViewModelTest.kt +++ b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/viewmodels/NestViewModelTest.kt @@ -313,7 +313,7 @@ class NestViewModelTest { } @Test - fun onReactionEventGroupsByTargetAndEvictsOnTick() = + fun onReactionEventGroupsBySenderAndEvictsOnTick() = runVmTest { val vm = newViewModel { FakeNestsListener() } val alice = "a".repeat(64) @@ -339,10 +339,13 @@ class NestViewModelTest { sig = "0".repeat(128), ) - // Two reactions land within the 30-s window. + // Two reactions sent BY alice land within the 30-s window. + // The aggregator groups by sender (so the floating chip + // rises from the reactor's avatar), NOT by the `p`-tag + // target — both land under alice's key. vm.onReactionEvent(rxn(alice, bob, "🔥", 100L), nowSec = 100L) vm.onReactionEvent(rxn(alice, bob, "👏", 105L), nowSec = 105L) - assertEquals(2, vm.recentReactions.value[bob]!!.size) + assertEquals(2, vm.recentReactions.value[alice]!!.size) // LocalCache.observeEvents re-emits the full matching list // on every cache mutation; the same kind-7 must collapse @@ -350,7 +353,7 @@ class NestViewModelTest { val replayed = rxn(alice, bob, "🔥", 100L, id = "f".repeat(64)) vm.onReactionEvent(replayed, nowSec = 105L) vm.onReactionEvent(replayed, nowSec = 105L) - assertEquals(3, vm.recentReactions.value[bob]!!.size) + assertEquals(3, vm.recentReactions.value[alice]!!.size) // Tick advances past the window — all reactions evicted. vm.evictReactions(olderThanSec = 200L)