summaryrefslogtreecommitdiff
path: root/tests/FundLab.Web.Tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests/FundLab.Web.Tests')
-rw-r--r--tests/FundLab.Web.Tests/BoundaryTests.fs52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/FundLab.Web.Tests/BoundaryTests.fs b/tests/FundLab.Web.Tests/BoundaryTests.fs
index 25d7867..3a9ec61 100644
--- a/tests/FundLab.Web.Tests/BoundaryTests.fs
+++ b/tests/FundLab.Web.Tests/BoundaryTests.fs
@@ -658,6 +658,58 @@ module ConfirmationBoundaryTests =
Assert.False(updated.stockPositionsInFlight)
[<Fact>]
+ let ``bond buy failure keeps no position and surfaces a message`` () =
+ let fundId = "3fa85f64-5717-4562-b3fc-2c963f66afa6"
+
+ let model =
+ { init () with
+ token = "qa-token"
+ createdFund = Some(FundBoundaryTests.sampleFund fundId)
+ bondCode = "999999"
+ bondTradeQuantity = "10"
+ bondTradeInFlight = true
+ bondTradeSeq = 1 }
+
+ let updated, _ = update (BondTradeFailed(1, fundId, "collector exited with code 2")) model
+
+ Assert.Empty updated.bondPositions
+ Assert.Contains("买入失败", updated.bondTradeMessage |> Option.defaultValue "")
+ Assert.False(updated.bondTradeInFlight)
+
+ [<Fact>]
+ let ``bond positions read completion stores decoded rows`` () =
+ let fundId = "3fa85f64-5717-4562-b3fc-2c963f66afa6"
+
+ let model =
+ { init () with
+ createdFund = Some(FundBoundaryTests.sampleFund fundId)
+ bondPositionsReadSeq = 1
+ bondPositionsInFlight = true }
+
+ let raw : RawBondPositions =
+ {
+ fundId = fundId
+ positions =
+ [|
+ {
+ instrumentCode = "110075"
+ bondName = box "南航转债"
+ quantity = "10"
+ costCash = "1063.68"
+ lastTradedAt = "2026-09-21T08:00:00Z"
+ }
+ |]
+ }
+
+ let updated, _ = update (BondPositionsReadCompleted(1, fundId, raw)) model
+
+ Assert.Equal(1, updated.bondPositions.Length)
+ Assert.Equal("110075", updated.bondPositions[0].instrumentCode)
+ Assert.Equal(Some "南航转债", updated.bondPositions[0].bondName)
+ Assert.Equal("10", updated.bondPositions[0].quantity)
+ Assert.False(updated.bondPositionsInFlight)
+
+ [<Fact>]
let ``order decode keeps decimal strings and decodes option fields`` () =
let confirmed = Api.decodeOrder (sampleConfirmedRaw ())
let pending = Api.decodeOrder (samplePendingRaw ())