// The catch-up holds the batch open until its end, so the two messages
// form one batch also on a slow machine.
require.True(t, fake.Emit(&events.Connected{}))
// The catch-up holds the batch open until its end, so the two messages
// form one batch also on a slow machine.
require.True(t, fake.Emit(&events.Connected{}))
at := time.Date(2026, 1, 1, 12, 0, 0, 0, time.UTC)
require.True(t, fake.Emit(whatsappTestMessage(whatsappTestAna, whatsappTestAna, "m1", "Are you at home?", at)))
require.True(t, fake.Emit(whatsappTestMessage(whatsappTestAna, whatsappTestOwn, "m2", "Yes", at)))
at := time.Date(2026, 1, 1, 12, 0, 0, 0, time.UTC)
require.True(t, fake.Emit(whatsappTestMessage(whatsappTestAna, whatsappTestAna, "m1", "Are you at home?", at)))
require.True(t, fake.Emit(whatsappTestMessage(whatsappTestAna, whatsappTestOwn, "m2", "Yes", at)))
text := "[WhatsApp] Family, group 120363000000000001@g.us, Thursday 2026-01-01\n" + tc.line
if tc.turn {
text += "\n" + whatsappBatchEmptyReply
text := "[WhatsApp] Family, group 120363000000000001@g.us, Thursday 2026-01-01\n" + tc.line
if tc.turn {
text += "\n" + whatsappBatchEmptyReply
client.WaitFor(t, "[done]")
require.Equal(t, 1, server.Calls())
} else {
client.WaitFor(t, "[done]")
require.Equal(t, 1, server.Calls())
} else {
at := time.Date(2026, 1, 1, 8, 0, 0, 0, time.UTC)
for index, event := range []*events.Message{
whatsappTestMessage(whatsappTestAna, whatsappTestAna, "m1", "Good morning", at),
at := time.Date(2026, 1, 1, 8, 0, 0, 0, time.UTC)
for index, event := range []*events.Message{
whatsappTestMessage(whatsappTestAna, whatsappTestAna, "m1", "Good morning", at),
time.Sleep(100 * time.Millisecond)
require.Equal(t, 1, server.Calls())
time.Sleep(100 * time.Millisecond)
require.Equal(t, 1, server.Calls())
for _, text := range []string{"Good morning", "Call me", "Are you there?"} {
require.Contains(t, string(server.Call(0).raw), text)
}
for _, text := range []string{"Good morning", "Call me", "Are you there?"} {
require.Contains(t, string(server.Call(0).raw), text)
}
func TestWhatsAppStateOfTheStateFileWaitForTheCatchup(t *testing.T) {
dir := t.TempDir()
whatsappTestSession(t, dir, true)
func TestWhatsAppStateOfTheStateFileWaitForTheCatchup(t *testing.T) {
dir := t.TempDir()
whatsappTestSession(t, dir, true)
before, _, _ := whatsappStartTest(t, dir, newTestClock())
_, err := before.state.Add(whatsappTestChat, WhatsAppMessage{
ID: "m1",
before, _, _ := whatsappStartTest(t, dir, newTestClock())
_, err := before.state.Add(whatsappTestChat, WhatsAppMessage{
ID: "m1",