fix: validate positive intra-bank transfer amounts#2012
fix: validate positive intra-bank transfer amounts#2012officialasishkumar wants to merge 2 commits intoopenMF:developmentfrom
Conversation
Reject zero and negative transfer amounts in the intra-bank confirmation flow before building a transfer payload. Also reset the processing flag when client-side validation fails so validation errors do not leave the screen in a blocked state. Add desktop common-state regression coverage for valid, non-positive, over-balance, and non-numeric transfer amounts.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe transfer confirmation validation was rewritten to parse the amount once, reject non-positive values early, reset Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
feature/transfer-intrabank/src/commonTest/kotlin/org/mifospay/feature/transfer/intrabank/confirm/TransferConfirmStateTest.kt (1)
18-66: Add a regression that exercises the blocked-screen fix.These cases only verify
TransferConfirmState.amountIsValid. They never driveTransferConfirmViewModelthroughInitiateTransfer, so the newisProcessing = falserecovery path on validation errors is still untested. That matters becauseisProcessingcontrols the disabled button, spinner, and overlay inTransferConfirmScreen.kt:310-332.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@feature/transfer-intrabank/src/commonTest/kotlin/org/mifospay/feature/transfer/intrabank/confirm/TransferConfirmStateTest.kt` around lines 18 - 66, Tests currently only exercise TransferConfirmState.amountIsValid and don't exercise the TransferConfirmViewModel.InitiateTransfer path that must reset isProcessing on validation errors; add a unit test that constructs a TransferConfirmViewModel, sets a state with an invalid amount (e.g., "abc" or amount > selectedAccountBalance), invokes the viewModel.initiateTransfer() action, and then asserts that viewModel.state.isProcessing is false after the call and any validation error event/state is emitted. Locate and use the TransferConfirmViewModel class and its initiateTransfer()/InitiateTransfer intent, and assert the isProcessing flag along with any validation error flag/message to verify the blocked-screen recovery path.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@feature/transfer-intrabank/src/commonTest/kotlin/org/mifospay/feature/transfer/intrabank/confirm/TransferConfirmStateTest.kt`:
- Around line 18-66: Tests currently only exercise
TransferConfirmState.amountIsValid and don't exercise the
TransferConfirmViewModel.InitiateTransfer path that must reset isProcessing on
validation errors; add a unit test that constructs a TransferConfirmViewModel,
sets a state with an invalid amount (e.g., "abc" or amount >
selectedAccountBalance), invokes the viewModel.initiateTransfer() action, and
then asserts that viewModel.state.isProcessing is false after the call and any
validation error event/state is emitted. Locate and use the
TransferConfirmViewModel class and its initiateTransfer()/InitiateTransfer
intent, and assert the isProcessing flag along with any validation error
flag/message to verify the blocked-screen recovery path.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 71816aa4-9a70-4227-a9de-882f4ebc6f65
📒 Files selected for processing (2)
feature/transfer-intrabank/src/commonMain/kotlin/org/mifospay/feature/transfer/intrabank/confirm/TransferConfirmViewModel.ktfeature/transfer-intrabank/src/commonTest/kotlin/org/mifospay/feature/transfer/intrabank/confirm/TransferConfirmStateTest.kt
|
Added the requested regression coverage in 1cd4370: the test now drives |
Issue Fix
Fixes #2011
Jira Task: N/A
Screenshots
N/A - validation logic and regression test change only.
Description
Validation
./gradlew :feature:transfer-intrabank:compileTestKotlinDesktop --no-daemon --max-workers=2 --stacktrace./gradlew :feature:transfer-intrabank:desktopTest --no-daemon --max-workers=2 --stacktrace./gradlew :feature:transfer-intrabank:spotlessKotlinCheck --no-daemon --max-workers=2 --stacktraceApply the
AndroidStyle.xmlstyle template to your code in Android Studio.Run the unit tests with
./gradlew checkto make sure you didn't break anythingIf you have multiple commits please combine them into one commit by squashing them.
Summary by CodeRabbit
Bug Fixes
Tests