Skip to content

Add stable multi-key tie-breaking test coverage for useSortableData #68

Description

@Jagadeeshftw

📌 Description

useSortableData<T, K> (src/hooks/useSortableData.ts) backs the sortable columns on AnchorTable, PoolTable, and SettlementTable. useSortableData.test.ts likely covers single-key ascending/descending sorts, but ties on the primary sort key (e.g. multiple settlements with the same status) aren't explicitly tested for stable ordering, which matters for a predictable UI when a user sorts a table with many equal values.

🧩 Requirements and context

  • Add a test asserting rows with equal values on the active sort key retain their original relative order (stable sort) rather than reshuffling arbitrarily.
  • Verify this holds across both ascending and descending directions.
  • Fix useSortableData.ts if it's found to use a non-stable comparator (e.g. relying on Array.prototype.sort without a documented tie-break) and stability doesn't hold.

🛠️ Suggested execution

  • Extend src/hooks/useSortableData.test.ts with a tied-values fixture and stability assertions.
  • Fix the hook if instability is found.
  • Spot-check AnchorTable.test.tsx/SettlementTable.test.tsx for an equivalent integration-level assertion.

✅ Acceptance criteria

  • Tied rows retain stable relative order in both sort directions.
  • Regression test locks in the guarantee.
  • Any instability found is fixed.

🔒 Security notes

No new attack surface; purely a UI-correctness concern.

📋 Guidelines

  • Minimum 95% test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26testingTests and coverage

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions