From 7c587f02882214f41fd76ddbe210c4e2eb7a0720 Mon Sep 17 00:00:00 2001 From: NandanAnantharamu <67676905+NandanAnantharamu@users.noreply.github.com> Date: Thu, 20 May 2021 11:15:48 +0530 Subject: [PATCH] binding list widget with Api (#4229) --- .../cypress/fixtures/listwidgetdsl.json | 275 ++++++++++++++++++ .../Binding/Bind_API_with_List_Widget_spec.js | 91 ++++++ 2 files changed, 366 insertions(+) create mode 100644 app/client/cypress/fixtures/listwidgetdsl.json create mode 100644 app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Binding/Bind_API_with_List_Widget_spec.js diff --git a/app/client/cypress/fixtures/listwidgetdsl.json b/app/client/cypress/fixtures/listwidgetdsl.json new file mode 100644 index 0000000000..cd2e85fa6a --- /dev/null +++ b/app/client/cypress/fixtures/listwidgetdsl.json @@ -0,0 +1,275 @@ +{ + "dsl": { + "widgetName": "MainContainer", + "backgroundColor": "none", + "rightColumn": 966, + "snapColumns": 16, + "detachFromLayout": true, + "widgetId": "0", + "topRow": 0, + "bottomRow": 800, + "containerStyle": "none", + "snapRows": 33, + "parentRowSpace": 1, + "type": "CANVAS_WIDGET", + "canExtend": true, + "version": 18, + "minHeight": 240, + "parentColumnSpace": 1, + "dynamicTriggerPathList": [], + "dynamicBindingPathList": [], + "leftColumn": 0, + "children": [ + { + "isVisible": true, + "backgroundColor": "", + "itemBackgroundColor": "white", + "gridType": "vertical", + "enhancements": true, + "gridGap": 0, + "items": "", + "widgetName": "List1", + "children": [ + { + "isVisible": true, + "widgetName": "Canvas1", + "version": 1, + "containerStyle": "none", + "canExtend": false, + "detachFromLayout": true, + "dropDisabled": true, + "noPad": true, + "children": [ + { + "isVisible": true, + "backgroundColor": "white", + "widgetName": "Container1", + "containerStyle": "card", + "children": [ + { + "isVisible": true, + "widgetName": "Canvas2", + "version": 1, + "containerStyle": "none", + "canExtend": false, + "detachFromLayout": true, + "children": [ + { + "isVisible": true, + "defaultImage": "https://res.cloudinary.com/drako999/image/upload/v1589196259/default.png", + "imageShape": "RECTANGLE", + "maxZoomLevel": 1, + "image": "{{currentItem.img}}", + "widgetName": "Image1", + "version": 1, + "dynamicBindingPathList": [ + { + "key": "image" + } + ], + "dynamicTriggerPathList": [], + "type": "IMAGE_WIDGET", + "isLoading": false, + "leftColumn": 0, + "rightColumn": 4, + "topRow": 0, + "bottomRow": 3, + "parentId": "muh6tmsm1f", + "widgetId": "vr29m4code" + }, + { + "isVisible": true, + "text": "{{currentItem.name}}", + "fontSize": "PARAGRAPH", + "fontStyle": "BOLD", + "textAlign": "LEFT", + "textColor": "#231F20", + "widgetName": "Text1", + "version": 1, + "textStyle": "HEADING", + "dynamicBindingPathList": [ + { + "key": "text" + } + ], + "dynamicTriggerPathList": [], + "type": "TEXT_WIDGET", + "isLoading": false, + "leftColumn": 4, + "rightColumn": 10, + "topRow": 0, + "bottomRow": 1, + "parentId": "muh6tmsm1f", + "widgetId": "envgv9f2j9" + }, + { + "isVisible": true, + "text": "{{currentItem.num}}", + "fontSize": "PARAGRAPH", + "fontStyle": "BOLD", + "textAlign": "LEFT", + "textColor": "#231F20", + "widgetName": "Text2", + "version": 1, + "textStyle": "BODY", + "dynamicBindingPathList": [ + { + "key": "text" + } + ], + "dynamicTriggerPathList": [], + "type": "TEXT_WIDGET", + "isLoading": false, + "leftColumn": 4, + "rightColumn": 10, + "topRow": 1, + "bottomRow": 2, + "parentId": "muh6tmsm1f", + "widgetId": "37xbmi0bbz" + } + ], + "minHeight": null, + "type": "CANVAS_WIDGET", + "isLoading": false, + "parentColumnSpace": 1, + "parentRowSpace": 1, + "leftColumn": 0, + "rightColumn": null, + "topRow": 0, + "bottomRow": null, + "parentId": "5q9jzp3d17", + "widgetId": "muh6tmsm1f" + } + ], + "version": 1, + "dragDisabled": true, + "isDeletable": false, + "disallowCopy": true, + "disablePropertyPane": true, + "type": "CONTAINER_WIDGET", + "isLoading": false, + "leftColumn": 0, + "rightColumn": 16, + "topRow": 0, + "bottomRow": 4, + "parentId": "qt3cziyljx", + "widgetId": "5q9jzp3d17" + } + ], + "minHeight": 400, + "type": "CANVAS_WIDGET", + "isLoading": false, + "parentColumnSpace": 1, + "parentRowSpace": 1, + "leftColumn": 0, + "rightColumn": 463, + "topRow": 0, + "bottomRow": 400, + "parentId": "wmuvmnfqm0", + "widgetId": "qt3cziyljx" + } + ], + "type": "LIST_WIDGET", + "isLoading": false, + "parentColumnSpace": 57.875, + "parentRowSpace": 40, + "leftColumn": 4, + "rightColumn": 12, + "topRow": 8, + "bottomRow": 18, + "parentId": "0", + "widgetId": "wmuvmnfqm0", + "dynamicBindingPathList": [ + { + "key": "template.Image1.image" + }, + { + "key": "template.Text1.text" + }, + { + "key": "template.Text2.text" + } + ], + "template": { + "Image1": { + "isVisible": true, + "defaultImage": "https://res.cloudinary.com/drako999/image/upload/v1589196259/default.png", + "imageShape": "RECTANGLE", + "maxZoomLevel": 1, + "image": "{{List1.items.map((currentItem) => currentItem.img)}}", + "widgetName": "Image1", + "version": 1, + "dynamicBindingPathList": [ + { + "key": "image" + } + ], + "dynamicTriggerPathList": [], + "type": "IMAGE_WIDGET", + "isLoading": false, + "leftColumn": 0, + "rightColumn": 4, + "topRow": 0, + "bottomRow": 3, + "parentId": "muh6tmsm1f", + "widgetId": "vr29m4code" + }, + "Text1": { + "isVisible": true, + "text": "{{List1.items.map((currentItem) => currentItem.name)}}", + "fontSize": "PARAGRAPH", + "fontStyle": "BOLD", + "textAlign": "LEFT", + "textColor": "#231F20", + "widgetName": "Text1", + "version": 1, + "textStyle": "HEADING", + "dynamicBindingPathList": [ + { + "key": "text" + } + ], + "dynamicTriggerPathList": [], + "type": "TEXT_WIDGET", + "isLoading": false, + "leftColumn": 4, + "rightColumn": 10, + "topRow": 0, + "bottomRow": 1, + "parentId": "muh6tmsm1f", + "widgetId": "envgv9f2j9" + }, + "Text2": { + "isVisible": true, + "text": "{{List1.items.map((currentItem) => currentItem.num)}}", + "fontSize": "PARAGRAPH", + "fontStyle": "BOLD", + "textAlign": "LEFT", + "textColor": "#231F20", + "widgetName": "Text2", + "version": 1, + "textStyle": "BODY", + "dynamicBindingPathList": [ + { + "key": "text" + } + ], + "dynamicTriggerPathList": [], + "type": "TEXT_WIDGET", + "isLoading": false, + "leftColumn": 4, + "rightColumn": 10, + "topRow": 1, + "bottomRow": 2, + "parentId": "muh6tmsm1f", + "widgetId": "37xbmi0bbz" + } + }, + "childAutoComplete": { + "currentItem": {} + }, + "dynamicTriggerPathList": [] + } + ] + } +} \ No newline at end of file diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Binding/Bind_API_with_List_Widget_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Binding/Bind_API_with_List_Widget_spec.js new file mode 100644 index 0000000000..e29f52dae6 --- /dev/null +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Binding/Bind_API_with_List_Widget_spec.js @@ -0,0 +1,91 @@ +const commonlocators = require("../../../../locators/commonlocators.json"); +const dsl = require("../../../../fixtures/listwidgetdsl.json"); +const pages = require("../../../../locators/Pages.json"); +const apiPage = require("../../../../locators/ApiEditor.json"); +const publishPage = require("../../../../locators/publishWidgetspage.json"); + +describe("Test Create Api and Bind to Table widget", function() { + let apiData; + before(() => { + cy.addDsl(dsl); + }); + + it("Test_Add users api and execute api", function() { + cy.createAndFillApi(this.data.userApi, "/users"); + cy.RunAPI(); + cy.get(apiPage.responseBody) + .contains("name") + .siblings("span") + .invoke("text") + .then((text) => { + const value = text.match(/"(.*)"/)[0]; + cy.log(value); + + apiData = value; + cy.log("val1:" + value); + }); + }); + + it("Test_Validate the Api data is updated on List widget", function() { + cy.SearchEntityandOpen("List1"); + cy.getCodeMirror().then(($cm) => { + cy.get(".CodeMirror textarea") + .first() + .type(`{{Api1.data.users}}`, { + force: true, + parseSpecialCharSequences: false, + }); + }); + cy.get(commonlocators.editPropCrossButton).click({ force: true }); + cy.get(".t--draggable-textwidget span").should("have.length", 4); + + cy.get(".t--draggable-textwidget span") + .first() + .invoke("text") + .then((text) => { + expect(text).to.equal("Barty Crouch"); + }); + cy.PublishtheApp(); + cy.get(".t--widget-textwidget span").should("have.length", 4); + cy.get(".t--widget-textwidget span") + .first() + .invoke("text") + .then((text) => { + expect(text).to.equal("Barty Crouch"); + }); + }); + + it("Test_Validate the list widget ", function() { + cy.get(publishPage.backToEditor).click({ force: true }); + cy.SearchEntityandOpen("List1"); + + cy.getCodeMirror().then(($cm) => { + cy.get(".CodeMirror textarea") + .last() + .type(`50`, { + force: true, + parseSpecialCharSequences: false, + }); + }); + cy.get(commonlocators.editPropCrossButton).click({ force: true }); + cy.get(".t--draggable-textwidget span").should("have.length", 2); + cy.get(".t--draggable-textwidget span") + .first() + .invoke("text") + .then((text) => { + expect(text).to.equal("Barty Crouch"); + }); + cy.PublishtheApp(); + cy.get(".t--widget-textwidget span").should("have.length", 2); + cy.get(".t--widget-textwidget span") + .first() + .invoke("text") + .then((text) => { + expect(text).to.equal("Barty Crouch"); + }); + }); + + afterEach(() => { + // put your clean up code if any + }); +});