fix(treasury): enforce StreamRecord as single source of truth for der… - #1591
Conversation
…ived Stream view - Make Stream interface strictly derived from StreamRecord with required fields (accruedAmount, startDate) - Remove defensive type checks in StreamRow.tsx now that normalization guarantees field presence - Update toLegacyStream to apply fallbacks (status: Active, amounts: 0) at the normalization boundary - Add 8 regression tests covering zero amounts, all status transitions, large values, and normalized-data consistency - Update malformedRecordDefensive and useTreasuryOverviewData tests to match new interface contract Closes Fluxora-Org#1459
|
@xtrial01 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! 🚀 |
|
Ready for review. One thing worth flagging up front: The
CI's own failure log on this PR matches that local repro exactly, which rules out anything environment-specific.
For this PR's own scope: Happy to rebase once |
Summary
Defines one derived-view model for the treasury overview page:
StreamRecord(src/data/streamRecords.ts) is the single source of truth, andStream(src/components/treasuryOverviewPage/Stream.ts) is a strict interface derived from it. Field-presence guarantees now live at the normalization boundary instead of being re-checked defensively at render time.Closes #1459.
Changes
src/components/treasuryOverviewPage/Stream.ts-accruedAmountandstartDatemade required fields, since normalization now guarantees they're always populatedsrc/components/treasuryOverviewPage/StreamRow.tsx, removed defensive type checks that are now redundant given the normalization guaranteesrc/components/treasuryOverviewPage/useTreasuryOverviewData.ts,toLegacyStreamupdated to apply fallbacks once at the boundary (status→"Active", amount fields →0)src/components/treasuryOverviewPage/__tests__/StreamRow.test.tsx, 8 new regression tests: zero accrued amounts, all status transitions, large amount values, required-field rendering without defensive checks, consistency with normalizedstreamRecordsdatasrc/components/treasuryOverviewPage/__tests__/malformedRecordDefensive.test.tsx, updated to match the new interface contractsrc/components/treasuryOverviewPage/__tests__/useTreasuryOverviewData.test.ts, updated for the newtoLegacyStreamfallback behavior.gitignore- stopped trackingtsconfig.tsbuildinfo(repo hygiene, unrelated to Keep StreamRow status and amount rendering consistent with source records #1459, split into its own commit)mainbuild is broken independent of this PRThe
Build & testcheck is failing due to a pre-existing issue onmain, unrelated to this PR.npm run buildfails with 20 TypeScript syntax errors across four files this PR doesn't touch:RecipientStreams.tsx,Streams/__tests__/testUtils.ts,voice/VoiceContext.tsx, andhooks/useStreamList.ts. Confirmed independently on a cleanmain, same errors, same lines, no changes from this branch involved:CI's own failure log on this PR matches that local repro exactly.
git diff main --statconfirms this PR's changes are scoped to 7 files, none overlapping with the broken ones.Test plan
npm run build- known-failing due to the unrelated upstream breakage onmaindescribed above. Not achievable until that's fixed.npm run test(scoped tosrc/components/treasuryOverviewPage) - 267 passed, 5 failed, 8 skipped, across 22 test files. All 5 failures are indemoMode.test.tsx(3) anduseTreasury.test.tsx(2), both pre-existing and unrelated to this change.StreamRow.test.tsxanduseTreasuryOverviewData.test.ts- the files this PR actually touches — pass fully.npm run test:coverage- pending, need the coverage percentage table (statements/branches/functions/lines) before checking this box.Coverage gate
CI enforces 95% coverage thresholds via the
coveragejob in.github/workflows/ci.yml. Given the removed defensive branches inStreamRow.tsx, branch coverage is worth checking specifically for that file, not just the aggregate, confirming once the coverage run completes.