Files
felhom.eu/hub/internal/notify/templates_offbox_test.go
T
admin 08fef4872b hub v0.55.0: accept offbox_enlarge_blocked event (Task 3a-fix delivery chain)
allowedEventTypes gains offbox_enlarge_blocked (was 400 at ingestion, dropping the customer email).
Deliberate NON-change: no customerMessages entry — the static map would discard the controller's
dynamic two-number Hungarian message (templates.go:129 fallback is correct). event_test acceptance +
400 red-proof; templates_offbox_test locks the raw-message fallback. manifest bumped to :0.55.0.
2026-07-15 07:50:29 +02:00

32 lines
1.5 KiB
Go

package notify
import (
"strings"
"testing"
)
// TestFormatCustomerEmail_OffboxEnlargeBlockedRawMessageSurvives locks in the deliberate non-change
// (Task 3a-fix): offbox_enlarge_blocked has NO customerMessages entry, so FormatCustomerEmail falls
// back to the controller's raw dynamic Hungarian message (templates.go:129) — the two-number text
// (estimate + quota) reaches the customer intact. A static customerMessages entry would DISCARD it.
func TestFormatCustomerEmail_OffboxEnlargeBlockedRawMessageSurvives(t *testing.T) {
// exactly the shape the controller sends (NotifyOffboxEnlargeBlocked).
raw := "A(z) immich teljes távoli mentése (~42.0 GB) túllépné a tárhelykeretet (20/50 GB). " +
"A konfiguráció és az adatbázis továbbra is mentésre kerül; nagyobb kerethez vedd fel velünk a kapcsolatot."
// guard: the map must NOT gain an entry for this type (the trap).
if _, ok := customerMessages["offbox_enlarge_blocked"]; ok {
t.Fatal("offbox_enlarge_blocked must have NO customerMessages entry (it would discard the dynamic numbers)")
}
subject, body := FormatCustomerEmail("c1", "offbox_enlarge_blocked", "warning", raw, "")
for _, want := range []string{"~42.0 GB", "20/50 GB"} {
if !strings.Contains(body, want) {
t.Errorf("email body must carry the dynamic figure %q (raw message survived): %s", want, body)
}
}
if !strings.Contains(subject, "túllépné a tárhelykeretet") {
t.Errorf("subject must carry the raw message, got %q", subject)
}
}