]> git.giacomolli.uk - onechat/blobdiff - whatsapp_import_test.go
Queue external data for the next root turn
[onechat] / whatsapp_import_test.go
index 553a2cbc288cc365a99a98a72fbb0149fd91b962..382d4bf8e8839cf7bd619254afb8d85f359e228b 100644 (file)
@@ -704,6 +704,27 @@ func TestWhatsAppImportRefusesPendingDeliveriesAndKeepsRestartSafe(t *testing.T)
        }
 }
 
        }
 }
 
+func TestWhatsAppImportBlocksPendingNotificationsButNotCompletedReceipts(t *testing.T) {
+       server := newModelFake(t)
+       test := newDaemonMessageTest(t, t.TempDir(), server)
+       _, err := test.messages.Notify(&NotifyInput{
+               Source: "check",
+               ID:     "1",
+               Text:   "A result.",
+       })
+       require.NoError(t, err)
+
+       root := test.agents[0].agent
+       directory := root.dir
+       require.ErrorContains(t, whatsappImportIdle(directory, root), "pending deliveries")
+       require.NoError(t, whatsappImportIdle(directory, test.agents[1].agent))
+       require.NoError(t, test.messages.Notifications(test.loops[0]))
+       require.NoError(t, test.loops[0].turn(t.Context()))
+       require.Len(t, test.Queue(t).Notifications, 1)
+       require.Empty(t, test.Queue(t).Pending)
+       require.NoError(t, whatsappImportIdle(directory, root))
+}
+
 func TestWhatsAppImportPendingDeliveriesBlockOnlyTheirTarget(t *testing.T) {
        dir := t.TempDir()
        t.Setenv("ONECHAT_DIR", dir)
 func TestWhatsAppImportPendingDeliveriesBlockOnlyTheirTarget(t *testing.T) {
        dir := t.TempDir()
        t.Setenv("ONECHAT_DIR", dir)