From 34fd4d42fed9421dcb52795f815ef04998587735 Mon Sep 17 00:00:00 2001 From: Nina Kylstad Date: Mon, 28 Oct 2024 21:56:43 +0100 Subject: [PATCH] fix(process): ensure layoutset is added when adding signing task (#13934) --- .../handlers/OnProcessTaskAddHandler.test.ts | 12 ++++++++++-- .../handlers/OnProcessTaskAddHandler.ts | 3 ++- .../process-editor/src/hooks/useBpmnEditor.ts | 6 +++++- .../tests/process-editor/process-editor.spec.ts | 1 + 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/frontend/app-development/features/processEditor/handlers/OnProcessTaskAddHandler.test.ts b/frontend/app-development/features/processEditor/handlers/OnProcessTaskAddHandler.test.ts index adda2765445..ef16f8bd2d3 100644 --- a/frontend/app-development/features/processEditor/handlers/OnProcessTaskAddHandler.test.ts +++ b/frontend/app-development/features/processEditor/handlers/OnProcessTaskAddHandler.test.ts @@ -118,7 +118,7 @@ describe('OnProcessTaskAddHandler', () => { expect(mutateApplicationPolicyMock).toHaveBeenCalledWith(expectedResponse); }); - it('should add datatype when signing task is added', () => { + it('should add layoutset and datatype when signing task is added', () => { const onProcessTaskAddHandler = createOnProcessTaskHandler(); const taskMetadata: OnProcessTaskEvent = { @@ -128,11 +128,19 @@ describe('OnProcessTaskAddHandler', () => { onProcessTaskAddHandler.handleOnProcessTaskAdd(taskMetadata); + expect(addLayoutSetMock).toHaveBeenCalledWith({ + layoutSetConfig: { + id: 'testElementId', + tasks: ['testElementId'], + }, + layoutSetIdToUpdate: 'testElementId', + taskType: 'signing', + }); + expect(addDataTypeToAppMetadataMock).toHaveBeenCalledWith({ dataTypeId: 'signatureInformation-1234', taskId: 'testElementId', }); - expect(addLayoutSetMock).not.toHaveBeenCalled(); expect(mutateApplicationPolicyMock).not.toHaveBeenCalled(); }); diff --git a/frontend/app-development/features/processEditor/handlers/OnProcessTaskAddHandler.ts b/frontend/app-development/features/processEditor/handlers/OnProcessTaskAddHandler.ts index 6eea89dc282..249018b75f9 100644 --- a/frontend/app-development/features/processEditor/handlers/OnProcessTaskAddHandler.ts +++ b/frontend/app-development/features/processEditor/handlers/OnProcessTaskAddHandler.ts @@ -87,11 +87,12 @@ export class OnProcessTaskAddHandler { } /** - * Adds a dataType to the added signing task + * Adds a dataType and layoutset to the added signing task * @param taskMetadata * @private */ private handleSigningTaskAdd(taskMetadata: OnProcessTaskEvent): void { + this.addLayoutSet(this.createLayoutSetConfig(taskMetadata)); const studioModeler = new StudioModeler(taskMetadata.taskEvent.element as any); const dataTypeId = studioModeler.getDataTypeIdFromBusinessObject( taskMetadata.taskType, diff --git a/frontend/packages/process-editor/src/hooks/useBpmnEditor.ts b/frontend/packages/process-editor/src/hooks/useBpmnEditor.ts index 0d8b2a84690..cf6c51b7ea0 100644 --- a/frontend/packages/process-editor/src/hooks/useBpmnEditor.ts +++ b/frontend/packages/process-editor/src/hooks/useBpmnEditor.ts @@ -36,7 +36,11 @@ export const useBpmnEditor = (): UseBpmnViewerResult => { taskEvent, taskType: bpmnDetails.taskType, }); - if (bpmnDetails.taskType === 'data' || bpmnDetails.taskType === 'payment') + if ( + bpmnDetails.taskType === 'data' || + bpmnDetails.taskType === 'payment' || + bpmnDetails.taskType === 'signing' + ) addAction(bpmnDetails.id); }; diff --git a/frontend/testing/playwright/tests/process-editor/process-editor.spec.ts b/frontend/testing/playwright/tests/process-editor/process-editor.spec.ts index 7e141402a01..ce653356886 100644 --- a/frontend/testing/playwright/tests/process-editor/process-editor.spec.ts +++ b/frontend/testing/playwright/tests/process-editor/process-editor.spec.ts @@ -215,6 +215,7 @@ const addNewSigningTaskToProcessEditor = async (page: Page): Promise => extraMovingDistanceX, extraMovingDistanceY, ); + await processEditorPage.skipRecommendedTask(); await processEditorPage.waitForTaskToBeVisibleInConfigPanel(signingTask); return signingTask;