GRI-2147: fail-first acceptance test for playlist default-duration inheritance #281

Merged
vivy merged 7 commits from test/GRI-2147-playlist-default-duration-inheritance into dev 2026-11-16 18:08:47 +00:00
Member

Summary

Fail-first acceptance test for forge #277 / GRI-2147 ("Playlist ignores a later change of the default playtime"), written from the forge issue's own "Fix" and "Done when" text, before nyssa's implementation — same convention as settings_playback_acceptance_integration.rs.

One test, a_global_default_change_reaches_an_inheriting_playlist_but_not_an_overridden_one in crates/server/tests/ws_integration.rs, covering the issue's "Done when" verbatim as one scenario:

  • a playlist created at the then-current global default (10s) must pick up a later global default change (to 20s) on its assigned device, without the playlist's own row being touched (verified: default_duration_seconds stays NULL in the DB, not silently pinned to 20);
  • a playlist carrying its own override (15s) must keep that value through the same change, and gets no spurious re-push.

Both halves are one test because only together do they fail first for the right reason: the "own override survives" half already holds on dev today, by accident — nothing today reacts to a playback-settings change at all, for any playlist. It's the inheriting half that cannot even be set up without the schema change, so that's where the test fails: playlists.default_duration_seconds is NOT NULL today, so inserting the fixture playlist with no override fails on that constraint — a Postgres 23502 not_null_violation, not a made-up assertion.

Deliberately independent of nyssa's wire-contract proposal (comment 14113 on forge #277): the open question there is the admin-facing GET/PUT /playlists/{id} JSON shape, which this test never touches — it drives playlists.default_duration_seconds directly (insert_playlist, the same shortcut insert_approved_device already takes for /devices), so it proves the resolve-at-push-time and re-push behaviour regardless of what that contract ends up being.

Fail-first run

SIGNAGE_TEST_DATABASE_URL=postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable \
  cargo test -p server --test ws_integration \
  a_global_default_change_reaches_an_inheriting_playlist_but_not_an_overridden_one -- --include-ignored --nocapture
thread 'a_global_default_change_reaches_an_inheriting_playlist_but_not_an_overridden_one' panicked at crates/server/tests/ws_integration.rs:1868:6:
inserting the playlist must succeed; a None default_duration_seconds fails here on the column's NOT NULL constraint until GRI-2147 makes it nullable: Database(PgDatabaseError { severity: Error, code: "23502", message: "null value in column \"default_duration_seconds\" of relation \"playlists\" violates not-null constraint", ... })
test a_global_default_change_reaches_an_inheriting_playlist_but_not_an_overridden_one ... FAILED

The other 15 tests in the same file still pass unmodified.

Criterion-to-test mapping

"Done when" clause Test
"playlist created at default 10 s, global default changed to 20 s, the device receives 20 s without touching the playlist" first half of a_global_default_change_reaches_an_inheriting_playlist_but_not_an_overridden_one
"A playlist with its own value keeps it" second half of the same test

Not covered here (out of scope for this PR, flagged on the forge issue): the campus-override half of "Fix" bullet 3 (only global is in "Done when"); the PPTX-bake-in-at-upload question (nyssa already scoped that out, conflicting with feature/GRI-2011-pptx-to-slide-images); and a migration-backfill test for existing rows (no migration file exists yet to test against).

Test plan

  • cargo fmt -- --check crates/server/tests/ws_integration.rs
  • cargo clippy -p server --tests --all-features -- -D warnings
  • cargo test -p server --test ws_integration -- --include-ignored (15 passed, 1 new fail-first failure, as expected)
## Summary Fail-first acceptance test for forge #277 / GRI-2147 ("Playlist ignores a later change of the default playtime"), written from the forge issue's own "Fix" and "Done when" text, before nyssa's implementation — same convention as `settings_playback_acceptance_integration.rs`. One test, `a_global_default_change_reaches_an_inheriting_playlist_but_not_an_overridden_one` in `crates/server/tests/ws_integration.rs`, covering the issue's "Done when" verbatim as one scenario: - a playlist created at the then-current global default (10s) must pick up a later global default change (to 20s) on its assigned device, **without the playlist's own row being touched** (verified: `default_duration_seconds` stays `NULL` in the DB, not silently pinned to 20); - a playlist carrying its own override (15s) must keep that value through the same change, and gets no spurious re-push. Both halves are one test because only together do they fail first for the right reason: the "own override survives" half already holds on `dev` today, by accident — nothing today reacts to a playback-settings change at all, for any playlist. It's the inheriting half that cannot even be set up without the schema change, so that's where the test fails: `playlists.default_duration_seconds` is `NOT NULL` today, so inserting the fixture playlist with no override fails on that constraint — a Postgres `23502 not_null_violation`, not a made-up assertion. Deliberately independent of nyssa's wire-contract proposal (comment 14113 on forge #277): the open question there is the admin-facing `GET`/`PUT /playlists/{id}` JSON shape, which this test never touches — it drives `playlists.default_duration_seconds` directly (`insert_playlist`, the same shortcut `insert_approved_device` already takes for `/devices`), so it proves the resolve-at-push-time and re-push behaviour regardless of what that contract ends up being. ## Fail-first run ``` SIGNAGE_TEST_DATABASE_URL=postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable \ cargo test -p server --test ws_integration \ a_global_default_change_reaches_an_inheriting_playlist_but_not_an_overridden_one -- --include-ignored --nocapture ``` ``` thread 'a_global_default_change_reaches_an_inheriting_playlist_but_not_an_overridden_one' panicked at crates/server/tests/ws_integration.rs:1868:6: inserting the playlist must succeed; a None default_duration_seconds fails here on the column's NOT NULL constraint until GRI-2147 makes it nullable: Database(PgDatabaseError { severity: Error, code: "23502", message: "null value in column \"default_duration_seconds\" of relation \"playlists\" violates not-null constraint", ... }) test a_global_default_change_reaches_an_inheriting_playlist_but_not_an_overridden_one ... FAILED ``` The other 15 tests in the same file still pass unmodified. ## Criterion-to-test mapping | "Done when" clause | Test | | --- | --- | | "playlist created at default 10 s, global default changed to 20 s, the device receives 20 s without touching the playlist" | first half of `a_global_default_change_reaches_an_inheriting_playlist_but_not_an_overridden_one` | | "A playlist with its own value keeps it" | second half of the same test | Not covered here (out of scope for this PR, flagged on the forge issue): the campus-override half of "Fix" bullet 3 (only global is in "Done when"); the PPTX-bake-in-at-upload question (nyssa already scoped that out, conflicting with `feature/GRI-2011-pptx-to-slide-images`); and a migration-backfill test for existing rows (no migration file exists yet to test against). ## Test plan - [x] `cargo fmt -- --check crates/server/tests/ws_integration.rs` - [x] `cargo clippy -p server --tests --all-features -- -D warnings` - [x] `cargo test -p server --test ws_integration -- --include-ignored` (15 passed, 1 new fail-first failure, as expected)
GRI-2147: fail-first acceptance test for playlist default-duration inheritance
Some checks failed
CI / the pre-push hook (pull_request) Successful in 4s
CI / install.sh client upgrade (pull_request) Successful in 14s
CI / cargo fmt (pull_request) Successful in 6s
CI / cargo deny (pull_request) Successful in 23s
CI / cargo deny advisories (pull_request) Successful in 19s
CI / cargo clippy (pull_request) Successful in 1m15s
CI / repository boundary (pull_request) Successful in 4s
CI / frontend-web (pull_request) Successful in 1m12s
CI / cargo test (pull_request) Failing after 3m42s
CI / CI (pull_request) Failing after 2s
CI / Notify gate failed (pull_request) Successful in 1s
13414d52fe
Owner

Good test, and it fails for the right reason. It cannot merge on its own: a red cargo test on dev breaks the rule that dev stays green. Land it together with the #277 fix: the implementation goes on top of this branch (or this commit is taken into the fix branch), and the PR merges when cargo test is green.

Good test, and it fails for the right reason. It cannot merge on its own: a red cargo test on dev breaks the rule that dev stays green. Land it together with the #277 fix: the implementation goes on top of this branch (or this commit is taken into the fix branch), and the PR merges when cargo test is green.
GRI-2147: resolve a playlist's default playtime at push time
Some checks failed
CI / cargo fmt (pull_request) Successful in 3s
CI / the pre-push hook (pull_request) Successful in 4s
CI / install.sh client upgrade (pull_request) Successful in 12s
CI / cargo deny (pull_request) Successful in 10s
CI / cargo deny advisories (pull_request) Successful in 20s
CI / repository boundary (pull_request) Successful in 6s
CI / cargo clippy (pull_request) Successful in 1m14s
CI / frontend-web (pull_request) Successful in 1m13s
CI / CI (pull_request) Has been cancelled
CI / Notify gate failed (pull_request) Has been cancelled
CI / cargo test (pull_request) Failing after 3m16s
1768d12337
playlists.default_duration_seconds becomes nullable. NULL means inherit
the campus override (if any) or else the global default, resolved fresh
in build_wire_playlist every time a playlist reaches a device, instead
of snapshotting a value at create time that a later default change can
never reach. Every existing row is migrated to NULL (0011): there is no
way to tell a deliberate override from a value that happened to match
the default in effect, so all of them are treated as inherited.

A change to the global default (put_global) or a campus override (set
or cleared, put_campus) now re-pushes every playlist currently
inheriting it, via two new lookups in playlists::store. GET/PUT
/playlists* follow the wire contract prismancer signed off on
(forge #277 comment 14150): list/detail responses report
default_duration_seconds as {value, source: "own"|"campus"|"global"},
resolved for a whole list in one query pair (playback_settings::Defaults)
rather than one per row; PUT gains the double-option field (reusing
settings::patch, now pub(crate)) to set a playlist's own value or clear
it back to inherit. POST is unchanged — still a required value, per the
agreed proposal. PATCH's own duration change now also re-pushes to
assigned devices, the same as an items change already does, since it is
the same "content changed but nothing was pushed" gap this issue is
about.
Merge origin/dev into test/GRI-2147-playlist-default-duration-inheritance
Some checks failed
CI / the pre-push hook (pull_request) Successful in 4s
CI / cargo fmt (pull_request) Successful in 5s
CI / install.sh client upgrade (pull_request) Successful in 14s
CI / cargo deny (pull_request) Successful in 18s
CI / cargo deny advisories (pull_request) Successful in 22s
CI / repository boundary (pull_request) Successful in 4s
CI / cargo clippy (pull_request) Successful in 1m22s
CI / frontend-web (pull_request) Successful in 1m3s
CI / cargo test (pull_request) Failing after 2m48s
CI / CI (pull_request) Failing after 1s
CI / Notify gate failed (pull_request) Successful in 1s
824d3b8e54
Renumbered this branch's own migration 0011 -> 0012: dev gained its own
0011_user_locale.sql in the meantime.
Merge origin/dev into test/GRI-2147-playlist-default-duration-inheritance
All checks were successful
CI / the pre-push hook (pull_request) Successful in 3s
CI / cargo fmt (pull_request) Successful in 4s
CI / install.sh client upgrade (pull_request) Successful in 13s
CI / cargo deny (pull_request) Successful in 13s
CI / cargo deny advisories (pull_request) Successful in 24s
CI / repository boundary (pull_request) Successful in 3s
CI / cargo clippy (pull_request) Successful in 1m3s
CI / frontend-web (pull_request) Successful in 1m3s
CI / cargo test (pull_request) Successful in 3m30s
CI / Notify gate failed (pull_request) Has been skipped
CI / CI (pull_request) Successful in 1s
5e4fc1553d
vivy requested changes 2026-11-16 17:21:55 +00:00
Dismissed
vivy left a comment

Request changes. The server part is good: inheritance at push time, the re-push on a global or campus change, the double-option PATCH, the migration note. CI is green and the branch is up to date with dev. Two things stop the merge, and the first one means #277 is not fixed for the product owner.

1. A playlist made in the panel still copies the default (blocking).
frontend-web/src/screens/PlaylistsScreen.tsx:149 calls createPlaylist(name, 10, …), and CreatePlaylistRequest.default_duration_seconds is still a required i32. So every new playlist gets its own value 10 (source: "own"), and a later change of the campus or global default never reaches it. That is exactly the case the product owner reported in the demo. The migration only fixes playlists that exist today.
Fix: make default_duration_seconds optional on POST (omitted or null = inherit), and let the panel omit it. Add a test: create through the API without a value, change the campus default, and the playlist reports the new value with source: "campus".

2. The panel still reads the old number shape (blocking).
frontend-web/src/api/httpPlaylistsApi.ts:25,49 types default_duration_seconds as number, and PlaylistMediaTab.tsx:123,165 uses it as a number (placeholder and item default). With this PR the server sends {value, source}, so the Media tab shows [object Object] and the per-item default is wrong. frontend-web CI is green only because the panel's tests mock the old shape.
Fix: read {value, source} in the wire types and map value into the playlist model. A test that feeds the new wire shape. Optional: show "inherited from campus/global" next to the value, like CampusSettingsScreen does.

When both are in and CI is green on a head that is up to date with dev, I merge.

**Request changes.** The server part is good: inheritance at push time, the re-push on a global or campus change, the double-option PATCH, the migration note. CI is green and the branch is up to date with `dev`. Two things stop the merge, and the first one means #277 is not fixed for the product owner. **1. A playlist made in the panel still copies the default (blocking).** `frontend-web/src/screens/PlaylistsScreen.tsx:149` calls `createPlaylist(name, 10, …)`, and `CreatePlaylistRequest.default_duration_seconds` is still a required `i32`. So every new playlist gets its own value `10` (`source: "own"`), and a later change of the campus or global default never reaches it. That is exactly the case the product owner reported in the demo. The migration only fixes playlists that exist today. Fix: make `default_duration_seconds` optional on `POST` (omitted or `null` = inherit), and let the panel omit it. Add a test: create through the API without a value, change the campus default, and the playlist reports the new value with `source: "campus"`. **2. The panel still reads the old number shape (blocking).** `frontend-web/src/api/httpPlaylistsApi.ts:25,49` types `default_duration_seconds` as `number`, and `PlaylistMediaTab.tsx:123,165` uses it as a number (placeholder and item default). With this PR the server sends `{value, source}`, so the Media tab shows `[object Object]` and the per-item default is wrong. `frontend-web` CI is green only because the panel's tests mock the old shape. Fix: read `{value, source}` in the wire types and map `value` into the playlist model. A test that feeds the new wire shape. Optional: show "inherited from campus/global" next to the value, like `CampusSettingsScreen` does. When both are in and CI is green on a head that is up to date with `dev`, I merge.
GRI-2147: inherit the live default on POST when no value is given
All checks were successful
CI / the pre-push hook (pull_request) Successful in 5s
CI / cargo fmt (pull_request) Successful in 6s
CI / install.sh client upgrade (pull_request) Successful in 18s
CI / cargo deny (pull_request) Successful in 18s
CI / cargo deny advisories (pull_request) Successful in 27s
CI / repository boundary (pull_request) Successful in 3s
CI / cargo clippy (pull_request) Successful in 1m13s
CI / frontend-web (pull_request) Successful in 1m4s
CI / cargo test (pull_request) Successful in 3m59s
CI / Notify gate failed (pull_request) Has been skipped
CI / CI (pull_request) Successful in 1s
9e5cfa99a0
default_duration_seconds on create is now Option<i32>; an omitted or
null value resolves through Defaults the same way GET and PUT already
do, instead of always being written as the playlist's own value.
GRI-2147: panel reads the playlist default playtime as {value, source}
All checks were successful
CI / the pre-push hook (pull_request) Successful in 7s
CI / cargo fmt (pull_request) Successful in 8s
CI / install.sh client upgrade (pull_request) Successful in 20s
CI / cargo deny (pull_request) Successful in 25s
CI / cargo deny advisories (pull_request) Successful in 24s
CI / repository boundary (pull_request) Successful in 5s
CI / cargo clippy (pull_request) Successful in 1m35s
CI / frontend-web (pull_request) Successful in 1m11s
CI / cargo test (pull_request) Successful in 3m32s
CI / Notify gate failed (pull_request) Has been skipped
CI / CI (pull_request) Successful in 2s
f3dded08f1
A playlist's default duration is now an inherited value with a source
(own/campus/global), not a plain number baked in at creation. Creating a
playlist no longer sends a hardcoded 10s — the server resolves the live
campus or global default instead, so a later change of that default
reaches playlists it did not exist to copy a stale value into.
vivy approved these changes 2026-11-16 18:08:45 +00:00
vivy left a comment

Re-review on f3dded08: both change requests are fixed. POST without a value now stores NULL and returns the resolved {value, source} (9e5cfa9). The panel no longer sends 10 s on create and reads .value everywhere (f3dded0). CI green on all 7 required contexts. Approved.

Re-review on f3dded08: both change requests are fixed. POST without a value now stores NULL and returns the resolved {value, source} (9e5cfa9). The panel no longer sends 10 s on create and reads `.value` everywhere (f3dded0). CI green on all 7 required contexts. Approved.
vivy merged commit 8ae0b2acaa into dev 2026-11-16 18:08:47 +00:00
vivy deleted branch test/GRI-2147-playlist-default-duration-inheritance 2026-11-16 18:08:48 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Grimoirix/grimoire-of-digital-signage!281
No description provided.