fix(approvals): populate Account/Payment/MonthlyCost on Approval queue rows (closes #733) - #734
Conversation
…e rows (closes #733) PR #713 added the Account, Term, Payment, and Monthly Cost columns to the Approval queue card; the columns render but every row showed "-" because the backend never copied those fields onto the synthesised PurchaseHistoryRecord: - Account: executionToHistoryRow read exec.CloudAccountID, but the web-initiated bulk-purchase flow (buildPendingExecution) only populates the per-recommendation CloudAccountID and leaves the execution-level field nil. Fall back to a new collapseRecommendationAccount helper that returns the shared rec CloudAccountID, or "" (rendered as "-") for a basket genuinely spanning accounts. - Payment: projectRecommendationFields populated Service, ResourceType, Region, Term, UpfrontCost, EstimatedSavings, and (single-rec only) MonthlyCost from the rec, but never set row.Payment. Single-rec now copies r.Payment; multi-rec collapses via collapseRecommendationPayment (same pattern as the existing Provider/Service/Term collapsers), returning "" when recs disagree so the dash fallback stays honest. - MonthlyCost (multi-rec): only the single-rec branch mapped it; the multi-rec branch now sums per-rec MonthlyCost via sumRecommendationMonthlyCost (nil contributes 0, matching the single-rec treatment of nil MonthlyCost). Regression tests: - TestHandler_getHistory_ApprovalQueueColumnsPopulated pins all three shapes (single-rec, multi-rec uniform, multi-rec heterogeneous Payment) so a future refactor cannot silently re-empty the cells. - TestHandler_getHistory_InProgressRowMapsRecFields extended with a Payment assertion. - history-approval-queue.test.ts adds a frontend test that mocks the populated API shape and asserts the cells show real values, not "-".
|
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 (3)
📝 WalkthroughWalkthroughThis PR resolves issue ChangesApproval Queue field population
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Summary
Closes #733. PR #713 added the Account, Term, Payment, and Monthly Cost columns to the Approval queue card, but every row rendered "-" because the backend never copied those fields onto synthesised pending rows. This patches the data-plumbing gap in
handler_history.goand pins the contract with regression tests on both sides.Backend fix (
internal/api/handler_history.go)executionToHistoryRowreadexec.CloudAccountID, but the web bulk-purchase flow'sbuildPendingExecutiononly populates the per-recCloudAccountIDand leaves the exec-level fieldnil.collapseRecommendationAccounthelper — returns the shared rec value, or""(renders as "-") for a basket genuinely spanning accounts.projectRecommendationFieldsnever setrow.Paymentin either branch.row.Payment = r.Payment. Multi-rec:collapseRecommendationPayment(recs)— same shape as the existing Provider/Service/Term collapsers; returns""on disagreement so the dash fallback stays honest.sumRecommendationMonthlyCost(recs)— nil entries contribute 0, matching the single-rec treatment of nil MonthlyCost.Regression coverage
TestHandler_getHistory_ApprovalQueueColumnsPopulated(new) pins all three shapes: single-rec passes Account/Payment/MonthlyCost from rec; multi-rec uniform collapses Account+Payment and sums MonthlyCost; multi-rec heterogeneous Payment collapses to""so the UI honestly shows "-".TestHandler_getHistory_InProgressRowMapsRecFieldsextended with a Payment assertion.history-approval-queue.test.tsadds an end-to-end frontend test that mocks the populated API shape and asserts the cells render real values (no-).Test plan
go build ./...cleango test ./internal/api/... -count=1— 1277 passedgo test -run TestHandler_getHistory_ApprovalQueueColumnsPopulated -v— 3/3 sub-tests passnpm test -- --testPathPattern=history-approval-queue— 14/14 pass (new test included)Summary by CodeRabbit