Skip to content

refactor(trustlines): adopt shared InsightsList component - #212

Open
samuel2926i39-art wants to merge 1 commit into
Stellar-Insightss:mainfrom
samuel2926i39-art:feat/asset-insights-shared-list
Open

refactor(trustlines): adopt shared InsightsList component#212
samuel2926i39-art wants to merge 1 commit into
Stellar-Insightss:mainfrom
samuel2926i39-art:feat/asset-insights-shared-list

Conversation

@samuel2926i39-art

Copy link
Copy Markdown

Summary

AssetInsights (the insight callout on the trustlines/Asset Intelligence page, #150/#152) had its own bespoke loading skeleton, empty-state copy, and bullet-list markup. Meanwhile dashboard/InsightsList (#157) already implements exactly that — loading, error, and empty states plus list rendering — with its own test coverage, but had zero consumers anywhere in the codebase.

This PR makes trustlines the first real consumer of InsightsList, per #157's own suggested approach ("Refactor #150/#152's AssetInsights to use this once it exists"):

  • AssetInsights now delegates loading/empty/list rendering to InsightsList, passing in the asset-specific generated sentences and a tailored empty message ("Insufficient data to generate insights for this asset.").
  • The sentence-generation logic (buildSentences) and the card chrome (icon + heading) are unchanged — only the previously-duplicated state/list markup was removed.
  • No change to the component's public props (data, loading), so trustlines/page.tsx needed no changes.

Before / after

  • Before: AssetInsights had its own 3-bar loading skeleton and its own "›"-prefixed bullet list.
  • After: it renders through InsightsList's loading skeleton (SkeletonText) and list items (data-testid="insights-list"), matching the visual/behavioral pattern used elsewhere in the dashboard.

Testing

  • Added frontend/src/components/trustlines/__tests__/AssetInsights.test.tsx (new — this component had no prior test coverage), following the existing convention from dashboard/__tests__/RealtimeDashboardFallback.test.tsx. Covers: loading state, empty state (null data), empty state (data with no derivable sentences), and the happy-path sentence rendering.
  • npx vitest run src/components/trustlines/__tests__/AssetInsights.test.tsx src/components/dashboard/__tests__/InsightsList.test.tsx → 2 files, 10 tests, all passing.
  • npx eslint on both changed/added files → no errors.

Scope note

Corridors/anchors/governance don't have insight callouts built yet (no matching components exist in the tree), so this PR doesn't touch them — wiring those up is separate, follow-on work once those pages get their own insight data sources.

Closes #152
Closes #157

AssetInsights on the trustlines page had its own bespoke loading
skeleton, empty-state message, and bullet list markup that duplicated
what the shared dashboard/InsightsList component already provides
(loading, error, and empty states + list rendering, with tests).

Delegate list/loading/empty rendering to InsightsList so trustlines
becomes its first real consumer, keeping only the asset-specific
sentence-generation logic and card chrome in AssetInsights. Adds a
test file for AssetInsights covering the loading, empty, and
happy-path states, following the existing dashboard test convention.

Closes Stellar-Insightss#152
Closes Stellar-Insightss#157
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.

Create shared InsightsList UI component in src/components/dashboard Create AssetInsights component wrapping the existing trustlines table

1 participant