workflow_tests: position duplicated action after parent (#88744)
gitea/wcs/pipeline/head Build queued... Details

This commit is contained in:
Valentin Deniaud 2024-03-27 11:16:07 +01:00
parent b5e58a310a
commit 745be4a1b4
2 changed files with 27 additions and 8 deletions

View File

@ -170,22 +170,38 @@ def test_workflow_tests_edit_actions(pub):
resp = resp.form.submit().follow()
assert 'not configured' not in resp.text
assert resp.text.count(escape('Click on "Accept"')) == 1
assert [x.text for x in resp.pyquery('ul li.workflow-test-action span.type')] == [
'Click on "Accept" by backoffice user',
]
resp = resp.click('Duplicate').follow()
assert resp.text.count(escape('Click on "Accept"')) == 2
assert [x.text for x in resp.pyquery('ul li.workflow-test-action span.type')] == [
'Click on "Accept" by backoffice user',
'Click on "Accept" by backoffice user',
]
resp = resp.click('Edit', index=0)
resp.form['button_name'] = 'Reject'
resp = resp.form.submit().follow()
assert resp.text.count(escape('Click on "Accept"')) == 1
assert resp.text.count(escape('Click on "Reject"')) == 1
assert [x.text for x in resp.pyquery('ul li.workflow-test-action span.type')] == [
'Click on "Reject" by backoffice user',
'Click on "Accept" by backoffice user',
]
resp = resp.click('Duplicate', index=0).follow()
assert [x.text for x in resp.pyquery('ul li.workflow-test-action span.type')] == [
'Click on "Reject" by backoffice user',
'Click on "Reject" by backoffice user',
'Click on "Accept" by backoffice user',
]
resp = resp.click('Delete', index=0)
resp = resp.form.submit().follow()
assert resp.text.count(escape('Click on "Accept"')) == 1
assert resp.text.count(escape('Click on "Reject"')) == 0
assert [x.text for x in resp.pyquery('ul li.workflow-test-action span.type')] == [
'Click on "Reject" by backoffice user',
'Click on "Accept" by backoffice user',
]
# simulate invalid action
testdef = TestDef.get(testdef.id)
@ -193,7 +209,9 @@ def test_workflow_tests_edit_actions(pub):
testdef.store()
resp = app.get('/backoffice/forms/1/tests/%s/workflow/' % testdef.id)
assert 'There are no workflow test actions yet.' in resp.text
assert [x.text for x in resp.pyquery('ul li.workflow-test-action span.type')] == [
'Click on "Accept" by backoffice user',
]
def test_workflow_tests_action_button_click(pub):

View File

@ -95,7 +95,8 @@ class WorkflowTestActionPage(Directory):
def duplicate(self):
new_action = copy.deepcopy(self.action)
new_action.id = self.testdef.workflow_tests.get_new_action_id()
self.testdef.workflow_tests.actions.append(new_action)
action_position = self.testdef.workflow_tests.actions.index(self.action)
self.testdef.workflow_tests.actions.insert(action_position + 1, new_action)
self.testdef.store()
return redirect('..')