fix: use Eventually for web push dispatch assertion in chatd test (#22700)

This commit is contained in:
Danielle Maywood
2026-03-06 09:52:28 +00:00
committed by GitHub
parent 48ab492f49
commit d91d9712f7
+6 -2
View File
@@ -1542,8 +1542,12 @@ func TestSuccessfulChatSendsWebPushWithNavigationData(t *testing.T) {
return fromDB.Status == database.ChatStatusWaiting && !fromDB.WorkerID.Valid
}, testutil.IntervalFast)
// Verify a web push notification was dispatched exactly once.
require.Equal(t, int32(1), mockPush.dispatchCount.Load(),
// Wait for a web push notification to be dispatched. The dispatch
// happens asynchronously after the DB status is updated, so we need
// to poll rather than assert immediately.
testutil.Eventually(ctx, t, func(ctx context.Context) bool {
return mockPush.dispatchCount.Load() == 1
}, testutil.IntervalFast,
"expected exactly one web push dispatch for a completed chat")
// Verify the notification was sent to the correct user.