From 4417d8269abd406864153bb18c8a75a433971744 Mon Sep 17 00:00:00 2001 From: Teisha McRae Date: Thu, 12 Sep 2024 00:51:56 -0400 Subject: [PATCH 1/5] Create cypress test for ScreenTemplateSection --- tests/e2e/specs/ScreenTemplateSection.js | 86 ++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 tests/e2e/specs/ScreenTemplateSection.js diff --git a/tests/e2e/specs/ScreenTemplateSection.js b/tests/e2e/specs/ScreenTemplateSection.js new file mode 100644 index 000000000..14404586d --- /dev/null +++ b/tests/e2e/specs/ScreenTemplateSection.js @@ -0,0 +1,86 @@ +describe('Screen Template Section', () => { + it('Opens the screen template panel when Templates button is clicked', () => { + cy.visit("/"); + cy.get("[data-cy=screen-templates]").click(); + cy.get("[data-cy=screen-templates-section]").should( + "be.visible" + ); + }) +}); + +it("Closes the screen template panel when X button is clicked", () => { + cy.visit("/"); + cy.get("[data-cy=screen-templates]").click(); + cy.get("[data-cy=screen-templates-section]").should( + "be.visible" + ); + cy.get("[data-cy=close-templates-section]").click(); + cy.wait(2000); + cy.get("[data-cy=screen-templates-section]").should( + "not.exist" + ); +}); + +it("Displays My Templates when My Templates button is clicked", () => { + cy.visit("/"); + cy.get("[data-cy=screen-templates]").click(); + cy.get("[data-cy=screen-templates-section]").should( + "be.visible" + ); + cy.get("[data-cy=screen-templates]").click(); + cy.get("[data-cy=my-templates-tab]").click(); + + // CHECK REQUEST DATA FOR is_public = 0 + + cy.intercept( + "POST", + "/api/1.0/scripts/execute/1", + JSON.stringify({ + output: [ + { + value: "Jobs", + content: "Steve Jobs" + }, + { + value: "Musk", + content: "Elon Musk" + } + ] + }) + ); + +}); + +it("Displays Shared Templates when Shared Templates button is clicked", () => { + cy.visit("/"); + cy.get("[data-cy=screen-templates]").click(); + cy.get("[data-cy=screen-templates-section]").should( + "be.visible" + ); + cy.get("[data-cy=screen-templates]").click(); + cy.get("[data-cy=shared-templates-tab]").click(); + + // CHECK REQUEST DATA FOR is_public = 1 + +}); + +it("Is hidden when an Inspector Panel should open", () => { + cy.visit("/"); + + cy.get("[data-cy=screen-templates]").click(); + cy.get("[data-cy=screen-templates-section]").should( + "be.visible" + ); + + cy.setPreviewDataInput({ name: "" }); + cy.openAcordeon("collapse-1"); + cy.get("[data-cy=controls-FormInput]").drag("[data-cy=screen-drop-zone]", { + position: "bottom" + }); + cy.get("[data-cy=screen-element-container]").click(); + // cy.get("[data-cy=accordion-Advanced]").click(); + + cy.get("[data-cy=screen-templates-section]").should( + "not.exist" + ); +}); \ No newline at end of file From 61537eaa90a19d6848ebf6baf6dfb9cc013c50e7 Mon Sep 17 00:00:00 2001 From: Teisha McRae Date: Thu, 12 Sep 2024 00:52:45 -0400 Subject: [PATCH 2/5] Remove commented code --- tests/e2e/specs/ScreenTemplateSection.js | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/e2e/specs/ScreenTemplateSection.js b/tests/e2e/specs/ScreenTemplateSection.js index 14404586d..904705f52 100644 --- a/tests/e2e/specs/ScreenTemplateSection.js +++ b/tests/e2e/specs/ScreenTemplateSection.js @@ -78,7 +78,6 @@ it("Is hidden when an Inspector Panel should open", () => { position: "bottom" }); cy.get("[data-cy=screen-element-container]").click(); - // cy.get("[data-cy=accordion-Advanced]").click(); cy.get("[data-cy=screen-templates-section]").should( "not.exist" From 46827c9e79171612a5aa4d802ed0a17091a63404 Mon Sep 17 00:00:00 2001 From: Teisha McRae Date: Thu, 12 Sep 2024 00:55:02 -0400 Subject: [PATCH 3/5] Add templates button to ScreenToolbar for use when package-versions not installed Also for use in screen-builder standalone --- src/components/ScreenToolbar.vue | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/components/ScreenToolbar.vue b/src/components/ScreenToolbar.vue index a1815d844..daf8a1eb9 100644 --- a/src/components/ScreenToolbar.vue +++ b/src/components/ScreenToolbar.vue @@ -21,6 +21,15 @@ {{ $t("Redo") }} + + + {{ $t("Templates") }} + Date: Thu, 12 Sep 2024 01:51:13 -0400 Subject: [PATCH 4/5] Handle open and close of templates panel from screen-builder For cypress testing and screen-builder standalone --- src/App.vue | 15 ++++++++++++++- src/components/ScreenTemplates.vue | 28 ++++++++++++++++++++++++---- src/components/vue-form-builder.vue | 19 ++++++++++++++----- 3 files changed, 52 insertions(+), 10 deletions(-) diff --git a/src/App.vue b/src/App.vue index a2ba161e2..cab3d7dc9 100644 --- a/src/App.vue +++ b/src/App.vue @@ -52,6 +52,7 @@ @@ -443,7 +446,11 @@ export default { minimap: { enabled: false } - } + }, + showTemplatesPanel: false, + reshowTemplatesPanel: false, + myTemplatesData: null, + sharedTemplatesData: null, }; }, computed: { @@ -696,6 +703,12 @@ export default { openWatchersPopup() { this.$refs.watchersPopup.show(); }, + openTemplatesPanel() { + this.showTemplatesPanel = true; + this.reshowTemplatesPanel = true; + this.$emit('update-templates-panel', this.showTemplatesPanel); + window.ProcessMaker.EventBus.$emit("open-templates-panel"); + }, openComputedProperties() { this.$refs.computedProperties.show(); }, diff --git a/src/components/ScreenTemplates.vue b/src/components/ScreenTemplates.vue index edafafd9b..2db30a5a9 100644 --- a/src/components/ScreenTemplates.vue +++ b/src/components/ScreenTemplates.vue @@ -1,12 +1,32 @@