From a5dbb5261b0d98f8dfe4c55c96c659ac7681c0e9 Mon Sep 17 00:00:00 2001 From: "vicky-primathon.in" Date: Thu, 6 May 2021 13:54:18 +0530 Subject: [PATCH] Added test case to validate onSearchTextChange function if configured in table widget --- app/client/cypress/fixtures/tableWidgetDsl.json | 6 +++++- .../ClientSideTests/Binding/Bind_tableApi_spec.js | 13 +++++++++++++ app/client/cypress/locators/Widgets.json | 2 ++ .../designSystems/appsmith/SearchComponent.tsx | 1 + 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/client/cypress/fixtures/tableWidgetDsl.json b/app/client/cypress/fixtures/tableWidgetDsl.json index 349f604903..9929225f5e 100644 --- a/app/client/cypress/fixtures/tableWidgetDsl.json +++ b/app/client/cypress/fixtures/tableWidgetDsl.json @@ -67,7 +67,11 @@ "bottomRow": 10, "parentId": "tyiwk4xuq0", "widgetId": "5up3r2iuvs", - "dynamicBindingPathList": [] + "dynamicTriggerPathList": [{ + "key": "onSearchTextChanged" + }], + "onSearchTextChanged": "{{Api1.run()}}", + "selectedRow": "{{Table1.tableData[Table1.selectedRowIndex]}}" } ], "widgetId": "tyiwk4xuq0", diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Binding/Bind_tableApi_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Binding/Bind_tableApi_spec.js index d65d22e80d..fb8eeb6b6e 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Binding/Bind_tableApi_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Binding/Bind_tableApi_spec.js @@ -3,6 +3,7 @@ const dsl = require("../../../../fixtures/tableWidgetDsl.json"); const pages = require("../../../../locators/Pages.json"); const apiPage = require("../../../../locators/ApiEditor.json"); const publishPage = require("../../../../locators/publishWidgetspage.json"); +const widgetsPage = require("../../../../locators/Widgets.json"); describe("Test Create Api and Bind to Table widget", function() { let apiData; @@ -43,6 +44,18 @@ describe("Test Create Api and Bind to Table widget", function() { cy.readTabledataPublish("0", "1").then((tabData) => { expect(apiData).to.eq(`\"${tabData}\"`); }); + cy.get(commonlocators.backToEditor).click(); + }); + + it("Validate onSearchTextChanged function is called when configured for search text", function() { + cy.SearchEntityandOpen("Table1"); + cy.get(".t--widget-tablewidget .t--search-input") + .first() + .type("Currey"); + cy.wait(5000); + cy.readTabledataPublish("0", "1").then((tabData) => { + expect(apiData).to.eq(`\"${tabData}\"`); + }); }); afterEach(() => { diff --git a/app/client/cypress/locators/Widgets.json b/app/client/cypress/locators/Widgets.json index 3e67eecebb..514ff56cc2 100644 --- a/app/client/cypress/locators/Widgets.json +++ b/app/client/cypress/locators/Widgets.json @@ -38,6 +38,8 @@ "textInputval": ".t--draggable-textwidget span.t--widget-name", "textCenterAlign": ".t--property-control-textalign .t--icon-tab-CENTER", "ColumnAction": ".t--property-control-rowbutton button", + "SearchTextChangeAction": ".t--property-control-onsearchtextchanged button", + "tableSearchTextChangeSelected": ".t--property-control-onsearchtextchanged", "videoWidget": ".t--draggable-videowidget", "autoPlay": ".t--property-control-autoplay > .bp3-control > .bp3-control-indicator", "defaultOption": ".t--property-control-defaultoption .CodeMirror-code", diff --git a/app/client/src/components/designSystems/appsmith/SearchComponent.tsx b/app/client/src/components/designSystems/appsmith/SearchComponent.tsx index 46bfac9a87..df90ccb1a4 100644 --- a/app/client/src/components/designSystems/appsmith/SearchComponent.tsx +++ b/app/client/src/components/designSystems/appsmith/SearchComponent.tsx @@ -52,6 +52,7 @@ class SearchComponent extends React.Component< render() { return (