Files
Maven/cmd/mavend/reminder_confirm_test.go
T
claude 69ecea19d5 reminders: confirm from the row, not from the sentence (V-507)
The confirmation was phrased by the replier off Slots.Text, so it named
whatever hour the utterance contained — including one the parser rejected
or read differently. He heard 'напомню в семь' with no row at seven, and
stopped thinking about it.

actionReminder now phrases it itself from the stored fire time, so the
sentence and the row cannot disagree. Deterministic: the one sentence that
must match a database row is not one to hand to a 1.7B.

Also fixes formatTime, which had t.Format("2 января") — Go reads that as a
literal, so every fact older than a day read as January. The month comes
from internal/lexicon now, which is where months live.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-05 01:48:18 +04:00

52 lines
1.9 KiB
Go

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)
}
}