From 6abd4c206fbfe8369b3fde4c905619d08f13c5d1 Mon Sep 17 00:00:00 2001 From: "Somhairle H. Marisol" Date: Tue, 22 Sep 2026 05:23:52 +0800 Subject: Add SIP plan pause/resume and rebalance plan archive lifecycle (3d-24) --- tests/FundLab.Web.Tests/BoundaryTests.fs | 60 ++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'tests/FundLab.Web.Tests') diff --git a/tests/FundLab.Web.Tests/BoundaryTests.fs b/tests/FundLab.Web.Tests/BoundaryTests.fs index d8bb472..4c05f37 100644 --- a/tests/FundLab.Web.Tests/BoundaryTests.fs +++ b/tests/FundLab.Web.Tests/BoundaryTests.fs @@ -1164,6 +1164,36 @@ module SipBoundaryTests = Assert.Equal(1, staleList.sipPlans.Length) + [] + let ``sip pause completion updates the matching plan row status`` () = + let model = + { init () with + token = "qa-token" + createdFund = Some(sampleFund ()) + sipStatusSeq = 1 + sipStatusInFlight = true + sipPlans = [ Api.decodeSipPlan (sampleSipRaw ()) ] } + + let pausedRaw = { sampleSipRaw () with status = "paused" } + let updated, _ = update (SipPlanStatusChanged(1, pausedRaw)) model + + Assert.Equal("paused", updated.sipPlans[0].status) + Assert.False(updated.sipStatusInFlight) + + [] + let ``sip pause failure clears in-flight and surfaces a message`` () = + let model = + { init () with + token = "qa-token" + createdFund = Some(sampleFund ()) + sipStatusSeq = 1 + sipStatusInFlight = true } + + let updated, _ = update (SipPlanStatusChangeFailed(1, "sip plan does not belong to this fund")) model + + Assert.Equal(Some "sip plan does not belong to this fund", updated.error) + Assert.False(updated.sipStatusInFlight) + module RebalanceBoundaryTests = open Xunit @@ -1249,3 +1279,33 @@ module RebalanceBoundaryTests = Assert.True(stale.rebalExecuteInFlight) Assert.Equal(None, stale.rebalResult) + + [] + let ``rebalance archive completion updates the matching plan row status`` () = + let model = + { init () with + token = "qa-token" + createdFund = Some(sampleFundInfo ()) + rebalArchiveSeq = 1 + rebalArchiveInFlight = true + rebalPlans = [ Api.decodeRebalancePlan (sampleRebalanceRaw ()) ] } + + let archivedRaw = { sampleRebalanceRaw () with status = "archived" } + let updated, _ = update (RebalancePlanArchived(1, archivedRaw)) model + + Assert.Equal("archived", updated.rebalPlans[0].status) + Assert.False(updated.rebalArchiveInFlight) + + [] + let ``rebalance archive failure clears in-flight and surfaces a message`` () = + let model = + { init () with + token = "qa-token" + createdFund = Some(sampleFundInfo ()) + rebalArchiveSeq = 1 + rebalArchiveInFlight = true } + + let updated, _ = update (RebalancePlanArchiveFailed(1, "rebalance plan does not belong to this fund")) model + + Assert.Equal(Some "rebalance plan does not belong to this fund", updated.error) + Assert.False(updated.rebalArchiveInFlight) -- cgit v1.2.3