Skip to content

Add holdings sorting by total value descending with unit tests - #735

Open
Benedict315 wants to merge 2 commits into
accesslayerorg:devfrom
Benedict315:feature/holdings-sorting-tests
Open

Add holdings sorting by total value descending with unit tests#735
Benedict315 wants to merge 2 commits into
accesslayerorg:devfrom
Benedict315:feature/holdings-sorting-tests

Conversation

@Benedict315

Copy link
Copy Markdown
Contributor

Description
Added holdings sorting functionality to display the highest-value positions at the top of the holdings list.

Implementation:

Added calculatePositionTotalValue() utility in portfolioValue.utils.ts to compute individual position total value (quantity × price)
Added sortHoldingsByTotalValue() utility to sort holdings by total value in descending order with stable secondary sort by creator ID
Applied sorting in LandingPage.tsx via useMemo before rendering the holdings list
Unit Tests (11 new tests):

Holdings rendered in descending total value order (1200, 500, 300)
Order updates when cache data changes (300 → 1500 reorders to 1500, 1200, 500)
Stable secondary sort by creator ID for equal total values
Handles missing prices by treating as zero value
Handles zero quantities by treating as zero value
Does not mutate original array
Acceptance Criteria Met:

Holdings rendered in descending total value order ✓
Order updates when cache data changes ✓
Stable secondary sort for equal values ✓
Sort applied before render (via useMemo) ✓

closes #673

jotel-dev and others added 2 commits July 30, 2026 00:45
- Add calculatePositionTotalValue utility to compute individual position value
- Add sortHoldingsByTotalValue utility to sort holdings by total value descending
- Apply sorting in LandingPage component before rendering holdings list
- Add comprehensive unit tests covering all acceptance criteria:
  - Holdings rendered in descending total value order (1200, 500, 300)
  - Order updates when cache data changes (300 -> 1500 reorders to 1500, 1200, 500)
  - Stable secondary sort by creator ID for equal total values
  - Handles missing prices and zero quantities gracefully
  - Does not mutate original array
- Sort applied before render via useMemo in LandingPage
@drips-wave

drips-wave Bot commented Jul 29, 2026

Copy link
Copy Markdown

@Benedict315 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Chucks1093

Copy link
Copy Markdown
Contributor

Fix CI

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.

Add unit tests for the holdings list sorting entries by total value descending

3 participants