Header removals wait for the code editor to be left: autosave saves with drop=false, so follow_header adds and renames from the header but keeps a port or setting whose parameter is gone, and leaving the editor (blur or closing the panel) saves once more with removals; source saves of a flow run one at a time

This commit is contained in:
2026-10-15 21:31:04 +02:00
parent 5ca90ffece
commit ce2ce4e3e7
10 changed files with 105 additions and 24 deletions
+7
View File
@@ -580,6 +580,13 @@ def test_saving_a_header_moves_the_node_ports_in_the_draft(
assert response["version"] == saved["definition"]["version"] + 1
logger = next(n for n in draft["definition"]["nodes"] if n["id"] == "logger")
assert logger["params"] == {"gain": 2}
# The editor's autosave: a parameter typed away keeps its port for now.
paused = client.put(
f"{PREFIX}/header/nodes/logger/source?drop=false",
headers=superuser_token_headers,
json={"code": "def process(reading, gain=2):\n return {}\n"},
).json()
assert paused["node"] is None
client.delete(f"{PREFIX}/header", headers=superuser_token_headers)
+15
View File
@@ -192,6 +192,21 @@ def test_a_renamed_parameter_keeps_the_message_and_a_dropped_one_goes():
assert dropped.params == {"factor": 3}
def test_without_drop_a_missing_parameter_stays_and_the_rest_follows():
node = _flow(
[*READING, MessageSpec(name="garden.level", port="depth")], factor=3
).nodes[0]
paused = follow_header(node, "def process(depth): pass\n", drop=False)
renamed = follow_header(node, "def process(value, depth, factor): pass\n", False)
added = follow_header(node, "def process(depth, gain=2): pass\n", drop=False)
assert paused == node
assert renamed.requires[0] == READING[0].model_copy(update={"port": "value"})
assert [spec.port for spec in added.requires] == ["reading", "depth"]
assert added.params == {"factor": 3, "gain": 2}
def test_a_new_parameter_after_a_setting_is_a_setting():
node = _flow(READING, factor=3).nodes[0]