Skip to content

Commit 0f5b923

Browse files
authored
Ensure simulate_until_node_is reset when node is replaced. (baserow#4249)
* Ensure simulate_until_node_is reset when node is replaced. * Set simulate_until_node_id to null instead of refreshing entire workflow
1 parent eb40993 commit 0f5b923

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

backend/src/baserow/contrib/automation/nodes/service.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,10 @@ def replace_node(
400400

401401
workflow.get_graph().replace(node_to_replace, new_node)
402402

403+
if workflow.simulate_until_node_id == node_to_replace.id:
404+
workflow.simulate_until_node = None
405+
workflow.save(update_fields=["simulate_until_node"])
406+
403407
automation_node_deleted.send(
404408
self,
405409
workflow=workflow,

backend/tests/baserow/contrib/automation/nodes/test_node_actions.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@ def test_replace_automation_action_node_type(data_fixture):
109109
node = data_fixture.create_automation_node(
110110
workflow=workflow, type=LocalBaserowCreateRowNodeType.type, label="To replace"
111111
)
112-
node_after = data_fixture.create_automation_node(
112+
workflow.simulate_until_node_id = node.id
113+
workflow.save()
114+
115+
data_fixture.create_automation_node(
113116
workflow=workflow, type=LocalBaserowCreateRowNodeType.type, label="After"
114117
)
115118

@@ -126,6 +129,9 @@ def test_replace_automation_action_node_type(data_fixture):
126129
user, node.id, LocalBaserowUpdateRowNodeType.type
127130
)
128131

132+
workflow.refresh_from_db()
133+
assert workflow.simulate_until_node_id is None
134+
129135
workflow.assert_reference(
130136
{
131137
"0": "local_baserow_rows_created",
@@ -209,10 +215,12 @@ def test_replace_automation_trigger_node_type(data_fixture):
209215
automation = data_fixture.create_automation_application(workspace=workspace)
210216
workflow = data_fixture.create_automation_workflow(user, automation=automation)
211217
original_trigger = workflow.get_trigger()
212-
action_node = data_fixture.create_automation_node(
218+
data_fixture.create_automation_node(
213219
workflow=workflow,
214220
type=LocalBaserowCreateRowNodeType.type,
215221
)
222+
workflow.simulate_until_node_id = original_trigger.id
223+
workflow.save()
216224

217225
workflow.assert_reference(
218226
{
@@ -226,6 +234,9 @@ def test_replace_automation_trigger_node_type(data_fixture):
226234
user, original_trigger.id, LocalBaserowRowsUpdatedNodeTriggerType.type
227235
)
228236

237+
workflow.refresh_from_db()
238+
assert workflow.simulate_until_node_id is None
239+
229240
workflow.assert_reference(
230241
{
231242
"0": "local_baserow_rows_updated",

web-frontend/modules/automation/store/automationWorkflowNode.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,10 @@ const actions = {
342342
throw error
343343
}
344344
},
345-
async replace({ commit, dispatch, getters }, { workflow, nodeId, newType }) {
345+
async replace(
346+
{ commit, dispatch, getters, rootGetters },
347+
{ workflow, nodeId, newType }
348+
) {
346349
const nodeToReplace = getters.findById(workflow, nodeId)
347350

348351
const { data: newNode } = await AutomationWorkflowNodeService(
@@ -361,6 +364,15 @@ const actions = {
361364

362365
commit('DELETE_ITEM', { workflow, nodeId })
363366

367+
await dispatch(
368+
'automationWorkflow/forceUpdate',
369+
{
370+
workflow,
371+
values: { simulate_until_node_id: null },
372+
},
373+
{ root: true }
374+
)
375+
364376
setTimeout(() => {
365377
dispatch('select', { workflow, node: newNode })
366378
})

0 commit comments

Comments
 (0)