diff --git a/package-lock.json b/package-lock.json index c94fa7c25..13c8fbbbe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@processmaker/screen-builder", - "version": "3.0.2", + "version": "3.0.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@processmaker/screen-builder", - "version": "3.0.2", + "version": "3.0.3", "dependencies": { "@chantouchsek/validatorjs": "1.2.3", "@storybook/addon-docs": "^7.6.13", @@ -34,7 +34,7 @@ "@fortawesome/fontawesome-free": "^5.6.1", "@originjs/vite-plugin-commonjs": "^1.0.3", "@panter/vue-i18next": "^0.15.2", - "@processmaker/vue-form-elements": "0.61.0", + "@processmaker/vue-form-elements": "0.61.1", "@processmaker/vue-multiselect": "2.3.0", "@storybook/addon-essentials": "^7.6.13", "@storybook/addon-interactions": "^7.6.13", @@ -97,7 +97,7 @@ }, "peerDependencies": { "@panter/vue-i18next": "^0.15.0", - "@processmaker/vue-form-elements": "0.61.0", + "@processmaker/vue-form-elements": "0.61.1", "i18next": "^15.0.8", "vue": "^2.6.12", "vuex": "^3.1.1" @@ -4015,9 +4015,9 @@ } }, "node_modules/@processmaker/vue-form-elements": { - "version": "0.61.0", - "resolved": "https://registry.npmjs.org/@processmaker/vue-form-elements/-/vue-form-elements-0.61.0.tgz", - "integrity": "sha512-n42Xtdta08phcLdG4tEXLv3pvkAvkKKhnBXV8y0L9qEc5/3Y76WoqRYqRcesIVJhrVOX3WsY0y8IGgQirGwAFQ==", + "version": "0.61.1", + "resolved": "https://registry.npmjs.org/@processmaker/vue-form-elements/-/vue-form-elements-0.61.1.tgz", + "integrity": "sha512-GnQ77kxhkoE7xjIvikL60dC2ESwYBXkTtr2GOHDnskG2cy1HwWuU/5+SfHY6Op27YVOlvlBMlwh0QCwgPmXKmg==", "dev": true, "dependencies": { "@chantouchsek/validatorjs": "1.2.3", diff --git a/package.json b/package.json index 0518a18cd..e67805b2f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@processmaker/screen-builder", - "version": "3.0.2", + "version": "3.0.3", "scripts": { "dev": "VITE_COVERAGE=true vite", "build": "vite build", @@ -57,7 +57,7 @@ "@fortawesome/fontawesome-free": "^5.6.1", "@originjs/vite-plugin-commonjs": "^1.0.3", "@panter/vue-i18next": "^0.15.2", - "@processmaker/vue-form-elements": "0.61.0", + "@processmaker/vue-form-elements": "0.61.1", "@processmaker/vue-multiselect": "2.3.0", "@storybook/addon-essentials": "^7.6.13", "@storybook/addon-interactions": "^7.6.13", @@ -116,7 +116,7 @@ }, "peerDependencies": { "@panter/vue-i18next": "^0.15.0", - "@processmaker/vue-form-elements": "0.61.0", + "@processmaker/vue-form-elements": "0.61.1", "i18next": "^15.0.8", "vue": "^2.6.12", "vuex": "^3.1.1" diff --git a/src/components/ScreenTemplateCard.vue b/src/components/ScreenTemplateCard.vue index fe7c0df3e..d80b7ae4a 100644 --- a/src/components/ScreenTemplateCard.vue +++ b/src/components/ScreenTemplateCard.vue @@ -24,9 +24,11 @@
- {{ template.name }} + {{ + truncateText(template.name, 45) + }} {{ - truncateText(template.description, 100) + truncateText(template.description, 60) }}
diff --git a/src/components/editor/loop.vue b/src/components/editor/loop.vue index 5e6808b03..189d9444c 100644 --- a/src/components/editor/loop.vue +++ b/src/components/editor/loop.vue @@ -27,6 +27,15 @@ class="mr-2 ml-1" /> {{ element.config.name || $t("Variable Name") }} + + + {{ $t('Copied')}} +
{{ element.config.name || $t("Variable Name") }} + + + {{ $t('Copied')}} +
diff --git a/src/components/editor/multi-column.vue b/src/components/editor/multi-column.vue index 4ba98470c..26a1ed263 100644 --- a/src/components/editor/multi-column.vue +++ b/src/components/editor/multi-column.vue @@ -42,6 +42,15 @@ class="mr-2 ml-1" /> {{ element.config.name || $t("Variable Name") }} + + + {{ $t('Copied')}} +
{{ element.config.name || $t("Variable Name") }} + + + {{ $t('Copied')}} +
diff --git a/src/components/inspector/collection-data-source.vue b/src/components/inspector/collection-data-source.vue index f71176063..88bf9bd59 100644 --- a/src/components/inspector/collection-data-source.vue +++ b/src/components/inspector/collection-data-source.vue @@ -194,6 +194,9 @@ }, deep: true }, + dataSelectionOptions() { + this.singleField = null; + } }, }; diff --git a/src/components/inspector/collection-designer-mode.vue b/src/components/inspector/collection-designer-mode.vue index 881f1ffb8..cf1b7c5de 100644 --- a/src/components/inspector/collection-designer-mode.vue +++ b/src/components/inspector/collection-designer-mode.vue @@ -36,6 +36,9 @@ ], }; }, + mounted () { + this.callBuilder(this.designerOptions); + }, computed: { options() { return Object.fromEntries( @@ -56,10 +59,15 @@ options: { handler() { this.$emit("input", this.options); - this.$root.$emit("style-mode", this.options.designerOptions); + this.callBuilder(this.options.designerOptions); }, deep: true }, }, + methods: { + callBuilder(option) { + this.$root.$emit("style-mode", option); + } + } }; diff --git a/src/components/inspector/encrypted-config.vue b/src/components/inspector/encrypted-config.vue index 38264a350..c24d97059 100644 --- a/src/components/inspector/encrypted-config.vue +++ b/src/components/inspector/encrypted-config.vue @@ -13,7 +13,7 @@
this.listenRecordList(recordList, index, id)); @@ -597,6 +601,10 @@ export default { } if (displayMessage.length > 0) { + const data = JSON.parse(displayMessage); + if (data.message) { + displayMessage = data.message; + } window.ProcessMaker.alert(`${this.$t('File Upload Error:')} ${displayMessage}`, 'danger'); } @@ -699,7 +707,29 @@ export default { }, cfSkipFileUpload() { this.$emit('cf-skip-file-upload'); - } + }, + async fetchFiles() { + const fileIds = Array.isArray(this.value) ? this.value : [this.value]; + + const fetchPromises = fileIds.map(async (file) => { + const id = file?.file ?? file; + const endpoint = `files/${id}`; + try { + const response = await ProcessMaker.apiClient.get(endpoint); + if (response?.data) { + const fileExists = this.files.some(existingFile => existingFile.id === response.data.id); + // Check if the file already exists in the list before adding it. + if (!fileExists) { + this.files.push(response.data); + } + } + } catch (error) { + console.error(`Failed to fetch file ${id}`, error); + } + }); + + return await Promise.all(fetchPromises); + }, }, }; diff --git a/src/components/renderer/form-collection-record-control.vue b/src/components/renderer/form-collection-record-control.vue index a13b7d4d3..701e534df 100644 --- a/src/components/renderer/form-collection-record-control.vue +++ b/src/components/renderer/form-collection-record-control.vue @@ -16,6 +16,7 @@ + + diff --git a/tests/e2e/specs/Clipboard.spec.js b/tests/e2e/specs/Clipboard.spec.js index 50aad5b31..f1b182b4d 100644 --- a/tests/e2e/specs/Clipboard.spec.js +++ b/tests/e2e/specs/Clipboard.spec.js @@ -28,7 +28,7 @@ describe("Clipboard Button Actions", () => { // Step 4: Verify 'Remove from Clipboard' button is visible after adding to clipboard and then click it cy.get('[data-cy="removeFromClipboard"]').should("be.visible"); - cy.get('[data-cy="removeFromClipboard"]').click(); + cy.get('[data-cy="removeFromClipboard"]').click({force: true}); cy.get('[data-cy="removeFromClipboard"]').should("not.exist"); }); @@ -73,7 +73,7 @@ describe("Clipboard Button Actions", () => { // Step 5: Remove the form input from the clipboard cy.get('[data-cy="removeFromClipboard"]').should("be.visible"); - cy.get('[data-cy="removeFromClipboard"]').click(); + cy.get('[data-cy="removeFromClipboard"]').click({force: true}); cy.get('[data-cy="removeFromClipboard"]').should("not.exist"); }); @@ -102,7 +102,7 @@ describe("Clipboard Button Actions", () => { // Step 4: Remove the form input from the clipboard cy.get('[data-cy="removeFromClipboard"]').should("be.visible"); - cy.get('[data-cy="removeFromClipboard"]').click(); + cy.get('[data-cy="removeFromClipboard"]').click({force: true}); cy.get('[data-cy="removeFromClipboard"]').should("not.exist"); }); diff --git a/tests/e2e/specs/ClipboardTabClearAll.spec.js b/tests/e2e/specs/ClipboardTabClearAll.spec.js new file mode 100644 index 000000000..561d1ac0b --- /dev/null +++ b/tests/e2e/specs/ClipboardTabClearAll.spec.js @@ -0,0 +1,42 @@ +describe("Clipboard Page and Clear All Functionality", () => { + + it("should remove all controls in the clipboard page when 'Clear All' is confirmed", () => { + // Clear local storage to ensure a clean test environment + cy.clearLocalStorage(); + + // Visit the home page + cy.visit("/"); + + // Open the 'Input Fields' accordion section + cy.openAcordeonByLabel("Input Fields"); + + // Navigate to the clipboard page + cy.get("[data-test=page-dropdown]").click(); + cy.get("[data-test=clipboard]").should("exist").click({ force: true }); + + // Step 1: Dragging controls to the screen drop zone in the clipboard + cy.get("[data-cy=controls-FormInput]").drag("[data-cy=editor-content]", { position: "bottom" }); + cy.get("[data-cy=controls-FormSelectList]").drag("[data-cy=screen-element-container]", { position: "top" }); + cy.get("[data-cy=controls-FormButton]").drag("[data-cy=screen-element-container]", { position: "top" }); + cy.get("[data-cy=controls-FormTextArea]").drag("[data-cy=screen-element-container]", { position: "top" }); + cy.get("[data-cy=controls-FormDatePicker]").drag("[data-cy=screen-element-container]", { position: "top" }); + cy.get("[data-cy=controls-FormCheckbox]").drag("[data-cy=screen-element-container]", { position: "top" }); + + // Verify that all controls have been successfully added + cy.get('[data-cy="screen-element-container"]').children().should('have.length', 6); + + // Step 2: Attempt to clear all controls but cancel the action + cy.contains('button', 'Clear All').click(); + cy.contains('button', 'Cancel').click(); + + // Ensure controls are still present after canceling + cy.get('[data-cy="screen-element-container"]').children().should('have.length', 6); + + // Step 3: Confirm clearing all controls + cy.contains('button', 'Clear All').click(); + cy.contains('button', 'Confirm').click(); + + // Validate that all controls have been removed + cy.get('[data-cy="editor-content"]').children().should('have.length', 0); + }); +}); diff --git a/tests/e2e/specs/ClipboardTestCases.spec.js b/tests/e2e/specs/ClipboardTestCases.spec.js index 393d74dd3..acf27457c 100644 --- a/tests/e2e/specs/ClipboardTestCases.spec.js +++ b/tests/e2e/specs/ClipboardTestCases.spec.js @@ -61,31 +61,37 @@ describe("Clipboard Button Actions", () => { cy.get('[data-cy="addToClipboard"]').should("be.visible"); cy.get('[data-cy="addToClipboard"]').click(); cy.get('[data-cy="addToClipboard"]').should("not.exist"); + cy.get('[data-cy="copied-badge"]').should("exist"); cy.get(':nth-child(2) > [data-cy="screen-element-container"]').click({ force: true }); cy.get('[data-cy="addToClipboard"]').should("be.visible"); cy.get('[data-cy="addToClipboard"]').click(); cy.get('[data-cy="addToClipboard"]').should("not.exist"); + cy.get('[data-cy="copied-badge"]').should("exist"); cy.get(':nth-child(3) > [data-cy="screen-element-container"]').click({ force: true }); cy.get('[data-cy="addToClipboard"]').should("be.visible"); cy.get('[data-cy="addToClipboard"]').click(); cy.get('[data-cy="addToClipboard"]').should("not.exist"); + cy.get('[data-cy="copied-badge"]').should("exist"); cy.get(':nth-child(4) > [data-cy="screen-element-container"]').click({ force: true }); cy.get('[data-cy="addToClipboard"]').should("be.visible"); cy.get('[data-cy="addToClipboard"]').click(); cy.get('[data-cy="addToClipboard"]').should("not.exist"); + cy.get('[data-cy="copied-badge"]').should("exist"); cy.get(':nth-child(5) > [data-cy="screen-element-container"]').click({ force: true }); cy.get('[data-cy="addToClipboard"]').should("be.visible"); cy.get('[data-cy="addToClipboard"]').click(); cy.get('[data-cy="addToClipboard"]').should("not.exist"); + cy.get('[data-cy="copied-badge"]').should("exist"); cy.get(':nth-child(6) > [data-cy="screen-element-container"]').click({ force: true }); cy.get('[data-cy="addToClipboard"]').should("be.visible"); cy.get('[data-cy="addToClipboard"]').click(); cy.get('[data-cy="addToClipboard"]').should("not.exist"); + cy.get('[data-cy="copied-badge"]').should("exist"); cy.get("[data-test=page-dropdown").click(); cy.get("[data-test=clipboard]").should("exist").click({ force: true }); @@ -111,32 +117,37 @@ describe("Clipboard Button Actions", () => { cy.get('[data-cy="addToClipboard"]').should("be.visible"); cy.get('[data-cy="addToClipboard"]').click(); cy.get('[data-cy="addToClipboard"]').should("not.exist"); + cy.get('[data-cy="copied-badge"]').should("exist"); cy.get(':nth-child(2) > [data-cy="screen-element-container"]').click({ force: true }); cy.get('[data-cy="addToClipboard"]').should("be.visible"); cy.get('[data-cy="addToClipboard"]').click(); cy.get('[data-cy="addToClipboard"]').should("not.exist"); + cy.get('[data-cy="copied-badge"]').should("exist"); cy.get(':nth-child(3) > [data-cy="screen-element-container"]').click({ force: true }); cy.get('[data-cy="addToClipboard"]').should("be.visible"); cy.get('[data-cy="addToClipboard"]').click(); cy.get('[data-cy="addToClipboard"]').should("not.exist"); + cy.get('[data-cy="copied-badge"]').should("exist"); cy.get(':nth-child(4) > [data-cy="screen-element-container"]').click({ force: true }); cy.get('[data-cy="addToClipboard"]').should("be.visible"); cy.get('[data-cy="addToClipboard"]').click(); cy.get('[data-cy="addToClipboard"]').should("not.exist"); + cy.get('[data-cy="copied-badge"]').should("exist"); cy.get(':nth-child(5) > [data-cy="screen-element-container"]').click({ force: true }); cy.get('[data-cy="addToClipboard"]').should("be.visible"); cy.get('[data-cy="addToClipboard"]').click(); cy.get('[data-cy="addToClipboard"]').should("not.exist"); + cy.get('[data-cy="copied-badge"]').should("exist"); cy.get(':nth-child(6) > [data-cy="screen-element-container"]').click({ force: true }); cy.get('[data-cy="addToClipboard"]').should("be.visible"); cy.get('[data-cy="addToClipboard"]').click(); cy.get('[data-cy="addToClipboard"]').should("not.exist"); - + cy.get('[data-cy="copied-badge"]').should("exist"); cy.get("[data-test=page-dropdown").click(); cy.get("[data-test=clipboard]").should("exist").click({ force: true }); @@ -158,6 +169,7 @@ describe("Clipboard Button Actions", () => { cy.get('[data-cy="addToClipboard"]').should("be.visible"); cy.get('[data-cy="addToClipboard"]').click(); cy.get('[data-cy="addToClipboard"]').should("not.exist"); + cy.get('[data-cy="copied-badge"]').should("exist"); cy.get("[data-test=page-dropdown").click(); cy.get("[data-test=clipboard]").should("exist").click({ force: true }); @@ -178,11 +190,13 @@ describe("Clipboard Button Actions", () => { cy.get('[data-cy="addToClipboard"]').should("be.visible"); cy.get('[data-cy="addToClipboard"]').click(); cy.get('[data-cy="addToClipboard"]').should("not.exist"); + cy.get('[data-cy="copied-badge"]').should("exist"); cy.get(':nth-child(2) > [data-cy="screen-element-container"]').click(); cy.get('[data-cy="addToClipboard"]').should("be.visible"); cy.get('[data-cy="addToClipboard"]').click(); cy.get('[data-cy="addToClipboard"]').should("not.exist"); + cy.get('[data-cy="copied-badge"]').should("exist"); cy.get("[data-test=page-dropdown").click(); diff --git a/tests/e2e/specs/EncryptedField.spec.js b/tests/e2e/specs/EncryptedField.spec.js index 48b081539..ba0dbde8e 100644 --- a/tests/e2e/specs/EncryptedField.spec.js +++ b/tests/e2e/specs/EncryptedField.spec.js @@ -90,4 +90,44 @@ describe("Encrypted Field", () => { // After conceal the value should be the same cy.get("[data-cy=preview-content] [name=form_input_1]").should("have.value", secretValue); }); -}); \ No newline at end of file + + it("Encrypted field in preview with 'readonly' property enabled", () => { + visitAndOpenAcordeon(); + dragFormInput(); + // Enable "readonly" mode + cy.get("[data-cy=inspector-readonly]").click(); + cy.get("[data-cy=accordion-Advanced]").click(); + // Enable encrypted + cy.get("[data-cy=inspector-encryptedConfig]") + .children() + .children(".custom-control") + .each((control) => { + // forced click over the control + control.children("input").trigger("click"); + }); + // Display available users/groups + cy.get('[data-cy="inspector-encryptedConfig"] .multiselect').click(); + // Select a group + cy.get('[data-cy="inspector-encryptedConfig"] #option-2-4').click(); + // Go to preview mode + enterPreviewMode(); + // Set initial data + cy.setPreviewDataInput('{"form_input_1":"Other value"}'); + // Click in "Conceal" with data + cy.get('[data-cy=preview-content] [name=form_input_1]').siblings('button').click(); + // After conceal should be keep the "readonly" mode + cy.get("[data-cy=preview-content] [name=form_input_1]").should("have.attr", "readonly"); + // After conceal the value should be different + cy.get("[data-cy=preview-content] [name=form_input_1]").should("have.not.value", secretValue); + // The value in data should be the uuid returned + cy.assertPreviewData({ + form_input_1: uuid, + }); + // Click in "Reveal" + cy.get('[data-cy=preview-content] [name=form_input_1]').siblings('button').click(); + // After conceal should be keep the "readonly" mode + cy.get("[data-cy=preview-content] [name=form_input_1]").should("have.attr", "readonly"); + // After conceal the value should be the same + cy.get("[data-cy=preview-content] [name=form_input_1]").should("have.value", secretValue); + }); +}); diff --git a/tests/e2e/specs/EndEventRedirection.spec.js b/tests/e2e/specs/EndEventRedirection.spec.js new file mode 100644 index 000000000..bc2d9c114 --- /dev/null +++ b/tests/e2e/specs/EndEventRedirection.spec.js @@ -0,0 +1,344 @@ +import SingleScreen from "../fixtures/single_line_input.json"; + + function initializeTaskAndScreenIntercepts(method, url, response) { + cy.intercept( + method, + url.replace(",screen,", ",").replace(",nested,", ","), + response + ); + cy.intercept( + method, + url.replace(/\?.*$/, "/screen?include=screen,nested"), + response.screen + ); + } + describe("End Event Redirect (Process completed) ", () => { + it("Element destination type is summaryScreen", () => { + initializeTaskAndScreenIntercepts( + "GET", + "http://localhost:5173/api/1.1/tasks/1?include=data,user,draft,requestor,processRequest,component,screen,requestData,loopContext,bpmnTagName,interstitial,definition,nested,userRequestPermission,elementDestination", + { + id: 1, + advanceStatus: "open", + component: "task-screen", + allow_interstitial: false, + elementDestination: { + type: 'taskList', + value: 'http://localhost:5173/tasks', + }, + user: { + id: 1 + }, + screen: SingleScreen.screens[0], + process_request: { + id: 1, + status: "ACTIVE" + } + } + ); + + cy.visit("/?scenario=TaskRedirect", {}); + + cy.get(".form-group").find("button").click(); + + + cy.socketEventNext("ProcessMaker\\Events\\RedirectTo", { + params: [{ + endEventDestination: { + type:"summaryScreen", + value: null + } + }], + method: "processCompletedRedirect" + }); + cy.url().should("eq", "http://localhost:5173/requests/1"); + }); + it("Element destination type is taskList", () => { + initializeTaskAndScreenIntercepts( + "GET", + "http://localhost:5173/api/1.1/tasks/1?include=data,user,draft,requestor,processRequest,component,screen,requestData,loopContext,bpmnTagName,interstitial,definition,nested,userRequestPermission,elementDestination", + { + id: 1, + advanceStatus: "open", + component: "task-screen", + allow_interstitial: false, + elementDestination: { + type: 'taskList', + value: 'http://localhost:5173/tasks', + }, + user: { + id: 1 + }, + screen: SingleScreen.screens[0], + process_request: { + id: 1, + status: "ACTIVE" + } + } + ); + + cy.visit("/?scenario=TaskRedirect", {}); + + cy.get(".form-group").find("button").click(); + + + cy.socketEventNext("ProcessMaker\\Events\\RedirectTo", { + params: [{ + endEventDestination: { + type:"taskList", + value:"http://localhost:5173/tasks" + } + }], + method: "processCompletedRedirect" + }); + cy.url().should("eq", "http://localhost:5173/tasks"); + }); + it("Element destination type is processLaunchpad", () => { + initializeTaskAndScreenIntercepts( + "GET", + "http://localhost:5173/api/1.1/tasks/1?include=data,user,draft,requestor,processRequest,component,screen,requestData,loopContext,bpmnTagName,interstitial,definition,nested,userRequestPermission,elementDestination", + { + id: 1, + advanceStatus: "open", + component: "task-screen", + allow_interstitial: false, + elementDestination: { + type: 'taskList', + value: 'http://localhost:5173/tasks', + }, + user: { + id: 1 + }, + screen: SingleScreen.screens[0], + process_request: { + id: 1, + status: "ACTIVE" + } + } + ); + + cy.visit("/?scenario=TaskRedirect", {}); + + cy.get(".form-group").find("button").click(); + + + cy.socketEventNext("ProcessMaker\\Events\\RedirectTo", { + params: [{ + endEventDestination: { + type:"processLaunchpad", + value: "http://localhost:5173/process-browser/7?categorySelected=-1" + } + }], + method: "processCompletedRedirect" + }); + cy.url().should("eq", "http://localhost:5173/process-browser/7?categorySelected=-1"); + }); + it("Element destination type is homepageDashboard", () => { + initializeTaskAndScreenIntercepts( + "GET", + "http://localhost:5173/api/1.1/tasks/1?include=data,user,draft,requestor,processRequest,component,screen,requestData,loopContext,bpmnTagName,interstitial,definition,nested,userRequestPermission,elementDestination", + { + id: 1, + advanceStatus: "open", + component: "task-screen", + allow_interstitial: false, + elementDestination: { + type: 'homepageDashboard', + value: 'http://localhost:5173/tasks', + }, + user: { + id: 1 + }, + screen: SingleScreen.screens[0], + process_request: { + id: 1, + status: "ACTIVE" + } + } + ); + + cy.visit("/?scenario=TaskRedirect", {}); + + cy.get(".form-group").find("button").click(); + + + cy.socketEventNext("ProcessMaker\\Events\\RedirectTo", { + params: [{ + endEventDestination: { + type: "homepageDashboard", + value: "http://localhost:5173/home/customize-ui/dashboards/eHEXsFrIwmClHoTRnMvOdMKSPbR3HalSFxaIHYxNh67UrtloUiuDBh5N8NrMoQVP" + } + }], + method: "processCompletedRedirect" + }); + cy.url().should("eq", "http://localhost:5173/home/customize-ui/dashboards/eHEXsFrIwmClHoTRnMvOdMKSPbR3HalSFxaIHYxNh67UrtloUiuDBh5N8NrMoQVP"); + }); + it("Element destination type is customDashboard", () => { + initializeTaskAndScreenIntercepts( + "GET", + "http://localhost:5173/api/1.1/tasks/1?include=data,user,draft,requestor,processRequest,component,screen,requestData,loopContext,bpmnTagName,interstitial,definition,nested,userRequestPermission,elementDestination", + { + id: 1, + advanceStatus: "open", + component: "task-screen", + allow_interstitial: false, + elementDestination: { + type: 'homepageDashboard', + value: 'http://localhost:5173/tasks', + }, + user: { + id: 1 + }, + screen: SingleScreen.screens[0], + process_request: { + id: 1, + status: "ACTIVE" + } + } + ); + + cy.visit("/?scenario=TaskRedirect", {}); + + cy.get(".form-group").find("button").click(); + + + cy.socketEventNext("ProcessMaker\\Events\\RedirectTo", { + params: [{ + endEventDestination: { + type: "customDashboard", + value: "http://localhost:5173/home/customize-ui/dashboards/eHEXsFrIwmClHoTRnMvOdMKSPbR3HalSFxaIHYxNh67UrtloUiuDBh5N8NrMoQVP" + } + }], + method: "processCompletedRedirect" + }); + cy.url().should("eq", "http://localhost:5173/home/customize-ui/dashboards/eHEXsFrIwmClHoTRnMvOdMKSPbR3HalSFxaIHYxNh67UrtloUiuDBh5N8NrMoQVP"); + }); + it("Element destination type is externalURL", () => { + initializeTaskAndScreenIntercepts( + "GET", + "http://localhost:5173/api/1.1/tasks/1?include=data,user,draft,requestor,processRequest,component,screen,requestData,loopContext,bpmnTagName,interstitial,definition,nested,userRequestPermission,elementDestination", + { + id: 1, + advanceStatus: "open", + component: "task-screen", + allow_interstitial: false, + elementDestination: { + type: 'homepageDashboard', + value: 'http://localhost:5173/tasks', + }, + user: { + id: 1 + }, + screen: SingleScreen.screens[0], + process_request: { + id: 1, + status: "ACTIVE" + } + } + ); + + cy.visit("/?scenario=TaskRedirect", {}); + + cy.get(".form-group").find("button").click(); + + + cy.socketEventNext("ProcessMaker\\Events\\RedirectTo", { + params: [{ + endEventDestination: { + type: "externalURL", + value: "http://localhost:5173/about" + } + }], + method: "processCompletedRedirect" + }); + cy.url().should("eq", "http://localhost:5173/about"); + }); + it("Element destination type is anotherProcess", () => { + initializeTaskAndScreenIntercepts( + "GET", + "http://localhost:5173/api/1.1/tasks/1?include=data,user,draft,requestor,processRequest,component,screen,requestData,loopContext,bpmnTagName,interstitial,definition,nested,userRequestPermission,elementDestination", + { + id: 1, + advanceStatus: "open", + component: "task-screen", + allow_interstitial: false, + elementDestination: { + type: 'homepageDashboard', + value: 'http://localhost:5173/tasks', + }, + user: { + id: 1 + }, + screen: SingleScreen.screens[0], + process_request: { + id: 1, + status: "ACTIVE" + } + } + ); + cy.intercept( + "POST", + "http://localhost:5173/api/1.0/process_events/4?event=node_1", + {} + ); + cy.intercept( + "GET", + "http://localhost:5173/api/1.1/tasks?user_id=1&process_request_id=undefined&page=1&per_page=1&status=ACTIVE", + { + "data": [ + { + "id": 585, + "uuid": "9ce21eaf-0991-495c-9f11-2e47b409acd5", + "user_id": 1, + "process_id": 7, + "process_request_id": 194, + "subprocess_request_id": null, + "element_id": "node_117", + "element_type": "task", + "element_name": "Form Task 222", + "status": "ACTIVE", + "element_index": 0, + "subprocess_start_event_id": null, + "completed_at": null, + "due_at": "2024-09-01T16:45:13+00:00", + "due_notified": 0, + "initiated_at": null, + "riskchanges_at": "2024-08-31T18:45:13+00:00", + "created_at": "2024-08-29T16:45:13+00:00", + "updated_at": "2024-08-29T16:45:13+00:00", + "version_id": 63, + "version_type": "ProcessMaker\\Models\\ScreenVersion", + "is_self_service": 0, + "self_service_groups": [], + "token_properties": [], + "is_priority": false, + "is_actionbyemail": false, + "user_viewed_at": null, + "advanceStatus": "open", + "draft": null, + "assignable_users": [ + 3 + ], + "can_view_parent_request": false, + } + ] + } + ); + cy.visit("/?scenario=TaskRedirect", {}); + + cy.get(".form-group").find("button").click(); + + + cy.socketEventNext("ProcessMaker\\Events\\RedirectTo", { + params: [{ + endEventDestination: { + type: "anotherProcess", + value: '{"calledElement":"ProcessId-4","processId":4,"startEvent":"node_1","name":"subprocess"}' + } + }], + method: "processCompletedRedirect" + }); + cy.wait(1000); + cy.url().should("eq", "http://localhost:5173/tasks/585/edit"); + }); + }); \ No newline at end of file diff --git a/tests/e2e/specs/InterstitialRedirect.spec.js b/tests/e2e/specs/InterstitialRedirect.spec.js new file mode 100644 index 000000000..9e7c8d658 --- /dev/null +++ b/tests/e2e/specs/InterstitialRedirect.spec.js @@ -0,0 +1,374 @@ +import SingleScreen from "../fixtures/single_line_input.json"; + + function initializeTaskAndScreenIntercepts(method, url, response) { + cy.intercept( + method, + url.replace(",screen,", ",").replace(",nested,", ","), + response + ); + cy.intercept( + method, + url.replace(/\?.*$/, "/screen?include=screen,nested"), + response.screen + ); + } + describe("Interstitial", () => { + it("Load interstitial screen", () => { + initializeTaskAndScreenIntercepts( + "GET", + "http://localhost:5173/api/1.1/tasks/1?include=data,user,draft,requestor,processRequest,component,screen,requestData,loopContext,bpmnTagName,interstitial,definition,nested,userRequestPermission,elementDestination", + { + "advanceStatus": "open", + "id": 667, + "element_name": "Form Task 11", + "element_id": "node_92", + "element_type": "task", + "status": "ACTIVE", + "due_at": "2024-09-02T16:12:01.000000Z", + "process_request_id": 219, + "is_self_service": 0, + + "user": { + "id": 1, + "firstname": "Admin", + "lastname": "User", + "email": "admin@processmaker.com", + "username": "admin", + "avatar": "", + "fullname": "Admin User" + }, + "requestor": { + "id": 1, + "uuid": "9cd28c78-f74c-4731-b0e5-aa5e49df3f7e", + "email": "admin@processmaker.com", + "firstname": "Admin", + "lastname": "User", + "username": "admin", + "status": "ACTIVE", + "address": null, + "city": null, + "state": null, + "postal": null, + "country": null, + "phone": null, + "fax": null, + "cell": null, + "title": null, + "birthdate": null, + "timezone": "America\/Los_Angeles", + "datetime_format": "m\/d\/Y H:i", + "language": "en", + "meta": { + }, + "connected_accounts": null, + "is_administrator": true, + "is_system": 0, + "expires_at": null, + "loggedin_at": "2024-08-30T14:01:18+00:00", + "active_at": "2024-08-30T16:12:13+00:00", + "remember_token": null, + "created_at": "2024-08-21T22:58:58+00:00", + "updated_at": "2024-08-23T15:06:58+00:00", + "deleted_at": null, + "delegation_user_id": null, + "manager_id": null, + "schedule": null, + "force_change_password": 0, + "avatar": "", + "password_changed_at": null, + "preferences_2fa": null, + "fullname": "Admin User" + }, + "process_request": { + "id": 219, + "uuid": "9ce415cb-08cd-49c9-aff5-b97fb8362346", + "process_id": 7, + "user_id": 1, + "parent_request_id": null, + "status": "ACTIVE", + "do_not_sanitize": [ + "interstitial_message", + " _user.fullname " + ], + "errors": null, + "completed_at": null, + "initiated_at": "2024-08-30T16:12:01+00:00", + "created_at": "2024-08-30T16:12:01+00:00", + "updated_at": "2024-08-30T16:12:01+00:00", + "case_title": "Case #207", + "case_number": 207, + "callable_id": "ProcessId", + "process_version_id": 143 + }, + "draft": null, + "component": "task-screen", + + "loop_context": "", + "definition": { + "outgoing": {}, + "incoming": {}, + "id": "node_92", + "name": "Form Task 11", + "screenRef": "33", + "allowInterstitial": "true", + "interstitialScreenRef": "22", + "assignment": "requester", + "assignmentLock": "false", + "allowReassignment": "false", + "config": "{\"web_entry\":null}", + "elementDestination": "{\"type\":\"taskSource\",\"value\":null}" + }, + "bpmn_tag_name": "task", + "allow_interstitial": true, + "interstitial_screen": { + "id": 22, + "uuid": "9ca9bc5c-468e-4a11-8bb9-30a29494833d", + "screen_category_id": "1", + "title": "IDA - Dynamic Message - Interstitial Screen 7", + "description": "IDA - Dynamic Message - Interstitial Screen", + "type": "DISPLAY", + "config": [ + { + "name": "Retrieving Invoices - Interstitial Screen", + "items": [ + { + "items": [ + [], + [ + { + "label": "Image", + "config": { + "icon": "fas fa-image", + "name": "Interstitial", + "event": "submit", + "label": "Image", + "value": null, + "width": "297.21", + "height": "220.61", + "variant": "primary", + "renderImage": false, + "customCssSelector": "imgInterstitial" + }, + "component": "FormImage", + "editor-control": "FormImage", + "editor-component": "FormImage" + }, + { + "label": "Rich Text", + "config": { + "icon": "fas fa-pencil-ruler", + "label": null, + "content": "

{{interstitial_title}}<\/h3>", + "interactive": true, + "renderVarHtml": false, + "conditionalHide": null + }, + "component": "FormHtmlViewer", + "editor-control": "FormHtmlEditor", + "editor-component": "FormHtmlEditor" + }, + { + "label": "Rich Text", + "config": { + "icon": "fas fa-pencil-ruler", + "label": null, + "content": "

{{interstitial_message}}<\/h5>", + "interactive": true, + "renderVarHtml": true, + "customCssSelector": null + }, + "component": "FormHtmlViewer", + "editor-control": "FormHtmlEditor", + "editor-component": "FormHtmlEditor" + } + ], + [] + ], + "label": "Multicolumn \/ Table", + "config": { + "icon": "fas fa-table", + "label": null, + "options": [ + { + "value": "1", + "content": "2" + }, + { + "value": "2", + "content": "8" + }, + { + "value": "3", + "content": "2" + } + ], + "customCssSelector": "fullbox" + }, + "component": "FormMultiColumn", + "container": true, + "editor-control": "FormMultiColumn", + "editor-component": "MultiColumn" + } + ], + "order": 1 + } + ], + "computed": [ + { + "id": 5, + "name": "interstitial_title", + "type": "javascript", + "formula": "if(this.interstitial_title == null){\r\n return \"We're getting the next task for you...\";\r\n}", + "property": "interstitial_title" + } + ], + "custom_css": "[selector='imgInterstitial']{\r\n text-align: center;\r\n padding-top: 10px;\r\n padding-bottom: 30px;\r\n}\r\n[selector='fullbox']{\r\n padding: 50px 10px 50px 10px;\r\n}\r\n[selector='text']{\r\n max-width: 430px; \r\n text-align: center;\r\n}", + "created_at": "2024-07-08T15:23:18+00:00", + "updated_at": "2024-08-21T22:59:40+00:00", + "status": "ACTIVE", + "key": null, + "watchers": [], + "translations": null, + "is_template": 0, + "asset_type": null, + "projects": "[]" + }, + "user_request_permission": [ + { + "process_request_id": 219, + "allowed": true + } + ], + "elementDestination": { + "type": "taskSource", + "value": "taskSource" + } + } + ); + initializeTaskAndScreenIntercepts( + "GET", + "http://localhost:5173/api/1.1/tasks/1/screen?include=screen,nested", + { + "id": 63, + "screen_id": 33, + "screen_category_id": 1, + "draft": 0, + "title": "first-form", + "description": "test", + "type": "FORM", + "config": [ + { + "name": "first-form", + "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", + "editor-control": "FormInput", + "editor-component": "FormInput" + }, + { + "label": "Submit Button", + "config": { + "icon": "fas fa-share-square", + "name": null, + "event": "submit", + "label": "New Submit", + "loading": false, + "tooltip": [], + "variant": "primary", + "fieldValue": null, + "loadingLabel": "Loading...", + "defaultSubmit": true + }, + "component": "FormButton", + "editor-control": "FormSubmit", + "editor-component": "FormButton" + } + ], + "order": 1 + } + ], + "computed": [], + "custom_css": null, + "created_at": "2024-08-22 15:00:04", + "updated_at": "2024-08-22 15:00:04", + "status": "ACTIVE", + "key": null, + "watchers": [], + "translations": null, + "is_template": 0, + "asset_type": null, + "nested": [] + } + ); + cy.visit("/?scenario=TaskRedirect", {}); + + cy.get(".form-group").find("button").click(); + initializeTaskAndScreenIntercepts( + "GET", + "http://localhost:5173/api/1.1/tasks/2?include=data,user,draft,requestor,processRequest,component,requestData,loopContext,bpmnTagName,interstitial,definition,userRequestPermission,elementDestination", + { + "data": [ + { + "id": 585, + "uuid": "9ce21eaf-0991-495c-9f11-2e47b409acd5", + "user_id": 1, + "process_id": 7, + "process_request_id": 194, + "subprocess_request_id": null, + "element_id": "node_117", + "element_type": "task", + "element_name": "Form Task 222", + "status": "ACTIVE", + "element_index": 0, + "subprocess_start_event_id": null, + "completed_at": null, + "due_at": "2024-09-01T16:45:13+00:00", + "due_notified": 0, + "initiated_at": null, + "riskchanges_at": "2024-08-31T18:45:13+00:00", + "created_at": "2024-08-29T16:45:13+00:00", + "updated_at": "2024-08-29T16:45:13+00:00", + "version_id": 63, + "version_type": "ProcessMaker\\Models\\ScreenVersion", + "is_self_service": 0, + "self_service_groups": [], + "token_properties": [], + "is_priority": false, + "is_actionbyemail": false, + "user_viewed_at": null, + "advanceStatus": "open", + "draft": null, + "assignable_users": [ + 3 + ], + "can_view_parent_request": false, + } + ] + } + ); + + + + + cy.socketEventNext("ProcessMaker\\Events\\RedirectTo", { + params: [{ + nodeId: 'node_2', + tokenId: 2, + userId: 1, + }], + method: "redirectToTask" + }); + cy.get("[data-cy=screen-field-Interstitial").should('exist') + }); + }); \ No newline at end of file diff --git a/tests/e2e/specs/TaskRedirect.spec.js b/tests/e2e/specs/TaskRedirect.spec.js new file mode 100644 index 000000000..7821e4329 --- /dev/null +++ b/tests/e2e/specs/TaskRedirect.spec.js @@ -0,0 +1,832 @@ + +import SingleScreen from "../fixtures/single_line_input.json"; + +function initializeTaskAndScreenIntercepts(method, url, response) { + cy.intercept( + method, + url.replace(",screen,", ",").replace(",nested,", ","), + response + ); + cy.intercept( + method, + url.replace(/\?.*$/, "/screen?include=screen,nested"), + response.screen + ); +} +describe("On Task Completed (Submitting Task) ", () => { + it("Element destination type is taskList", () => { + initializeTaskAndScreenIntercepts( + "GET", + "http://localhost:5173/api/1.1/tasks/1?include=data,user,draft,requestor,processRequest,component,screen,requestData,loopContext,bpmnTagName,interstitial,definition,nested,userRequestPermission,elementDestination", + { + id: 1, + advanceStatus: "open", + component: "task-screen", + allow_interstitial: false, + elementDestination: { + type: 'taskList', + value: 'http://localhost:5173/tasks', + }, + user: { + id: 1 + }, + screen: SingleScreen.screens[0], + process_request: { + id: 1, + status: "ACTIVE" + } + } + ); + + cy.visit("/?scenario=TaskRedirect", {}); + + cy.get(".form-group").find("button").click(); + + + cy.socketEventNext("ProcessMaker\\Events\\RedirectTo", { + params: [{ + nodeId: 'node_2', + tokenId: 2, + userId: 1, + }], + method: "redirectToTask" + }); + cy.url().should("eq", "http://localhost:5173/tasks"); + }); + it("Element destination type is processLaunchpad", () => { + initializeTaskAndScreenIntercepts( + "GET", + "http://localhost:5173/api/1.1/tasks/1?include=data,user,draft,requestor,processRequest,component,screen,requestData,loopContext,bpmnTagName,interstitial,definition,nested,userRequestPermission,elementDestination", + { + id: 1, + advanceStatus: "open", + component: "task-screen", + allow_interstitial: false, + elementDestination: { + type: 'processLaunchpad', + value: "http://localhost:5173/process-browser/7?categorySelected=-1", + }, + user: { + id: 1 + }, + screen: SingleScreen.screens[0], + process_request: { + id: 1, + status: "ACTIVE" + } + } + ); + + cy.visit("/?scenario=TaskRedirect", {}); + + cy.get(".form-group").find("button").click(); + + cy.socketEventNext("ProcessMaker\\Events\\RedirectTo", { + params: [{ + nodeId: 'node_2', + tokenId: 2, + userId: 1, + }], + method: "redirectToTask" + }); + cy.url().should("eq", "http://localhost:5173/process-browser/7?categorySelected=-1"); + }); + it("Element destination type is homepageDashboard", () => { + initializeTaskAndScreenIntercepts( + "GET", + "http://localhost:5173/api/1.1/tasks/1?include=data,user,draft,requestor,processRequest,component,screen,requestData,loopContext,bpmnTagName,interstitial,definition,nested,userRequestPermission,elementDestination", + { + id: 1, + advanceStatus: "open", + component: "task-screen", + allow_interstitial: false, + elementDestination: { + type: 'homepageDashboard', + value: "http://localhost:5173", + }, + user: { + id: 1 + }, + screen: SingleScreen.screens[0], + process_request: { + id: 1, + status: "ACTIVE" + } + } + ); + + cy.visit("/?scenario=TaskRedirect", {}); + + cy.get(".form-group").find("button").click(); + + cy.socketEventNext("ProcessMaker\\Events\\RedirectTo", { + params: [{ + nodeId: 'node_2', + tokenId: 2, + userId: 1, + }], + method: "redirectToTask" + }); + cy.url().should("eq", "http://localhost:5173/"); + }); + it("Element destination type is customDashboard", () => { + initializeTaskAndScreenIntercepts( + "GET", + "http://localhost:5173/api/1.1/tasks/1?include=data,user,draft,requestor,processRequest,component,screen,requestData,loopContext,bpmnTagName,interstitial,definition,nested,userRequestPermission,elementDestination", + { + id: 1, + advanceStatus: "open", + component: "task-screen", + allow_interstitial: false, + elementDestination: { + type: 'customDashboard', + value: "http://localhost:5173/home/customize-ui/dashboards/eHEXsFrIwmClHoTRnMvOdMKSPbR3HalSFxaIHYxNh67UrtloUiuDBh5N8NrMoQVP", + }, + user: { + id: 1 + }, + screen: SingleScreen.screens[0], + process_request: { + id: 1, + status: "ACTIVE" + } + } + ); + + cy.visit("/?scenario=TaskRedirect", {}); + + cy.get(".form-group").find("button").click(); + + cy.socketEventNext("ProcessMaker\\Events\\RedirectTo", { + params: [{ + nodeId: 'node_2', + tokenId: 2, + userId: 1, + }], + method: "redirectToTask" + }); + cy.url().should("eq", "http://localhost:5173/home/customize-ui/dashboards/eHEXsFrIwmClHoTRnMvOdMKSPbR3HalSFxaIHYxNh67UrtloUiuDBh5N8NrMoQVP"); + }); + it("Element destination type is externalURL", () => { + initializeTaskAndScreenIntercepts( + "GET", + "http://localhost:5173/api/1.1/tasks/1?include=data,user,draft,requestor,processRequest,component,screen,requestData,loopContext,bpmnTagName,interstitial,definition,nested,userRequestPermission,elementDestination", + { + id: 1, + advanceStatus: "open", + component: "task-screen", + allow_interstitial: false, + elementDestination: { + type: 'externalURL', + value: "http://localhost:5173/about", + }, + user: { + id: 1 + }, + screen: SingleScreen.screens[0], + process_request: { + id: 1, + status: "ACTIVE" + } + } + ); + + cy.visit("/?scenario=TaskRedirect", {}); + + cy.get(".form-group").find("button").click(); + + cy.socketEventNext("ProcessMaker\\Events\\RedirectTo", { + params: [{ + nodeId: 'node_2', + tokenId: 2, + userId: 1, + }], + method: "redirectToTask" + }); + cy.url().should("eq", "http://localhost:5173/about"); + }); + it("Element destination type is taskSource case 1(redirect to task list if the next user is not assigned to the same user)" , () => { + initializeTaskAndScreenIntercepts( + "GET", + "http://localhost:5173/api/1.1/tasks/1?include=data,user,draft,requestor,processRequest,component,screen,requestData,loopContext,bpmnTagName,interstitial,definition,nested,userRequestPermission,elementDestination", + { + id: 1, + advanceStatus: "open", + component: "task-screen", + allow_interstitial: false, + elementDestination: { + type: "taskSource", + value: "taskSource", + }, + user: { + id: 1 + }, + screen: SingleScreen.screens[0], + process_request: { + id: 1, + status: "ACTIVE" + } + } + ); + initializeTaskAndScreenIntercepts( + "GET", + "http://localhost:5173/api/1.1/tasks?user_id=1&process_request_id=1&page=1&per_page=1&status=ACTIVE", + { + "data": [ + { + "id": 585, + "uuid": "9ce21eaf-0991-495c-9f11-2e47b409acd5", + "user_id": 3, + "process_id": 7, + "process_request_id": 194, + "subprocess_request_id": null, + "element_id": "node_117", + "element_type": "task", + "element_name": "Form Task 222", + "status": "ACTIVE", + "element_index": 0, + "subprocess_start_event_id": null, + "completed_at": null, + "due_at": "2024-09-01T16:45:13+00:00", + "due_notified": 0, + "initiated_at": null, + "riskchanges_at": "2024-08-31T18:45:13+00:00", + "created_at": "2024-08-29T16:45:13+00:00", + "updated_at": "2024-08-29T16:45:13+00:00", + "version_id": 63, + "version_type": "ProcessMaker\\Models\\ScreenVersion", + "is_self_service": 0, + "self_service_groups": [], + "token_properties": [], + "is_priority": false, + "is_actionbyemail": false, + "user_viewed_at": null, + "advanceStatus": "open", + "process_request": { + "id": 194, + "uuid": "9ce21e35-087d-45dd-b1ed-f2874307e293", + "process_id": 7, + "process_collaboration_id": null, + "collaboration_uuid": null, + "user_id": 1, + "parent_request_id": null, + "participant_id": null, + "callable_id": "ProcessId", + "status": "ACTIVE", + "name": "processTL", + "do_not_sanitize": [], + "errors": null, + "completed_at": null, + "initiated_at": "2024-08-29T16:43:53+00:00", + "created_at": "2024-08-29T16:43:53+00:00", + "updated_at": "2024-08-29T16:45:13+00:00", + "process_version_id": 129, + "signal_events": [], + "case_title": "Case #182", + "case_number": 182, + "case_title_formatted": "Case #182<\/b>", + "process": { + "id": 7, + "uuid": "9cdc0e74-0e60-4a33-a6e6-71c96b6b7330", + "process_category_id": "2", + "user_id": 1, + "description": "test", + "name": "processTL", + "cancel_screen_id": null, + "request_detail_screen_id": null, + "status": "ACTIVE", + "is_valid": 1, + "package_key": null, + "pause_timer_start": 0, + "deleted_at": null, + "created_at": "2024-08-26T16:24:52+00:00", + "updated_at": "2024-08-29T16:43:37+00:00", + "updated_by": 1, + "start_events": [ + { + "id": "node_91", + "name": "Start Event", + "config": "{\"web_entry\":null}", + "ownerProcessId": "ProcessId", + "eventDefinitions": [], + "ownerProcessName": "ProcessName", + "allowInterstitial": "false", + "interstitialScreenRef": "1" + } + ], + "self_service_tasks": [], + "signal_events": [], + "conditional_events": [], + "properties": { + "manager_id": "undefined" + }, + "is_template": 0, + "case_title": null, + "launchpad_properties": null, + "asset_type": null, + "alternative": "A", + "has_timer_start_events": false, + "projects": "[]" + } + }, + "process": { + "id": 7, + "uuid": "9cdc0e74-0e60-4a33-a6e6-71c96b6b7330", + "process_category_id": "2", + "user_id": 1, + "description": "test", + "name": "processTL", + "cancel_screen_id": null, + "request_detail_screen_id": null, + "status": "ACTIVE", + "is_valid": 1, + "package_key": null, + "pause_timer_start": 0, + "deleted_at": null, + "created_at": "2024-08-26T16:24:52+00:00", + "updated_at": "2024-08-29T16:43:37+00:00", + "updated_by": 1, + "start_events": [ + { + "id": "node_91", + "name": "Start Event", + "config": "{\"web_entry\":null}", + "ownerProcessId": "ProcessId", + "eventDefinitions": [], + "ownerProcessName": "ProcessName", + "allowInterstitial": "false", + "interstitialScreenRef": "1" + } + ], + "self_service_tasks": [], + "signal_events": [], + "conditional_events": [], + "properties": { + "manager_id": "undefined" + }, + "is_template": 0, + "case_title": null, + "launchpad_properties": null, + "asset_type": null, + "alternative": "A", + "has_timer_start_events": false, + "projects": "[]" + }, + "user": { + "id": 3, + "uuid": "9cdee13e-7aff-4d09-9322-0257e4a4996f", + "email": "homero@simpsom.com", + "firstname": "homero", + "lastname": "simpsom", + "username": "homero", + "status": "ACTIVE", + "address": null, + "city": null, + "state": null, + "postal": null, + "country": null, + "phone": null, + "fax": null, + "cell": null, + "title": "none", + "birthdate": null, + "timezone": "UTC", + "datetime_format": "m\/d\/Y H:i", + "language": "en", + "meta": null, + "connected_accounts": null, + "is_administrator": true, + "is_system": 0, + "expires_at": null, + "loggedin_at": "2024-08-28T02:09:33+00:00", + "active_at": "2024-08-28T02:25:55+00:00", + "remember_token": null, + "created_at": "2024-08-28T02:05:56+00:00", + "updated_at": "2024-08-28T02:06:05+00:00", + "deleted_at": null, + "delegation_user_id": null, + "manager_id": null, + "schedule": null, + "force_change_password": 0, + "avatar": null, + "password_changed_at": "2024-08-28 02:05:56", + "preferences_2fa": null, + "fullname": "homero simpsom" + }, + "draft": null, + "assignable_users": [ + 3 + ], + "can_view_parent_request": false + } + ], + "meta": { + "filter": "", + "sort_by": "due_at", + "sort_order": "asc", + "count": 1, + "total_pages": 1, + "in_overdue": 0, + "current_page": 1, + "from": 1, + "last_page": 1, + "links": [ + { + "url": null, + "label": "« Previous", + "active": false + }, + { + "url": "http:\/\/processmaker.test\/api\/1.0\/tasks?page=1", + "label": "1", + "active": true + }, + { + "url": null, + "label": "Next »", + "active": false + } + ], + "path": "http:\/\/processmaker.test\/api\/1.0\/tasks", + "per_page": 15, + "to": 1, + "total": 1 + } +} + ); + + + cy.visit("/?scenario=TaskRedirect", { + onBeforeLoad: function (window) { + sessionStorage.removeItem('sessionUrlSelfService'); + } + }); + cy.get(".form-group").find("button").click(); + + cy.socketEventNext("ProcessMaker\\Events\\RedirectTo", { + params: [{ + nodeId: 'node_2', + tokenId: 2, + userId: 2, + }], + method: "redirectToTask" + }); + cy.url().should("eq", "http://localhost:5173/tasks"); + }); + it("Element destination type is taskSource case 2(redirect to previous page if the next task is not assigned to the same user)" , () => { + initializeTaskAndScreenIntercepts( + "GET", + "http://localhost:5173/api/1.1/tasks/1?include=data,user,draft,requestor,processRequest,component,screen,requestData,loopContext,bpmnTagName,interstitial,definition,nested,userRequestPermission,elementDestination", + { + id: 1, + advanceStatus: "open", + component: "task-screen", + allow_interstitial: false, + elementDestination: { + type: "taskSource", + value: "taskSource", + }, + user: { + id: 1 + }, + screen: SingleScreen.screens[0], + process_request: { + id: 1, + status: "ACTIVE" + } + } + ); + initializeTaskAndScreenIntercepts( + "GET", + "http://localhost:5173/api/1.1/tasks?user_id=1&process_request_id=1&page=1&per_page=1&status=ACTIVE", + { + "data": [ + { + "id": 585, + "uuid": "9ce21eaf-0991-495c-9f11-2e47b409acd5", + "user_id": 3, + "process_id": 7, + "process_request_id": 194, + "subprocess_request_id": null, + "element_id": "node_117", + "element_type": "task", + "element_name": "Form Task 222", + "status": "ACTIVE", + "element_index": 0, + "subprocess_start_event_id": null, + "completed_at": null, + "due_at": "2024-09-01T16:45:13+00:00", + "due_notified": 0, + "initiated_at": null, + "riskchanges_at": "2024-08-31T18:45:13+00:00", + "created_at": "2024-08-29T16:45:13+00:00", + "updated_at": "2024-08-29T16:45:13+00:00", + "version_id": 63, + "version_type": "ProcessMaker\\Models\\ScreenVersion", + "is_self_service": 0, + "self_service_groups": [], + "token_properties": [], + "is_priority": false, + "is_actionbyemail": false, + "user_viewed_at": null, + "advanceStatus": "open", + "process_request": { + "id": 194, + "uuid": "9ce21e35-087d-45dd-b1ed-f2874307e293", + "process_id": 7, + "process_collaboration_id": null, + "collaboration_uuid": null, + "user_id": 1, + "parent_request_id": null, + "participant_id": null, + "callable_id": "ProcessId", + "status": "ACTIVE", + "name": "processTL", + "do_not_sanitize": [], + "errors": null, + "completed_at": null, + "initiated_at": "2024-08-29T16:43:53+00:00", + "created_at": "2024-08-29T16:43:53+00:00", + "updated_at": "2024-08-29T16:45:13+00:00", + "process_version_id": 129, + "signal_events": [], + "case_title": "Case #182", + "case_number": 182, + "case_title_formatted": "Case #182<\/b>", + "process": { + "id": 7, + "uuid": "9cdc0e74-0e60-4a33-a6e6-71c96b6b7330", + "process_category_id": "2", + "user_id": 1, + "description": "test", + "name": "processTL", + "cancel_screen_id": null, + "request_detail_screen_id": null, + "status": "ACTIVE", + "is_valid": 1, + "package_key": null, + "pause_timer_start": 0, + "deleted_at": null, + "created_at": "2024-08-26T16:24:52+00:00", + "updated_at": "2024-08-29T16:43:37+00:00", + "updated_by": 1, + "start_events": [ + { + "id": "node_91", + "name": "Start Event", + "config": "{\"web_entry\":null}", + "ownerProcessId": "ProcessId", + "eventDefinitions": [], + "ownerProcessName": "ProcessName", + "allowInterstitial": "false", + "interstitialScreenRef": "1" + } + ], + "self_service_tasks": [], + "signal_events": [], + "conditional_events": [], + "properties": { + "manager_id": "undefined" + }, + "is_template": 0, + "case_title": null, + "launchpad_properties": null, + "asset_type": null, + "alternative": "A", + "has_timer_start_events": false, + "projects": "[]" + } + }, + "process": { + "id": 7, + "uuid": "9cdc0e74-0e60-4a33-a6e6-71c96b6b7330", + "process_category_id": "2", + "user_id": 1, + "description": "test", + "name": "processTL", + "cancel_screen_id": null, + "request_detail_screen_id": null, + "status": "ACTIVE", + "is_valid": 1, + "package_key": null, + "pause_timer_start": 0, + "deleted_at": null, + "created_at": "2024-08-26T16:24:52+00:00", + "updated_at": "2024-08-29T16:43:37+00:00", + "updated_by": 1, + "start_events": [ + { + "id": "node_91", + "name": "Start Event", + "config": "{\"web_entry\":null}", + "ownerProcessId": "ProcessId", + "eventDefinitions": [], + "ownerProcessName": "ProcessName", + "allowInterstitial": "false", + "interstitialScreenRef": "1" + } + ], + "self_service_tasks": [], + "signal_events": [], + "conditional_events": [], + "properties": { + "manager_id": "undefined" + }, + "is_template": 0, + "case_title": null, + "launchpad_properties": null, + "asset_type": null, + "alternative": "A", + "has_timer_start_events": false, + "projects": "[]" + }, + "user": { + "id": 3, + "uuid": "9cdee13e-7aff-4d09-9322-0257e4a4996f", + "email": "homero@simpsom.com", + "firstname": "homero", + "lastname": "simpsom", + "username": "homero", + "status": "ACTIVE", + "address": null, + "city": null, + "state": null, + "postal": null, + "country": null, + "phone": null, + "fax": null, + "cell": null, + "title": "none", + "birthdate": null, + "timezone": "UTC", + "datetime_format": "m\/d\/Y H:i", + "language": "en", + "meta": null, + "connected_accounts": null, + "is_administrator": true, + "is_system": 0, + "expires_at": null, + "loggedin_at": "2024-08-28T02:09:33+00:00", + "active_at": "2024-08-28T02:25:55+00:00", + "remember_token": null, + "created_at": "2024-08-28T02:05:56+00:00", + "updated_at": "2024-08-28T02:06:05+00:00", + "deleted_at": null, + "delegation_user_id": null, + "manager_id": null, + "schedule": null, + "force_change_password": 0, + "avatar": null, + "password_changed_at": "2024-08-28 02:05:56", + "preferences_2fa": null, + "fullname": "homero simpsom" + }, + "draft": null, + "assignable_users": [ + 3 + ], + "can_view_parent_request": false + } + ], + "meta": { + "filter": "", + "sort_by": "due_at", + "sort_order": "asc", + "count": 1, + "total_pages": 1, + "in_overdue": 0, + "current_page": 1, + "from": 1, + "last_page": 1, + "links": [ + { + "url": null, + "label": "« Previous", + "active": false + }, + { + "url": "http:\/\/processmaker.test\/api\/1.0\/tasks?page=1", + "label": "1", + "active": true + }, + { + "url": null, + "label": "Next »", + "active": false + } + ], + "path": "http:\/\/processmaker.test\/api\/1.0\/tasks", + "per_page": 15, + "to": 1, + "total": 1 + } + } + ); + + + cy.visit("/?scenario=TaskRedirect", { + onBeforeLoad: function (window) { + sessionStorage.removeItem('sessionUrlSelfService'); + sessionStorage.setItem('sessionUrlSelfService', "http://localhost:5173/about"); + } + }); + cy.get(".form-group").find("button").click(); + + cy.socketEventNext("ProcessMaker\\Events\\RedirectTo", { + params: [{ + nodeId: 'node_2', + tokenId: 2, + userId: 2, + }], + method: "redirectToTask" + }); + cy.url().should("eq", "http://localhost:5173/about"); + sessionStorage.removeItem("sessionUrlSelfService"); + }); + it("Element destination type is taskSource case 3(redirect to next task if the next task is assigned to the same user)" , () => { + initializeTaskAndScreenIntercepts( + "GET", + "http://localhost:5173/api/1.1/tasks/1?include=data,user,draft,requestor,processRequest,component,screen,requestData,loopContext,bpmnTagName,interstitial,definition,nested,userRequestPermission,elementDestination", + { + id: 1, + advanceStatus: "open", + component: "task-screen", + allow_interstitial: false, + elementDestination: { + type: "taskSource", + value: "taskSource", + }, + user: { + id: 1 + }, + screen: SingleScreen.screens[0], + process_request: { + id: 1, + status: "ACTIVE" + } + } + ); + initializeTaskAndScreenIntercepts( + "GET", + "http://localhost:5173/api/1.1/tasks/2?include=data,user,draft,requestor,processRequest,component,requestData,loopContext,bpmnTagName,interstitial,definition,userRequestPermission,elementDestination", + { + "data": [ + { + "id": 585, + "uuid": "9ce21eaf-0991-495c-9f11-2e47b409acd5", + "user_id": 1, + "process_id": 7, + "process_request_id": 194, + "subprocess_request_id": null, + "element_id": "node_117", + "element_type": "task", + "element_name": "Form Task 222", + "status": "ACTIVE", + "element_index": 0, + "subprocess_start_event_id": null, + "completed_at": null, + "due_at": "2024-09-01T16:45:13+00:00", + "due_notified": 0, + "initiated_at": null, + "riskchanges_at": "2024-08-31T18:45:13+00:00", + "created_at": "2024-08-29T16:45:13+00:00", + "updated_at": "2024-08-29T16:45:13+00:00", + "version_id": 63, + "version_type": "ProcessMaker\\Models\\ScreenVersion", + "is_self_service": 0, + "self_service_groups": [], + "token_properties": [], + "is_priority": false, + "is_actionbyemail": false, + "user_viewed_at": null, + "advanceStatus": "open", + "draft": null, + "assignable_users": [ + 3 + ], + "can_view_parent_request": false, + } + ] + } + + ); + + + cy.visit("/?scenario=TaskRedirect", { + onBeforeLoad: function (window) { + sessionStorage.removeItem('sessionUrlSelfService'); + } + }); + cy.get(".form-group").find("button").click(); + + cy.socketEventNext("ProcessMaker\\Events\\RedirectTo", { + params: [{ + nodeId: 'node_2', + tokenId: 2, + userId: 1, + }], + method: "redirectToTask" + }); + cy.url().should("eq", "http://localhost:5173/?scenario=TaskRedirect"); + }); +}); \ No newline at end of file diff --git a/tests/e2e/specs/WebEntryEndEventRedirect.spec.js b/tests/e2e/specs/WebEntryEndEventRedirect.spec.js new file mode 100644 index 000000000..52a6162de --- /dev/null +++ b/tests/e2e/specs/WebEntryEndEventRedirect.spec.js @@ -0,0 +1,56 @@ +import SingleScreen from "../fixtures/single_line_input.json"; + +function initializeTaskAndScreenIntercepts(method, url, response) { + cy.intercept(method, url.replace(",screen,", ",").replace(",nested,", ","), response).as('getTask'); + cy.intercept(method, url.replace(/\?.*$/, "/screen?include=screen,nested"), response.screen).as('getScreen'); +} + +describe("End Event Redirect (Process completed)", () => { + beforeEach(() => { + // Reset the intercepts and the state before each test + cy.visit("/?scenario=TaskWebEntry", {}); + }); + + it("Element destination type is summaryScreen and process was opened from webEntry", () => { + const taskUrl = "http://localhost:5173/api/1.1/tasks/1?include=data,user,draft,requestor,processRequest,component,screen,requestData,loopContext,bpmnTagName,interstitial,definition,nested,userRequestPermission,elementDestination"; + + initializeTaskAndScreenIntercepts("GET", taskUrl, { + id: 1, + advanceStatus: "open", + component: "task-screen", + allow_interstitial: false, + elementDestination: { + type: "taskList", + value: "http://localhost:5173/tasks", + }, + user: { + id: 1, + }, + screen: SingleScreen.screens[0], + process_request: { + id: 1, + status: "ACTIVE", + }, + }); + + // Interact with the UI + cy.get('.form-group > .btn').click(); + + // Emit socket event and verify the URL change + cy.socketEventNext("ProcessMaker\\Events\\RedirectTo", { + params: [ + { + endEventDestination: { + type: "summaryScreen", + value: null, + }, + }, + ], + method: "processCompletedRedirect", + }) + cy.wait(1000); + // This code will execute after the socket event is finished + cy.url().should("eq", "http://localhost:5173/?scenario=TaskWebEntry"); + + }); +}); diff --git a/tests/e2e/support/commands.js b/tests/e2e/support/commands.js index 48e2910cb..6a9da03a5 100644 --- a/tests/e2e/support/commands.js +++ b/tests/e2e/support/commands.js @@ -65,6 +65,11 @@ Cypress.Commands.add("socketEvent", (event, body) => { }); }); +Cypress.Commands.add("socketEventNext", (event, body) => { + cy.window().then((win) => { + win.Echo.eventMockNext(event, body); + }); +}); /** * Converts Cypress fixtures, including JSON, to a Blob. All file types are * converted to base64 then converted to a Blob using Cypress