carlos / platform Public

console: close the tautology in the bake member-view test

Review flagged TestLadderBakeControlsMemberView's owner-gate assertions
as vacuous: the flag was off and no channel held, so turn-off/fast-track
were structurally unreachable for anyone — deleting $.IsOwner from the
two gates in ladder.html left the test green. Fix: ship+seed a held beta
channel and flip the flag on before checking the member, and confirm
through the OWNER's own browser, in that same state, that the controls
DO render, before checking the member does not get them. Also extends
TestLadderShowsBakeStateAndControls to assert the owner sees the
turn-off control once bake is on.

Mutation-checked: temporarily stripped $.IsOwner from ladder.html's two
gates (turn-off form, fast-track form) — TestLadderBakeControlsMemberView
failed as expected ("member is offered the owner-only turn-off control
once bake is on" / "...fast-track control on a held head"); reverted.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VioXzogWf1Xi4Rswz2B6EK
Paul Campbell 1426b20fd9d11508f3fb0880e93be337890d44e8 parent 72b0abe
1 file changed, +47 −8
  • internal/console/ladder_test.go +47 −8
diff --git a/internal/console/ladder_test.go b/internal/console/ladder_test.go
index c0b90edf3..8c993278a 100644
--- a/internal/console/ladder_test.go
+++ b/internal/console/ladder_test.go
@@ -569,6 +569,9 @@ func TestLadderShowsBakeStateAndControls(t *testing.T) {
if !strings.Contains(body, `action="/a/bab/apps/kass/fasttrack"`) {
t.Fatalf("no fast-track control on a held head:\n%s", rungBlock(t, body, "beta"))
}
+ if !strings.Contains(body, `name="production" value="off"`) {
+ t.Fatal("owner is offered no turn-off control once bake is on")
+ }
if strings.Contains(body, `name="enable_bake"`) {
t.Fatal("the enable_bake prompt survived the flag turning on")
}
@@ -589,28 +592,64 @@ func TestLadderShowsBakeStateAndControls(t *testing.T) {
}
// A member sees state, never the owner-only controls (off / fast-track) —
-// but IS offered turn-on, the safe direction.
+// but IS offered turn-on, the safe direction. Off-state alone would make
+// the turn-off/fast-track assertions tautological (neither control is
+// eligible to render for ANYONE — owner included — when the flag is off
+// and no channel is held): so this also flips the flag on and confirms
+// through the OWNER's own browser, first, that the controls DO render in
+// that state, before checking the member does not get them in the same
+// state. That ordering is what keeps the member-side absence checks from
+// passing vacuously.
func TestLadderBakeControlsMemberView(t *testing.T) {
fx := newConsoleFixture(t)
+ shipVersion(t, fx, "kass", "v9")
+ seedChannel(t, fx, "kass", "beta", "v9")
+ c := signInPaul(t, fx)
+
if err := fx.st.AddMember(OpsAccountID, "sam@keymail.dev", RoleMember, time.Now()); err != nil {
t.Fatal(err)
}
fx.setUser("sam@keymail.dev")
- c := newBrowser(t)
- signUp(t, fx, c, "code-sam-baketpl")
- _, _, body := get(t, c, fx.u("/apps/kass"))
- if !strings.Contains(body, "Supply-chain bake") {
+ cm := newBrowser(t)
+ signUp(t, fx, cm, "code-sam-baketpl")
+
+ _, _, mbody := get(t, cm, fx.u("/apps/kass"))
+ if !strings.Contains(mbody, "Supply-chain bake") {
t.Fatal("member sees no bake status")
}
- if !strings.Contains(body, `name="production" value="on"`) {
+ if !strings.Contains(mbody, `name="production" value="on"`) {
t.Error("member is not offered the turn-on control")
}
- if strings.Contains(body, `name="production" value="off"`) {
+ if strings.Contains(mbody, `name="production" value="off"`) {
t.Error("member is offered the owner-only turn-off control")
}
- if strings.Contains(body, `/fasttrack"`) {
+ if strings.Contains(mbody, `/fasttrack"`) {
t.Error("member is offered the owner-only fast-track control")
}
+
+ // Put the page into the state where turn-off and fast-track are
+ // ELIGIBLE to render: flag on, with a held beta head. Confirm the
+ // OWNER gets both controls in this state...
+ if err := release.SetProduction(context.Background(), fx.rel, fx.priv,
+ release.OpsAccount, "kass", true, "test"); err != nil {
+ t.Fatal(err)
+ }
+ _, _, obody := get(t, c, fx.u("/apps/kass"))
+ if !strings.Contains(obody, `name="production" value="off"`) {
+ t.Fatal("owner is not offered the turn-off control once bake is eligible — the member-only checks below would be vacuous")
+ }
+ if !strings.Contains(obody, `action="/a/bab/apps/kass/fasttrack"`) {
+ t.Fatalf("owner is not offered the fast-track control on a held head — the member-only checks below would be vacuous:\n%s", rungBlock(t, obody, "beta"))
+ }
+
+ // ...then confirm the member does NOT, in that same eligible state.
+ _, _, mbody = get(t, cm, fx.u("/apps/kass"))
+ if strings.Contains(mbody, `name="production" value="off"`) {
+ t.Error("member is offered the owner-only turn-off control once bake is on")
+ }
+ if strings.Contains(mbody, `action="/a/bab/apps/kass/fasttrack"`) {
+ t.Error("member is offered the owner-only fast-track control on a held head")
+ }
}
// The prod-wiring nudge: a stable route with bake off gets the persistent