+ require.Equal(t, "new WhatsApp messages wait, because the first connection failed (the next try is automatic)\n", logs.String())
+}
+
+func TestWhatsAppLogsEachChangeOfTheConnectionOnce(t *testing.T) {
+ dir := t.TempDir()
+ whatsappTestSession(t, dir, true)
+ clock := newTestClock()
+ whatsapp, fake, logs := whatsappStartTest(t, dir, clock)
+ daemonStartTestWithWhatsApp(t, newModelFake(t), nil, whatsapp)
+
+ <-fake.connects
+ require.True(t, fake.Emit(&events.Connected{}))
+ clock.now = clock.now.Add(time.Minute)
+ require.True(t, fake.Emit(&events.Disconnected{}))
+ clock.now = clock.now.Add(time.Minute)
+ require.True(t, fake.Emit(&events.Disconnected{}))
+ clock.now = clock.now.Add(25 * time.Second)
+ require.True(t, fake.Emit(&events.Connected{}))
+
+ require.Equal(t, []string{
+ "WhatsApp is connected, and new messages come in",
+ "new WhatsApp messages wait, because the connection is lost (the next try is automatic)",
+ "WhatsApp is connected again, after 1m25s",
+ }, strings.Split(strings.TrimSuffix(logs.String(), "\n"), "\n"))
+ require.NotContains(t, logs.String(), whatsappTestNumber)
+ require.NotContains(t, logs.String(), whatsappTestLID)