Merge remote-tracking branch 'origin/main' into bug/improve_reset_to_previous_task

This commit is contained in:
danfunk 2023-05-10 16:51:47 -04:00
commit e417eb57f3
10 changed files with 3904 additions and 3885 deletions

1000
poetry.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -3121,7 +3121,7 @@ lxml = "*"
type = "git"
url = "https://github.com/sartography/SpiffWorkflow"
reference = "main"
resolved_reference = "0a455cdd221137ec52d39801dd5ad6dabad4ed4f"
resolved_reference = "a844b34f9327a572d8f26110a01af21e22c548d1"
[[package]]
name = "sqlalchemy"

View File

@ -1786,6 +1786,18 @@ class ProcessInstanceProcessor:
)
task_service.update_all_tasks_from_spiff_tasks(spiff_tasks, deleted_tasks, start_time)
# we may want to move this to task_service.update_all_tasks_from_spiff_tasks but not sure it's always good to it.
# for cancelled tasks, spiff only returns tasks that were cancelled, not the ones that were deleted so we have to find them
spiff_task_guids = [str(st.id) for st in spiff_tasks]
tasks_no_longer_in_spiff = TaskModel.query.filter(
and_(
TaskModel.process_instance_id == self.process_instance_model.id,
TaskModel.guid.not_in(spiff_task_guids), # type: ignore
)
).all()
for task in tasks_no_longer_in_spiff:
db.session.delete(task)
self.save()
self.process_instance_model.status = "terminated"
db.session.add(self.process_instance_model)

View File

@ -462,7 +462,10 @@ class TaskService:
human_tasks_to_clear = HumanTaskModel.query.filter(
HumanTaskModel.task_id.in_(deleted_task_ids) # type: ignore
).all()
for task in tasks_to_clear + human_tasks_to_clear:
# delete human tasks first to avoid potential conflicts when deleting tasks.
# otherwise sqlalchemy returns several warnings.
for task in human_tasks_to_clear + tasks_to_clear:
db.session.delete(task)
# Note: Can't restrict this to definite, because some things are updated and are now CANCELLED
@ -473,6 +476,7 @@ class TaskService:
spiff_tasks_updated[str(spiff_task.id)] = spiff_task
for _id, spiff_task in spiff_tasks_updated.items():
self.update_task_model_with_spiff_task(spiff_task)
self.save_objects_to_database()
@classmethod

View File

@ -1611,6 +1611,10 @@ class TestProcessApi(BaseTest):
assert len(ready_tasks) == 1
ready_task = ready_tasks[0]
# check all_tasks here to ensure we actually deleted items when cancelling the instance
all_tasks = TaskModel.query.filter_by(process_instance_id=process_instance_id).all()
assert len(all_tasks) == 8
response = client.post(
f"/v1.0/process-instance-terminate/{self.modify_process_identifier_for_path_param(process_model_identifier)}/{process_instance_id}",
headers=self.logged_in_headers(with_super_admin_user),
@ -1621,11 +1625,13 @@ class TestProcessApi(BaseTest):
process_instance = ProcessInstanceModel.query.filter_by(id=process_instance_id).first()
assert process_instance
assert process_instance.status == "terminated"
assert ready_task.state == "CANCELLED"
# TODO: uncomment this once spiff is returning deleted tasks on cancel
# remaining_tasks = TaskModel.query.filter_by(process_instance_id=process_instance_id).all()
# assert len(remaining_tasks) == 3
ready_task_that_is_now_cancelled = TaskModel.query.filter_by(guid=ready_task.guid).first()
assert ready_task_that_is_now_cancelled is not None
assert ready_task_that_is_now_cancelled.state == "CANCELLED"
remaining_tasks = TaskModel.query.filter_by(process_instance_id=process_instance_id).all()
assert len(remaining_tasks) == 3
def test_process_instance_delete(
self,

View File

@ -33,3 +33,5 @@ cypress/screenshots
# Editors
.idea
/cypress.env

View File

@ -30,6 +30,14 @@ if [[ -z "${CYPRESS_SPIFFWORKFLOW_FRONTEND_AUTH_WITH_KEYCLOAK:-}" ]]; then
export CYPRESS_SPIFFWORKFLOW_FRONTEND_AUTH_WITH_KEYCLOAK=true
fi
if [[ -f cypress.env ]]; then
# shellcheck disable=1091
source cypress.env
else
>&2 echo "ERROR: This requires a cypress.env file to run. You may be able to use generate_pp1_cypress_env_configs."
exit 1
fi
cypress_run_file="/var/tmp/cypress_run"
echo "Recording stats to ${cypress_run_file}"
@ -44,7 +52,6 @@ for attempt in $(seq 1 "$ATTEMPTS" ); do
start_time=$(date +%s)
success="false"
# spec_pattern="cypress/pilot/**/*.cy.{js,jsx,ts,tsx}"
spec_pattern="cypress/pilot/**/*.cy.{js,jsx,ts,tsx}"
if ./node_modules/.bin/cypress "$command" -c specPattern="${spec_pattern}" --e2e --browser chrome "$@"; then
success="true"

View File

@ -63,6 +63,7 @@ Cypress.Commands.add('login', (username, password) => {
Cypress.Commands.add('logout', (_selector, ..._args) => {
cy.get('#user-profile-toggletip').click();
cy.wait(2000);
cy.getBySel('logout-button').click();
if (Cypress.env('SPIFFWORKFLOW_FRONTEND_AUTH_WITH_KEYCLOAK') === true) {
// otherwise we can click logout, quickly load the next page, and the javascript