package web import ( "net/http" "net/http/httptest" "strings" "testing" ) // v0.282.0 (decision 49) — "close sign-up now": the card on an app installed before the rule, and the refusal on // an app with nothing to close. func TestCloseSignupPage_TheCardAndItsPress(t *testing.T) { on := renderAppInfoWith(t, map[string]interface{}{"CloseSignupOffered": true}) if !strings.Contains(on, `id="close-signup-card"`) || !strings.Contains(on, "/apps/gapp/close-signup") || !strings.Contains(on, "Zárd le a regisztrációt most") { t.Fatal("offered, but the card, its sentence or its press is missing") } if off := renderAppInfoWith(t, nil); strings.Contains(off, `id="close-signup-card"`) { t.Fatal("the card shows on an app with nothing to close") } native := renderAppInfoWith(t, map[string]interface{}{"SignupClosed": true, "SignupNative": true, "SignupNativeFailed": true}) if !strings.Contains(native, "újraindul") || !strings.Contains(native, `id="signup-native-failed"`) { t.Fatal("the window's restart line or the failed-switch line is missing") } } // COMPANION RED-PROOF: skip the CloseSignupNow error mapping → the gated app answers 500, not 409. func TestCloseSignup_RefusedWhenNothingToClose(t *testing.T) { s := gateHarness(t) // gapp: gated (closed), no signup_block r := httptest.NewRequest(http.MethodPost, "/apps/gapp/close-signup", nil) w := httptest.NewRecorder() s.appCloseSignupHandler(w, r, "gapp") if w.Code != http.StatusConflict { t.Fatalf("close sign-up on an app with nothing to close: %d", w.Code) } }