Files
OrcaSlicer/tools/mcp/tests/preview.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

145 lines
8.8 KiB
JSON

// plate_slice_stats and app_state.preview on a sliced 25.6 mm cube: the summary, the feature and layer
// tables, the object with its object_list index, the legend's state as view_set changes it (rows,
// time estimate, layers by height, a view type picked as the legend's combo does), and the same reads
// on the cube's G-code opened for viewing. Run it on a fresh datadir set up with the
// default printer (Bambu Lab X1 Carbon 0.4, 0.2 mm layers):
// tools/mcp/orca_mcp.py run-replay tools/mcp/tests/preview.json --out /tmp/preview
// The tables' arithmetic (shares of the print time, heights, paging, the unique-name rule) is unit
// tested in tests/slic3rutils/test_mcp_results.cpp, since a replay step cannot add values up, and a
// refusal cannot be expected in a replay; tools/mcp/test_set_view_preview.py checks view_set's.
{
"orca_replay_version": "0.2.0",
"name": "preview data",
"steps": [
{"tool": "app_wait", "args": {"for": "ready"}},
// Opening a G-code file asks to save the project it replaces, discard_changes or not.
{"tool": "dialog_auto_answer", "args": {"rules": [{"match": "Uniform scale", "button": "ok"},
{"match": "unsaved changes. Would you like to save", "button": "No"}]}},
{"tool": "project_new", "args": {"discard_changes": true}},
{"tool": "window_set", "args": {"size": [1600, 900]}},
{"tool": "view_set", "args": {"tab": "prepare"}},
{"tool": "action_run", "args": {"id": "orca_command:add_primitive_cube:orca"}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "plate_slice", "expect": {"/plates/0/outcome": {"eq": "ok"}, "/plates/0/layers": {"eq": 128}}},
// A new result with as many layers keeps the slider and the view type, so a rerun sets both.
{"tool": "view_set", "args": {"view_type": "feature_type", "layer_range": [1, 128]}},
// ---- The tables, and the legend of the plate the Preview shows ----
{"tool": "plate_slice_stats", "args": {"include": ["features", "layers", "objects", "view"], "limit": 5}, "expect": {
"/plate": {"eq": 0},
"/summary/layers": {"eq": 128},
"/summary/filament_g": {"gt": 0},
"/summary/travel_mm": {"gt": 0},
"/features/Outer wall/time_s": {"gt": 0},
"/features/Outer wall/percent": {"gt": 0, "lt": 100},
"/features/Outer wall/g": {"gt": 0},
"/features/Travel/mm": {"gt": 0},
"/layers/total": {"eq": 128},
"/layers/next_offset": {"eq": 5},
"/layers/items/0/layer": {"eq": 1},
"/layers/items/0/z": {"eq": 0.2},
"/layers/items/4/z": {"eq": 1.0},
"/layers/items/4/height": {"eq": 0.2},
"/layers/items/4/time_s": {"gt": 0},
"/objects/0/object": {"eq": 0},
"/objects/0/instance": {"eq": 0},
"/objects/0/g": {"gt": 0},
"/view/view_type": {"eq": "feature_type"},
"/view/layers/0": {"eq": 1},
"/view/layers/1": {"eq": 128},
"/view/layer_count": {"eq": 128},
"/view/time_mode": {"eq": "normal"},
"/view/legend/features/Outer wall": {"eq": true},
"/view/legend/options/travel": {"exists": true},
"/view/ranges/height/1": {"ge": 0.2},
"/view/ranges/volumetric_flow_rate/1": {"gt": 0},
"/view/ranges/layer_time_linear/1": {"gt": 0}}},
// The last page, with each layer's seconds per feature type, and no other part.
{"tool": "plate_slice_stats", "args": {"include": ["layer_features"], "offset": 127}, "expect": {
"/layers/items/0/layer": {"eq": 128},
"/layers/items/0/z": {"eq": 25.6},
"/layers/items/0/features/Top surface": {"gt": 0},
"/layers/next_offset": {"exists": false},
"/features": {"exists": false},
"/view": {"exists": false}}},
// ---- view_set's legend rows, time estimate and layers by height ----
{"tool": "view_set", "args": {"view_type": "feature_type", "legend": {"Sparse infill": false, "travel": true}, "layer_z": 1.0}, "expect": {
"/legend/Sparse infill": {"eq": false},
"/legend/travel": {"eq": true},
"/layers/1": {"eq": 5},
"/z/1": {"eq": 1.0}}},
{"tool": "plate_slice_stats", "args": {"include": ["view"]}, "expect": {
"/view/legend/features/Sparse infill": {"eq": false},
"/view/legend/features/Outer wall": {"eq": true},
"/view/legend/options/travel": {"eq": true},
"/view/layers/1": {"eq": 5}}},
// Between two layer tops a height takes the layer that covers it, as the slider places a custom G-code.
{"tool": "view_set", "args": {"layer_z": 1.05}, "expect": {"/layers/1": {"eq": 6}, "/z/1": {"eq": 1.2}}},
{"tool": "view_set", "args": {"time_mode": "normal"}, "expect": {"/time_mode": {"eq": "normal"}}},
// A view type is picked as in the legend's combo: Line Type shows every feature type again.
{"tool": "view_set", "args": {"view_type": "speed"}},
{"tool": "plate_slice_stats", "args": {"include": ["view"]}, "expect": {"/view/legend/features/Sparse infill": {"eq": false}}},
{"tool": "view_set", "args": {"view_type": "feature_type", "legend": {"travel": false}}},
{"tool": "plate_slice_stats", "args": {"include": ["view"]}, "expect": {
"/view/legend/features/Sparse infill": {"eq": true},
"/view/legend/options/travel": {"eq": false}}},
{"tool": "window_screenshot", "args": {"target": "canvas", "save_path": "${out_dir}/legend.png", "overwrite": true, "include_image": false}},
// ---- app_state.preview follows view_set ----
{"tool": "view_set", "args": {"layer": 5}},
{"tool": "app_state", "expect": {
"/preview/plate": {"eq": 0},
"/preview/layers/0": {"eq": 1},
"/preview/layers/1": {"eq": 5},
"/preview/z/1": {"eq": 1.0},
"/preview/layer_count": {"eq": 128}}},
{"tool": "view_set", "args": {"view_type": "fan_speed"}},
{"tool": "app_state", "expect": {"/preview/view_type": {"eq": "fan_speed"}}},
{"tool": "plate_slice_stats", "args": {"include": ["view"]}, "expect": {
"/view/view_type": {"eq": "fan_speed"},
"/view/layers/1": {"eq": 5},
"/features": {"exists": false}}},
// ---- A plate the Preview has not shown: the Preview loads a plate's toolpaths only while shown,
// so after another plate is selected it still holds the last one's, which no read reports as
// the selected plate's ----
{"tool": "view_set", "args": {"tab": "prepare"}},
{"tool": "action_run", "args": {"id": "orca_command:plate_add:orca"}},
{"tool": "plate_select", "args": {"plate": 1}},
{"tool": "object_select", "args": {"none": true}},
{"tool": "action_run", "args": {"id": "orca_command:add_primitive_cube:orca"}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "plate_list", "expect": {"/items/1/objects": {"gt": 0}}},
{"tool": "plate_slice", "args": {"plates": "all"}, "expect": {"/plates/0/outcome": {"eq": "ok"}, "/plates/1/outcome": {"eq": "ok"}}},
// Slicing every plate leaves the Preview on its all-plates statistics; plate 0 is shown from Prepare.
{"tool": "view_set", "args": {"tab": "prepare"}},
{"tool": "plate_select", "args": {"plate": 0}},
{"tool": "view_set", "args": {"tab": "preview"}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "app_state", "expect": {"/plates/current": {"eq": 0}, "/preview/plate": {"eq": 0}}},
{"tool": "view_set", "args": {"tab": "prepare"}},
{"tool": "plate_select", "args": {"plate": 1}},
{"tool": "app_state", "expect": {"/plates/current": {"eq": 1}, "/preview": {"eq": null}}},
{"tool": "plate_slice_stats", "expect": {"/plate": {"eq": 1}, "/summary/layers": {"eq": 128}, "/view": {"eq": null},
"/note": {"contains": "has not loaded this plate's toolpaths"}}},
{"tool": "view_set", "args": {"tab": "preview"}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "app_state", "expect": {"/preview/plate": {"eq": 1}}},
{"tool": "plate_slice_stats", "args": {"include": ["view"]}, "expect": {"/view/layer_count": {"eq": 128}, "/note": {"exists": false}}},
// ---- The same cube's G-code opened for viewing: its plate is never marked sliced ----
{"tool": "project_export", "args": {"format": "gcode", "path": "${out_dir}/cube.gcode", "overwrite": true}},
{"tool": "project_open", "args": {"path": "${out_dir}/cube.gcode", "discard_changes": true}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "app_state", "expect": {"/preview/layer_count": {"eq": 128}}},
{"tool": "plate_slice_stats", "args": {"include": ["features", "layers", "objects", "view"]}, "expect": {
"/summary/layers": {"eq": 128},
"/summary/filament_g": {"gt": 0},
"/features/Outer wall/time_s": {"gt": 0},
"/layers/total": {"eq": 128},
"/view/layer_count": {"eq": 128}}},
{"tool": "project_new", "args": {"discard_changes": true}}
]
}