This commit is contained in:
ponzischeme89
2026-08-27 15:50:15 +12:00
parent 6b2bf767e2
commit 2f4bd0da31
19 changed files with 456 additions and 144 deletions
@@ -4,6 +4,7 @@ import (
"testing"
"github.com/ponzischeme89/memby/server/internal/appupdate"
"github.com/ponzischeme89/memby/server/internal/sonarr"
"github.com/ponzischeme89/memby/server/internal/store"
)
@@ -81,3 +82,45 @@ func TestClearableNotificationIDsHonourPreferences(t *testing.T) {
t.Fatalf("an empty list should clear nothing, got %v", ids)
}
}
func TestNotificationResponsesShowRemoveMyShowsActionOnlyForCurrentFollow(t *testing.T) {
shows := []store.UserShow{
{ItemID: "emby-1", Title: "The Peripheral", Year: intPtr(2022)},
{ItemID: "emby-2", Title: "Shogun", Year: intPtr(2024)},
}
series := []sonarr.Series{
{ID: 10, TVDBID: 123, Title: "The Peripheral", Year: 2022},
{ID: 11, TVDBID: 456, Title: "Shogun", Year: 2024},
}
notifications := []store.UserNotification{
{ID: 1, Kind: "show-cancelled", SourceKey: "show-cancelled:tvdb:123:9", Title: "The Peripheral - Cancelled"},
{ID: 2, Kind: "show-cancelled", SourceKey: "show-cancelled:tvdb:999:8", Title: "Unknown Show - Cancelled"},
{ID: 3, Kind: "show-return", SourceKey: "show-return:emby-2:2026-08-27", Title: "Shogun returns"},
}
got := notificationResponses(notifications, shows, series)
if got[0].Action == nil {
t.Fatalf("cancelled followed show should offer an action: %#v", got[0])
}
if got[0].Action.Kind != "remove-my-show" || got[0].Action.Label != "Remove from My Shows" {
t.Fatalf("unexpected action = %#v", got[0].Action)
}
if got[0].ItemID != "emby-1" {
t.Fatalf("cancelled followed show item = %q, want emby-1", got[0].ItemID)
}
if got[1].Action != nil {
t.Fatalf("unfollowed cancelled show should not offer an action: %#v", got[1])
}
if got[2].Action != nil {
t.Fatalf("non-cancelled notification should not offer an action: %#v", got[2])
}
}
func TestCancelledNotificationCopy(t *testing.T) {
if got := cancelledNotificationTitle("The Peripheral"); got != "The Peripheral - Cancelled" {
t.Fatalf("title = %q", got)
}
if got := cancelledNotificationBody("The Peripheral"); got != "The Peripheral has been cancelled by the network." {
t.Fatalf("body = %q", got)
}
}