From 98b6b21c56c7b061578e7d4b56d52450dc7bd575 Mon Sep 17 00:00:00 2001 From: "Somhairle H. Marisol" Date: Mon, 21 Sep 2026 19:34:32 +0800 Subject: feat(desktop): P12 中文每日任务面板——T 键任务页、Offered/Active/Done 三态+职业名,存读档字段级携带职业 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/LivingVillage.Desktop.Tests/DesktopTests.fs | 52 +++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'src/LivingVillage.Desktop.Tests') 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(0L, defaultWorld.Tick) Assert.AreEqual(0.0, defaultWorld.Time) Assert.AreEqual(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 } + +[] +type TaskPanelTests () = + + [] + member _.TaskPanelWithoutOccupationShowsNoOccupationLine () = + let world = Sim.initialWorldN 42UL 4 + let _, view = M5Interaction.apply ShowTaskPanel world M5Interaction.initial + + Assert.AreEqual(TaskPanel, view.Panel) + Assert.AreEqual("task", M5Interaction.panelName view) + let lines = M5Interaction.panelLines world view + Assert.IsTrue(lines |> List.contains "任务", "panel heading expected") + Assert.IsTrue(lines |> List.contains "无职业") + + [] + 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}") + + [] + 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("任务")) + + [] + 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(dialogueView, afterTask) + let _, closed = M5Interaction.apply ClosePanel world { dialogueView with Panel = TaskPanel } + Assert.AreEqual(WorldPanel, closed.Panel) -- cgit v1.2.3