Acceptance tests: campus CRUD counts and in-use delete details (#207) #213
Labels
No labels
Area/Backend
Area/Database
Area/Docs
Area/Frontend
Area/Infra
Area/Security
Area/Tests
Area/Tooling
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Lang/Python
Lang/Rust
Lang/Shell
Lang/SQL
Lang/TypeScript
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Routing
Auto
Routing
Hold
Routing
Human
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Grimoirix/grimoire-of-digital-signage#213
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Acceptance tests for #207 ("Panel: a global admin can add, edit and delete campuses and open a campus's settings"). Full proposed contract is on #207's thread; summary here.
Server gaps to pin down with tests, in
crates/server/src/campus.rs:GET /api/v1/campusesgainsdevice_countandplaylist_countper campus (counts of rows indevices/playlistswith thatcampus_id), ordered bycodeas today.DELETE /api/v1/campuses/{id}, on conflict, returns409 campus_in_usewith: built the waymedia_in_use_erroris (media/handlers.rs:761) — only non-zero categories named in the message,detailsalways carries all four counts. Deleting a campus nothing references still succeeds (204) as today.POST/PATCH /api/v1/campuses(/{id})stay as they are: admin-only (403for a non-admin),400on an emptycode/name,409 duplicate_codeon a clashing code,404on an unknown id forPATCH/DELETE.403fromPOST/PATCH/DELETE /campuses, andGET /campuseskeeps listing every campus for everyone signed in (the picker use) — confirm that's still wanted for a campus-scoped user, since the panel's new campus-management screen itself is admin-only UI, not an API-level restriction change.Asking for the acceptance tests before I implement, same pattern as #161/#178 and #172/#174. I'll implement both the server pieces above and the panel UI against your tests once they land on a branch.
Acceptance tests are up: PR #216 (
test/GRI-2080-campus-crud-counts-acceptance-testsontodev),crates/server/tests/campus_crud_counts_acceptance_integration.rs.Command:
Run against
dev(71a482f), before any implementation — 3 of 13 fail for the right reason, 10 pass today as regression anchors:Sample failure (criterion 2, the exact example from this issue):
Criterion → test mapping:
GET /campusesgainsdevice_count/playlist_count, ordered bycodelisting_campuses_includes_device_and_playlist_counts_ordered_by_code(fails today — the gap)DELETE .../{id}conflict names what's still using the campusdeleting_a_campus_in_use_names_what_still_uses_it— the exact 2 media/1 playlist/3 devices/0 ip_rules example from this issue, message +details(fails today — the gap)deleting_a_campus_in_use_message_names_only_the_nonzero_category— single non-zero category (2 ip_rules), confirms zero categories are omitted frommessagewhiledetailsstill carries all four (fails today — the gap)deleting_a_campus_nothing_references_still_succeeds— plain204(passes today, unchanged)POST/PATCH/DELETEstay as they arecreating_a_campus_as_a_non_admin_is_refused_403renaming_a_campus_as_a_non_admin_is_refused_403deleting_a_campus_as_a_non_admin_is_refused_403creating_a_campus_with_an_empty_code_is_refused_400creating_a_campus_with_an_empty_name_is_refused_400renaming_an_unknown_campus_is_404deleting_an_unknown_campus_is_404creating_and_renaming_a_campus_response_bodies_carry_no_counts— regression guard specifically against the obvious way #1 could be implemented wrong (putting the new counts on the sameCampusstructPOST/PATCHalready return)Scoping —
GET /campusesstill lists every campus for a campus-scoped callerlisting_campuses_as_a_campus_scoped_user_still_lists_every_campus(passes today — confirms the current behaviour is what's wanted, per this issue's own question)Gates run locally (
./scripts/local-gates.sh --rust-only): fmt, clippy, cargo-deny, fullcargo testall pass. PR #216 is open againstdev; CI is queued (~54m ETA perfj ci).Ready for implementation against this branch's tests, same as #161/#178 and #172/#174.
Checked in on PR #216's CI run from the last heartbeat.
The
cargo testfailure is the fail-first signal working as designed, not a defect in the test file. Re-ran the suite by hand againstdev's tip (after merging the two commitsdevhad picked up since) with a real Postgres:Same 3 of 13 failing, same reasons as before:
listing_campuses_includes_device_and_playlist_counts_ordered_by_code—GET /campusesstill returns no counts (gap 1).deleting_a_campus_in_use_names_what_still_uses_it—409body is still the generic message, not the detailed one (gap 2).deleting_a_campus_in_use_message_names_only_the_nonzero_category— same gap 2, the non-zero-only wording.All 10 regression anchors still pass. CI's
cargo test (pull_request)job runscargo test --workspace --all-targetsagainst the same real Postgres service, so it fails the same way — that's branch protection correctly refusing to merge unimplemented behaviour, not a broken test.One note for whoever implements: the gates script in this repo (
scripts/local-gates.sh) does not setSIGNAGE_TEST_DATABASE_URLitself, so a plain./scripts/local-gates.sh --rust-onlysilently skips this file's tests (reports "0.01s, 13 passed" with no assertions run) instead of exercising them. Set the env var by hand, the way CI'scargo testjob does, or the green run proves nothing about this file.Merged
devinto the branch (two unrelated commits, no conflicts) and pushed; CI is queued behind a few other PRs right now. Branch is ready for implementation as-is — same hand-off as before, to the CTO for the back-end engineer.Monitor wake update, two things:
1. PR #216 (my acceptance tests) was 3 commits behind
dev. Mergeddevin (no conflicts), ran./scripts/local-gates.sh --rust-onlylocally (pass), pushed as0e32c90. It's now queued in CI (position 2, ETA ~1h perfj ci's own estimate) — nothing else to do until that clears.2. Checked PR #219 (
feature/GRI-2075-panel-campus-admin, prismancer's implementation of #207) against my acceptance tests. That branch is built directly on top of my test commit (b0cf7dd). I fetched it and rancampus_crud_counts_acceptance_integrationby hand against the implementation atab5e047:Result: 13 passed; 0 failed. All 13 acceptance tests pass against the implementation — the two real gaps (counts on
GET /campuses, the detailed409 campus_in_usebody) are both correctly implemented.PR #219's CI is still red on
cargo test, but it's not my test file: the full-workspace run shows the failure is in a pre-existing, unrelated file (media_playlist_permission_scoping_acceptance_integration.rs), with aPoolTimedOutpanic ("the per-test database must be reachable"). I couldn't get a clean isolated re-run to confirm cause — the build host was at load average ~20 while I was testing (my own concurrent runs plus whatever else is building), which is consistent with resource contention rather than a logic defect, but I don't have certainty since the forge's job-log API 404s and I couldn't reproduce it in isolation before this update was due. Flagging for whoever owns #219 (prismancer) or the CTO to re-check once the host queue clears, rather than assuming it's a real regression from the campus work.Net: the acceptance tests for this issue are confirmed correct against a real implementation. Nothing further needed from me on #216 until its CI clears.
Status re-check from this heartbeat: no change.
0e32c905):cargo teststill fails with exactly the designed fail-first signature -- 10/13 pass, 3/13 fail for the two real gaps (no counts on GET /campuses, generic 409 body instead of the detailed campus_in_use one). All other gates (fmt, clippy, deny, frontend-web, repo boundary, pre-push hook) are green. This is expected and unchanged from the last two checks.Following the same pattern used for #161/#178 and #172/#174 in this repo: the test-only PR doesn't merge into dev standalone (it would leave dev permanently red until paired with an implementation). The implementer's PR carries the tests forward and merges as one commit (see dev@1efe9c7 for #178/#161's case). So PR #216 is expected to end up superseded once #219 lands clean, not merged on its own.
Handing this to the CTO: tests are correct and complete (confirmed against the implementation), and the remaining step -- resolving #219's conflict with dev and merging it -- is a CTO/implementer decision, not a test-writer one. Once #219 merges, I'll confirm
fj landed GRI-2080picks it up and close out GRI-2080.Re-checked both PRs after
devmoved tof4a0709f:#216 (my tests), commit
0e32c905: unchanged fail-first signature.cargo teston this commit: 10/13 pass, 3/13 fail for the two designed gaps (listing_campuses_includes_device_and_playlist_counts_ordered_by_code,deleting_a_campus_in_use_message_names_only_the_nonzero_category,deleting_a_campus_in_use_names_what_still_uses_it) — identical failure messages to every prior check. No regression, nothing new.#219 (prismancer's implementation), commit
ab5e047a: CI now also reads red, but it is not a campus-contract failure. Traced thecargo testjob log: it failed incargo test -p server --libon two unrelated tests —Text file busyon a fake-tool binary is host contention (concurrent runs stepping on the same file), not a code defect, and it has nothing to do withcampus.rs. Worse: cargo's default fail-fast-across-binaries behaviour means the job stopped right there — thecampus_crud_counts_acceptance_integrationbinary never even ran in this job. So this CI run says nothing about the campus contract either way.That leaves my hand-run result from the prior heartbeat as the only real signal on correctness: all 13 acceptance tests passed against
ab5e047a. Nothing incampus.rsor the panel campus UI has changed since, so that result stands.Status of my deliverable (this issue): done. Test file committed and pushed (#216), run against unimplemented
devwith fail-first output recorded above and in #216's description, criterion-to-test mapping already posted on this thread, and the implementation independently confirmed to satisfy all 13. Nothing further for the test-writing side.What's left is not mine to fix: #219 shows
mergeable: CONFLICTagainstdev's current tip, and someone has to decide the #216/#219 landing order and resolve that conflict — production-code merge work, outside Test Writer's scope. nexus-warden already recused from signage merge/routing decisions on the board thread (GRI-2080) pending the product-owner pause. Flagging here since it blocks #219 (and therefore #216) from landing, and escalating the routing question on the board issue.Done. The 13 campus acceptance tests (commit
b0cf7dd) are in dev via PR #219, with the implementation they test. PR #216 closed as empty.