Files
OrcaSlicer/tools/mcp/tests/ops_save_project_as.json
T
SoftFever 0616068e26 Run commands, tools and the plugin API through one operations layer
A Speed Dial command, the MCP tool that does the same thing and the plugin
API's preset calls now run one shared operation, so every route accepts and
refuses the same states, with one wording and a code for each refusal. An
import by a command or a tool is one undo step, and import_file adds geometry
only.

The cases where two routes behaved differently now behave the same: a project
is not saved under a .gcode.3mf name, an empty project exports as .3mf but not
as STL, arrange runs from any view and with a gizmo open, a mixed-colour
filament slot is refused as one, a hidden preset is shown before it is
selected, and a layer is refused while the Preview has none.
2026-11-12 22:06:10 +08:00

72 lines
5.1 KiB
JSON

// Records what saving the project under a name does through its two routes, the save_project_as command run with
// run_action and a path param and the save_project tool: a .3mf path, a .gcode.3mf path, a folder that does not
// exist, a file that exists (the tool without overwrite), and a project with no objects. After each it reads the
// project's name, file and unsaved state, the recent projects and the undo snapshots taken since the last read
// (fixtures/ops_undo.py), and whether the file is there: an stl export to the same path with a plate the project
// lacks refuses with "exists" when it is, with the plate when not. Every call it records is optional. Run it
// into a fresh --out directory (a command's JSON path param can't carry a Windows ${out_dir}, so the commands
// write without overwrite and refuse the files of an earlier run):
// tools/mcp/orca_mcp.py run-replay tools/mcp/tests/ops_save_project_as.json --out <new dir>
{
"orca_replay": 1,
"name": "ops save_project_as",
"vars": {"undo": "${replay_dir}/fixtures/ops_undo.py"},
"steps": [
{"tool": "wait", "args": {"for": "ready"}},
{"tool": "new_project", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "set_view", "args": {"tab": "prepare"}},
// ---- No objects (the probes come once there is one) ----
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "run_action", "args": {"id": "orca_command:save_project_as:orca", "param": "${out_dir}/empty_cmd.3mf"}, "optional": true},
{"tool": "get_app_state"},
{"tool": "save_project", "args": {"path": "${out_dir}/empty_tool.3mf", "overwrite": true}, "optional": true},
{"tool": "get_app_state"},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
// ---- A .3mf path ----
{"tool": "new_project", "args": {"discard_changes": true}},
{"tool": "run_action", "args": {"id": "orca_command:add_primitive_cube:orca", "param": "20 20 20"}},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "export", "args": {"format": "stl", "path": "${out_dir}/empty_cmd.3mf", "plates": 999}, "optional": true},
{"tool": "export", "args": {"format": "stl", "path": "${out_dir}/empty_tool.3mf", "plates": 999}, "optional": true},
{"tool": "get_app_state"},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "run_action", "args": {"id": "orca_command:save_project_as:orca", "param": "${out_dir}/cmd.3mf"}, "optional": true},
{"tool": "export", "args": {"format": "stl", "path": "${out_dir}/cmd.3mf", "plates": 999}, "optional": true},
{"tool": "get_app_state"},
{"tool": "search_actions", "args": {"group": "Recent Projects"}},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "transform", "args": {"object": 0, "translate": [5, 0, 0]}},
{"tool": "save_project", "args": {"path": "${out_dir}/tool.3mf", "overwrite": true}, "optional": true},
{"tool": "export", "args": {"format": "stl", "path": "${out_dir}/tool.3mf", "plates": 999}, "optional": true},
{"tool": "get_app_state"},
{"tool": "search_actions", "args": {"group": "Recent Projects"}},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
// ---- A .gcode.3mf path ----
{"tool": "transform", "args": {"object": 0, "translate": [5, 0, 0]}},
{"tool": "run_action", "args": {"id": "orca_command:save_project_as:orca", "param": "${out_dir}/cmd.gcode.3mf"}, "optional": true},
{"tool": "export", "args": {"format": "stl", "path": "${out_dir}/cmd.gcode.3mf", "plates": 999}, "optional": true},
{"tool": "get_app_state"},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "save_project", "args": {"path": "${out_dir}/tool.gcode.3mf", "overwrite": true}, "optional": true},
{"tool": "export", "args": {"format": "stl", "path": "${out_dir}/tool.gcode.3mf", "plates": 999}, "optional": true},
{"tool": "get_app_state"},
// ---- A folder that does not exist ----
{"tool": "run_action", "args": {"id": "orca_command:save_project_as:orca", "param": "${out_dir}/missing/cmd.3mf"}, "optional": true},
{"tool": "save_project", "args": {"path": "${out_dir}/missing/tool.3mf", "overwrite": true}, "optional": true},
{"tool": "get_app_state"},
// ---- A file that exists: the command to the tool's file, the tool without overwrite to the command's ----
{"tool": "run_action", "args": {"id": "orca_command:save_project_as:orca", "param": "${out_dir}/tool.3mf"}, "optional": true},
{"tool": "save_project", "args": {"path": "${out_dir}/cmd.3mf"}, "optional": true},
{"tool": "get_app_state"},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "new_project", "args": {"discard_changes": true}}
]
}