From 978756006befcf826c693c084b0b154346f1a20f Mon Sep 17 00:00:00 2001 From: Agustin Busso <90727999+agustinbusso@users.noreply.github.com> Date: Mon, 24 Jan 2022 17:01:51 -0300 Subject: [PATCH 1/9] Get next task when you have interstitial. Show parent summary screen --- src/components/task.vue | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/components/task.vue b/src/components/task.vue index fcdb11cd8..08827fccf 100644 --- a/src/components/task.vue +++ b/src/components/task.vue @@ -279,7 +279,7 @@ export default { } this.prepareTask(); }, - closeTask() { + closeTask(parentRequestId = null) { if (this.hasErrors) { this.$emit('error', this.requestId); return; @@ -291,7 +291,7 @@ export default { } else if (this.task.allow_interstitial) { this.task.interstitial_screen['_interstitial'] = true; this.screen = this.task.interstitial_screen; - this.loadNextAssignedTask(); + this.loadNextAssignedTask(parentRequestId); } else { this.$emit('closed', this.task.id); @@ -315,6 +315,11 @@ export default { this.redirecting = task.process_request_id; this.$emit('redirect', task); return; + } else { + // Only emit completed after getting the subprocess tasks and there are no tasks + if (requestId == this.task.process_request_id && this.parentRequest) { + this.$emit('completed', this.parentRequest); + } } this.taskId = task.id; this.nodeId = task.element_id; @@ -365,6 +370,9 @@ export default { // There could be another task in the parent, so don't emit completed return; } + if (this.parentRequest) { + this.$emit('completed', this.parentRequest); + } this.$emit('completed', this.requestId); }, processUpdated: _.debounce(function(data) { @@ -413,7 +421,8 @@ export default { '.ProcessUpdated', (data) => { if (['ACTIVITY_COMPLETED', 'ACTIVITY_ACTIVATED'].includes(data.event)) { - this.loadNextAssignedTask(this.parentRequest); + // this.loadNextAssignedTask(this.parentRequest); + this.closeTask(this.parentRequest); } if (data.event === 'ACTIVITY_EXCEPTION') { this.$emit('error', this.requestId); From c84fe5efe5ae0a698491989100dc9177d3e55077 Mon Sep 17 00:00:00 2001 From: Agustin Busso <90727999+agustinbusso@users.noreply.github.com> Date: Mon, 24 Jan 2022 17:16:21 -0300 Subject: [PATCH 2/9] Removed comment --- src/components/task.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/task.vue b/src/components/task.vue index 08827fccf..fbd1df290 100644 --- a/src/components/task.vue +++ b/src/components/task.vue @@ -421,7 +421,6 @@ export default { '.ProcessUpdated', (data) => { if (['ACTIVITY_COMPLETED', 'ACTIVITY_ACTIVATED'].includes(data.event)) { - // this.loadNextAssignedTask(this.parentRequest); this.closeTask(this.parentRequest); } if (data.event === 'ACTIVITY_EXCEPTION') { From 60bb5b58d6bf26c18ce4dba4cc2cdc22013e4229 Mon Sep 17 00:00:00 2001 From: Agustin Busso <90727999+agustinbusso@users.noreply.github.com> Date: Tue, 25 Jan 2022 15:58:06 -0300 Subject: [PATCH 3/9] Emit completed when no tasks --- src/components/task.vue | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/task.vue b/src/components/task.vue index fbd1df290..aa5cdff11 100644 --- a/src/components/task.vue +++ b/src/components/task.vue @@ -323,6 +323,8 @@ export default { } this.taskId = task.id; this.nodeId = task.element_id; + } else { + this.$emit('completed', (this.parentRequest ? this.parentRequest : null)); } }); }, From c7e06bea6d666693de979be59536a6d58e8a7ec5 Mon Sep 17 00:00:00 2001 From: Agustin Busso <90727999+agustinbusso@users.noreply.github.com> Date: Wed, 26 Jan 2022 10:13:45 -0300 Subject: [PATCH 4/9] Redirect when no tasks to summary --- src/components/task.vue | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/components/task.vue b/src/components/task.vue index aa5cdff11..89ef547b3 100644 --- a/src/components/task.vue +++ b/src/components/task.vue @@ -368,10 +368,6 @@ export default { // This may no longer be needed }, processCompleted() { - if (this.parentRequest && this.task.allow_interstitial) { - // There could be another task in the parent, so don't emit completed - return; - } if (this.parentRequest) { this.$emit('completed', this.parentRequest); } @@ -422,9 +418,14 @@ export default { `ProcessMaker.Models.ProcessRequest.${this.parentRequest}`, '.ProcessUpdated', (data) => { - if (['ACTIVITY_COMPLETED', 'ACTIVITY_ACTIVATED'].includes(data.event)) { + if (['ACTIVITY_ACTIVATED'].includes(data.event)) { this.closeTask(this.parentRequest); } + if (['ACTIVITY_COMPLETED'].includes(data.event)) { + if (this.task.process_request.status === 'COMPLETED') { + this.processCompleted(); + } + } if (data.event === 'ACTIVITY_EXCEPTION') { this.$emit('error', this.requestId); } From c239bf4b3a292e8dbbe4ad6325fee87ee07befa5 Mon Sep 17 00:00:00 2001 From: Agustin Busso <90727999+agustinbusso@users.noreply.github.com> Date: Wed, 26 Jan 2022 11:59:53 -0300 Subject: [PATCH 5/9] Avoiding redirect if process not completed yet --- src/components/task.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/task.vue b/src/components/task.vue index 89ef547b3..9b5ad4ebe 100644 --- a/src/components/task.vue +++ b/src/components/task.vue @@ -316,8 +316,8 @@ export default { this.$emit('redirect', task); return; } else { - // Only emit completed after getting the subprocess tasks and there are no tasks - if (requestId == this.task.process_request_id && this.parentRequest) { + // Only emit completed after getting the subprocess tasks and there are no tasks and process is completed + if (requestId == this.task.process_request_id && this.parentRequest && this.task.process_request.status === 'COMPLETED') { this.$emit('completed', this.parentRequest); } } From 7751eafcf15b3817d066e039f8d87e58a0905515 Mon Sep 17 00:00:00 2001 From: Agustin Busso <90727999+agustinbusso@users.noreply.github.com> Date: Wed, 26 Jan 2022 13:24:04 -0300 Subject: [PATCH 6/9] Go to next task in parent if exist --- src/components/task.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/task.vue b/src/components/task.vue index 9b5ad4ebe..3e537aef1 100644 --- a/src/components/task.vue +++ b/src/components/task.vue @@ -286,7 +286,7 @@ export default { } if (this.task.process_request.status === 'COMPLETED') { - this.processCompleted(); + this.loadNextAssignedTask(parentRequestId); } else if (this.task.allow_interstitial) { this.task.interstitial_screen['_interstitial'] = true; @@ -313,7 +313,7 @@ export default { } this.unsubscribeSocketListeners(); this.redirecting = task.process_request_id; - this.$emit('redirect', task); + window.location.href = `/tasks/${task.id}/edit`; return; } else { // Only emit completed after getting the subprocess tasks and there are no tasks and process is completed From 1594a276831e0d718d063c2400902553a2ab27b6 Mon Sep 17 00:00:00 2001 From: Agustin Busso <90727999+agustinbusso@users.noreply.github.com> Date: Fri, 28 Jan 2022 11:28:09 -0300 Subject: [PATCH 7/9] Emit instead redirect with force redirect in true --- src/components/task.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/task.vue b/src/components/task.vue index 3e537aef1..70950f9e3 100644 --- a/src/components/task.vue +++ b/src/components/task.vue @@ -313,7 +313,7 @@ export default { } this.unsubscribeSocketListeners(); this.redirecting = task.process_request_id; - window.location.href = `/tasks/${task.id}/edit`; + this.$emit('redirect', task.id, true); return; } else { // Only emit completed after getting the subprocess tasks and there are no tasks and process is completed @@ -324,7 +324,7 @@ export default { this.taskId = task.id; this.nodeId = task.element_id; } else { - this.$emit('completed', (this.parentRequest ? this.parentRequest : null)); + this.$emit('completed', (this.parentRequest ? this.parentRequest : requestId)); } }); }, From d9243c56cec2dea063ee2ff98db099cff01b103b Mon Sep 17 00:00:00 2001 From: Agustin Busso <90727999+agustinbusso@users.noreply.github.com> Date: Fri, 28 Jan 2022 11:28:41 -0300 Subject: [PATCH 8/9] Added test cases --- src/main.js | 12 +- tests/components/TaskRedirect.vue | 160 ++++++ tests/e2e/fixtures/single_line_input.json | 573 ++++++++++++++++++++++ tests/e2e/specs/Task.spec.js | 439 ++++++++++++++++- tests/e2e/support/commands.js | 6 + 5 files changed, 1176 insertions(+), 14 deletions(-) create mode 100644 tests/components/TaskRedirect.vue create mode 100644 tests/e2e/fixtures/single_line_input.json diff --git a/src/main.js b/src/main.js index 69aa58e1f..816460b0f 100644 --- a/src/main.js +++ b/src/main.js @@ -152,7 +152,7 @@ window.ProcessMaker = { {value: 2, content: 'John'}, {value: 3, content: 'Mary'}, {value: 4, content: 'Patricia'}, - ], + ], }}); break; default: @@ -201,6 +201,16 @@ window.Echo = { }, 1000); }); }, + eventMocks(event, response) { + this.listeners.forEach((listener) => { + setTimeout(() => { + listener.callback({ + type: event, + response, + }); + }, 1000); + }); + }, private() { return { notification(callback) { diff --git a/tests/components/TaskRedirect.vue b/tests/components/TaskRedirect.vue new file mode 100644 index 000000000..328a782eb --- /dev/null +++ b/tests/components/TaskRedirect.vue @@ -0,0 +1,160 @@ + + + + + \ No newline at end of file diff --git a/tests/e2e/fixtures/single_line_input.json b/tests/e2e/fixtures/single_line_input.json new file mode 100644 index 000000000..b31a18574 --- /dev/null +++ b/tests/e2e/fixtures/single_line_input.json @@ -0,0 +1,573 @@ +{ + "type": "screen_package", + "version": "2", + "screens": [ + { + "id": 80, + "screen_category_id": "1", + "title": "FOUR-5159", + "description": "FOUR-5159", + "type": "FORM", + "config": [ + { + "name": "FOUR-5159", + "items": [ + { + "label": "Line Input", + "config": { + "icon": "far fa-square", + "name": "form_input_1", + "type": "text", + "label": "New Input", + "helper": null, + "dataFormat": "string", + "validation": null, + "placeholder": null + }, + "component": "FormInput", + "inspector": [ + { + "type": "FormInput", + "field": "name", + "config": { + "name": "Variable Name", + "label": "Variable Name", + "helper": "A variable name is a symbolic name to reference information.", + "validation": "regex:/^([a-zA-Z]([a-zA-Z0-9_]?)+\\.?)+(? Date ##/##/####
SSN ###-##-####
Phone (###) ###-####", + "validation": null + } + }, + { + "type": "FormInput", + "field": "customCssSelector", + "config": { + "label": "CSS Selector Name", + "helper": "Use this in your custom css rules", + "validation": "regex: [-?[_a-zA-Z]+[_-a-zA-Z0-9]*]" + } + }, + { + "type": "FormInput", + "field": "ariaLabel", + "config": { + "label": "Aria Label", + "helper": "Attribute designed to help assistive technology (e.g. screen readers) attach a label" + } + }, + { + "type": "FormInput", + "field": "tabindex", + "config": { + "label": "Tab Order", + "helper": "Order in which a user will move focus from one control to another by pressing the Tab key", + "validation": "regex: [0-9]*" + } + } + ], + "editor-control": "FormInput", + "editor-component": "FormInput" + }, + { + "label": "Submit Button", + "config": { + "icon": "fas fa-share-square", + "name": null, + "event": "submit", + "label": "New Submit", + "tooltip": [], + "variant": "primary", + "fieldValue": null, + "defaultSubmit": true + }, + "component": "FormButton", + "inspector": [ + { + "type": "FormInput", + "field": "label", + "config": { + "label": "Label", + "helper": "The label describes the button's text" + } + }, + { + "type": "FormInput", + "field": "name", + "config": { + "name": "Variable Name", + "label": "Variable Name", + "helper": "A variable name is a symbolic name to reference information.", + "validation": "regex:/^(?:[A-Za-z])(?:[0-9A-Z_.a-z])*(? Date ##/##/####
SSN ###-##-####
Phone (###) ###-####", + "validation": null + } + }, + { + "type": "FormInput", + "field": "customCssSelector", + "config": { + "label": "CSS Selector Name", + "helper": "Use this in your custom css rules", + "validation": "regex: [-?[_a-zA-Z]+[_-a-zA-Z0-9]*]" + } + }, + { + "type": "FormInput", + "field": "ariaLabel", + "config": { + "label": "Aria Label", + "helper": "Attribute designed to help assistive technology (e.g. screen readers) attach a label" + } + }, + { + "type": "FormInput", + "field": "tabindex", + "config": { + "label": "Tab Order", + "helper": "Order in which a user will move focus from one control to another by pressing the Tab key", + "validation": "regex: [0-9]*" + } + } + ], + "editor-control": "FormSubmit", + "editor-component": "FormButton" + } + ] + } + ], + "computed": [], + "custom_css": null, + "created_at": "2022-01-20T15:37:47+00:00", + "updated_at": "2022-01-20T15:37:57+00:00", + "status": "ACTIVE", + "key": null, + "watchers": [], + "categories": [ + { + "id": 1, + "name": "Uncategorized", + "status": "ACTIVE", + "is_system": 0, + "created_at": "2021-12-22T18:37:43+00:00", + "updated_at": "2021-12-22T18:37:43+00:00", + "pivot": { + "assignable_id": 80, + "category_id": 1, + "category_type": "ProcessMaker\\Models\\ScreenCategory" + } + } + ] + } + ], + "screen_categories": [], + "scripts": [] +} \ No newline at end of file diff --git a/tests/e2e/specs/Task.spec.js b/tests/e2e/specs/Task.spec.js index 46561e63b..4b164c179 100644 --- a/tests/e2e/specs/Task.spec.js +++ b/tests/e2e/specs/Task.spec.js @@ -1,9 +1,11 @@ import moment from 'moment'; import Screens from '../fixtures/webentry.json'; +import SingleScreen from '../fixtures/single_line_input.json'; import InterstitialScreen from '../fixtures/interstitial_screen.json'; describe('Task component', () => { - it('In a webentry', () => { + let echoMock; + it.skip('In a webentry', () => { cy.server(); cy.visit('/?scenario=WebEntry', { @@ -17,14 +19,14 @@ describe('Task component', () => { send(){}, })); win.Echo = { - + }; }, }); cy.wait(2000); }); - it('Task inside a Request', () => { + it.skip('Task inside a Request', () => { cy.server(); cy.route( 'GET', @@ -79,11 +81,11 @@ describe('Task component', () => { cy.get('[data-cy=screen-field-lastname]').should('be.visible'); }); - it('Completes the Task', () => { + it.skip('Completes the Task', () => { cy.server(); cy.route( 'GET', - 'http://localhost:8080/api/1.0/tasks/1?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', + 'http://localhost:8081/api/1.0/tasks/1?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', { id: 1, advanceStatus: 'open', @@ -136,30 +138,30 @@ describe('Task component', () => { cy.wait(2000); cy.get('.form-group').find('button').click(); - cy.route('PUT', 'http://localhost:8080/api/1.0/tasks/1').then(function() { + cy.route('PUT', 'http://localhost:8081/api/1.0/tasks/1').then(function() { cy.get('@windowAlert').should('have.been.calledOnce') .and('have.been.calledWith', 'Task Completed Successfully') .then(function() { cy.route( 'GET', - 'http://localhost:8080/api/1.0/tasks/1?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', + 'http://localhost:8081/api/1.0/tasks/1?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', { id: 1, advanceStatus: 'completed', status: 'CLOSED', } - ); + ); cy.reload(); }); }); cy.get('#tab-form > .card').should('contain.text', 'Task Completed'); }); - it('Progresses to the interstitial screen', () => { + it.skip('Progresses to the interstitial screen', () => { cy.server(); cy.route( 'GET', - 'http://localhost:8080/api/1.0/tasks/1?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', + 'http://localhost:8081/api/1.0/tasks/1?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', { id: 1, advanceStatus: 'open', @@ -211,13 +213,13 @@ describe('Task component', () => { }); cy.wait(2000); cy.get('.form-group').find('button').click(); - cy.route('PUT', 'http://localhost:8080/api/1.0/tasks/1').then(function() { + cy.route('PUT', 'http://localhost:8081/api/1.0/tasks/1').then(function() { cy.get('@windowAlert').should('have.been.calledOnce') .and('have.been.calledWith', 'Task Completed Successfully') .then(function() { cy.route( 'GET', - 'http://localhost:8080/api/1.0/tasks/1?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', + 'http://localhost:8081/api/1.0/tasks/1?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', { id: 1, advanceStatus: 'completed', @@ -250,11 +252,422 @@ describe('Task component', () => { lastname: 'Doe', }, } - ); + ); cy.reload(); }); cy.wait(2000); cy.get('.form-group > :nth-child(1) > div').should('contain.text', 'Please wait'); }); }); + + /* DNAT = Display Next Assigned Task + + parentTask1 parentTask2 + \_______childTask1_______childTask2_______/ + (DNAT) + + After childTask1 should redirect to childTask2 + */ + it('Task with display next assigned task checked with another pending task in same request should redirect to the next task of same request', () => { + cy.server(); + cy.route( + 'GET', + 'http://localhost:8081/api/1.0/tasks/1?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', + { + id: 1, + advanceStatus: 'open', + component: 'task-screen', + screen: SingleScreen.screens[0], + process_request: { + id: 1, + status: 'ACTIVE', + }, + } + ); + + cy.visit('/?scenario=TaskRedirect', { + onLoad(win) { + echoMock = win.Echo; + }, + }); + + cy.wait(2000); + cy.get('.form-group').find('button').click(); + + cy.route('PUT', 'http://localhost:8081/api/1.0/tasks/1').then(function() { + let responseDataTask1 = { + 'status': 'CLOSED', + 'process_request_id': 2, + 'id': 1, + 'screen': SingleScreen.screens[0], + 'allow_interstitial': true, + 'interstitial_screen': InterstitialScreen.screens[0], + }; + + getTask( + 'http://localhost:8081/api/1.0/tasks/'+responseDataTask1['id']+'?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', + responseDataTask1 + ); + + let responseDataTasks = { + 'status': 'ACTIVE', + 'taskId': 2, + 'process_request_id': 2, + }; + + getTasks( + 'http://localhost:8081/api/1.0/tasks?user_id=1&status=ACTIVE&process_request_id=1&include_sub_tasks=1', + responseDataTasks + ); + + let responseDataTask2 = { + 'status': 'ACTIVE', + 'process_request_id': 2, + 'parent_request_id': 1, + 'taskId': 2, + 'screen': Screens.screens[0], + 'allow_interstitial': false, + 'interstitial_screen': null, + }; + + getTask( + 'http://localhost:8081/api/1.0/tasks/'+responseDataTask2['taskId']+'?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', + responseDataTask2 + ); + + cy.wait(2000); + cy.reload(); + }); + + cy.socketEvent('ProcessMaker\\Events\\ProcessUpdated', { + requestId: 1, + event: 'ACTIVITY_ACTIVATED', + }); + + cy.url().should('eq', 'http://localhost:8081/tasks/2/edit'); + }); + + /* DNAT = Display Next Assigned Task + + parentTask1 parentTask2 + \_______childTask1_______/ + (DNAT) + + After childTask1 should redirect to parentTask2 + */ + it('Task with display next assigned task checked in different process request should redirect to the next task of parent request', () => { + cy.server(); + cy.route( + 'GET', + 'http://localhost:8081/api/1.0/tasks/1?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', + { + id: 1, + advanceStatus: 'open', + component: 'task-screen', + screen: SingleScreen.screens[0], + process_request: { + id: 1, + status: 'ACTIVE', + }, + } + ); + + cy.visit('/?scenario=TaskRedirect', { + onLoad(win) { + echoMock = win.Echo; + }, + }); + + cy.wait(2000); + cy.get('.form-group').find('button').click(); + + cy.route('PUT', 'http://localhost:8081/api/1.0/tasks/1').then(function() { + let responseDataTask1 = { + 'status': 'CLOSED', + 'process_request_id': 1, + 'id': 1, + 'screen': SingleScreen.screens[0], + 'allow_interstitial': true, + 'interstitial_screen': InterstitialScreen.screens[0], + }; + + getTask( + 'http://localhost:8081/api/1.0/tasks/'+responseDataTask1['id']+'?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', + responseDataTask1 + ); + + let responseDataTasks = { + 'status': 'ACTIVE', + 'taskId': 2, + 'process_request_id': 2, + }; + + getTasks( + 'http://localhost:8081/api/1.0/tasks?user_id=1&status=ACTIVE&process_request_id=1&include_sub_tasks=1', + responseDataTasks + ); + + let responseDataTask2 = { + 'status': 'ACTIVE', + 'process_request_id': 1, + 'taskId': 2, + 'screen': Screens.screens[0], + 'allow_interstitial': false, + 'interstitial_screen': null, + }; + + getTask( + 'http://localhost:8081/api/1.0/tasks/'+responseDataTask2['taskId']+'?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', + responseDataTask2 + ); + + cy.wait(2000); + cy.reload(); + }); + + cy.socketEvent('ProcessMaker\\Events\\ProcessUpdated', { + requestId: 1, + event: 'ACTIVITY_ACTIVATED', + }); + + cy.url().should('eq', 'http://localhost:8081/tasks/2/edit'); + }); + + /* DNAT = Display Next Assigned Task + + parentTask1 parentTask2 + \_______childTask1_______/ + + After childTask1 (Not DNAT) should redirect to tasks list + */ + it('Task with display next assigned task unchecked should redirect to tasks list', () => { + cy.server(); + cy.route( + 'GET', + 'http://localhost:8081/api/1.0/tasks/1?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', + { + id: 1, + advanceStatus: 'open', + component: 'task-screen', + screen: SingleScreen.screens[0], + process_request: { + id: 1, + status: 'ACTIVE', + }, + } + ); + + cy.visit('/?scenario=TaskRedirect', { + onLoad(win) { + echoMock = win.Echo; + }, + }); + + cy.wait(2000); + cy.get('.form-group').find('button').click(); + + cy.route('PUT', 'http://localhost:8081/api/1.0/tasks/1').then(function() { + let responseDataTask1 = { + 'status': 'CLOSED', + 'process_request_id': 1, + 'id': 1, + 'screen': SingleScreen.screens[0], + 'allow_interstitial': false, + 'interstitial_screen': null, + }; + + getTask( + 'http://localhost:8081/api/1.0/tasks/'+responseDataTask1['id']+'?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', + responseDataTask1 + ); + + cy.wait(2000); + cy.reload(); + }); + + cy.socketEvent('ProcessMaker\\Events\\ProcessUpdated', { + requestId: 1, + event: 'ACTIVITY_ACTIVATED', + }); + + cy.url().should('eq', 'http://localhost:8081/tasks'); + }); + + /* DNAT = Display Next Assigned Task + + parentTask1_____________________endEvent + (DNAT) + + After parentTask1 and not pending tasks should redirect to same request + */ + it('Process without pending task should redirect to request', () => { + cy.server(); + cy.route( + 'GET', + 'http://localhost:8081/api/1.0/tasks/1?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', + { + id: 1, + advanceStatus: 'open', + component: 'task-screen', + screen: SingleScreen.screens[0], + process_request: { + id: 1, + status: 'ACTIVE', + }, + } + ); + + cy.visit('/?scenario=TaskRedirect', { + onLoad(win) { + echoMock = win.Echo; + }, + }); + + cy.wait(2000); + cy.get('.form-group').find('button').click(); + + cy.route('PUT', 'http://localhost:8081/api/1.0/tasks/1').then(function() { + let responseDataTask1 = { + 'status': 'CLOSED', + 'process_request_id': 1, + 'id': 1, + 'screen': SingleScreen.screens[0], + 'allow_interstitial': true, + 'interstitial_screen': InterstitialScreen.screens[0], + }; + + getTask( + 'http://localhost:8081/api/1.0/tasks/'+responseDataTask1['id']+'?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', + responseDataTask1 + ); + + getTasks('http://localhost:8081/api/1.0/tasks?user_id=1&status=ACTIVE&process_request_id=1&include_sub_tasks=1'); + + cy.wait(2000); + cy.reload(); + }); + + cy.socketEvent('ProcessMaker\\Events\\ProcessUpdated', { + requestId: 1, + event: 'ACTIVITY_ACTIVATED', + }); + + cy.url().should('eq', 'http://localhost:8081/requests/1'); + }); + + /* DNAT = Display Next Assigned Task + + parentTask1 endEvent + \_______childTask1_______/ + (DNAT) + + After childTask1 and not pending tasks should redirect to parent Request + */ + it('Subprocess without pending task should redirect to parent request', () => { + cy.server(); + cy.route( + 'GET', + 'http://localhost:8081/api/1.0/tasks/1?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', + { + id: 1, + advanceStatus: 'open', + component: 'task-screen', + screen: SingleScreen.screens[0], + process_request: { + id: 2, + status: 'ACTIVE', + parent_request_id: 1, + }, + } + ); + + cy.visit('/?scenario=TaskRedirect', { + onLoad(win) { + echoMock = win.Echo; + }, + }); + + cy.wait(2000); + cy.get('.form-group').find('button').click(); + + cy.route('PUT', 'http://localhost:8081/api/1.0/tasks/1').then(function() { + let responseDataTask1 = { + 'status': 'CLOSED', + 'process_request_id': 2, + 'parent_request_id': 3, + 'id': 1, + 'screen': SingleScreen.screens[0], + 'allow_interstitial': true, + 'interstitial_screen': InterstitialScreen.screens[0], + }; + + getTask( + 'http://localhost:8081/api/1.0/tasks/'+responseDataTask1['id']+'?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', + responseDataTask1 + ); + + getTasks('http://localhost:8081/api/1.0/tasks?user_id=1&status=ACTIVE&process_request_id=1&include_sub_tasks=1'); + + cy.wait(2000); + cy.reload(); + }); + + cy.socketEvent('ProcessMaker\\Events\\ProcessUpdated', { + requestId: 1, + event: 'ACTIVITY_ACTIVATED', + }); + + cy.url().should('eq', 'http://localhost:8081/requests/3'); + }); }); + +function getTask(url, responseData) { + cy.route( + 'GET', + url, + { + id: responseData['id'], + advanceStatus: 'completed', + component: 'task-screen', + status: responseData['status'], + allow_interstitial: responseData['allow_interstitial'], + interstitial_screen: responseData['interstitial_screen'], + screen: responseData['screen'], + process_request: { + id: 1, + parent_request_id: responseData['parent_request_id'], + status: responseData['status'], + }, + } + ); +} +function getTasks(url, responseData = null) { + if (responseData) { + cy.route( + 'GET', + url, + { + data: + [ + { + id: responseData['taskId'], + advanceStatus: 'open', + process_id: 1, + process_request_id: responseData['process_request_id'], + subprocess_request_id: 1, + status: responseData['status'], + completed_at: null, + due_at: moment().add(1, 'day').toISOString(), + due_notified: 0, + process_request: { + id: 1, + status: responseData['status'], + }, + }, + ], + } + ); + } else { + cy.route('GET', url, {data:[]}); + } +} diff --git a/tests/e2e/support/commands.js b/tests/e2e/support/commands.js index 8c996a98b..8a9b1fa6d 100644 --- a/tests/e2e/support/commands.js +++ b/tests/e2e/support/commands.js @@ -33,6 +33,12 @@ Cypress.Commands.add('setVueComponentProperty', (selector, property, value) => { }); }); +Cypress.Commands.add('socketEvent', (event, body) => { + cy.window().then((win) => { + win.Echo.eventMocks(event, body); + }); +}); + /** * Converts Cypress fixtures, including JSON, to a Blob. All file types are * converted to base64 then converted to a Blob using Cypress From 5a5c7c783cb2a52d0f2d54e95b9df01c5b92fc2f Mon Sep 17 00:00:00 2001 From: Agustin Busso <90727999+agustinbusso@users.noreply.github.com> Date: Fri, 28 Jan 2022 11:51:56 -0300 Subject: [PATCH 9/9] Removed unnecessary socket mocks. Removed skips. Changed url port to default --- tests/e2e/specs/Task.spec.js | 128 +++++++++++------------------------ 1 file changed, 41 insertions(+), 87 deletions(-) diff --git a/tests/e2e/specs/Task.spec.js b/tests/e2e/specs/Task.spec.js index 4b164c179..3f28d21c3 100644 --- a/tests/e2e/specs/Task.spec.js +++ b/tests/e2e/specs/Task.spec.js @@ -4,8 +4,7 @@ import SingleScreen from '../fixtures/single_line_input.json'; import InterstitialScreen from '../fixtures/interstitial_screen.json'; describe('Task component', () => { - let echoMock; - it.skip('In a webentry', () => { + it('In a webentry', () => { cy.server(); cy.visit('/?scenario=WebEntry', { @@ -26,7 +25,7 @@ describe('Task component', () => { cy.wait(2000); }); - it.skip('Task inside a Request', () => { + it('Task inside a Request', () => { cy.server(); cy.route( 'GET', @@ -81,11 +80,11 @@ describe('Task component', () => { cy.get('[data-cy=screen-field-lastname]').should('be.visible'); }); - it.skip('Completes the Task', () => { + it('Completes the Task', () => { cy.server(); cy.route( 'GET', - 'http://localhost:8081/api/1.0/tasks/1?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', + 'http://localhost:8080/api/1.0/tasks/1?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', { id: 1, advanceStatus: 'open', @@ -138,13 +137,13 @@ describe('Task component', () => { cy.wait(2000); cy.get('.form-group').find('button').click(); - cy.route('PUT', 'http://localhost:8081/api/1.0/tasks/1').then(function() { + cy.route('PUT', 'http://localhost:8080/api/1.0/tasks/1').then(function() { cy.get('@windowAlert').should('have.been.calledOnce') .and('have.been.calledWith', 'Task Completed Successfully') .then(function() { cy.route( 'GET', - 'http://localhost:8081/api/1.0/tasks/1?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', + 'http://localhost:8080/api/1.0/tasks/1?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', { id: 1, advanceStatus: 'completed', @@ -157,11 +156,11 @@ describe('Task component', () => { cy.get('#tab-form > .card').should('contain.text', 'Task Completed'); }); - it.skip('Progresses to the interstitial screen', () => { + it('Progresses to the interstitial screen', () => { cy.server(); cy.route( 'GET', - 'http://localhost:8081/api/1.0/tasks/1?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', + 'http://localhost:8080/api/1.0/tasks/1?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', { id: 1, advanceStatus: 'open', @@ -213,13 +212,13 @@ describe('Task component', () => { }); cy.wait(2000); cy.get('.form-group').find('button').click(); - cy.route('PUT', 'http://localhost:8081/api/1.0/tasks/1').then(function() { + cy.route('PUT', 'http://localhost:8080/api/1.0/tasks/1').then(function() { cy.get('@windowAlert').should('have.been.calledOnce') .and('have.been.calledWith', 'Task Completed Successfully') .then(function() { cy.route( 'GET', - 'http://localhost:8081/api/1.0/tasks/1?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', + 'http://localhost:8080/api/1.0/tasks/1?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', { id: 1, advanceStatus: 'completed', @@ -272,7 +271,7 @@ describe('Task component', () => { cy.server(); cy.route( 'GET', - 'http://localhost:8081/api/1.0/tasks/1?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', + 'http://localhost:8080/api/1.0/tasks/1?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', { id: 1, advanceStatus: 'open', @@ -285,16 +284,12 @@ describe('Task component', () => { } ); - cy.visit('/?scenario=TaskRedirect', { - onLoad(win) { - echoMock = win.Echo; - }, - }); + cy.visit('/?scenario=TaskRedirect', {}); cy.wait(2000); cy.get('.form-group').find('button').click(); - cy.route('PUT', 'http://localhost:8081/api/1.0/tasks/1').then(function() { + cy.route('PUT', 'http://localhost:8080/api/1.0/tasks/1').then(function() { let responseDataTask1 = { 'status': 'CLOSED', 'process_request_id': 2, @@ -305,7 +300,7 @@ describe('Task component', () => { }; getTask( - 'http://localhost:8081/api/1.0/tasks/'+responseDataTask1['id']+'?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', + 'http://localhost:8080/api/1.0/tasks/'+responseDataTask1['id']+'?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', responseDataTask1 ); @@ -316,7 +311,7 @@ describe('Task component', () => { }; getTasks( - 'http://localhost:8081/api/1.0/tasks?user_id=1&status=ACTIVE&process_request_id=1&include_sub_tasks=1', + 'http://localhost:8080/api/1.0/tasks?user_id=1&status=ACTIVE&process_request_id=1&include_sub_tasks=1', responseDataTasks ); @@ -331,7 +326,7 @@ describe('Task component', () => { }; getTask( - 'http://localhost:8081/api/1.0/tasks/'+responseDataTask2['taskId']+'?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', + 'http://localhost:8080/api/1.0/tasks/'+responseDataTask2['taskId']+'?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', responseDataTask2 ); @@ -339,12 +334,7 @@ describe('Task component', () => { cy.reload(); }); - cy.socketEvent('ProcessMaker\\Events\\ProcessUpdated', { - requestId: 1, - event: 'ACTIVITY_ACTIVATED', - }); - - cy.url().should('eq', 'http://localhost:8081/tasks/2/edit'); + cy.url().should('eq', 'http://localhost:8080/tasks/2/edit'); }); /* DNAT = Display Next Assigned Task @@ -359,7 +349,7 @@ describe('Task component', () => { cy.server(); cy.route( 'GET', - 'http://localhost:8081/api/1.0/tasks/1?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', + 'http://localhost:8080/api/1.0/tasks/1?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', { id: 1, advanceStatus: 'open', @@ -372,16 +362,12 @@ describe('Task component', () => { } ); - cy.visit('/?scenario=TaskRedirect', { - onLoad(win) { - echoMock = win.Echo; - }, - }); + cy.visit('/?scenario=TaskRedirect', {}); cy.wait(2000); cy.get('.form-group').find('button').click(); - cy.route('PUT', 'http://localhost:8081/api/1.0/tasks/1').then(function() { + cy.route('PUT', 'http://localhost:8080/api/1.0/tasks/1').then(function() { let responseDataTask1 = { 'status': 'CLOSED', 'process_request_id': 1, @@ -392,7 +378,7 @@ describe('Task component', () => { }; getTask( - 'http://localhost:8081/api/1.0/tasks/'+responseDataTask1['id']+'?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', + 'http://localhost:8080/api/1.0/tasks/'+responseDataTask1['id']+'?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', responseDataTask1 ); @@ -403,7 +389,7 @@ describe('Task component', () => { }; getTasks( - 'http://localhost:8081/api/1.0/tasks?user_id=1&status=ACTIVE&process_request_id=1&include_sub_tasks=1', + 'http://localhost:8080/api/1.0/tasks?user_id=1&status=ACTIVE&process_request_id=1&include_sub_tasks=1', responseDataTasks ); @@ -417,7 +403,7 @@ describe('Task component', () => { }; getTask( - 'http://localhost:8081/api/1.0/tasks/'+responseDataTask2['taskId']+'?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', + 'http://localhost:8080/api/1.0/tasks/'+responseDataTask2['taskId']+'?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', responseDataTask2 ); @@ -425,12 +411,7 @@ describe('Task component', () => { cy.reload(); }); - cy.socketEvent('ProcessMaker\\Events\\ProcessUpdated', { - requestId: 1, - event: 'ACTIVITY_ACTIVATED', - }); - - cy.url().should('eq', 'http://localhost:8081/tasks/2/edit'); + cy.url().should('eq', 'http://localhost:8080/tasks/2/edit'); }); /* DNAT = Display Next Assigned Task @@ -444,7 +425,7 @@ describe('Task component', () => { cy.server(); cy.route( 'GET', - 'http://localhost:8081/api/1.0/tasks/1?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', + 'http://localhost:8080/api/1.0/tasks/1?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', { id: 1, advanceStatus: 'open', @@ -457,16 +438,12 @@ describe('Task component', () => { } ); - cy.visit('/?scenario=TaskRedirect', { - onLoad(win) { - echoMock = win.Echo; - }, - }); + cy.visit('/?scenario=TaskRedirect', {}); cy.wait(2000); cy.get('.form-group').find('button').click(); - cy.route('PUT', 'http://localhost:8081/api/1.0/tasks/1').then(function() { + cy.route('PUT', 'http://localhost:8080/api/1.0/tasks/1').then(function() { let responseDataTask1 = { 'status': 'CLOSED', 'process_request_id': 1, @@ -477,7 +454,7 @@ describe('Task component', () => { }; getTask( - 'http://localhost:8081/api/1.0/tasks/'+responseDataTask1['id']+'?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', + 'http://localhost:8080/api/1.0/tasks/'+responseDataTask1['id']+'?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', responseDataTask1 ); @@ -485,12 +462,7 @@ describe('Task component', () => { cy.reload(); }); - cy.socketEvent('ProcessMaker\\Events\\ProcessUpdated', { - requestId: 1, - event: 'ACTIVITY_ACTIVATED', - }); - - cy.url().should('eq', 'http://localhost:8081/tasks'); + cy.url().should('eq', 'http://localhost:8080/tasks'); }); /* DNAT = Display Next Assigned Task @@ -504,7 +476,7 @@ describe('Task component', () => { cy.server(); cy.route( 'GET', - 'http://localhost:8081/api/1.0/tasks/1?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', + 'http://localhost:8080/api/1.0/tasks/1?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', { id: 1, advanceStatus: 'open', @@ -517,16 +489,12 @@ describe('Task component', () => { } ); - cy.visit('/?scenario=TaskRedirect', { - onLoad(win) { - echoMock = win.Echo; - }, - }); + cy.visit('/?scenario=TaskRedirect', {}); cy.wait(2000); cy.get('.form-group').find('button').click(); - cy.route('PUT', 'http://localhost:8081/api/1.0/tasks/1').then(function() { + cy.route('PUT', 'http://localhost:8080/api/1.0/tasks/1').then(function() { let responseDataTask1 = { 'status': 'CLOSED', 'process_request_id': 1, @@ -537,22 +505,17 @@ describe('Task component', () => { }; getTask( - 'http://localhost:8081/api/1.0/tasks/'+responseDataTask1['id']+'?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', + 'http://localhost:8080/api/1.0/tasks/'+responseDataTask1['id']+'?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', responseDataTask1 ); - getTasks('http://localhost:8081/api/1.0/tasks?user_id=1&status=ACTIVE&process_request_id=1&include_sub_tasks=1'); + getTasks('http://localhost:8080/api/1.0/tasks?user_id=1&status=ACTIVE&process_request_id=1&include_sub_tasks=1'); cy.wait(2000); cy.reload(); }); - cy.socketEvent('ProcessMaker\\Events\\ProcessUpdated', { - requestId: 1, - event: 'ACTIVITY_ACTIVATED', - }); - - cy.url().should('eq', 'http://localhost:8081/requests/1'); + cy.url().should('eq', 'http://localhost:8080/requests/1'); }); /* DNAT = Display Next Assigned Task @@ -567,7 +530,7 @@ describe('Task component', () => { cy.server(); cy.route( 'GET', - 'http://localhost:8081/api/1.0/tasks/1?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', + 'http://localhost:8080/api/1.0/tasks/1?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', { id: 1, advanceStatus: 'open', @@ -581,16 +544,12 @@ describe('Task component', () => { } ); - cy.visit('/?scenario=TaskRedirect', { - onLoad(win) { - echoMock = win.Echo; - }, - }); + cy.visit('/?scenario=TaskRedirect', {}); cy.wait(2000); cy.get('.form-group').find('button').click(); - cy.route('PUT', 'http://localhost:8081/api/1.0/tasks/1').then(function() { + cy.route('PUT', 'http://localhost:8080/api/1.0/tasks/1').then(function() { let responseDataTask1 = { 'status': 'CLOSED', 'process_request_id': 2, @@ -602,22 +561,17 @@ describe('Task component', () => { }; getTask( - 'http://localhost:8081/api/1.0/tasks/'+responseDataTask1['id']+'?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', + 'http://localhost:8080/api/1.0/tasks/'+responseDataTask1['id']+'?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested', responseDataTask1 ); - getTasks('http://localhost:8081/api/1.0/tasks?user_id=1&status=ACTIVE&process_request_id=1&include_sub_tasks=1'); + getTasks('http://localhost:8080/api/1.0/tasks?user_id=1&status=ACTIVE&process_request_id=1&include_sub_tasks=1'); cy.wait(2000); cy.reload(); }); - cy.socketEvent('ProcessMaker\\Events\\ProcessUpdated', { - requestId: 1, - event: 'ACTIVITY_ACTIVATED', - }); - - cy.url().should('eq', 'http://localhost:8081/requests/3'); + cy.url().should('eq', 'http://localhost:8080/requests/3'); }); });