Files
mesh-catalog/modules/mesh-mail-web/internal/web/mailreading_integration_test.go
T
jochen ad4f312263 issue 1859: open the mail page on the operator's list (1859.1)
ADR 0515 §1, §5: / greets the operator with what the mail signal told today and when they last looked, then
shows today, this week, later, the promises by kind, good to know, read later, handled today and the scam
warnings, from mail-reading.list; it records the page opened. The classical list moves to /all, as All mail.
2026-10-22 20:03:21 +02:00

55 lines
2.3 KiB
Go

//go:build integration
package web
// Design 59 test 16's page half (novox/hq ADR 0459 §12, §13; issue 1524, split from 1431): mesh-mail-web
// started whole, its stand-in mail-reading.status answering unhealthy with a cause, shows that cause above
// the classical list, which still renders. Reuses issue 1285's own harness, its stand-in seat extended to
// mail-reading by issue 1523 (standInMailReading, runtime_integration_test.go). Compiled by
// `go vet -tags integration ./...`; never run on this machine — the lead's try runs it for real.
import (
"io"
"net/http"
"strings"
"testing"
)
// 1524/AC3: mesh-mail-web started whole, its stand-in mail-reading.status answering unhealthy with a
// cause, shows that cause above the classical list, and the list's accounts still render.
func TestAcceptanceUnhealthyMailReadingShowsItsCauseAboveTheStillRenderingList(t *testing.T) {
mw := startMailWeb(t, acceptanceAccounts(), []string{"alice"})
mw.store.Accounts = func(map[string]any) (any, error) {
return map[string]any{"accounts": []map[string]any{
{"account": "a", "kind": "imap", "address": "a@example.org", "state": "current"},
}}, nil
}
mw.mailReading.Status = func(map[string]any) (any, error) {
return map[string]any{"healthy": false, "cause": "refused", "why": "holds no licence", "since": "2026-10-20T09:30:00Z"}, nil
}
mw.mailReading.Entries = func(map[string]any) (any, error) {
return map[string]any{"entries": []map[string]any{}}, nil
}
mw.mailReading.Lessons = func(map[string]any) (any, error) {
return map[string]any{"lessons": []map[string]any{}}, nil
}
cookie := signIn(t, mw, "alice", "/")
page := doWithCookie(t, mw, http.MethodGet, "/all", nil, cookie)
body, _ := io.ReadAll(page.Body)
_ = page.Body.Close()
if page.StatusCode != http.StatusOK {
t.Fatalf("the accounts page: status %d: %s", page.StatusCode, body)
}
if !strings.Contains(string(body), "Unhealthy") || !strings.Contains(string(body), "refused") ||
!strings.Contains(string(body), "2026-10-20T09:30:00Z") {
t.Fatalf("the page does not show the cause and since when:\n%s", body)
}
// The classical list — accounts a and c — still renders in full (design 59 test 16; ADR 0459 §13:
// "the classical list always opens").
if !strings.Contains(string(body), "a@example.org") {
t.Fatalf("the classical list did not render:\n%s", body)
}
}