carlos / platform Public

fix: bound demo claim hints and show stopping progress

Apply the approved claim copy and retain its review decks. Show aborting without marking a progress step, bound room hints by time and account count, and address the same-round account and polling fixes. Cover the regressions and long content in Chromium.
codex agent, operated by paul@keymail.dev pushed by paul@keymail.dev f68807685353f4455d2d89385599ba33317a685e parent e240344
10 files changed, +309 −43
  • docs/superpowers/specs/LUNA-COPY-BRIEF-DEMO-CLAIM-ACCOUNT-UI.md +34 −0
  • docs/superpowers/specs/LUNA-COPY-RESULT-DEMO-CLAIM-ACCOUNT-UI.md +22 −0
  • internal/console/demo_claim_choice_test.go +145 −13
  • internal/console/demo_claim_copy.go +6 −4
  • internal/console/demo_claim_page.go +9 −7
  • internal/console/demo_claim_resume_browser_test.go +33 −3
  • internal/console/demo_claim_status_page.go +5 −1
  • internal/console/static/demo_claim.js +13 −5
  • internal/console/templates/demo_claim.html +6 −6
  • internal/console/testdata/demo_claim_resume_browser.mjs +36 −4

CI passed — run details

Intent

Human

<task-notification> <task-id>bvaz88t9d</task-id> <tool-use-id>toolu_01WThg6icKEK9Q5MFv27s3pF</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/bvaz88t9d.output</output-file> <status>completed</status> <summary>Background command "S=/home/paulca/.cache/tmp/dcau; until [ -f $S/done ]; do sleep 20; done; tail -1 $S/log; cat $S/final.md; cut -c1-200 $S/strings.tsv" completed (exit code 0)</summary> </task-notification>

Human

<task-notification> <task-id>ae31b866796ba75e9</task-id> <tool-use-id>toolu_01XJrhnAUgF4RgmdwvmmsSwz</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/ae31b866796ba75e9.output</output-file> <status>completed</status> <summary>Agent "Review claim account UI" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result># Round 1 of 3: review of `demo-claim-account-ui`, tip e240344c **Verdict: READY AFTER FIXES (tip e240344c).** There are no P1s, so under the stopping rules this review stops here. Apply the two P2s without opening another round. The P3s go on the follow-up list. P2-1 needs one new string, so it goes to the copy pass. All paths are under `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/demo-claim-account-ui/internal/console/`. ## What I ran - **Focused tests:** the choice, status, CSP, chrome, census, resume, wrong-demo, replay and `TestDemoClaimBrowser*` tests all pass, except the headless one below. - **Probes:** I added out-of-tree probes through `go test -overlay`. The worktree stayed clean and the scratch is deleted. - **Blocked:** Chromium can't start in this sandbox (`socket() failed: Operation not permitted`), and I did not bypass that. - `TestDemoClaimBrowserHeadless` fails here, most likely for that reason, because its node harness died on start. - I did not run `TestDemoClaimSelectStepUpHeadless`. - All real-browser claims (JS auto-submit, polling, CSP violations) rest on Codex's run, plus my reading of the code and five of the 20 screenshots. ## Findings **P2-1: the `aborting` phase shows "Copying your data" for up to a day.** Family: progress UI reports the real operation state. - **Where:** `demo_claim_status_page.go:53` (default case) and `demo_claim_page.go:132`. The probe confirmed door `{claiming, 1}` and the page's current step "Copying your data". - **Scenario:** a claim passes its deadline with the box offline, so it is already lost. - `continueDemoClaimAbort` (`demo_claim_transfer.go:849-859`) waits for an ack that doesn't come. It only retires the demo at source expiry (`:835`), and demos last 24 hours. - The page keeps saying it is copying and polls every 3 s. An abort from `verifying` also moves the page backwards from step 2 to step 1. - It does not hang forever: it ends at `aborted`, or at a 401 after expiry plus 24 hours. - **Fix:** - Have the door return a distinct state such as `{state:"stopping", step:0}`. - Render one new sentence with no step marked, and keep polling. - Update the JS allow-list at `demo_claim.js:47`. - Add `aborting` to the test table at `demo_claim_choice_test.go:93`, which omits it today. **P2-2: the room hint has no budget for time or requests.** Family: an advisory hint must be bounded and must not delay the gate. - **Where:** `demo_claim_page.go:173-174` and `:600-635`. - **Numbers:** the probe measured 4 accounts x 5 apps = 20 `List` calls per GET, so it grows linearly with accounts times apps. - Accounts run one after another. `readConcurrency` of 10 applies only within an account. - No membership cap exists, and over-limit accounts have no ceiling. Plan caps limit apps only for accounts within their plan. - 10 accounts x 100 apps would be 1000 Lists per reload, with no throttle on GET. - Polling itself adds none of this. - **Scenario:** a slow store holds up the only page that leads to a claim, because a hint failure is handled only when the call returns an error. - **Fix:** one shared `context.WithTimeout` of about 2 s across the whole loop, and a cap on counted accounts (for example 20). Past either limit, omit the hint and leave the account eligible, since reservation still enforces. Add a test with a blocking store. **P3 follow-ups** 1. **Admission off** (`demo_claim_page.go:159`, `:196`): the signed-in branch still counts (probe: 3 Lists). With a full account, it also replaces "unavailable" with "None of your accounts can take this demo". Skip the account view when `!p.CanClaim`. 2. **Exempt accounts** (`demo_claim_page.go:605-613`): the card shows the default plan label ("Free") for a `planExempt` account, which is false. Skip the label when exempt. 3. **Double submit** (`demo_claim.js:22`): changing a radio during a pending POST re-enables the button. A second POST can't double-claim, because `demo_claim_page.go:232` refuses it, but the person sees "Open the claim link" while the claim runs. Add a submitted guard. 4. **Live region** (`demo_claim.js:53`): the same text is rewritten every 3 s, which some screen readers may repeat. Write only on change. 5. **Brittle test** (`demo_claim_choice_test.go:151`): `TestDemoClaimSharedChromeUnchanged` pins the SHA of `console_chrome.html`, so any later chrome edit by anyone fails it. Drop it before merge; it is a branch check, not an invariant. 6. **Test gaps:** - Nothing committed pins the hidden summary for another person at `demo_claim_page.go:164`. - Signed-out is only asserted as zero Lists, not absent names. - The Chromium harness has no long account name or long host at 360 px. 7. **Small template points:** - The `no_accounts` state (`demo_claim.html:46`) omits "You are signed in as", so someone in the wrong session can't tell why. - The reason text on line 81 lacks `claim-detail`, so it renders larger (visible in `many-dark-360`). - `Copy["url"]` (`demo_claim_page.go:552`) is now unused. ## The eight checks **1. Disclosure: OK.** Probe results: | Viewer | Account names and plan | Demo name and host | |---|---|---| | Signed-out, intent cookie | none | shown | | Signed-out, proved flow | none | shown | | Other person, proved flow | none | none (`:161-165`) | | Bad cookie or expired intent | none | none | - **Own data only:** other accounts never appeared. The owner case showed only their own. - **No cross-account path:** `runningThings` (`plancaps.go:57-106`) and `EffectiveLimits` key only on `acct.ID` and `acct.Sqid`. `demoClaimReservedThings` also filters by account. - **Summary:** it adds only demo name, host and the apps domain. I judged those to be what a link holder already has; I did not separately confirm the link response exposes the name. - **Role-disabled cards:** viewers see the plan name but no counts. `billingpage.go:319` suggests the billing page already serves non-owners. I read only that line, so check this if it matters. - **Sqids:** none in the choice UI as text. The done page's address contains the sqid, because that is the app's host. - **Escaping:** a hostile account name came out escaped in the card, `data-button`, `data-neutral`, the destination line and the button. JS uses only `textContent`. **2. Status door: OK.** - **Auth:** only a status-purpose row passes (`status_page.go:27`), and a proof cookie gets 401 (test). The cookie binds through `flow_hash` to its own operation, and an unrelated live intent gets 401. - **Same-origin:** cross-site and same-site get 403, and so does missing evidence (`:12`). Browsers without `Sec-Fetch-Site` degrade to the reload link after three failures. - **Response:** `no-store`, and only `state`, `step`, plus `url` on done. - **Store use:** expired and purpose cases are tested. A panicking store confirms zero remote calls. - **Independence:** it works with admission off (`TestDemoClaimRecoveryRoutes`). - **Agent endpoints:** they refuse the cookie as cookie or Bearer, all 401. - **Census:** `TestClaimConsoleRouteCensus` passes without listing this door, and the diff adds no inventory entry. So the census says little about it. `TestClaimConsoleMuxHasOneRegistrar` and the door tests are the real guards, which is acceptable for a read-only door. - **Old-cookie URL (judged acceptable):** - `demo_claim_store.go:214` promotes every browser on the flow. So someone who opened the link and typed a victim's email keeps a cookie that later reads the victim's public app URL. - The page has always shown this. The URL is public and the link holder started the flow. - The same holds for a shared browser. The `url` field is unused by the client, so dropping it is optional and buys little. **3. Enforcement: OK.** - The select handler is unchanged. Probe: tampered full account got 409 with cap copy, tampered viewer and foreign accounts got 404. - The hint uses the same `EffectiveLimits` and `runningThings` as `checkRunningThings(ctx, acct, 2)`. `n+2 &gt; limit` matches exactly, and this covers reservations and team plans. So only a race can make "Has room" wrong on capacity. - A failed count leaves the account eligible. - No path blocks a viable account. Disabled radios don't submit, so the single hidden input wins. With no-JS the button is enabled and `required` validates. Without radios, `update()` never runs. **4. Resume: OK.** - Radio `checked` and the single hidden input both work. - `AutoSubmit` is set only inside `Reason == ""`, so a now-full account stops the auto-submit, and it never submits a different account. - `requestSubmit()` ignores button state, and `update()` already enabled the button. - `WrongDemo`, `CopiedCookieReplay`, `Gates` and `ConcurrentGET` pass. The real-browser JS round trip was not re-run here. **5. Cost:** the report's numbers hold, including role-disabled accounts skipping the count. It needs a session and a live intent: signed-out and missing-intent gave zero Lists. It isn't bounded for many memberships (P2-2). Polling is 3 s after each completed attempt, with a 10 s timeout. It stops on claimed, aborted or three failures, and is SQL only. **6. CSP: OK.** `TestDemoClaimChoiceCSP` compares the whole policy against the hash of the rendered bytes. It finds no inline style and one script. The hash covers the new block automatically. `console_chrome.html` and `fiesta.html` are untouched. **7. Progress mapping:** `reserved`, `freezing` and `copying` map to step 1. `verifying` and `committed` map to step 2. `aborted` is correct. `done` is set only once the outbox is empty (`demo_claim_transfer.go:763`). `aborting` is wrong (P2-1). A stuck `committed` stays on "Starting your app" and rolls forward through retries, polling within the same bound. **8. Accessibility and layout: OK, except P3 items 4 and 7.** - Fieldset and legend, real radios inside labels, `aria-current`, and the hidden live region are all correct. - The chrome already has `--muted` on `--rst-surface-2` at about 6.9:1 or better in both themes. - The screenshots I opened show no left stripes and no all-caps labels. - **Not measured:** long names at 360 px. The CSS looks safe (`overflow-wrap: anywhere` is inherited, no `nowrap` on buttons), but my measurement was blocked and the harness only uses short names. ## Copy accuracy I found no false statements beyond P2-1 and P3-2. The old-address sentence matches `demo_claim_moved.go:77-79`.</result> <usage><subagent_tokens>176222</subagent_tokens><tool_uses>36</tool_uses><duration_ms>580098</duration_ms></usage> </task-notification>

Human

<task-notification> <task-id>bej33e9yj</task-id> <tool-use-id>toolu_01U6mQwtoUChLE2vdTZPm4ZA</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/bej33e9yj.output</output-file> <status>completed</status> <summary>Background command "S=/home/paulca/.cache/tmp/dcau; until [ -f $S/luna.done ]; do sleep 10; done; cut -c1-260 $S/luna-final.md; until amadan ci status carlos/platform -branch demo-claim-account-ui 2&gt;&amp;1 | head -1 | grep -q 'e240344c.*CI \(passed\|failed\)'; do sleep 45; done; amadan ci status carlos/platform -branch demo-claim-account-ui 2&gt;&amp;1 | head -1" completed (exit code 0)</summary> </task-notification>

Attributed to this commit: 20.3 g CO₂e (2,682,860 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on demo-claim-account-ui, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.

diff --git a/docs/superpowers/specs/LUNA-COPY-BRIEF-DEMO-CLAIM-ACCOUNT-UI.md b/docs/superpowers/specs/LUNA-COPY-BRIEF-DEMO-CLAIM-ACCOUNT-UI.md
new file mode 100644
index 000000000..ac0718137
--- /dev/null
+++ b/docs/superpowers/specs/LUNA-COPY-BRIEF-DEMO-CLAIM-ACCOUNT-UI.md
@@ -0,0 +1,34 @@
+You are the copy-review gate itself for this set. Paul delegated copy review to you on 2026-10-25; your verdicts ARE the review. Do NOT run the copy-review skill or start any server. Do not edit any file. You are writing a review report into your final answer.
+
+The page: a person keeps a temporary 24-hour demo as a permanent app. They choose an account on a page in a web console. Accounts appear as cards. They press a button naming the account, then watch progress steps, then see the result. The audience is a person, often not technical.
+
+Facts that must stay true:
+- The app keeps its data. Its address changes; the exact name can have a suffix, so only the domain is promised before the claim.
+- A claim needs room for 2 under the plan: one app plus its instance. The plan copy elsewhere calls them "apps and instances"; keep that term.
+- The old address shows a short notice with a link until the demo's original 24 hours end. It does not forward automatically.
+- A new personal account is made only if they have none. Plan limits apply; no payment happens here.
+
+House rules: plain words, short sentences, no marketing tone, no exclamation marks. No em or en dashes used as dashes. Sentence case, full stops on sentences. Labels, headings and button text have no full stop. Keep %s and %d placeholders, their number and order. Do not name the product.
+
+Answer with one markdown table, `| key | new | why |`, one row per deck row in deck order, `unchanged` in why when you keep a string. Then a short **Flags** list only if needed. Nothing else.
+
+## Deck
+
+| key | Surface | Draft |
+|---|---|---|
+| demoClaimNewAccount | CLAIM-ACCOUNT-NEW: zero membership confirmation. | We will create a personal account and keep this demo in it. |
+| demoClaimNoEligibleAccount | CLAIM-ACCOUNT-NONE: memberships exist but none can take the claim. | None of your accounts can take this demo right now. |
+| demoClaimUnavailableAccounts | CLAIM-UNAVAILABLE-ACCOUNTS: the disabled account list. | Unavailable accounts |
+| demoClaimSaved | CLAIM-SAVED: what the person keeps. | Its saved data comes with it. |
+| demoClaimPermanent | CLAIM-PERMANENT: domain only; the eventual name may need a suffix. | It gets a permanent address on %s. |
+| demoClaimDestination | CLAIM-DESTINATION: the only eligible account. | This goes into %s |
+| demoClaimKeepIn | CLAIM-KEEP-IN: action after choosing an account. | Keep in %s |
+| demoClaimHasRoom | CLAIM-ROOM-AVAILABLE: the account has room for the app and its instance. | Has room |
+| demoClaimFull | CLAIM-ROOM-FULL: current use is at or above the catalog cap. | Full: %d of %d apps and instances in use |
+| demoClaimNoRoom | CLAIM-ROOM-INSUFFICIENT: one slot remains, but the claim needs two. | Not enough room: %d of %d apps and instances in use. This demo needs room for 2. |
+| demoClaimRoleDenied | CLAIM-ROLE-DENIED: membership cannot create apps. | Your role cannot create apps in this account. |
+| demoClaimCopying | CLAIM-STEP-COPYING: first progress step. | Copying your data |
+| demoClaimStarting | CLAIM-STEP-STARTING: second progress step. | Starting your app |
+| demoClaimDone | CLAIM-STEP-DONE: final progress step. | Done |
+| demoClaimPollFailed | CLAIM-POLL-FAILED: repeated status failures, with a reload link. | Progress could not be checked. Reload to try again. |
+| demoClaimOldAddress | CLAIM-OLD-ADDRESS: notice lifetime, without a redirect promise. | The old address shows a short notice with a link to this app until the demo's original expiry. |
diff --git a/docs/superpowers/specs/LUNA-COPY-RESULT-DEMO-CLAIM-ACCOUNT-UI.md b/docs/superpowers/specs/LUNA-COPY-RESULT-DEMO-CLAIM-ACCOUNT-UI.md
new file mode 100644
index 000000000..5eeb04bbe
--- /dev/null
+++ b/docs/superpowers/specs/LUNA-COPY-RESULT-DEMO-CLAIM-ACCOUNT-UI.md
@@ -0,0 +1,22 @@
+| key | new | why |
+|---|---|---|
+| demoClaimNewAccount | We will create a personal account only if you do not have one. We will keep this demo in it. | Makes clear an account is created only when needed. |
+| demoClaimNoEligibleAccount | None of your accounts can take this demo right now. | unchanged |
+| demoClaimUnavailableAccounts | Unavailable accounts | unchanged |
+| demoClaimSaved | Its saved data comes with it. | unchanged |
+| demoClaimPermanent | It gets a permanent address on %s. | unchanged |
+| demoClaimDestination | This goes into %s. | Adds the required full stop. |
+| demoClaimKeepIn | Keep in %s | unchanged |
+| demoClaimHasRoom | Has room | unchanged |
+| demoClaimFull | Full: %d of %d apps and instances in use | unchanged |
+| demoClaimNoRoom | Not enough room: %d of %d apps and instances in use. This demo needs room for one app and its instance. | Clarifies what the two spaces are for. |
+| demoClaimRoleDenied | Your role cannot create apps in this account. | unchanged |
+| demoClaimCopying | Copying your data | unchanged |
+| demoClaimStarting | Starting your app | unchanged |
+| demoClaimDone | Done | unchanged |
+| demoClaimPollFailed | Progress could not be checked. Reload to try again. | unchanged |
+| demoClaimOldAddress | The old address shows a short notice with a link to this app until the demo's original 24 hours end. | States the notice lasts only until the original 24 hours end, without promising a redirect. |
+| key | new | why |
+|---|---|---|
+| demoClaimNewAccount | You don't have an account yet. We will create a personal one and keep this demo in it. | unchanged |
+| demoClaimStopping | The claim did not finish. The demo is not serving its pages while we undo the claim. When this finishes, the demo resumes if its 24 hours have not ended. | The draft promises the demo stays paused until undo finishes but omits what happens afterward. The replacement avoids promising that the demo is safe or will return. |
\ No newline at end of file
diff --git a/internal/console/demo_claim_choice_test.go b/internal/console/demo_claim_choice_test.go
index 7e9dbd6a6..2e64d73aa 100644
--- a/internal/console/demo_claim_choice_test.go
+++ b/internal/console/demo_claim_choice_test.go
@@ -11,7 +11,6 @@ import (
"net/http"
"net/http/httptest"
"net/url"
- "os"
"regexp"
"strings"
"sync/atomic"
@@ -90,7 +89,7 @@ func TestDemoClaimStatusDoor(t *testing.T) {
for _, tc := range []struct {
phase, state string
step int
- }{{"reserved", "claiming", 1}, {"freezing", "claiming", 1}, {"copying", "claiming", 1}, {"verifying", "claiming", 2}, {"committed", "claiming", 2}, {"done", "claimed", 3}, {"aborted", "aborted", 0}} {
+ }{{"reserved", "claiming", 1}, {"freezing", "claiming", 1}, {"copying", "claiming", 1}, {"verifying", "claiming", 2}, {"committed", "claiming", 2}, {"done", "claimed", 3}, {"aborted", "aborted", 0}, {"aborting", "stopping", 0}, {"future-phase", "claiming", 0}} {
if _, err := s.store.db.Exec(`UPDATE demo_claim_ops SET phase=? WHERE id=?`, tc.phase, op.ID); err != nil {
t.Fatal(err)
}
@@ -102,6 +101,18 @@ func TestDemoClaimStatusDoor(t *testing.T) {
if got["state"] != tc.state || got["step"] != float64(tc.step) {
t.Errorf("%s: %v", tc.phase, got)
}
+ page := request(raw, "/demo/claim", "same-origin").Body.String()
+ if tc.step == 0 {
+ if strings.Contains(page, `aria-current="step"`) {
+ t.Errorf("%s marks a progress step", tc.phase)
+ }
+ if tc.state != "aborted" && !strings.Contains(page, `id="claim-progress"`) {
+ t.Errorf("%s lost polling", tc.phase)
+ }
+ }
+ if tc.state == "stopping" && !strings.Contains(page, "The claim did not finish. The demo is not serving its pages while we undo the claim.") {
+ t.Error("missing stopping explanation")
+ }
want := 2
if tc.phase == "done" {
want = 3
@@ -143,16 +154,6 @@ func TestDemoClaimStatusDoor(t *testing.T) {
}
-func TestDemoClaimSharedChromeUnchanged(t *testing.T) {
- b, err := os.ReadFile("templates/console_chrome.html")
- if err != nil {
- t.Fatal(err)
- }
- if got := fmt.Sprintf("%x", sha256.Sum256(b)); got != "555292d40296be5866bec0de6af1d8c5c7121de21b30d1618f2ed2078bd991de" {
- t.Fatal("shared chrome changed", got)
- }
-}
-
// Any accidental remote operation panics, including a newly added Store method.
type claimNoRemoteStore struct{ release.Store }
@@ -179,7 +180,7 @@ func TestDemoClaimChoiceRoom(t *testing.T) {
reason, room string
}{
{"fits exactly", RoleOwner, 0, true, false, "", "Has room"},
- {"needs two slots", RoleMember, 1, true, false, "Not enough room: 2 of 3 apps and instances in use. This demo needs room for 2.", ""},
+ {"needs two slots", RoleMember, 1, true, false, "Not enough room: 2 of 3 apps and instances in use. This demo needs room for one app and its instance.", ""},
{"full", RoleOwner, 2, true, false, "Full: 3 of 3 apps and instances in use", ""},
{"over limit", RoleOwner, 3, true, false, "Full: 4 of 3 apps and instances in use", ""},
{"role", "viewer", 0, true, false, demoClaimRoleDenied, ""},
@@ -214,6 +215,9 @@ func TestDemoClaimChoiceRoom(t *testing.T) {
if !strings.Contains(body, tc.reason) || !strings.Contains(body, `value="`+a.Sqid+`" disabled`) || strings.Contains(body, `action="/demo/claim/select"`) {
t.Error("ineligible account not disabled with its reason")
}
+ if !strings.Contains(body, "You are signed in as") || !strings.Contains(body, `<span class="claim-detail">`+tc.reason+"</span>") {
+ t.Error("no_accounts missing identity or muted reason")
+ }
} else if !strings.Contains(body, `type="hidden" name="accountId" value="`+a.Sqid+`"`) {
t.Error("eligible account lost")
}
@@ -403,3 +407,131 @@ func TestDemoClaimProgressAndOutcome(t *testing.T) {
})
}
}
+
+type claimBlockingRoomStore struct {
+ release.Store
+ calls atomic.Int32
+}
+
+func (s *claimBlockingRoomStore) List(ctx context.Context, prefix string) ([]string, error) {
+ s.calls.Add(1)
+ select {
+ case <-ctx.Done():
+ return nil, ctx.Err()
+ case <-time.After(3 * time.Second):
+ return nil, errors.New("test safety timeout")
+ }
+}
+
+func TestDemoClaimRoomBudget(t *testing.T) {
+ for _, n := range []int{2, 22} {
+ t.Run(fmt.Sprint(n), func(t *testing.T) {
+ s, _, token := claimTestServer(t)
+ b := newClaimBrowser(t, s, token)
+ b.login("shop@example.com", MethodEmail, true)
+ for i := 0; i < n; i++ {
+ a := claimAccount(t, s, int64(501+i), "shop@example.com", RoleOwner)
+ if _, err := s.store.CreateAppIn(a.ID, "shop", "shop@example.com", time.Now()); err != nil {
+ t.Fatal(err)
+ }
+ }
+ s.cfg.PlanCatalog = examplePlanCatalog(t)
+ blocking := &claimBlockingRoomStore{Store: s.cfg.Releases}
+ counting := &claimRoomStore{Store: s.cfg.Releases}
+ if n == 2 {
+ s.cfg.Releases = blocking
+ } else {
+ s.cfg.Releases = counting
+ }
+ start := time.Now()
+ w := b.request("GET", "/demo/claim", nil)
+ elapsed := time.Since(start)
+ if w.Code != 200 {
+ t.Fatal(w.Code)
+ }
+ body := w.Body.String()
+ if strings.Count(body, ` required`) != n {
+ t.Error("budget omitted eligible accounts")
+ }
+ if n == 2 {
+ if elapsed > 2700*time.Millisecond {
+ t.Errorf("page exceeded shared 2s budget: %v", elapsed)
+ }
+ if blocking.calls.Load() != 1 {
+ t.Errorf("counted after deadline: %d", blocking.calls.Load())
+ }
+ if strings.Contains(body, ">Has room<") {
+ t.Error("unverified room hint")
+ }
+ } else {
+ if counting.calls.Load() != 20 {
+ t.Errorf("counted %d accounts, want 20", counting.calls.Load())
+ }
+ if strings.Count(body, ">Has room<") != 20 {
+ t.Error("wrong number of room hints")
+ }
+ }
+ })
+ }
+}
+
+func TestDemoClaimChoiceAdmissionAndExemption(t *testing.T) {
+ for _, exempt := range []bool{false, true} {
+ t.Run(fmt.Sprint(exempt), func(t *testing.T) {
+ s, _, token := claimTestServer(t)
+ b := newClaimBrowser(t, s, token)
+ b.login("shop@example.com", MethodEmail, true)
+ a := claimAccount(t, s, 501, "shop@example.com", RoleOwner)
+ s.cfg.PlanCatalog = examplePlanCatalog(t)
+ if exempt {
+ s.store.planExemptID = a.ID
+ } else {
+ s.demoClaimTestEnabled = false
+ s.cfg.Demo.ClaimEnabled = false
+ }
+ spy := &claimRoomStore{Store: s.cfg.Releases}
+ s.cfg.Releases = spy
+ if _, err := s.store.CreateAppIn(a.ID, "shop", "shop@example.com", time.Now()); err != nil {
+ t.Fatal(err)
+ }
+ for i := 0; i < 2; i++ {
+ if _, err := spy.Put(t.Context(), provision.RecordKey(a.Sqid, "shop", fmt.Sprintf("shop%d.example.com", i)), []byte("{}"), ""); err != nil {
+ t.Fatal(err)
+ }
+ }
+ body := b.request("GET", "/demo/claim", nil).Body.String()
+ if spy.calls.Load() != 0 {
+ t.Error("counted unavailable or exempt account")
+ }
+ if strings.Contains(body, ">Free<") {
+ t.Error("false plan label")
+ }
+ if !exempt && (!strings.Contains(body, "<p>unavailable</p>") || strings.Contains(body, demoClaimNoEligibleAccount)) {
+ t.Error("admission-off state replaced by account refusal")
+ }
+ })
+ }
+}
+
+func TestDemoClaimChoicePrivacy(t *testing.T) {
+ s, _, token := claimTestServer(t)
+ b := newClaimBrowser(t, s, token)
+ b.login("shop@example.com", MethodEmail, true)
+ a := claimAccount(t, s, 501, "shop@example.com", RoleOwner)
+ if _, err := s.store.db.Exec(`UPDATE accounts SET name='Private account name' WHERE id=?`, a.ID); err != nil {
+ t.Fatal(err)
+ }
+ b.session = ""
+ body := b.request("GET", "/demo/claim", nil).Body.String()
+ if strings.Contains(body, "Private account name") || strings.Contains(body, a.Sqid) {
+ t.Error("signed-out account leak")
+ }
+ if _, err := s.store.db.Exec(`UPDATE demo_claim_flows SET person='someone-else@example.com'`); err != nil {
+ t.Fatal(err)
+ }
+ b.login("shop@example.com", MethodEmail, true)
+ body = b.request("GET", "/demo/claim", nil).Body.String()
+ if strings.Contains(body, `<div class="claim-summary">`) || strings.Contains(body, "Private account name") {
+ t.Error("another person's proved flow revealed summary or accounts")
+ }
+}
diff --git a/internal/console/demo_claim_copy.go b/internal/console/demo_claim_copy.go
index 0e4518f26..d6de609db 100644
--- a/internal/console/demo_claim_copy.go
+++ b/internal/console/demo_claim_copy.go
@@ -58,7 +58,7 @@ const (
// CLAIM-ACCOUNT: empty picker choice.
demoClaimChooseAccount = "Choose an account"
// CLAIM-ACCOUNT-NEW: zero membership confirmation.
- demoClaimNewAccount = "We will create a personal account and keep this demo in it."
+ demoClaimNewAccount = "You don't have an account yet. We will create a personal one and keep this demo in it."
// CLAIM-ACCOUNT: explicit claim action.
demoClaimConfirm = "Keep this demo"
// CLAIM-RESULT: reload action.
@@ -93,7 +93,7 @@ const (
// CLAIM-PERMANENT: domain only; the eventual name may need a suffix.
demoClaimPermanent = "It gets a permanent address on %s."
// CLAIM-DESTINATION: the only eligible account.
- demoClaimDestination = "This goes into %s"
+ demoClaimDestination = "This goes into %s."
// CLAIM-KEEP-IN: action after choosing an account.
demoClaimKeepIn = "Keep in %s"
// CLAIM-ROOM-AVAILABLE: the account has room for the app and its instance.
@@ -101,7 +101,7 @@ const (
// CLAIM-ROOM-FULL: current use is at or above the catalog cap.
demoClaimFull = "Full: %d of %d apps and instances in use"
// CLAIM-ROOM-INSUFFICIENT: one slot remains, but the claim needs two.
- demoClaimNoRoom = "Not enough room: %d of %d apps and instances in use. This demo needs room for 2."
+ demoClaimNoRoom = "Not enough room: %d of %d apps and instances in use. This demo needs room for one app and its instance."
// CLAIM-ROLE-DENIED: membership cannot create apps.
demoClaimRoleDenied = "Your role cannot create apps in this account."
// CLAIM-STEP-COPYING: first progress step.
@@ -110,8 +110,10 @@ const (
demoClaimStarting = "Starting your app"
// CLAIM-STEP-DONE: final progress step.
demoClaimDone = "Done"
+ // CLAIM-STOPPING: undoing an unfinished claim.
+ demoClaimStopping = "The claim did not finish. The demo is not serving its pages while we undo the claim. When this finishes, the demo resumes if its 24 hours have not ended."
// CLAIM-POLL-FAILED: repeated status failures, with a reload link.
demoClaimPollFailed = "Progress could not be checked. Reload to try again."
// CLAIM-OLD-ADDRESS: notice lifetime, without a redirect promise.
- demoClaimOldAddress = "The old address shows a short notice with a link to this app until the demo's original expiry."
+ demoClaimOldAddress = "The old address shows a short notice with a link to this app until the demo's original 24 hours end."
)
diff --git a/internal/console/demo_claim_page.go b/internal/console/demo_claim_page.go
index 6b88cb47a..9dee722e5 100644
--- a/internal/console/demo_claim_page.go
+++ b/internal/console/demo_claim_page.go
@@ -163,15 +163,17 @@ func (s *Server) handleDemoClaimPage(w http.ResponseWriter, r *http.Request) {
p.HasIntent = false
p.DemoName, p.DemoHost, p.Permanent = "", "", ""
p.CanClaim = false
- } else {
+ } else if p.CanClaim {
var accounts []Account
accounts, err = s.store.AccountsFor(address)
if err != nil {
s.demoClaimBrowserError(w, 503, demoClaimUnavailable)
return
}
- for _, a := range accounts {
- choice := s.demoClaimAccountView(r.Context(), a, r.Method == http.MethodGet)
+ roomCtx, cancelRoom := context.WithTimeout(r.Context(), 2*time.Second)
+ defer cancelRoom()
+ for i, a := range accounts {
+ choice := s.demoClaimAccountView(roomCtx, a, r.Method == http.MethodGet && i < 20)
p.Accounts = append(p.Accounts, choice)
if choice.Reason == "" {
p.Eligible++
@@ -549,7 +551,7 @@ func demoClaimBrowserCopy() map[string]string {
"confirm": demoClaimConfirm,
"reload": demoClaimReload,
"complete": demoClaimComplete,
- "url": demoClaimURLLabel,
+ "stopping": demoClaimStopping,
"aborted": demoClaimAborted,
"disabled": demoClaimUnavailable,
}
@@ -602,7 +604,7 @@ func (s *Server) demoClaimAccountView(ctx context.Context, a Account, count bool
if !demoClaimCanCreate(a) {
c.Reason = demoClaimRoleDenied
}
- if cat := s.cfg.PlanCatalog; cat != nil {
+ if cat := s.cfg.PlanCatalog; cat != nil && !s.store.planExempt(a.ID) {
name := cat.DefaultPlan
row, err := s.store.AccountPlan(a.ID)
if err == nil {
@@ -612,7 +614,7 @@ func (s *Server) demoClaimAccountView(ctx context.Context, a Account, count bool
c.Plan = planLabel(name)
}
}
- if !count || c.Reason != "" {
+ if !count || c.Reason != "" || ctx.Err() != nil {
return c
}
limits, err := s.EffectiveLimits(&a)
@@ -620,7 +622,7 @@ func (s *Server) demoClaimAccountView(ctx context.Context, a Account, count bool
return c
}
n, err := s.runningThings(ctx, &a)
- if err != nil {
+ if err != nil || ctx.Err() != nil {
return c
}
switch {
diff --git a/internal/console/demo_claim_resume_browser_test.go b/internal/console/demo_claim_resume_browser_test.go
index b1452bee6..065f8e69c 100644
--- a/internal/console/demo_claim_resume_browser_test.go
+++ b/internal/console/demo_claim_resume_browser_test.go
@@ -36,7 +36,16 @@ func TestDemoClaimSelectStepUpHeadless(t *testing.T) {
if r.URL.Query().Get("testProgress") == "abort" {
mode.Store(2)
}
- if _, err := s.store.db.Exec(`UPDATE demo_claim_ops SET phase='copying'`); err != nil {
+ phase := "copying"
+ if r.URL.Query().Get("testProgress") == "stopping" {
+ mode.Store(3)
+ phase = "verifying"
+ }
+ if r.URL.Query().Get("testProgress") == "unknown" {
+ mode.Store(4)
+ phase = "future-phase"
+ }
+ if _, err := s.store.db.Exec(`UPDATE demo_claim_ops SET phase=?`, phase); err != nil {
t.Error(err)
}
}
@@ -54,6 +63,15 @@ func TestDemoClaimSelectStepUpHeadless(t *testing.T) {
if n >= 4 {
phase = "done"
}
+ if mode.Load() == 3 {
+ phase = "aborting"
+ if n >= 3 {
+ phase = "aborted"
+ }
+ }
+ if mode.Load() == 4 {
+ phase = "future-phase"
+ }
if mode.Load() == 2 {
phase = "aborted"
}
@@ -102,7 +120,19 @@ func TestDemoClaimSelectStepUpHeadless(t *testing.T) {
// multi-account flow used for the keyboard and fresh-auth round trip.
single, _, singleToken := claimTestServer(t)
single.registerRoute("GET /static/{hash}/{file...}", single.handleStatic)
- singleServer := httptest.NewServer(single.mux)
+ singleServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if r.URL.Query().Has("long") {
+ if _, err := single.store.db.Exec(`UPDATE accounts SET name=? WHERE id=601`, strings.Repeat("LongAccountName", 10)); err != nil {
+ t.Error(err)
+ }
+ claimAccount(t, single, 602, "shop@example.com", RoleOwner)
+ host := strings.Repeat("long-demo-", 6) + "." + strings.Repeat("long-domain-", 5) + ".example.com"
+ if _, err := single.store.db.Exec(`UPDATE demo_apps SET host=?`, host); err != nil {
+ t.Error(err)
+ }
+ }
+ single.mux.ServeHTTP(w, r)
+ }))
defer singleServer.Close()
single.cfg.Origin = singleServer.URL
one := newClaimBrowser(t, single, singleToken)
@@ -133,7 +163,7 @@ func TestDemoClaimSelectStepUpHeadless(t *testing.T) {
}
singleArgs, _ := json.Marshal(map[string]string{"target": singleServer.URL, "session": one.session, "cookie": one.cookie,
"capacityTarget": capacityServer.URL, "capacitySession": room.session, "capacityCookie": room.cookie})
- ctx, cancel := context.WithTimeout(t.Context(), 90*time.Second)
+ ctx, cancel := context.WithTimeout(t.Context(), 120*time.Second)
defer cancel()
cmd := exec.CommandContext(ctx, node, "testdata/demo_claim_resume_browser.mjs", chromium, t.TempDir(), ts.URL, b.session, b.cookie, a.Sqid, os.Getenv("CARLOS_DEMO_CLAIM_SCREENSHOTS"), string(singleArgs))
output, err := cmd.CombinedOutput()
diff --git a/internal/console/demo_claim_status_page.go b/internal/console/demo_claim_status_page.go
index 7caa821e8..e61ff461d 100644
--- a/internal/console/demo_claim_status_page.go
+++ b/internal/console/demo_claim_status_page.go
@@ -44,6 +44,10 @@ func (s *Server) handleDemoClaimBrowserStatus(w http.ResponseWriter, r *http.Req
func demoClaimProgressStep(phase string) (string, int) {
switch phase {
+ case "reserved", "freezing", "copying":
+ return "claiming", 1
+ case "aborting":
+ return "stopping", 0
case "verifying", "committed":
return "claiming", 2
case "done":
@@ -51,6 +55,6 @@ func demoClaimProgressStep(phase string) (string, int) {
case "aborted":
return "aborted", 0
default:
- return "claiming", 1
+ return "claiming", 0
}
}
diff --git a/internal/console/static/demo_claim.js b/internal/console/static/demo_claim.js
index 2a48b76c1..b1c8f1b34 100644
--- a/internal/console/static/demo_claim.js
+++ b/internal/console/static/demo_claim.js
@@ -13,7 +13,10 @@
if (choice) {
const radios = choice.querySelectorAll('input[type="radio"]:not(:disabled)');
const button = choice.querySelector('button[type="submit"]');
+ let submitted = false;
+ choice.addEventListener("submit", () => { submitted = true; });
const update = () => {
+ if (submitted) return;
const selected = choice.querySelector('input[type="radio"]:checked:not(:disabled)');
button.disabled = !selected;
button.textContent = selected ? selected.dataset.button : button.dataset.neutral;
@@ -27,7 +30,10 @@
if (progress && !token) {
const status = document.getElementById("claim-status");
const reload = document.getElementById("claim-reload");
- const labels = ["", progress.dataset.copying, progress.dataset.starting, progress.dataset.done];
+ const labels = [progress.dataset.neutral, progress.dataset.copying, progress.dataset.starting, progress.dataset.done];
+ const setStatus = text => {
+ if (status.textContent !== text) status.textContent = text;
+ };
let failures = 0;
reload.hidden = true;
const poll = async () => {
@@ -41,16 +47,18 @@
if (result.state === "aborted" && result.step === 0) {
for (const step of progress.querySelectorAll("[data-step]")) step.removeAttribute("aria-current");
status.classList.remove("claim-sr-only");
- status.textContent = progress.dataset.aborted;
+ setStatus(progress.dataset.aborted);
return;
}
- if (!((result.state === "claiming" && [1, 2].includes(result.step)) ||
+ if (!((result.state === "claiming" && [0, 1, 2].includes(result.step)) ||
+ (result.state === "stopping" && result.step === 0) ||
(result.state === "claimed" && result.step === 3))) throw new Error();
for (const step of progress.querySelectorAll("[data-step]")) {
if (Number(step.dataset.step) === result.step) step.setAttribute("aria-current", "step");
else step.removeAttribute("aria-current");
}
- status.textContent = labels[result.step];
+ status.classList.toggle("claim-sr-only", result.step > 0);
+ setStatus(result.state === "stopping" ? progress.dataset.stopping : labels[result.step]);
if (result.state === "claimed") {
location.replace("/demo/claim");
return;
@@ -59,7 +67,7 @@
} catch (_) {
if (++failures >= 3) {
status.classList.remove("claim-sr-only");
- status.textContent = progress.dataset.pollFailed;
+ setStatus(progress.dataset.pollFailed);
reload.hidden = false;
return;
}
diff --git a/internal/console/templates/demo_claim.html b/internal/console/templates/demo_claim.html
index dbe51a32f..1c701b957 100644
--- a/internal/console/templates/demo_claim.html
+++ b/internal/console/templates/demo_claim.html
@@ -43,21 +43,21 @@
<p>{{.Copy.saved}} {{.Permanent}}</p>
</div>{{end}}
{{if .Error}}<p role="alert">{{.Error}}</p><p><a href="/demo/claim">{{.Copy.back}}</a></p>{{end}}
-{{if eq .State "no_accounts"}}<p>{{.Copy.noAccounts}}</p>
+{{if eq .State "no_accounts"}}<p>{{.Copy.identity}} <strong>{{.Address}}</strong></p><p>{{.Copy.noAccounts}}</p>
<fieldset class="claim-unavailable"><legend>{{.Copy.unavailableAccounts}}</legend>{{range .Accounts}}{{template "claim_card" .}}{{end}}</fieldset>{{end}}
<input type="hidden" name="nonce" value="{{.Nonce}}">
<input type="hidden" name="csrf" value="{{.CSRF}}">
<p id="claim-error" role="alert" tabindex="-1" hidden></p>
{{if eq .State "missing"}}<p>{{.Copy.missing}}</p>{{end}}
{{if eq .State "disabled"}}<p>{{.Copy.disabled}}</p>{{end}}
-{{if eq .State "claiming"}}
-<div id="claim-progress" data-copying="{{.Copy.copying}}" data-starting="{{.Copy.starting}}" data-done="{{.Copy.done}}" data-aborted="{{.Copy.aborted}}" data-poll-failed="{{.Copy.pollFailed}}">
+{{if or (eq .State "claiming") (eq .State "stopping")}}
+<div id="claim-progress" data-neutral="{{.Copy.title}}" data-stopping="{{.Copy.stopping}}" data-copying="{{.Copy.copying}}" data-starting="{{.Copy.starting}}" data-done="{{.Copy.done}}" data-aborted="{{.Copy.aborted}}" data-poll-failed="{{.Copy.pollFailed}}">
<ol class="claim-steps">
<li data-step="1"{{if eq .Step 1}} aria-current="step"{{end}}>{{.Copy.copying}}</li>
<li data-step="2"{{if eq .Step 2}} aria-current="step"{{end}}>{{.Copy.starting}}</li>
<li data-step="3"{{if eq .Step 3}} aria-current="step"{{end}}>{{.Copy.done}}</li>
</ol>
-<p id="claim-status" class="claim-sr-only" role="status" aria-live="polite">{{if eq .Step 2}}{{.Copy.starting}}{{else}}{{.Copy.copying}}{{end}}</p>
+<p id="claim-status"{{if gt .Step 0}} class="claim-sr-only"{{end}} role="status" aria-live="polite">{{if eq .State "stopping"}}{{.Copy.stopping}}{{else if eq .Step 2}}{{.Copy.starting}}{{else if eq .Step 1}}{{.Copy.copying}}{{else}}{{.Copy.title}}{{end}}</p>
<a id="claim-reload" href="/demo/claim">{{.Copy.reload}}</a>
</div>{{end}}
{{if eq .State "aborted"}}<p>{{.Copy.aborted}}</p>{{end}}
@@ -78,7 +78,7 @@
<fieldset><legend>{{.Copy.choose}}</legend>
{{range .Accounts}}
<label class="claim-card"><input type="radio" name="accountId" value="{{.Sqid}}"{{if eq .Sqid $.SelectedAccount}} checked{{end}}{{if .Reason}} disabled{{else}} required{{end}} data-button="{{.Button}}">
-<span><strong>{{.Name}}</strong>{{with .Plan}}<span class="claim-detail">{{.}}</span>{{end}}{{with .Room}}<span class="claim-detail">{{.}}</span>{{end}}{{with .Reason}}<span>{{.}}</span>{{end}}</span></label>
+<span><strong>{{.Name}}</strong>{{with .Plan}}<span class="claim-detail">{{.}}</span>{{end}}{{with .Room}}<span class="claim-detail">{{.}}</span>{{end}}{{with .Reason}}<span class="claim-detail">{{.}}</span>{{end}}</span></label>
{{end}}</fieldset>
{{else}}<p>{{.Copy.new}}</p><input type="hidden" name="create" value="1">{{end}}
<p id="claim-resuming" role="status" hidden>{{.Copy.resuming}}</p>
@@ -109,5 +109,5 @@
{{define "claim_card"}}
<label class="claim-card"><input type="radio" name="accountId" value="{{.Sqid}}" disabled>
-<span><strong>{{.Name}}</strong>{{with .Plan}}<span class="claim-detail">{{.}}</span>{{end}}{{with .Room}}<span class="claim-detail">{{.}}</span>{{end}}<span>{{.Reason}}</span></span></label>
+<span><strong>{{.Name}}</strong>{{with .Plan}}<span class="claim-detail">{{.}}</span>{{end}}{{with .Room}}<span class="claim-detail">{{.}}</span>{{end}}<span class="claim-detail">{{.Reason}}</span></span></label>
{{end}}
diff --git a/internal/console/testdata/demo_claim_resume_browser.mjs b/internal/console/testdata/demo_claim_resume_browser.mjs
index 64264d637..4c08dfecd 100644
--- a/internal/console/testdata/demo_claim_resume_browser.mjs
+++ b/internal/console/testdata/demo_claim_resume_browser.mjs
@@ -56,7 +56,7 @@ async function capture(state) {
for (const scheme of ['light','dark']) {
await call('Emulation.setEmulatedMedia',{features:[{name:'prefers-color-scheme',value:scheme},{name:'prefers-reduced-motion',value:'reduce'}]});
await new Promise(r=>setTimeout(r,150));
- assert.equal(await evaluate('document.documentElement.scrollWidth <= innerWidth'),true,state+' overflows at '+width);
+ assert.equal(await evaluate('document.documentElement.scrollWidth <= document.documentElement.clientWidth'),true,state+' overflows at '+width);
if (state === 'done') {
assert.equal(await evaluate('(() => { const link = document.querySelector(".claim-result a"); const rect = link.getBoundingClientRect(); return rect.left >= 0 && rect.right <= innerWidth && link.scrollWidth <= link.clientWidth; })()'),true,'result address overflows at '+width);
}
@@ -67,7 +67,7 @@ async function capture(state) {
}
}
}
-const timer = setTimeout(() => { chrome.kill('SIGKILL'); process.exitCode = 1; }, 85000);
+const timer = setTimeout(() => { chrome.kill('SIGKILL'); process.exitCode = 1; }, 115000);
try {
const created = await call('Target.createTarget', {url:'about:blank'}, false);
session = (await call('Target.attachToTarget', {targetId:created.targetId, flatten:true}, false)).sessionId;
@@ -100,6 +100,12 @@ try {
assert.equal(await evaluate('document.querySelector(".claim-single").innerText.includes("Has room")'),true);
assert.equal(await evaluate('document.querySelector(".claim-single").innerText.includes("apps and instances")'),false);
await capture('one');
+ await call('Page.navigate',{url:single.target+'/demo/claim?long=1'});
+ await until('document.readyState === "complete" && document.querySelectorAll(".claim-card").length === 2');
+ assert.equal(await evaluate('document.querySelector(".claim-card strong").textContent.length > 100'), true);
+ assert.equal(await evaluate('document.querySelector(".claim-summary a").textContent.length > 100'), true);
+ await evaluate('document.querySelector(".claim-card input").click()');
+ await capture('long-name');
await call('Network.setCookies', {cookies:[
{name:'carlos_console_session',value:single.capacitySession,url:single.capacityTarget,path:'/',httpOnly:true,sameSite:'Lax'},
{name:'carlos_demo_claim_flow',value:single.capacityCookie,url:single.capacityTarget,path:'/demo/claim',httpOnly:true,secure:true,sameSite:'Lax'}
@@ -109,7 +115,7 @@ try {
const capacityCards = await evaluate('Array.from(document.querySelectorAll(".claim-card"), card => ({text:card.innerText,disabled:card.querySelector("input").disabled}))');
assert(capacityCards.every(card=>card.disabled));
assert(capacityCards.some(card=>card.text.includes('Full: 3 of 3 apps and instances in use')));
- assert(capacityCards.some(card=>card.text.includes('Not enough room: 2 of 3 apps and instances in use. This demo needs room for 2.')));
+ assert(capacityCards.some(card=>card.text.includes('Not enough room: 2 of 3 apps and instances in use. This demo needs room for one app and its instance.')));
await capture('capacity');
await call('Network.setCookies', {cookies:[
{name:'carlos_console_session',value:sessionToken,url:target,path:'/',httpOnly:true,sameSite:'Lax'},
@@ -148,8 +154,14 @@ try {
assert.equal(await evaluate('document.querySelectorAll("script").length'),1);
assert.equal(await evaluate('document.querySelector("#claim button[type=submit]").textContent'), 'Keep in Personal projects');
assert.equal(await evaluate('Array.from(document.querySelectorAll(".claim-card:has(input:not(:disabled))")).every(card => card.innerText.includes("Has room") && !card.innerText.includes("apps and instances"))'),true);
- assert.deepEqual(await evaluate('Array.from(document.querySelectorAll(".claim-card:has(input:disabled) .claim-detail")).map(el => el.textContent)'),['Free']);
+ assert.deepEqual(await evaluate('Array.from(document.querySelectorAll(".claim-card:has(input:disabled) .claim-detail")).map(el => el.textContent)'),['Free', 'Your role cannot create apps in this account.']);
await capture('many');
+ await evaluate(`const form = document.querySelector('form[action="/demo/claim/select"]'); form.addEventListener('submit', event => event.preventDefault(), {once:true}); form.requestSubmit(); document.querySelector('#claim input[type=radio]:not(:disabled)').click()`);
+ assert.equal(await evaluate('document.querySelector("#claim button[type=submit]").disabled'),true,'radio change re-enabled submitted button');
+ await call('Page.navigate', {url:target+'/demo/claim'});
+ await until('document.readyState === "complete" && !!document.querySelector("input[type=radio][name=accountId]")');
+ await evaluate(`document.querySelector('input[value='+${JSON.stringify(account)}+']').click()`);
+ submissions.length = 0;
await evaluate(`const button = document.querySelector('form[action="/demo/claim/select"] button'); button.click(); button.click()`);
await until(`!!document.querySelector("p[role=status]") && !document.querySelector('form[action="/demo/claim/select"]')`);
assert.equal(await evaluate('location.pathname'),'/demo/claim');
@@ -166,6 +178,12 @@ try {
assert.equal(await evaluate('getComputedStyle(document.getElementById("claim-status")).clipPath'),'inset(50%)');
assert.equal(await evaluate('document.querySelector("li[aria-current=step]").getBoundingClientRect().height > 1'),true);
await capture('progress');
+ await evaluate('window.liveWrites = 0; new MutationObserver(records => window.liveWrites += records.length).observe(document.getElementById("claim-status"), {childList:true,subtree:true,characterData:true})');
+ const repeatedPoll = statusRequests;
+ await until('document.querySelector("li[aria-current=step]")?.dataset.step === "2"');
+ for (let i=0; i<40 && statusRequests === repeatedPoll; i++) await new Promise(r=>setTimeout(r,100));
+ await new Promise(r=>setTimeout(r,200));
+ assert.equal(await evaluate('window.liveWrites'),0,'unchanged poll rewrote live region');
await until('!!document.querySelector(".claim-result a")');
await capture('done');
assert.equal(await evaluate('document.querySelector(".claim-result a").textContent.replace(/^https:\\/\\//, "")'),await evaluate('document.querySelector(".claim-result a").getAttribute("href").replace(/^https:\\/\\//, "")'));
@@ -200,6 +218,20 @@ try {
await new Promise(r=>setTimeout(r,3500));
assert.equal(statusRequests-beforeAbort,1,'aborted kept polling');
assert.equal(security.length,0,JSON.stringify(security));
+ await call('Page.navigate',{url:target+'/demo/claim?testProgress=stopping'});
+ await until('document.querySelector("li[aria-current=step]")?.dataset.step === "2"');
+ await until('document.getElementById("claim-status")?.textContent === document.getElementById("claim-progress")?.dataset.stopping');
+ assert.equal(await evaluate('document.querySelectorAll("[aria-current=step]").length'),0);
+ assert.equal(await evaluate('getComputedStyle(document.getElementById("claim-status")).clipPath'),'none');
+ await capture('stopping');
+ await until('document.getElementById("claim-status")?.textContent === document.getElementById("claim-progress")?.dataset.aborted');
+ await call('Page.navigate',{url:target+'/demo/claim?testProgress=unknown'});
+ await until('!!document.getElementById("claim-progress") && document.querySelectorAll("[aria-current=step]").length === 0');
+ const unknownPolls = statusRequests;
+ await new Promise(r=>setTimeout(r,6500));
+ assert(statusRequests >= unknownPolls + 2, 'neutral progress stopped polling');
+ assert.equal(await evaluate('document.getElementById("claim-status").textContent'),'Keep your demo');
+ assert.equal(await evaluate('document.querySelectorAll("[aria-current=step]").length'),0);
process.stdout.write('fallback: stopped after three failures, retained no-script reload, stopped on abort; no CSP violations\n');
} finally {
clearTimeout(timer);