From a3b4036627aa71ee5385baab1497ea801f6c3f45 Mon Sep 17 00:00:00 2001 From: Tobias Gesellchen Date: Sat, 5 Sep 2026 19:10:57 +0200 Subject: [PATCH] test(player): cover NowPlayingRevision advancing for both poll and event The rebase derives NowPlayingRevision from the existing FieldNowPlaying generation rather than a counter of its own. Nothing asserted that it advances down both paths that write the field, a completed poll and a push event, which is the property the player's readback loop depends on to tell a fresh now-playing write from an unrelated field's merge. Co-Authored-By: Claude Opus 5 (1M context) --- .../soundtouchweb/webtypes/revision_test.go | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/pkg/service/soundtouchweb/webtypes/revision_test.go b/pkg/service/soundtouchweb/webtypes/revision_test.go index 4b5d4f52..14946448 100644 --- a/pkg/service/soundtouchweb/webtypes/revision_test.go +++ b/pkg/service/soundtouchweb/webtypes/revision_test.go @@ -72,6 +72,29 @@ func TestUnrelatedProjectionDoesNotAdvanceNowPlayingRevision(t *testing.T) { } } +func TestNowPlayingRevisionAdvancesForPollAndEvent(t *testing.T) { + conn := NewDeviceConnection(nil, nil) + baseline := conn.Status().NowPlayingRevision + + generation := conn.BeginFieldPoll(FieldNowPlaying) + conn.CompleteFieldPoll(FieldNowPlaying, generation, func(status *DeviceStatus) { + status.NowPlaying = &models.NowPlaying{Source: "AUX"} + }) + + polled := conn.Status().NowPlayingRevision + if polled <= baseline { + t.Fatalf("now-playing revision after poll = %d, want newer than %d", polled, baseline) + } + + conn.ApplyFieldEvent(FieldNowPlaying, func(status *DeviceStatus) { + status.NowPlaying = &models.NowPlaying{Source: "SPOTIFY"} + }) + + if got := conn.Status().NowPlayingRevision; got <= polled { + t.Fatalf("now-playing revision after event = %d, want newer than %d", got, polled) + } +} + func TestDeviceStatusRevisionIsMonotonicWithConcurrentProjections(t *testing.T) { conn := NewDeviceConnection(nil, nil) const projections = 64