Skip to content

Add category grouping to VerificationResults projection#143

Merged
jfrench9 merged 3 commits into
mainfrom
feature/verification-summary
May 23, 2026
Merged

Add category grouping to VerificationResults projection#143
jfrench9 merged 3 commits into
mainfrom
feature/verification-summary

Conversation

@jfrench9
Copy link
Copy Markdown
Member

Summary

Enhances the VerificationResults projection component with category-based grouping of verification results, updates the @robosystems/client dependency to version 0.3.33, and simplifies the envelope structure in ReportViewerContent. Adds comprehensive unit test coverage for the updated component.

Changes

VerificationResults Projection Enhancement

  • Category Grouping: Refactored VerificationResults.tsx to organize verification results by category, providing a more structured and scannable view for users reviewing ledger close block data.
  • New Type Definitions: Extended types.ts with additional type definitions to support the category grouping data structure.
  • Significant Refactor: The projection component grew from ~66 lines of net changes to a ~210-line component with improved organization (~254 additions, ~68 deletions across all files).

Dependency Update

  • Updated @robosystems/client from its previous version to 0.3.33 (via intermediate 0.3.31), which likely provides the underlying API/type changes needed to support category-grouped verification results.
  • Simplified envelope structure in ReportViewerContent as part of aligning with the updated client API.

Test Coverage

  • New test file: Added VerificationResults.test.tsx with 97 lines of unit tests covering the category grouping behavior, ensuring correctness of the new projection logic.

Key UI/UX Improvements

  • Verification results are now visually organized by category, making it significantly easier for users to scan and understand verification outcomes during the ledger close process.
  • Improved information hierarchy reduces cognitive load when reviewing large sets of verification results.

Breaking Changes

  • The @robosystems/client upgrade to 0.3.33 and the envelope structure simplification may affect other components consuming the same client API. Reviewers should verify no downstream consumers rely on the previous envelope shape.
  • The VerificationResults projection now expects data structured with category information — ensure the backend/client provides this shape.

Testing Notes for Reviewers

  1. Unit Tests: Run npm test -- --testPathPattern=VerificationResults to verify the new test suite passes.
  2. Manual Verification: Navigate to the ledger close block view and confirm verification results render correctly grouped by category.
  3. Edge Cases to Check:
    • Empty verification results (no categories)
    • Single category with multiple results
    • Multiple categories with varying numbers of results
    • Verify the ReportViewerContent envelope simplification doesn't break report viewing flows
  4. Regression: Confirm other projections in the block view are unaffected by the type changes.

Browser Compatibility Considerations

  • No new browser APIs or CSS features introduced — changes are limited to React component logic and data transformation.
  • Standard compatibility expectations apply (modern evergreen browsers). No special polyfills required.

🤖 Generated with Claude Code

Branch Info:

  • Source: feature/verification-summary
  • Target: main
  • Type: feature

Co-Authored-By: Claude noreply@anthropic.com

@jfrench9
Copy link
Copy Markdown
Member Author

@claude please review this PR

@claude
Copy link
Copy Markdown

claude Bot commented May 23, 2026

Claude finished @jfrench9's task in 2m 4s —— View job


PR Review: Add category grouping to VerificationResults projection

  • Gather context and understand request
  • Read changed files
  • Analyze code for correctness, style, and coverage
  • Post review findings

This is a well-structured refactor. The two-level category/status layout is a clear UX improvement and the implementation quality is high overall. I have one meaningful design question and a handful of smaller notes.


Design question: verificationSummary.byCategory is fetched but never read

The component defines EnvelopeVerificationCategory in types.ts (and the test fixture populates byCategory), but the component always builds category groups in-memory from the verificationResults + rulesById join — it never reads byCategory from the server-computed summary.

// VerificationResults.tsx:118-139 — always in-memory, ignores byCategory
const groups = useMemo<CategoryGroup[]>(() => {
  const byCategory = new Map<string, EnvelopeVerificationResult[]>()
  for (const result of envelope.verificationResults) {
    const category = rulesById.get(result.ruleId)?.ruleCategory ?? 'Uncategorized'
    ...
  }
  ...
}, [envelope.verificationResults, rulesById])

The verificationSummary top-level counts (passed, failed, etc.) are correctly used for the tally header. But byCategory is dead data. The type alias EnvelopeVerificationCategory (added to types.ts:25-26) is exported but has no consumers yet.

This is probably the right call for now — the in-memory join is simpler and avoids the risk of byCategory aggregates getting out of sync with the individual result rows. But it's worth a comment explaining the decision, or removing the unused type export until byCategory is actually needed. If it's intentionally deferred, a // TODO(§7.12) note would prevent confusion for the next person.

Fix this →


Minor: summaryParts doesn't pluralize "error"

types.ts:229:

if (counts.error > 0) summaryParts.push(`${counts.error} error`)

With 2+ errors this renders as "2 error". Pass/fail/skipped are fine since they already work without an s. Should be:

if (counts.error > 0) summaryParts.push(`${counts.error} error${counts.error === 1 ? '' : 's'}`)

Fix this →


Test coverage gaps

The three tests cover the critical paths well, but there are gaps worth noting:

  1. No test for the in-memory fallback tally — when verificationSummary is absent (older envelopes), the component falls back to rolling up counts from groups. There's no test for this path. The empty-state test uses makeEnvelope() which has no verificationSummary, but that hits the early-return before the tally is computed.

  2. No test for error or skipped statuses — only pass and fail are exercised. The header icon and tone logic branches for error (amber) and skip-only groups are untested.

  3. _envelope-fixtures.ts base shape missing verificationSummarymakeEnvelope() doesn't include verificationSummary: null in its defaults (line 89-118 of _envelope-fixtures.ts). The component handles undefined correctly via if (summary), but adding verificationSummary: null to the fixture would make the intent explicit and future-proof the fixture against SDK type changes.


Nit: accordion button missing aria-controls

The button has aria-expanded (good), but no aria-controls linking it to the <ul> it toggles. For full ARIA compliance the <ul> should have an id and the button should reference it:

<button aria-expanded={open} aria-controls={`cat-${group.category}`} ...>
// ...
<ul id={`cat-${group.category}`} ...>

Low priority but worth addressing if accessibility is a priority for this surface.


What's well done

  • The dual-mode tally (verificationSummary → in-memory fallback) is a clean backward-compat pattern.
  • normalizeStatus with the dev-only console.warn is the right guard against future backend schema drift.
  • Default-expanded-on-failure behavior (useState(hasProblems)) correctly surfaces problems without extra interaction.
  • humanizeCategory regex handles both camelCase→PascalCase boundaries and consecutive-uppercase sequences correctly.
  • STATUS_ORDER inside the accordion (via flatMap) keeps failures-first within categories, consistent with the global ordering.
  • key={result.id} on ResultRow — stable key, correctly avoids index.
  • The rulesById dependency chain (useMemouseMemo) is correct and appropriate.

@jfrench9 jfrench9 merged commit 17472a4 into main May 23, 2026
3 checks passed
@jfrench9 jfrench9 deleted the feature/verification-summary branch May 23, 2026 02:00
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