Skip to content

fix(treasury): enforce StreamRecord as single source of truth for der… - #1591

Merged
Jagadeeshftw merged 1 commit into
Fluxora-Org:mainfrom
xtrial01:fix/1459-stream-derived-view-model
Aug 31, 2026
Merged

fix(treasury): enforce StreamRecord as single source of truth for der…#1591
Jagadeeshftw merged 1 commit into
Fluxora-Org:mainfrom
xtrial01:fix/1459-stream-derived-view-model

Conversation

@xtrial01

@xtrial01 xtrial01 commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Defines one derived-view model for the treasury overview page: StreamRecord (src/data/streamRecords.ts) is the single source of truth, and Stream (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 - accruedAmount and startDate made required fields, since normalization now guarantees they're always populated
  • src/components/treasuryOverviewPage/StreamRow.tsx, removed defensive type checks that are now redundant given the normalization guarantee
  • src/components/treasuryOverviewPage/useTreasuryOverviewData.ts, toLegacyStream updated 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 normalized streamRecords data
  • src/components/treasuryOverviewPage/__tests__/malformedRecordDefensive.test.tsx, updated to match the new interface contract
  • src/components/treasuryOverviewPage/__tests__/useTreasuryOverviewData.test.ts, updated for the new toLegacyStream fallback behavior
  • .gitignore - stopped tracking tsconfig.tsbuildinfo (repo hygiene, unrelated to Keep StreamRow status and amount rendering consistent with source records #1459, split into its own commit)

⚠️ Known upstream issue - main build is broken independent of this PR

The Build & test check is failing due to a pre-existing issue on main, unrelated to this PR.

npm run build fails with 20 TypeScript syntax errors across four files this PR doesn't touch: RecipientStreams.tsx, Streams/__tests__/testUtils.ts, voice/VoiceContext.tsx, and hooks/useStreamList.ts. Confirmed independently on a clean main, same errors, same lines, no changes from this branch involved:

git checkout main
git pull origin main
npm run build

CI's own failure log on this PR matches that local repro exactly.

git diff main --stat confirms 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 on main described above. Not achievable until that's fixed.
  • npm run test (scoped to src/components/treasuryOverviewPage) - 267 passed, 5 failed, 8 skipped, across 22 test files. All 5 failures are in demoMode.test.tsx (3) and useTreasury.test.tsx (2), both pre-existing and unrelated to this change. StreamRow.test.tsx and useTreasuryOverviewData.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 coverage job in .github/workflows/ci.yml. Given the removed defensive branches in StreamRow.tsx, branch coverage is worth checking specifically for that file, not just the aggregate, confirming once the coverage run completes.

…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
@drips-wave

drips-wave Bot commented Aug 30, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@xtrial01

Copy link
Copy Markdown
Contributor Author

Ready for review. One thing worth flagging up front:

The Build & test check is failing due to a pre-existing issue on main, unrelated to this PR.

npm run build fails with 20 TypeScript syntax errors across four files this PR doesn't touch: RecipientStreams.tsx, Streams/__tests__/testUtils.ts, voice/VoiceContext.tsx, and hooks/useStreamList.ts. I confirmed this independently by checking out a clean main and running the build directly, same errors, same lines, no changes from this branch involved:

git checkout main
git pull origin main
npm run build

CI's own failure log on this PR matches that local repro exactly, which rules out anything environment-specific.

git diff main --stat confirms this PR's changes are scoped to 7 files (Stream.ts, StreamRow.tsx, useTreasuryOverviewData.ts, three test files, and .gitignore), none overlap with the broken files. The Playwright E2E check is skipped as a downstream consequence of the build failure, not a separate issue.

For this PR's own scope: npm run test (scoped to treasuryOverviewPage) passes 267/272 runnable tests, with the 5 failures isolated to demoMode.test.tsx and useTreasury.test.tsx, both pre-existing and unrelated to this change. The files this PR actually modifies (StreamRow.test.tsx, useTreasuryOverviewData.test.ts) pass fully.

Happy to rebase once main is fixed, or if you'd rather I hold this as a draft until then, let me know.

@Jagadeeshftw
Jagadeeshftw merged commit d2877ab into Fluxora-Org:main Aug 31, 2026
1 of 2 checks passed
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.

Keep StreamRow status and amount rendering consistent with source records

2 participants