fix(coderd/x/chatd): deflake TestRunner_StartsRealRequiresActionTimeoutTask (#26343)

Addresses
https://github.com/coder/internal/issues/1588#issuecomment-4692645760
This commit is contained in:
Hugo Dutka
2026-06-12 15:47:20 +00:00
committed by GitHub
parent 3184ed9e9e
commit bc2d9b607b
+9 -6
View File
@@ -890,13 +890,16 @@ func (f *taskTestFixture) publishChatUpdate(t *testing.T, chat database.Chat) {
func (f *taskTestFixture) requireWatchEvent(t *testing.T, chatID uuid.UUID, kind codersdk.ChatWatchEventKind) {
t.Helper()
events := f.pubsub.watchEvents(t)
for _, event := range events {
if event.Kind == kind && event.Chat.ID == chatID {
return
// Watch events are published after the corresponding database update
// commits, so poll instead of asserting on a single snapshot.
testutil.Eventually(testutil.Context(t, testutil.WaitLong), t, func(_ context.Context) bool {
for _, event := range f.pubsub.watchEvents(t) {
if event.Kind == kind && event.Chat.ID == chatID {
return true
}
}
}
t.Fatalf("missing watch event kind=%s chat_id=%s events=%v", kind, chatID, events)
return false
}, testutil.IntervalFast)
}
func (f *taskTestFixture) requireNoWatchEvents(t *testing.T) {