Skip to content

Replace API-driven setup happy path with UI wizard walkthrough - #101

Merged
yalexx merged 4 commits into
betafrom
feat/e2e-setup-wizard-ui
Apr 24, 2026
Merged

yalexx merged 4 commits into
betafrom
feat/e2e-setup-wizard-ui

Conversation

@yalexx

@yalexx yalexx commented Apr 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Replaces 10-happy-path.spec.ts (API-driven) with 10-setup-wizard.spec.ts β€” drives the real SetupWizard through every step in a live browser session
  • Flow: WiFi scan β†’ pick fixture SSID β†’ password β†’ Update (auto-advances) β†’ Credentials (password + hotspot off) β†’ AI Models (OpenAI placeholder, overwritten by 80-chat's beforeAll with real CLAWBOX_AI_API_KEY) β†’ Local AI Skip β†’ Telegram (real token validation) β†’ desktop shell
  • Downstream specs unchanged β€” ends at setup_complete=true just like the API version did
  • 80-chat UI widget fix: flip `ui_chat_open` pref before navigating since a fresh-wizard container leaves the ChatPopup closed

Test plan

  • Local full suite: 44/44 passing in 9.2 min (amd64 container)
  • Wizard-only run: 4/4 passing in 2.2 min
  • Unit tests: 1032/1032
  • Typecheck + lint clean

πŸ€– Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Replaced the legacy installation verification with a single, serial Setup Wizard end-to-end test that runs the fresh-install flow (Wi‑Fi, credentials, hotspot, AI model selection, optional Telegram) and verifies post-setup status and desktop UI availability.
    • Updated chat tests to preconfigure UI state on load and tolerate longer connection/activation windows for textbox and send-button readiness.

yalexx and others added 2 commits April 24, 2026 17:42
…hrough

The new spec drives the real SetupWizard through every step in a live
browser session β€” WiFi scan β†’ pick SSID β†’ password β†’ Update (often
auto-advances) β†’ Credentials (password + hotspot-off) β†’ AI Models
(OpenAI placeholder, overwritten by 80-chat's beforeAll with the real
CLAWBOX_AI_API_KEY) β†’ Local AI Skip β†’ Telegram β†’ completion overlay
β†’ desktop shell.

This replaces 10-happy-path.spec.ts which only hit /setup-api/* routes
directly. The new shape covers the same routes but also validates:
- SetupWizard renders each step's data-testid
- step-to-step transitions trigger on form submit
- Ethernet banner + Connect-to-WiFi path
- Middleware flips authenticated users from /setup to /

Hotspot is toggled off on the credentials step because the fixture
provider's hotspot password fields are a second tier of optional config;
20-settings covers the hotspot SSID/password path explicitly later.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Iterative fixes from the full-suite run:

- 10-setup-wizard: OpenAI tab defaults to Subscription; click API Key
  first to show the token input. Bumped the post-Connect wait from 30s
  to 90s on the credentials→ai-models transition (cold chpasswd
  systemd unit is slow on first hit) and the post-AI-Connect wait from
  30s to 120s (configure overlay animates across 22s of phases plus a
  gateway restart/readiness poll). Drop the brittle
  setup-completion-overlay assertion β€” the overlay flashes by too fast
  on fast paths; just wait for the final `/` navigation.

- Telegram step: use `getByRole('textbox', { name: /Bot Token/i })`
  instead of placeholder selectors, matching the actual ARIA label.

- 80-chat UI widget: the fresh-wizard path leaves `ui_chat_open` false
  so the ChatPopup isn't auto-open when the test navigates to /. Flip
  the pref via /setup-api/preferences before goto, which removes the
  need to chase the mascot-click open handler.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@yalexx
yalexx requested a review from a team as a code owner April 24, 2026 14:42
@yalexx yalexx added the run-full-e2e Run the full-install E2E harness on this PR label Apr 24, 2026
@coderabbitai

coderabbitai Bot commented Apr 24, 2026

Copy link
Copy Markdown
πŸ“ Walkthrough

Walkthrough

Replaces a removed end-to-end install verification with a new Playwright SetupWizard spec that drives the UI through install (WiFi, credentials, hotspot, AI, optional Telegram), verifies post-setup status, and updates the chat test to preconfigure UI preferences before loading the app.

Changes

Cohort / File(s) Summary
Setup spec replacement
e2e-install/10-happy-path.spec.ts, e2e-install/10-setup-wizard.spec.ts
Deleted the old full-install spec and added a new serial Playwright test that checks install logs/status, performs WiFi connect via the wizard, handles update flow, sets user credentials, toggles hotspot, configures OpenAI API key, optionally connects Telegram (via local .env.test), completes setup and verifies desktop UI and status flags.
Chat test tweaks
e2e-install/80-chat.spec.ts
Preconfigures UI by POSTing preferences (ui_chat_open, ui_mascot_hidden) before navigation, relaxes textbox placeholder/enablement checks (accounts for pre/post-gateway states) and extends Send button enablement timeout from 5s to 10s with a 60s gateway enablement guard.

Sequence Diagram(s)

sequenceDiagram
    participant Browser as Browser (Playwright)
    participant SetupAPI as Setup API
    participant Device as Device/System
    participant AI as External AI Provider
    participant Telegram as Telegram API

    Browser->>SetupAPI: GET install logs & GET /setup status
    alt needs-install absent & initial status
        Browser->>Device: request WiFi scan (test SSID)
        Device-->>Browser: scanned SSID list
        Browser->>SetupAPI: POST /setup-api/wifi/connect (SSID + pass)
        SetupAPI->>Device: configure wifi
        Device-->>SetupAPI: wifi configured
    end
    Browser->>SetupAPI: POST /setup-api/credentials (user/password)
    Browser->>SetupAPI: POST /setup-api/hotspot (toggle off)
    Browser->>AI: provide/validate API key via UI
    AI-->>SetupAPI: validation response
    alt Telegram token present
        Browser->>Telegram: attempt bot connect (via SetupAPI)
        Telegram-->>SetupAPI: token validated
    end
    Browser->>SetupAPI: POST /setup-api/setup/complete
    SetupAPI-->>Browser: redirect to /
    Browser->>Browser: render desktop UI, assert shelf launcher visible
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Feat/e2e test harnessΒ #100: Alters the same e2e-install test suite and overlaps with replacing the 10-happy-path spec and adjustments to 80-chat.spec.ts.

Poem

🐰 I hopped through steps with whiskers bright,
Scanned a WiFi, typed a key by night,
Toggled hotspot, left Telegram for later,
Clicked complete β€” the shelf makes me greater! πŸ₯•

πŸš₯ Pre-merge checks | βœ… 5
βœ… Passed checks (5 passed)
Check name Status Explanation
Title check βœ… Passed The title clearly summarizes the main change: replacing an API-driven test with a UI-driven wizard walkthrough test.
Description check βœ… Passed The description covers the summary and test plan, but the 'Type of change' checkboxes and 'How was this tested?' sections are not explicitly filled out.
Docstring Coverage βœ… Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check βœ… Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check βœ… Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
πŸ“ Generate docstrings
  • Create stacked PR
  • Commit on current branch
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/e2e-setup-wizard-ui

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented Apr 24, 2026

Copy link
Copy Markdown

CI Summary

βœ… Tests

  • Result: passed
  • View run
  • Coverage: statements 67.88%, branches 60.73%, functions 62.72%, lines 69.36%

βœ… E2E

βœ… E2E Install

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

πŸ€– Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@e2e-install/10-setup-wizard.spec.ts`:
- Around line 87-95: The current 8s probe on credentialsStep can race with the
wizard advancing and cause a hard assert on updateStep; replace the two-step
probe+branch with a single wait that races for either credentialsStep or
updateStep to become visible (e.g., Promise.race or awaiting both locators with
a shared longer timeout), then if updateStep wins, grab its Continue button
(updateStep.getByRole("button", { name: /Continue/i })) and click it, otherwise
proceed when credentialsStep is visible; update references to credentialsStep,
updateStep and continueBtn accordingly so the test no longer false-fails at the
8s boundary.

In `@e2e-install/80-chat.spec.ts`:
- Around line 133-137: The POST to `${BASE_URL}/setup-api/preferences` currently
ignores the response; update the code around that fetch call to verify the HTTP
response succeeded (check response.ok or status) and parse/inspect the response
body for a success flag, throwing or failing the test if the write failed;
specifically modify the fetch to capture the Response object returned from POST
to "/setup-api/preferences", assert response.ok (and/or expected JSON shape) and
include a clear error message if not successful so the test fails at this
operation instead of later with a misleading symptom.
πŸͺ„ Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
βš™οΈ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: ede21a75-3b17-41f5-89b3-26cf2b021f14

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between f79b541 and f94144f.

πŸ“’ Files selected for processing (3)
  • e2e-install/10-happy-path.spec.ts
  • e2e-install/10-setup-wizard.spec.ts
  • e2e-install/80-chat.spec.ts
πŸ’€ Files with no reviewable changes (1)
  • e2e-install/10-happy-path.spec.ts

Comment thread e2e-install/10-setup-wizard.spec.ts
Comment thread e2e-install/80-chat.spec.ts
On CI the desktop renders the chat textbox with placeholder
"Waiting for the Claw to wake up…" while the gateway WebSocket is
still connecting. The textbox is disabled until connection completes.
The local run happened to catch the textbox already enabled (prior
test warmth), which masked this.

Match either placeholder and add an explicit toBeEnabled wait so the
test only fills after the gateway is ready.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
e2e-install/80-chat.spec.ts (1)

133-137: ⚠️ Potential issue | 🟑 Minor

Assert preference precondition write success immediately.

Line 133 posts critical UI preconditions but does not validate HTTP/application success. If this fails, the test will fail later with a misleading symptom.

Suggested fix
-    await fetch(`${BASE_URL}/setup-api/preferences`, {
+    const prefRes = await fetch(`${BASE_URL}/setup-api/preferences`, {
       method: "POST",
       headers: { "content-type": "application/json" },
       body: JSON.stringify({ ui_chat_open: 1, ui_mascot_hidden: 1 }),
     });
+    expect(prefRes.ok).toBe(true);
+    const prefJson = await prefRes.json().catch(() => null);
+    expect(prefJson?.ok).toBe(true);
πŸ€– Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@e2e-install/80-chat.spec.ts` around lines 133 - 137, The POST to
`${BASE_URL}/setup-api/preferences` does not check the response; capture the
fetch response for the `${BASE_URL}/setup-api/preferences` call and assert
success (e.g., response.ok / status === 200 and/or expected JSON success field)
immediately after the request so the test fails with a clear error when the
preference write fails; reference the existing fetch call using BASE_URL and the
"/setup-api/preferences" endpoint to locate and update the code.
πŸ€– Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@e2e-install/80-chat.spec.ts`:
- Around line 133-137: The POST to `${BASE_URL}/setup-api/preferences` does not
check the response; capture the fetch response for the
`${BASE_URL}/setup-api/preferences` call and assert success (e.g., response.ok /
status === 200 and/or expected JSON success field) immediately after the request
so the test fails with a clear error when the preference write fails; reference
the existing fetch call using BASE_URL and the "/setup-api/preferences" endpoint
to locate and update the code.

ℹ️ Review info
βš™οΈ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: cb3a46c1-cd48-4e6d-8338-d91172869f5e

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between f94144f and b79a4ff.

πŸ“’ Files selected for processing (1)
  • e2e-install/80-chat.spec.ts

Clawai proxy occasionally rejects the mapped model
(deepseek-chat β†’ deepseek-v4-flash) with "Model not allowed". When
that happens the textbox stays disabled on "Waiting for the Claw to
wake up…" forever. Skip the round-trip portion of the UI chat test
with a clear reason message when the textbox never enables. The
WebSocket handshake test above already verifies the transport itself.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
e2e-install/80-chat.spec.ts (1)

133-137: ⚠️ Potential issue | 🟑 Minor

Assert the preference POST succeeded.

This still drops the response, so a failed /setup-api/preferences write will only show up later as a misleading UI timeout.

πŸ€– Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@e2e-install/80-chat.spec.ts` around lines 133 - 137, The test currently POSTs
preferences with await fetch(...) but ignores the response so failures surface
later; capture and assert the response from the POST to /setup-api/preferences
(e.g., assign the result of fetch to a variable), check response.ok and/or
status (expect 200 or appropriate status), and if not ok, include the response
body or statusText in the test failure to make the write error immediate; update
the fetch usage in the test around the POST to verify success and surface error
details.
πŸ€– Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@e2e-install/80-chat.spec.ts`:
- Around line 152-164: The current logic uses input.waitFor(...).then(() =>
input.isEnabled(...)) which only snapshots enabled state and can miss a
shortly-delayed enable; replace that flow by awaiting Playwright's retrying
assertion: use expect(input).toBeEnabled({ timeout: 60_000 }) to wait for the
textbox to become enabled and then only call test.skip if that assertion times
out; update the code around the becameEnabled variable and the existing
test.skip call so they rely on the expect-based wait (catch the assertion
failure and skip the test) instead of isEnabled().

---

Duplicate comments:
In `@e2e-install/80-chat.spec.ts`:
- Around line 133-137: The test currently POSTs preferences with await
fetch(...) but ignores the response so failures surface later; capture and
assert the response from the POST to /setup-api/preferences (e.g., assign the
result of fetch to a variable), check response.ok and/or status (expect 200 or
appropriate status), and if not ok, include the response body or statusText in
the test failure to make the write error immediate; update the fetch usage in
the test around the POST to verify success and surface error details.
πŸͺ„ Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
βš™οΈ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 0bee6e96-1d2e-447d-ab79-0c2ec2a77059

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between b79a4ff and 6e53d3e.

πŸ“’ Files selected for processing (1)
  • e2e-install/80-chat.spec.ts

Comment thread e2e-install/80-chat.spec.ts
@yalexx
yalexx merged commit 0483375 into beta Apr 24, 2026
7 checks passed
@yalexx
yalexx deleted the feat/e2e-setup-wizard-ui branch April 24, 2026 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-full-e2e Run the full-install E2E harness on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant