summaryrefslogtreecommitdiff
path: root/src/LivingVillage.Desktop.Tests/DesktopTests.fs
diff options
context:
space:
mode:
authorSomhairle H. Marisol <[email protected]>2026-09-21 19:34:32 +0800
committerSomhairle H. Marisol <[email protected]>2026-09-21 19:34:32 +0800
commit98b6b21c56c7b061578e7d4b56d52450dc7bd575 (patch)
tree8c3ce5912294207d37863c37b15f2bce89c0787f /src/LivingVillage.Desktop.Tests/DesktopTests.fs
parentc348da258f072bc88ea422cbc534c0831817b3c8 (diff)
downloadliving-village-98b6b21c56c7b061578e7d4b56d52450dc7bd575.tar.gz
feat(desktop): P12 中文每日任务面板——T 键任务页、Offered/Active/Done 三态+职业名,存读档字段级携带职业
Diffstat (limited to 'src/LivingVillage.Desktop.Tests/DesktopTests.fs')
-rw-r--r--src/LivingVillage.Desktop.Tests/DesktopTests.fs52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/LivingVillage.Desktop.Tests/DesktopTests.fs b/src/LivingVillage.Desktop.Tests/DesktopTests.fs
index e9713e5..52443e9 100644
--- a/src/LivingVillage.Desktop.Tests/DesktopTests.fs
+++ b/src/LivingVillage.Desktop.Tests/DesktopTests.fs
@@ -156,3 +156,55 @@ type DesktopTests () =
Assert.AreEqual<int64>(0L, defaultWorld.Tick)
Assert.AreEqual<float>(0.0, defaultWorld.Time)
Assert.AreEqual<M6DayNight>(Night, defaultProfile.Mode)
+
+// ---- P12 中文每日任务面板 ----
+
+module private TaskPanelHarness =
+
+ let occupationWithTask (taskState: Occupation.TaskState) : Occupation.State =
+ let occupation = Occupation.stateOf Occupation.Farmer
+ let task =
+ (Occupation.dailyTaskOf 42UL 7UL 0L Occupation.Farmer).Value
+ |> Occupation.acceptTask
+ |> fun active -> if taskState = Occupation.Done then { active with State = Occupation.Done } else { active with State = taskState }
+ { occupation with Today = Some task }
+
+[<TestClass>]
+type TaskPanelTests () =
+
+ [<TestMethod>]
+ member _.TaskPanelWithoutOccupationShowsNoOccupationLine () =
+ let world = Sim.initialWorldN 42UL 4
+ let _, view = M5Interaction.apply ShowTaskPanel world M5Interaction.initial
+
+ Assert.AreEqual<M5Panel>(TaskPanel, view.Panel)
+ Assert.AreEqual<string>("task", M5Interaction.panelName view)
+ let lines = M5Interaction.panelLines world view
+ Assert.IsTrue(lines |> List.contains "任务", "panel heading expected")
+ Assert.IsTrue(lines |> List.contains "无职业")
+
+ [<TestMethod>]
+ member _.TaskPanelShowsChineseOccupationNameAndTheThreeStates () =
+ let world = Sim.initialWorldN 42UL 4
+ for taskState, expected in [ Occupation.Offered, "待接受"; Occupation.Active, "进行中"; Occupation.Done, "已完成" ] do
+ let withTask = { M5Interaction.initial with Task = Some (TaskPanelHarness.occupationWithTask taskState) }
+ let _, view = M5Interaction.apply ShowTaskPanel world withTask
+ let lines = M5Interaction.panelLines world view
+ Assert.IsTrue(lines |> List.contains "农夫", $"occupation name missing for {taskState}")
+ Assert.IsTrue(lines |> List.exists (fun line -> line.Contains(expected)), $"state {expected} missing in {lines}")
+
+ [<TestMethod>]
+ member _.TaskPanelTitleUsesChineseHeading () =
+ let world = Sim.initialWorldN 42UL 4
+ let _, view = M5Interaction.apply ShowTaskPanel world M5Interaction.initial
+ Assert.IsTrue(M5Interaction.titleText view |> fun text -> text.Contains("任务"))
+
+ [<TestMethod>]
+ member _.ShowTaskPanelIsRejectedFromDialoguePanelLikeOtherOverlays () =
+ let world = Sim.initialWorldN 42UL 4 |> Harness.atNpc 0
+ let openedWorld, dialogueView = M5Interaction.apply Interact world M5Interaction.initial
+ let _, afterTask = M5Interaction.apply ShowTaskPanel openedWorld dialogueView
+
+ Assert.AreEqual<M5View>(dialogueView, afterTask)
+ let _, closed = M5Interaction.apply ClosePanel world { dialogueView with Panel = TaskPanel }
+ Assert.AreEqual<M5Panel>(WorldPanel, closed.Panel)