]> git.giacomolli.uk - onechat/blobdiff - whatsapp_import_test.go
Describe queued event delivery boundaries
[onechat] / whatsapp_import_test.go
index 4bd0a1f3354db5b41b2bab288f9af598cd4343bd..382d4bf8e8839cf7bd619254afb8d85f359e228b 100644 (file)
@@ -486,6 +486,7 @@ func TestWhatsAppImportChildPlanReadsRootCutoffButNotRootImportedDays(t *testing
                        Date: "2025-01-03T10:20:00Z",
                },
        })
+
        rebuildTestLog(t, childDir, []DatedMessage{
                {
                        Kind: "work",
@@ -529,6 +530,7 @@ func TestWhatsAppImportChildRebuildUsesOwnPromptAndCache(t *testing.T) {
                Text: "Keep the root history.",
                Date: "2025-02-01T00:00:00Z",
        }})
+
        rebuildTestLog(t, childDir, []DatedMessage{{
                Kind: "user",
                Text: "Keep the child history.",
@@ -702,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)