issue 1859: the page shown after an act records nothing, so each act leaves one line
Review round 1 F1 (ADR 0517 §3, §5): a form act went back to the list or the pane, which recorded page opened or opened again, and the script's refresh did too, so last looked became the last act and opened counts grew. The redirect after an act carries acted=1 and the refresh an X-Mail-Refresh header; that page records nothing. The 1860 test now follows each redirect and counts every line, and reminds the task (F2, 1858/AC9), which the store's own integration test also reads back as a date.
This commit is contained in:
@@ -284,13 +284,31 @@ func TestPgStoreKeepsEachActWithItsLine(t *testing.T) {
|
||||
if err := s.Act(ctx, Handling{Entry: id, Item: "task 1", Handled: at}, ActionLine{What: ActHandled, Entry: id, Item: "task 1", Mode: "work", At: at}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// 1858/AC9 (review round 1 F2): a reminder's day, a date column written from midnight UTC, reads back the
|
||||
// same day.
|
||||
tomorrow := time.Date(2026, 10, 23, 0, 0, 0, 0, time.UTC)
|
||||
if err := s.Act(ctx, Handling{Entry: id, Item: ItemMail, ShowsAgain: tomorrow}, ActionLine{What: ActReminded, Entry: id, Item: ItemMail, Mode: "work", At: at}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
reminded := false
|
||||
if hs, err := s.Handlings(ctx); err == nil {
|
||||
for _, h := range hs {
|
||||
reminded = reminded || (h.Item == ItemMail && h.ShowsAgain.Equal(tomorrow) && h.Handled.IsZero())
|
||||
}
|
||||
}
|
||||
if !reminded {
|
||||
t.Fatal("the mail's reminder did not read back as 2026-10-23")
|
||||
}
|
||||
if err := s.Act(ctx, Handling{Entry: id, Item: ItemMail}, ActionLine{What: ActUndone, Entry: id, Item: ItemMail, Mode: "work", At: at}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.Act(ctx, Handling{Entry: id + 99, Item: ItemMail, Handled: at}, ActionLine{What: ActHandled, Entry: id + 99, Item: ItemMail, Mode: "work", At: at}); err != ErrNotFound {
|
||||
t.Fatalf("an act on no entry: %v, want ErrNotFound", err)
|
||||
}
|
||||
hs, _ := s.Handlings(ctx)
|
||||
lines, _ := s.Actions(ctx, 10)
|
||||
if len(hs) != 1 || !hs[0].Handled.Equal(at) || len(lines) != 1 || lines[0].Item != "task 1" {
|
||||
t.Fatalf("handlings %+v, lines %+v; want the one act and its one line", hs, lines)
|
||||
if len(hs) != 1 || !hs[0].Handled.Equal(at) || len(lines) != 3 || lines[2].Item != "task 1" {
|
||||
t.Fatalf("handlings %+v, lines %+v; want task 1 handled, and a line for each of the three acts", hs, lines)
|
||||
}
|
||||
e, _, _ := s.Entry(ctx, id)
|
||||
e.Mark = MarkNeither
|
||||
@@ -301,8 +319,8 @@ func TestPgStoreKeepsEachActWithItsLine(t *testing.T) {
|
||||
if lessons, _ := s.Lessons(ctx); len(lessons) != 1 {
|
||||
t.Fatalf("lessons %+v, want the correction's one", lessons)
|
||||
}
|
||||
if removed, err := s.RemoveActionsBefore(ctx, at.Add(30*time.Second)); err != nil || removed != 1 {
|
||||
t.Fatalf("removed %d (%v), want the one line older than the bound", removed, err)
|
||||
if removed, err := s.RemoveActionsBefore(ctx, at.Add(30*time.Second)); err != nil || removed != 3 {
|
||||
t.Fatalf("removed %d (%v), want the three lines older than the bound", removed, err)
|
||||
}
|
||||
if _, err := s.pool.Exec(ctx, `delete from mail_entry where id = $1`, id); err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
Reference in New Issue
Block a user