package main import ( "strings" "testing" "time" ) // A reminder confirmation is the one sentence that must match a database row. // It used to be phrased by the replier from Slots.Text, which meant it named // whatever hour the sentence contained — including an hour the parser had // rejected or read differently (Vikunja #507). func TestReminderConfirmNamesTheStoredHour(t *testing.T) { now := time.Date(2026, 8, 5, 9, 0, 0, 0, time.UTC) got := reminderConfirm(now.Add(10*time.Hour), now) // 19:00 today if !strings.Contains(got, "19:00") { t.Fatalf("confirmation = %q, want the stored 19:00 in it", got) } if !strings.Contains(got, "сегодня") { t.Fatalf("confirmation = %q, want it to say сегодня", got) } } func TestReminderConfirmUsesADateBeyondTheDayWords(t *testing.T) { // dayPrefix answers "это" past послезавтра, and "напомню это в 09:00" is // not a sentence. A date is. now := time.Date(2026, 8, 5, 9, 0, 0, 0, time.UTC) got := reminderConfirm(now.Add(10*24*time.Hour), now) if strings.Contains(got, "это") { t.Fatalf("confirmation = %q, want a date rather than the fallback day word", got) } if !strings.Contains(got, "15 августа") { t.Fatalf("confirmation = %q, want the date in it", got) } } func TestReminderConfirmIsFeminineAndInformal(t *testing.T) { // The persona checks the phrasing eval enforces apply here too, and this // sentence never passes through a phraser. now := time.Date(2026, 8, 5, 9, 0, 0, 0, time.UTC) got := reminderConfirm(now.Add(time.Hour), now) for _, bad := range []string{"вы", "ваш", "напомнил ", "рад "} { if strings.Contains(strings.ToLower(got), bad) { t.Fatalf("confirmation = %q contains %q", got, bad) } } if !strings.HasPrefix(got, "хорошо, напомню") { t.Fatalf("confirmation = %q, want it to open with the promise", got) } }