From d91d9712f7073b9b03cb96df6cbbc55c0d8807b3 Mon Sep 17 00:00:00 2001 From: Danielle Maywood Date: Fri, 6 Mar 2026 09:52:28 +0000 Subject: [PATCH] fix: use Eventually for web push dispatch assertion in chatd test (#22700) --- coderd/chatd/chatd_test.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/coderd/chatd/chatd_test.go b/coderd/chatd/chatd_test.go index 94f9b5b742..7f307b57b9 100644 --- a/coderd/chatd/chatd_test.go +++ b/coderd/chatd/chatd_test.go @@ -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.