release / web (push) Failing after 1m29s
release / go (push) Successful in 1m55s
release / govulncheck (push) Successful in 19s
release / integration (push) Successful in 4m22s
release / android (push) Successful in 4m57s
release / Attach APK to the Release (tag releases only) (push) Canceled after 0s
release / Build + push container image (push) Canceled after 0s
release / Verify release artifacts (tag releases only) (push) Canceled after 0s
release / Build signed APK (push) Canceled after 4m23s
Request notifications (approved, declined, completed, pending) are removed
along with the request flow that produced them. A new_music kind takes the
"new music arrived" slot: when a scan or a watcher batch finishes, the
scanner claims every album not yet announced (albums.announced_at) and tells
every user about the ones that are new: an album with a track on disk and
no track older than itself. The first import into an empty library, and an
album formed only by retagging tracks already held, announce nothing. One
notice per scan, carrying up to 50 albums and the total; it is never
coalesced, so a notice already emailed can't quietly absorb later arrivals.
It feeds the daily summary email, grouped by artist. Defaults: inbox and
email on, phone off.
Migration 0103 deletes request-kind notification rows and prefs, swaps the
kind CHECKs to new_music, and adds albums.announced_at with every album
held marked announced, so the first scan after it announces nothing old.
Web and Android: labels, the Android "Requests" settings section becomes
"New music", the shade channel your_requests becomes new_music (the old one
is deleted at startup), and "/" opens Home in the app. TrackLabel moves to
the notifications package. docs/smart-music-{server,client}-spec.md are
deleted per the operator; an Android comment loses the word "exchanges".
Grimoire #7666, #7671.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
65 lines
2.3 KiB
Go
65 lines
2.3 KiB
Go
package notifications
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestEffective_PhoneAndEmailRideOnInbox(t *testing.T) {
|
|
cases := []struct {
|
|
in, want Channels
|
|
}{
|
|
{Channels{true, true, true}, Channels{true, true, true}},
|
|
{Channels{true, false, true}, Channels{true, false, true}},
|
|
{Channels{false, true, true}, Channels{false, false, false}},
|
|
{Channels{false, false, false}, Channels{false, false, false}},
|
|
}
|
|
for _, c := range cases {
|
|
require.Equal(t, c.want, c.in.Effective(), "in=%+v", c.in)
|
|
}
|
|
}
|
|
|
|
// The display order and the spec table must name the same kinds, or a kind
|
|
// is either unreachable from settings or has no behaviour.
|
|
func TestKinds_OrderAndSpecsAgree(t *testing.T) {
|
|
require.Len(t, order, len(specs))
|
|
seen := map[Kind]bool{}
|
|
for _, k := range Kinds() {
|
|
require.True(t, k.Valid(), "%s in order but not in specs", k)
|
|
require.False(t, seen[k], "%s listed twice", k)
|
|
seen[k] = true
|
|
}
|
|
}
|
|
|
|
func TestKinds_HealthKindsStayOutOfEmailAndCoalesce(t *testing.T) {
|
|
// The burst-prone health kinds stay out of email unless an admin opts in.
|
|
for _, k := range []Kind{KindScanFailed, KindTracksMissing, KindDuplicatesFound, KindDuplicatesResolved, KindPlaybackErrors} {
|
|
require.True(t, k.AdminOnly(), k)
|
|
require.False(t, k.Defaults().Email, k)
|
|
require.NotEmpty(t, k.coalesceKey(), "%s should coalesce", k)
|
|
}
|
|
}
|
|
|
|
// New music reaches everyone, goes out in the daily summary, and never buzzes
|
|
// a phone unless the user asks. Each scan's notice is its own row, so a
|
|
// notice that was already emailed never silently absorbs later arrivals.
|
|
func TestKinds_NewMusicIsForEveryoneAndDailyByEmail(t *testing.T) {
|
|
require.False(t, KindNewMusic.AdminOnly())
|
|
require.Equal(t, EmailSummary, KindNewMusic.EmailGroup())
|
|
require.Equal(t, Channels{Inbox: true, Email: true}, KindNewMusic.Defaults())
|
|
require.Empty(t, KindNewMusic.coalesceKey())
|
|
require.Equal(t, EmailBatch, KindQuarantineFlagged.EmailGroup())
|
|
}
|
|
|
|
func TestNotify_NilNotifierIsANoOp(t *testing.T) {
|
|
var n *Notifier
|
|
require.NoError(t, n.Notify(context.Background(), KindNewMusic, Recipients{}, nil))
|
|
}
|
|
|
|
func TestNotify_UnknownKindIsRefusedBeforeTouchingTheDB(t *testing.T) {
|
|
n := New(nil, nil, nil)
|
|
require.Error(t, n.Notify(context.Background(), Kind("bogus"), Recipients{}, nil))
|
|
}
|