test(trial): status read shows a staff-extended trial end
ci / shared (pull_request) Successful in 12s
ci / test (pull_request) Successful in 5m52s
ci / image (pull_request) Skipped

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Sharang ParnerkarandClaude Opus 5.5 committed 2026-11-12 09:42:48 +01:00
1 parent d0b1287afb
commit 2e6f360751
1 file changed
+22
+22
View File
@@ -2,6 +2,7 @@ package server_test
import (
"bytes"
"context"
"encoding/json"
"io"
"net/http"
@@ -301,6 +302,27 @@ func TestTrialOffer_status(t *testing.T) {
if resp, _ = h.do("GET", "/v1/trial-offers/does-not-exist", nil); resp.StatusCode != 404 {
t.Fatalf("unknown offer %d", resp.StatusCode)
}
// staff extended the trial: the status shows the later end
before, _ := st["trial_expires_at"].(string)
tn, err := h.store.GetTenantBySlug(context.Background(), st["tenant_slug"].(string))
if err != nil {
t.Fatal(err)
}
req, _ := http.NewRequest("POST", h.srv.URL+"/v1/admin/tenants/"+tn.ID+"/trial", strings.NewReader(`{"days":30}`))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("X-Portal-User-Email", "staff@breakpilot.com")
ext, err := http.DefaultClient.Do(req)
if err != nil || ext.StatusCode != 200 {
t.Fatalf("extend %v %v", err, ext)
}
_ = ext.Body.Close()
_, raw = h.do("GET", "/v1/trial-offers/"+id, nil)
st = map[string]any{}
_ = json.Unmarshal(raw, &st)
if after, _ := st["trial_expires_at"].(string); after == "" || after <= before {
t.Fatalf("extended end not shown: before %q, now %s", before, raw)
}
})
}