v0.297.0: burn-down round 2 — 24 small rows (R-591 R-568 R-567 R-363 R-547 R-10 R-552 R-251 R-104 R-619 R-362 R-675 R-256 R-257 R-240 R-365 R-425 R-565 R-564 R-603 R-454 R-208 R-457-swept) + the banner countdown and deepCopyStack twins; MinAgent 0.131.0
gates / gates (push) Failing after 50s
gates / gates (push) Failing after 50s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"gitea.dooplex.hu/admin/felhom-controller/internal/settings"
|
||||
)
|
||||
|
||||
// R-365 follow-up: at 0 days left the reminder bar's `{{if .RecoveryAbandonDays}}` is false, so a
|
||||
// countdown whose due moment had PASSED fell back to the undecided-box reminder text — the deletion
|
||||
// vanished from the bar on the very day it is due — and offered „Ne emlékeztessen újra" over it. The
|
||||
// consequence asserted through the real data path (addRecoveryBanner, reading a real countdown from
|
||||
// settings) and the real layout: the bar says the deletion is due since the date, and offers no
|
||||
// reminder opt-out; a running countdown (negative control) still says „N nap múlva".
|
||||
func TestR365_BannerSaysDueAtZeroDays(t *testing.T) {
|
||||
render := func(t *testing.T, due time.Time) string {
|
||||
f := newRecoveryFixture(t)
|
||||
if err := f.sett.SetOffboxTarget(&settings.OffboxTarget{
|
||||
Enabled: true, Host: "nas.local", Port: 22, User: "felhom", RepoPath: "/srv/repo",
|
||||
Schedule: "daily", EscrowState: "escrowed",
|
||||
AbandonAt: due.UTC().Format(time.RFC3339), AbandonStartedAt: due.Add(-30 * 24 * time.Hour).UTC().Format(time.RFC3339),
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
f.s.recoveryInterrupts() // advances the situation's epoch, exactly as the landing page does
|
||||
rr := httptest.NewRecorder()
|
||||
f.s.backupsRemoteHandler(rr, httptest.NewRequest(http.MethodGet, "/backups/remote", nil))
|
||||
body := rr.Body.String()
|
||||
i := strings.Index(body, `alert-banner alert-banner-warning`)
|
||||
if i < 0 {
|
||||
t.Fatalf("setup: the reminder bar did not render (status %d)", rr.Code)
|
||||
}
|
||||
j := strings.Index(body[i:], "</div>\n</div>")
|
||||
if j < 0 {
|
||||
j = len(body) - i
|
||||
}
|
||||
return body[i : i+j]
|
||||
}
|
||||
|
||||
overdue := time.Now().Add(-20 * time.Hour)
|
||||
bar := render(t, overdue)
|
||||
if !strings.Contains(bar, "óta esedékes") || !strings.Contains(bar, overdue.UTC().Format("2006-01-02")) {
|
||||
t.Errorf("R-365: at 0 days the bar does not say the deletion is due:\n%s", bar)
|
||||
}
|
||||
if strings.Contains(bar, "remind-optout") {
|
||||
t.Errorf("R-365: at 0 days the bar offers to stop reminders over a due deletion")
|
||||
}
|
||||
|
||||
bar = render(t, time.Now().Add(2*24*time.Hour+time.Hour))
|
||||
if !strings.Contains(bar, "nap múlva") || strings.Contains(bar, "óta esedékes") {
|
||||
t.Errorf("a running countdown must keep its „N nap múlva” sentence:\n%s", bar)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user