Skip to content

test(web): cover dashboard failover semantics in dashboardView#46

Merged
adriannoes merged 1 commit into
developmentfrom
pr40/dashboard-failover-js
Jul 1, 2026
Merged

test(web): cover dashboard failover semantics in dashboardView#46
adriannoes merged 1 commit into
developmentfrom
pr40/dashboard-failover-js

Conversation

@adriannoes

Copy link
Copy Markdown
Owner

Summary

Cherry-picks net-new dashboard failover assertions from PR #40 (cursor/test-coverage-automation-6059) into developmenttests/test_web_dashboard.js only.

  • providerSemanticClass: fallback and standby → dash-yellow
  • discordSemanticClass: connecting → dash-yellow
  • dashboardMarkup: last_error banner (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

@cursor cursor 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.

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

  1. failoverHtml integration test is shallow (tests/test_web_dashboard.js ~L41–54): it asserts dash-banner-err and stub * substrings but not that provider rows receive the correct semantic classes. A regression disconnecting providerSemanticClass() from dashboardMarkup() would slip through. Consider asserting dash-red on the unavailable row and dash-yellow on the active fallback row.
  2. discordSemanticClass('connecting') (~L36): valuable as documentation, but connecting is handled by the default branch in dashboardView.js:44, not an explicit case. Also worth covering reconnecting — a real lifecycle string from discord_helpers.c — or adding explicit cases in the helper for clarity.
  3. Substring assertions (indexOf('stub *')): low risk here, but slightly brittle vs. checking the provider <td> class + name pattern.

Nice to Have

  • Assert the last_error message text appears in the banner (complements existing escapeHtml unit 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: unavailable for skipped backends, fallback for active non-primary, plus last_error / active_provider.
  • Appropriately scoped cherry-pick — tests only, no unrelated router or gateway changes.
  • Fits established Node headless test pattern and CI (nodejs installed in .github/workflows/ci.yml, test_web_dashboard in make test).
Open in Web View Automation 

Sent by Cursor Automation: Adrianno’s personal code review

},
{},
);
assert(failoverHtml.indexOf('dash-banner-err') !== -1, 'last_error banner');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@adriannoes
adriannoes merged commit 4d3f085 into development Jul 1, 2026
2 checks passed
@adriannoes
adriannoes deleted the pr40/dashboard-failover-js branch July 1, 2026 03:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant