fix test_cad_commands

This commit is contained in:
SoftFever 2026-11-26 03:13:08 +08:00
parent b3dcf0ac7d
commit b92cc124c8
2 changed files with 19 additions and 8 deletions

View file

@ -463,9 +463,12 @@ folder has them (`reset_switches()`), the window widened when the sketch ribbon
`reset_view()`'s camera. What follows the bed is read, not written out: `modeling_origin`, for the XY frame and the
cameras that look at it, and where Commit to Plate places an object, which place compares only between two parts of
one object. The rungs that read the Origin switch set it first: off for the plane refusals, on for the plane pick.
replace starts a new project of its own (`project_new {discard_changes: true}`), so the objects it counts are its own.
confirm_refused_add presses Commit to Plate by its label in assembly mode, the mode the folder keeps while no one
picks another from the button's list. A Speed Dial pick names its action with its source, OrcaSlicer, so an action
replace starts a new project of its own (`project_new {discard_changes: true}`), so the objects it counts are its own,
and sketch_edit_failed_replace and action_pick_replay each replay their exported session into one. A new project shows
Prepare, so each then shows the Design tab again in `reset_view()`'s camera (`CadGui.show_design()`): replace to press
New Design on the tab's ribbon, and the two replays to start where their live session ran: a Design tab action, such
as the pick action_pick_replay replays, runs only on that tab. confirm_refused_add presses Commit to Plate by its
label in assembly mode, the mode the folder keeps while no one picks another from the button's list. A Speed Dial pick names its action with its source, OrcaSlicer, so an action
of the same title that a plugin left in the folder adds is not taken. The dial closes when another window takes the
focus, as it does for a person, and on a desktop the sweep's apps share, another test's app opening a dialog or
starting takes it: `checks.dial_pick()` then opens the dial again and picks again, until the pick is taken or 90 s

View file

@ -497,6 +497,14 @@ def steps_of(path):
return json.loads("\n".join(l for l in text.splitlines() if not l.lstrip().startswith("//")))["steps"]
def replay_in_new_project(path, out_dir):
"""replay_run's reply for the session replay_export wrote at `path`, replayed into a new project on the Design tab,
where the live session ran: a new project shows Prepare, which refuses a Design tab action as wrong_mode."""
gui.client.call("project_new", discard_changes=True)
gui.show_design()
return gui.client.await_job(gui.client.call("replay_run", path=path, out_dir=out_dir), timeout=900)
def rung_sketch_edit_failed_replace():
# The session the replay must reproduce starts on the empty design.
gui.new_design()
@ -521,8 +529,7 @@ def rung_sketch_edit_failed_replace():
tools = [s["tool"] for s in steps_of(path)]
gui.check("sketch_edit_failed_replace: the export keeps the sketch_finish that did not replace",
tools.count("sketch_edit") == 1 and tools.count("sketch_finish") == 3, tools)
gui.client.call("project_new", discard_changes=True)
replay = gui.client.await_job(gui.client.call("replay_run", path=path, out_dir=out_dir), timeout=900)
replay = replay_in_new_project(path, out_dir)
gui.check("sketch_edit_failed_replace: the exported session replays", replay.get("passed") is True,
[s for s in replay.get("steps", []) if not s.get("ok")][:1])
replayed = [f["type"] for f in gui.cad("design_describe")["features"]]
@ -1772,8 +1779,10 @@ def refusal(call):
def rung_replace():
# design_commit_to_plate's replace deletes as Prepare's Delete does: a part of a cut is refused before anything
# changes, naming it, a replacing commit is one Prepare undo step, and it leaves the selection a plain commit
# leaves, on the canvas and in the Objects list, in the Prepare view it was called in.
# leaves, on the canvas and in the Objects list, in the Prepare view it was called in. The new project shows
# Prepare, and New Design is on the Design tab's ribbon.
gui.client.call("project_new", discard_changes=True)
gui.show_design()
gui.new_design()
gui.cad("solid_extrude", distance=10, width=30, height=20)
gui.cad("solid_extrude", distance=10, operation="new_body", profile=[[60, -5], [70, -5], [70, 5], [60, 5]])
@ -1990,8 +1999,7 @@ def rung_action_pick_replay():
len(picks) == 1 and picks[0]["args"].get("id") == "orca_command:sk_array_polar:orca"
and picks[0]["args"].get("args") == {"type": "circular"}, picks)
gui.cad("sketch_cancel")
gui.client.call("project_new", discard_changes=True)
replay = gui.client.await_job(gui.client.call("replay_run", path=path, out_dir=out_dir), timeout=900)
replay = replay_in_new_project(path, out_dir)
gui.check("action_pick_replay: the exported session replays", replay.get("passed") is True,
[s for s in replay.get("steps", []) if not s.get("ok")][:1])
gui.check("action_pick_replay: the replayed pick arms the polar array tool", gui.sketch()["tool"] == "array_polar",