df58710141
Two of the four defects on the task.
The stored payload was the whole utterance, so /reminders and the agenda
recited "напомни завтра в 9 утра выпить таблетки" where the reminder is
"выпить таблетки". The marker is an instruction that was already carried out
and the hour is already a column, so reminderBody strips both, and falls back
to the unstripped body whenever stripping would leave nothing — a reminder
that fires and says nothing is worse than a wordy one.
The page rendered the raw {"text":...} envelope and the UTC instant. Both are
now done in mavweb: reminderRows unwraps the payload and formats through
Local(). The unwrap is a copy of store.ReminderText rather than a call to it,
because mavweb builds without CGO and internal/store carries the sqlite
driver — the ipc DTOs are decoupled from the store on purpose.
TestClarifySubjectAnswerFillsRatherThanClobbers asserted the hour survived as
a word in the payload. It now asserts the fire time, which is where the hour
lives.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
47 lines
1.4 KiB
Go
47 lines
1.4 KiB
Go
package main
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/kami/maven/internal/ipc"
|
|
)
|
|
|
|
// The page showed the storage envelope and the UTC instant (Vikunja #469).
|
|
func TestReminderRowsUnwrapAndLocalise(t *testing.T) {
|
|
fire := time.Date(2026, 8, 4, 18, 30, 0, 0, time.UTC)
|
|
rows := reminderRows([]ipc.Reminder{{
|
|
CreatedTs: fire.Add(-time.Hour),
|
|
FireTs: fire,
|
|
Status: "pending",
|
|
Payload: `{"text":"выпить таблетки"}`,
|
|
}})
|
|
if len(rows) != 1 {
|
|
t.Fatalf("rows = %d, want 1", len(rows))
|
|
}
|
|
if rows[0].Text != "выпить таблетки" {
|
|
t.Errorf("Text = %q, want the words without the envelope", rows[0].Text)
|
|
}
|
|
if want := fire.Local().Format("02 Jan 15:04"); rows[0].Fires != want {
|
|
t.Errorf("Fires = %q, want %q", rows[0].Fires, want)
|
|
}
|
|
if strings.Contains(rows[0].Text, "{") {
|
|
t.Errorf("Text still carries JSON: %q", rows[0].Text)
|
|
}
|
|
}
|
|
|
|
// A payload that is not the envelope is his own words, so it is shown as it is.
|
|
func TestReminderTextKeepsPlainPayload(t *testing.T) {
|
|
for _, tc := range []struct{ in, want string }{
|
|
{`{"text":"позвонить маме"}`, "позвонить маме"},
|
|
{" полить цветы ", "полить цветы"},
|
|
{`{"body":"nope"}`, `{"body":"nope"}`},
|
|
{"", ""},
|
|
} {
|
|
if got := reminderText(tc.in); got != tc.want {
|
|
t.Errorf("reminderText(%q) = %q, want %q", tc.in, got, tc.want)
|
|
}
|
|
}
|
|
}
|