test(notifications): pin recovery wording in received webhook payloads

Recovery notifications must describe the healthy state rather than repeat the original breach. Existing Telegram and Discord receiver tests checked resolved markers and colours but did not protect that distinction, allowing misleading recovery wording to regress unnoticed.

Assert healthy wording and absence of the breach message in received payloads, and preserve the original alert message. This is test-only regression protection; it does not establish external provider acceptance or installed recovery.

Validation: go test -race ./internal/notifications -run 'Test(SendResolvedWebhook|ResolvedJobs|BuildResolvedNotificationContent)' -count=3 passed.

Change-source: pulse-maintainer
This commit is contained in:
pulse-triage[bot]
2026-09-05 10:31:48 +01:00
parent 58413ebdf6
commit 6c65396376
@@ -4155,6 +4155,12 @@ func TestSendResolvedWebhookServiceTemplates(t *testing.T) {
if !strings.Contains(text, "Resolved") {
t.Errorf("expected 'Resolved' in text, got %q", text)
}
if !strings.Contains(text, "web-vm-01 on pve1 is now healthy") || strings.Contains(text, testAlert.Message) {
t.Errorf("recovery text must describe recovery, not the original breach: %q", text)
}
if testAlert.Message != "CPU high on web-vm-01" {
t.Fatal("rendering recovery mutated the original alert message")
}
})
t.Run("discord resolved uses green embed color", func(t *testing.T) {
@@ -4190,6 +4196,10 @@ func TestSendResolvedWebhookServiceTemplates(t *testing.T) {
t.Fatal("expected at least one embed")
}
embed := embeds[0].(map[string]any)
description, _ := embed["description"].(string)
if !strings.Contains(description, "web-vm-01 on pve1 is now healthy") || strings.Contains(description, testAlert.Message) {
t.Errorf("recovery description must describe recovery, not the original breach: %q", description)
}
// Green color = 3066993
if embed["color"] != float64(3066993) {
t.Errorf("expected green embed color 3066993, got %v", embed["color"])