Skip to content

feat(dashrate): add single-file lite companion with test coverage#103

Merged
thephez merged 1 commit into
mainfrom
feat/dashrate-lite
Jul 2, 2026
Merged

feat(dashrate): add single-file lite companion with test coverage#103
thephez merged 1 commit into
mainfrom
feat/dashrate-lite

Conversation

@thephez

@thephez thephez commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Adds dashrate-lite.html, a no-build, CDN-loaded standalone page that demonstrates the same read-only count/query SDK patterns as the React app, for readers who want a minimal reference without a toolchain.

Adds a Playwright spec exercising it against real testnet.

Summary by CodeRabbit

  • New Features
    • Added a new DashRate Lite page for browsing review ratings on Dash Platform testnet.
    • Users can now view overall rating summaries, per-star distributions, and recent reviews.
    • Added resource selection and star-rating filtering to refine displayed reviews.
    • Added a refresh action to reload the latest data while keeping the current selection.

Adds dashrate-lite.html, a no-build, CDN-loaded standalone page that demonstrates the same read-only count/query SDK patterns as the React app, for readers who want a minimal reference without a toolchain.

Adds a Playwright spec exercising it against real testnet.
@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a new single-file "DashRate Lite" static HTML page (example-apps/dashrate/public/dashrate-lite.html) that connects to Dash Platform testnet to browse and filter review documents, computing aggregate ratings and rendering recent reviews. Adds a corresponding Playwright e2e test spec covering connection, filtering, and refresh flows.

Changes

DashRate Lite Page and Tests

Layer / File(s) Summary
Page structure and connection setup
example-apps/dashrate/public/dashrate-lite.html
Adds intro documentation, static HTML markup for sidebar/status/controls/result sections, and connectSdk() establishing a testnet connection via @dashevo/evo-sdk.
Data fetching and normalization logic
example-apps/dashrate/public/dashrate-lite.html
Implements count/distribution normalization helpers, conditional review query building, review result normalization, and aggregate summary (count/sum/average) computation.
UI rendering and interactivity
example-apps/dashrate/public/dashrate-lite.html
Wires DOM references, renders resource nav/header and aggregate rating panel, renders review cards, and implements loadResource() with event listeners for resource selection, filter changes, and refresh.
Playwright e2e tests for lite page
example-apps/dashrate/test/e2e/lite.spec.ts
Adds e2e tests verifying testnet connection status, initial rendering, resource selection, rating filter behavior, and refresh functionality.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant UI as dashrate-lite.html UI
  participant SDK as EvoSDK
  participant Platform as Dash Platform Testnet

  User->>UI: load page
  UI->>SDK: EvoSDK.testnetTrusted().connect()
  SDK->>Platform: establish connection
  Platform-->>SDK: connection established
  SDK-->>UI: connected status
  UI-->>User: enable controls, show "Connected to testnet"

  User->>UI: select resource / change rating filter / click refresh
  UI->>SDK: sdk.documents.count (total, grouped by rating)
  UI->>SDK: sdk.documents.query (where rating, orderBy, limit)
  SDK->>Platform: fetch counts and documents
  Platform-->>SDK: query results
  SDK-->>UI: counts and review documents
  UI->>UI: normalize results, compute average score
  UI-->>User: render aggregate panel and recent reviews
Loading

Related PRs: None found.

Suggested labels: documentation, example-app, e2e-tests

Suggested reviewers: None determined from provided context.


🐰 A rabbit hops through star-filled code,
Ratings gathered, testnet mode,
Filters spin and reviews appear,
Playwright checks each click is clear,
One HTML file, a tale it told.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: a single-file DashRate Lite companion page plus Playwright test coverage.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ 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/dashrate-lite

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

example-apps/dashrate/test/e2e/lite.spec.ts

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
example-apps/dashrate/test/e2e/lite.spec.ts (1)

1-99: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Double quotes violate repo Prettier guideline.

The file consistently uses double quotes (e.g. Line 1, Line 3, Lines 9-11), but the project's Prettier config for **/*.{js,mjs,ts,tsx,json} mandates single quotes.

As per coding guidelines, "Prettier formatting must use single quotes, 2-space indentation, and trailing commas."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@example-apps/dashrate/test/e2e/lite.spec.ts` around lines 1 - 99, The
Playwright test file formatting is inconsistent with the repo’s Prettier rule
because it uses double quotes instead of single quotes. Update the literals and
string-based selectors in the dashrate-lite e2e spec to match the project style,
keeping the existing structure and behavior of test.describe, test, and
page.locator/getByRole calls unchanged.

Source: Coding guidelines

🧹 Nitpick comments (3)
example-apps/dashrate/test/e2e/lite.spec.ts (1)

6-98: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract repeated navigation/connection setup into a beforeEach hook.

Every test repeats page.goto(LITE_URL) followed by the same #status "Connected to testnet" assertion (Lines 7-11, 21-24, 39-42, 58-61, 74-77). Hoisting this into test.beforeEach would reduce duplication.

♻️ Proposed refactor
 test.describe("dashrate-lite (single-file companion)", () => {
+  test.beforeEach(async ({ page }) => {
+    await page.goto(LITE_URL);
+    await expect(page.locator("`#status`")).toHaveText(/Connected to testnet/, {
+      timeout: 60_000,
+    });
+  });
+
   test("connects to testnet and enables controls on load", async ({ page }) => {
-    await page.goto(LITE_URL);
-
-    await expect(page.locator("`#status`")).toHaveText(/Connected to testnet/, {
-      timeout: 60_000,
-    });
     await expect(page.locator("`#refresh-btn`")).toBeEnabled({
       timeout: 60_000,
     });
     await expect(page.locator("`#rating-filter`")).toBeEnabled();
   });

(similarly remove the duplicated goto/status block from the remaining tests)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@example-apps/dashrate/test/e2e/lite.spec.ts` around lines 6 - 98, The
lite.spec.ts e2e tests repeat the same page.goto(LITE_URL) and "`#status`"
Connected to testnet wait in every test, so hoist that shared setup into a
test.beforeEach hook. Update the tests in the suite to rely on the shared
beforeEach, and keep the per-test assertions/actions focused on their specific
behavior while preserving references like LITE_URL, `#status`, and the existing
test(...) cases.
example-apps/dashrate/public/dashrate-lite.html (2)

378-387: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider aria-current for the active resource nav button.

Selected state is conveyed only via the .active CSS class; adding aria-current="page" (or aria-selected if treated as a tablist) would let assistive tech announce the current selection.

♿ Proposed tweak
         const button = document.createElement('button');
         button.type = 'button';
         button.className = resource.id === selectedResourceId ? 'active' : '';
+        if (resource.id === selectedResourceId) button.setAttribute('aria-current', 'page');
         button.dataset.resourceId = resource.id;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@example-apps/dashrate/public/dashrate-lite.html` around lines 378 - 387, The
active state in renderResourceNav is only exposed via the active CSS class, so
assistive tech cannot identify the current resource. Update the button creation
in renderResourceNav to set an appropriate ARIA state on the selected item,
using aria-current="page" for the active resource (or aria-selected if you
convert this pattern to a tablist), and ensure non-selected buttons do not carry
that attribute.

242-267: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Redundant round-trip: total count can be derived from the distribution.

getRatingCount and getRatingDistribution both hit the network, but getRatingDistribution already covers all valid ratings (1-5) via the between filter, so its sum equals the total count. renderAggregate even falls back to summary.count (derived from distribution) when totalCount is missing — suggesting the separate getRatingCount call is unnecessary overhead on every loadResource().

♻️ Proposed fix to drop the extra query
 async function loadResource() {
   ...
-    const [totalCount, distribution, reviews] = await Promise.all([
-      getRatingCount(sdk, resource.id),
-      getRatingDistribution(sdk, resource.id),
-      listResourceReviews(sdk, resource.id, ratingFilter),
-    ]);
-    renderAggregate(totalCount, distribution);
+    const [distribution, reviews] = await Promise.all([
+      getRatingDistribution(sdk, resource.id),
+      listResourceReviews(sdk, resource.id, ratingFilter),
+    ]);
+    renderAggregate(null, distribution);

Also applies to: 396-404

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@example-apps/dashrate/public/dashrate-lite.html` around lines 242 - 267,
Remove the redundant network call by deriving the total rating count from the
existing distribution query. Update the rating-loading flow around
getRatingCount, getRatingDistribution, and loadResource so the total is computed
from the grouped counts returned by sdk.documents.count instead of making a
second request, and keep renderAggregate using that derived total/count summary
fallback.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@example-apps/dashrate/public/dashrate-lite.html`:
- Around line 459-500: `loadResource()` can overwrite the UI with stale data if
`selectedResourceId` or the filter changes before its async `Promise.all`
resolves. Add a request guard inside `loadResource()` (using
`currentResource()`, `selectedResourceId`, and the current
`filterEl.value`/`ratingFilter`) so the function only renders results when the
response still matches the latest requested resource/filter. Ensure the click
and change handlers still call `loadResource()` normally, but ignore any
late-arriving response from an older invocation before calling
`renderAggregate()` and `renderReviews()`.

---

Outside diff comments:
In `@example-apps/dashrate/test/e2e/lite.spec.ts`:
- Around line 1-99: The Playwright test file formatting is inconsistent with the
repo’s Prettier rule because it uses double quotes instead of single quotes.
Update the literals and string-based selectors in the dashrate-lite e2e spec to
match the project style, keeping the existing structure and behavior of
test.describe, test, and page.locator/getByRole calls unchanged.

---

Nitpick comments:
In `@example-apps/dashrate/public/dashrate-lite.html`:
- Around line 378-387: The active state in renderResourceNav is only exposed via
the active CSS class, so assistive tech cannot identify the current resource.
Update the button creation in renderResourceNav to set an appropriate ARIA state
on the selected item, using aria-current="page" for the active resource (or
aria-selected if you convert this pattern to a tablist), and ensure non-selected
buttons do not carry that attribute.
- Around line 242-267: Remove the redundant network call by deriving the total
rating count from the existing distribution query. Update the rating-loading
flow around getRatingCount, getRatingDistribution, and loadResource so the total
is computed from the grouped counts returned by sdk.documents.count instead of
making a second request, and keep renderAggregate using that derived total/count
summary fallback.

In `@example-apps/dashrate/test/e2e/lite.spec.ts`:
- Around line 6-98: The lite.spec.ts e2e tests repeat the same
page.goto(LITE_URL) and "`#status`" Connected to testnet wait in every test, so
hoist that shared setup into a test.beforeEach hook. Update the tests in the
suite to rely on the shared beforeEach, and keep the per-test assertions/actions
focused on their specific behavior while preserving references like LITE_URL,
`#status`, and the existing test(...) cases.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 949a778b-5b39-40a2-b8e4-64948a12c8b9

📥 Commits

Reviewing files that changed from the base of the PR and between 89decb5 and acb7686.

📒 Files selected for processing (2)
  • example-apps/dashrate/public/dashrate-lite.html
  • example-apps/dashrate/test/e2e/lite.spec.ts

Comment thread example-apps/dashrate/public/dashrate-lite.html
@thephez thephez merged commit 0b6a0a9 into main Jul 2, 2026
4 checks passed
@thephez thephez deleted the feat/dashrate-lite branch July 2, 2026 20:09
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