Files
OrcaSlicer/tools/mcp/tests/ops_open_project.json
T
SoftFever d64e10f4dd Regroup the slicer's MCP commands and let each run from its arguments
Outside the Design tab an agent had 175 commands, 50 of them in the tool
list. There are now 118, named by what they act on (`object_`, `plate_`,
`preset_`, `filament_`, `plugin_` and so on), and 115 are listed. Each takes
its target and values in the call, acts on the selection when it names no
target and says what it acted on; an old name is refused. Printers and
system filaments install and uninstall, preferences read and write, plugins
enable, reload, uninstall and refresh, and objects reorder, with no dialog
to drive.

The Speed Dial keeps its 129 tiles under the same ids. Eight defects in the
rows these commands share with the menus are fixed. For a person: an object
row that cannot run says why instead of "Select an object first.", rows
that failed no longer claim success, Duplicate Plate can be undone, and
Refresh Plugins picked while a refresh runs now runs after it instead of
beside it.
2026-11-18 16:50:32 +08:00

84 lines
6.2 KiB
JSON

// Records what opening a project, project_open with a .3mf's path, does. On a clean project it opens at once. On
// one with unsaved project changes (a cylinder), and on an empty one with unsaved preset changes (top_shell_layers
// 7), it is refused with the code unsaved_changes and changes nothing; with discard_changes it then drops the
// project's changes and opens. Unsaved preset changes still open the dialog that asks about them, which the replay
// answers with Discard: that call runs with "await": false, and app_state lists the dialog. The project it opens
// is saved here first: a cube with wall_loops 5. After each call it reads the objects, the project's name, file and
// unsaved state, the presets and their unsaved keys, and the undo snapshots taken since the last read
// (fixtures/ops_undo.py), and after the clean open the recent projects; in the two refused cases the reads check
// what the refusal left and what the project opened with discard_changes holds. Every call it records is
// optional, so a refusal is kept in result.json with its text. Run it with
// tools/mcp/orca_mcp.py run-replay tools/mcp/tests/ops_open_project.json --out <dir>
{
"orca_replay_version": "0.2.0",
"name": "ops open_project",
"vars": {"undo": "${replay_dir}/fixtures/ops_undo.py"},
"steps": [
{"tool": "app_wait", "args": {"for": "ready"}},
{"tool": "project_new", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "view_set", "args": {"tab": "prepare"}},
// ---- The project to open: a cube with wall_loops 5 ----
{"tool": "object_add_primitive", "args": {"shape": "cube", "size": [20, 20, 20]}},
{"tool": "settings_set", "args": {"values": {"wall_loops": 5}}},
{"tool": "project_save", "args": {"path": "${out_dir}/open_src.3mf", "overwrite": true}},
// ---- A clean project: it opens at once ----
{"tool": "project_new", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "view_set", "args": {"tab": "home"}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "app_state"},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "project_open", "args": {"path": "${out_dir}/open_src.3mf"}, "optional": true},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "app_state"},
{"tool": "object_list"},
{"tool": "settings_get", "args": {"type": "process", "compare": ":saved"}},
{"tool": "action_search", "args": {"group": "Recent Projects"}},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
// ---- Unsaved project changes (a cylinder): refused, then opened with discard_changes ----
{"tool": "project_new", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "object_add_primitive", "args": {"shape": "cylinder", "size": [20, 10]}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "app_state"},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "project_open", "args": {"path": "${out_dir}/open_src.3mf"}, "optional": true},
{"tool": "app_state", "expect": {"/project/dirty": {"eq": true}, "/dialogs/0": {"exists": false}}},
{"tool": "object_list", "expect": {"/total": {"eq": 1}, "/plates/0/objects/0/name": {"eq": "Cylinder"}}},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "project_open", "args": {"path": "${out_dir}/open_src.3mf", "discard_changes": true}, "optional": true},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "app_state", "expect": {"/project/name": {"eq": "open_src"}, "/project/dirty": {"eq": false}}},
{"tool": "object_list", "expect": {"/total": {"eq": 1}, "/plates/0/objects/0/name": {"eq": "Cube"}}},
{"tool": "settings_get", "args": {"type": "process", "compare": ":saved"}},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
// ---- Unsaved preset changes (top_shell_layers 7) on an empty project: refused, then opened with
// discard_changes, after the presets' dialog is answered ----
{"tool": "project_new", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "settings_set", "args": {"values": {"top_shell_layers": 7}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "app_state"},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "project_open", "args": {"path": "${out_dir}/open_src.3mf"}, "optional": true},
{"tool": "app_state", "expect": {"/dialogs/0": {"exists": false}}},
{"tool": "object_list", "expect": {"/total": {"eq": 0}}},
{"tool": "settings_get", "args": {"keys": ["wall_loops", "top_shell_layers"]}, "expect": {"/items/1/value": {"eq": "7"}}},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "project_open", "args": {"path": "${out_dir}/open_src.3mf", "discard_changes": true}, "await": false, "save_as": "presets_discarded", "optional": true},
{"tool": "app_state", "expect": {"/dialogs/0/title": {"regex": "unsaved changes"}}},
{"tool": "dialog_answer", "args": {"dialog": {"title": "unsaved changes"}, "button": "Discard"}, "optional": true},
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.presets_discarded}"}, "optional": true},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "app_state", "expect": {"/project/name": {"eq": "open_src"}, "/dialogs/0": {"exists": false}}},
{"tool": "object_list", "expect": {"/total": {"eq": 1}, "/plates/0/objects/0/name": {"eq": "Cube"}}},
{"tool": "settings_get", "args": {"type": "process", "compare": ":saved"}},
{"tool": "settings_get", "args": {"keys": ["wall_loops", "top_shell_layers"]},
"expect": {"/items/0/value": {"eq": "5"}, "/items/1/value": {"ne": "7"}}},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "project_new", "args": {"discard_changes": true, "preset_changes": "discard"}}
]
}