test(web): cover dashboard failover semantics in dashboardView#46
Conversation
There was a problem hiding this comment.
Repository context
ShellClaw is a C99/C11 edge AI agent (Jetson / Raspberry Pi) with an embedded gateway Web UI (web/js/, libwebsockets). Frontend helpers in dashboardView.js are exercised headlessly via Node (tests/test_web_dashboard.js, wired into make test when Node is available).
PR context
Cherry-picks net-new dashboard failover assertions from PR #40 into development. Scope: tests/test_web_dashboard.js only (+18 lines). Intent: lock in failover UX semantics already implemented in web/js/dashboardView.js — yellow fallback/standby providers, yellow Discord connecting state, error banner, and active-provider asterisk.
Summary
Focused, test-only PR with good intent and alignment to the real /api/status contract from src/providers/router.c. Tests pass (node tests/test_web_dashboard.js). No production code changes; low risk. Approve with minor test-hardening suggestions below.
Must Fix
None.
Should Fix
failoverHtmlintegration test is shallow (tests/test_web_dashboard.js~L41–54): it assertsdash-banner-errandstub *substrings but not that provider rows receive the correct semantic classes. A regression disconnectingproviderSemanticClass()fromdashboardMarkup()would slip through. Consider assertingdash-redon the unavailable row anddash-yellowon the active fallback row.discordSemanticClass('connecting')(~L36): valuable as documentation, butconnectingis handled by the default branch indashboardView.js:44, not an explicit case. Also worth coveringreconnecting— a real lifecycle string fromdiscord_helpers.c— or adding explicit cases in the helper for clarity.- Substring assertions (
indexOf('stub *')): low risk here, but slightly brittle vs. checking the provider<td>class + name pattern.
Nice to Have
- Assert the
last_errormessage text appears in the banner (complements existingescapeHtmlunit tests). - Assert the "Active provider" card renders
stub(dashboardView.js:112). - Extract a shared failover fixture object if more dashboard scenarios are added later.
Positive Highlights
- Failover fixture mirrors
provider_router_api_status_json()semantics:unavailablefor skipped backends,fallbackfor active non-primary, pluslast_error/active_provider. - Appropriately scoped cherry-pick — tests only, no unrelated router or gateway changes.
- Fits established Node headless test pattern and CI (
nodejsinstalled in.github/workflows/ci.yml,test_web_dashboardinmake test).
Sent by Cursor Automation: Adrianno’s personal code review
| }, | ||
| {}, | ||
| ); | ||
| assert(failoverHtml.indexOf('dash-banner-err') !== -1, 'last_error banner'); |
There was a problem hiding this comment.
Should fix: This integration test only checks banner class and stub * text. Consider also asserting provider-row CSS classes — e.g. dash-red for { role: 'unavailable', reachable: false } and dash-yellow for { role: 'fallback', reachable: true }. That would catch a regression where providerSemanticClass() stops being wired into dashboardMarkup().
| assert(dash.providerSemanticClass('fallback', true) === 'dash-yellow', 'fallback yellow'); | ||
| assert(dash.providerSemanticClass('standby', true) === 'dash-yellow', 'standby yellow'); | ||
| assert(dash.discordSemanticClass('disconnected') === 'dash-red', 'discord red'); | ||
| assert(dash.discordSemanticClass('connecting') === 'dash-yellow', 'discord connecting'); |
There was a problem hiding this comment.
Nice to have: connecting is a real lifecycle string (discord_lifecycle_str), but discordSemanticClass handles it via the default yellow branch (dashboardView.js:44). Consider also asserting reconnecting, or add explicit cases for both in the helper so the comment and code stay in sync.


Summary
Cherry-picks net-new dashboard failover assertions from PR #40 (
cursor/test-coverage-automation-6059) intodevelopment—tests/test_web_dashboard.jsonly.providerSemanticClass: fallback and standby →dash-yellowdiscordSemanticClass: connecting →dash-yellowdashboardMarkup:last_errorbanner (dash-banner-err) and active provider mark (stub *)Does not include
tests/test_router.c(already on development).Test plan
node tests/test_web_dashboard.js