From cfa020c063c1fe69c784d173f57576b053005953 Mon Sep 17 00:00:00 2001 From: Nikhil Nandagopal Date: Wed, 9 Dec 2020 11:50:39 +0530 Subject: [PATCH 01/11] pruned expensive redux actions and console logs from sentry --- app/client/src/utils/AppsmithUtils.tsx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/client/src/utils/AppsmithUtils.tsx b/app/client/src/utils/AppsmithUtils.tsx index c6432893328..9b5ddfdd2ee 100644 --- a/app/client/src/utils/AppsmithUtils.tsx +++ b/app/client/src/utils/AppsmithUtils.tsx @@ -46,7 +46,23 @@ export const appInitializer = () => { FeatureFlag.initialize(appsmithConfigs.featureFlag); if (appsmithConfigs.sentry.enabled) { - Sentry.init(appsmithConfigs.sentry); + Sentry.init({ + ...appsmithConfigs.sentry, + beforeBreadcrumb(breadcrumb, hint) { + if (breadcrumb.category === "console") { + return null; + } + if (breadcrumb.category === "redux.action") { + if ( + breadcrumb.data && + breadcrumb.data.type === "SET_EVALUATED_TREE" + ) { + breadcrumb.data = undefined; + } + } + return breadcrumb; + }, + }); } if (appsmithConfigs.smartLook.enabled) { From e0ac6e98509fafa8786532c2855ecccdebec0d29 Mon Sep 17 00:00:00 2001 From: Nikhil Nandagopal Date: Wed, 9 Dec 2020 11:59:40 +0530 Subject: [PATCH 02/11] Allowed console errors to still be logged --- app/client/src/utils/AppsmithUtils.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/client/src/utils/AppsmithUtils.tsx b/app/client/src/utils/AppsmithUtils.tsx index 9b5ddfdd2ee..7863999fc70 100644 --- a/app/client/src/utils/AppsmithUtils.tsx +++ b/app/client/src/utils/AppsmithUtils.tsx @@ -49,7 +49,7 @@ export const appInitializer = () => { Sentry.init({ ...appsmithConfigs.sentry, beforeBreadcrumb(breadcrumb, hint) { - if (breadcrumb.category === "console") { + if (breadcrumb.category === "console" && breadcrumb.level !== "error") { return null; } if (breadcrumb.category === "redux.action") { From 0fc5817caa995d93c0d8493aa5755e7f83bf5c3e Mon Sep 17 00:00:00 2001 From: Nikhil Nandagopal Date: Wed, 9 Dec 2020 12:32:27 +0530 Subject: [PATCH 03/11] added a check for errors without payloads --- app/client/src/sagas/ErrorSagas.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/client/src/sagas/ErrorSagas.tsx b/app/client/src/sagas/ErrorSagas.tsx index a680b793163..5382365ec22 100644 --- a/app/client/src/sagas/ErrorSagas.tsx +++ b/app/client/src/sagas/ErrorSagas.tsx @@ -87,7 +87,7 @@ export function* errorSaga( // Just a pass through for now. // Add procedures to customize errors here log.debug(`Error in action ${errorAction.type}`); - log.error(errorAction.payload.error); + if (errorAction.payload) log.error(errorAction.payload.error); // Show a toast when the error occurs const { type, @@ -105,7 +105,7 @@ export function* errorSaga( yield put({ type: ReduxActionTypes.REPORT_ERROR, payload: { - message: errorAction.payload.error, + message: errorAction.payload ? errorAction.payload.error : undefined, source: errorAction.type, }, }); From 7d70a71d7010031490de19e841260168fb2a8be7 Mon Sep 17 00:00:00 2001 From: Nikhil Nandagopal Date: Wed, 9 Dec 2020 14:42:12 +0530 Subject: [PATCH 04/11] added code to prune payloads from sentry actions and reduce depth of actions reported --- app/client/src/configs/index.ts | 2 +- app/client/src/store.ts | 12 +++++++++++- app/client/src/utils/AppsmithUtils.tsx | 3 +++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/client/src/configs/index.ts b/app/client/src/configs/index.ts index 08375a4a36d..3eb5d274bae 100644 --- a/app/client/src/configs/index.ts +++ b/app/client/src/configs/index.ts @@ -209,7 +209,7 @@ export const getAppsmithConfigs = (): AppsmithUIConfigs => { dsn: sentryDSN.value, release: sentryRelease.value, environment: sentryENV.value, - normalizeDepth: 5, + normalizeDepth: 3, integrations: [ new Integrations.BrowserTracing({ // Can also use reactRouterV4Instrumentation diff --git a/app/client/src/store.ts b/app/client/src/store.ts index b3a9ed63e00..a3b5d55274a 100644 --- a/app/client/src/store.ts +++ b/app/client/src/store.ts @@ -9,10 +9,20 @@ import createSagaMiddleware from "redux-saga"; import { rootSaga } from "sagas"; import { composeWithDevTools } from "redux-devtools-extension/logOnlyInProduction"; import * as Sentry from "@sentry/react"; +import { ReduxActionTypes } from "constants/ReduxActionConstants"; const sagaMiddleware = createSagaMiddleware(); const sentryReduxEnhancer = Sentry.createReduxEnhancer({ - // Optionally pass options listed below + actionTransformer: action => { + if ( + action.type === ReduxActionTypes.SET_EVALUATED_TREE || + action.type === ReduxActionTypes.EXECUTE_API_ACTION_SUCCESS + ) { + // Return null to not log the action to Sentry + action.payload = null; + } + return action; + }, }); export default createStore( diff --git a/app/client/src/utils/AppsmithUtils.tsx b/app/client/src/utils/AppsmithUtils.tsx index e8b4c718ded..4e65456a803 100644 --- a/app/client/src/utils/AppsmithUtils.tsx +++ b/app/client/src/utils/AppsmithUtils.tsx @@ -52,6 +52,9 @@ export const appInitializer = () => { if (breadcrumb.category === "console" && breadcrumb.level !== "error") { return null; } + if (breadcrumb.category === "sentry.transaction") { + return null; + } if (breadcrumb.category === "redux.action") { if ( breadcrumb.data && From d228f6d117f1efd988a61010f2ea123108122c3d Mon Sep 17 00:00:00 2001 From: Nikhil Nandagopal Date: Wed, 9 Dec 2020 18:22:36 +0530 Subject: [PATCH 05/11] fix for undefined access to crash field --- app/client/src/sagas/ErrorSagas.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/client/src/sagas/ErrorSagas.tsx b/app/client/src/sagas/ErrorSagas.tsx index 2fd96971cf3..4b6d95d3563 100644 --- a/app/client/src/sagas/ErrorSagas.tsx +++ b/app/client/src/sagas/ErrorSagas.tsx @@ -108,7 +108,7 @@ export function* errorSaga( if (show) { effects.push(ErrorEffectTypes.SHOW_ALERT); } - if (error.crash) { + if (error && error.crash) { effects.push(ErrorEffectTypes.SAFE_CRASH); } for (const effect of effects) { From 888d79b06d14732d12a9bc2df572def5e549543b Mon Sep 17 00:00:00 2001 From: Trisha Anand Date: Wed, 9 Dec 2020 19:03:51 +0530 Subject: [PATCH 06/11] Removing printing of result objects from plugin execution. --- .../src/main/java/com/external/plugins/DynamoPlugin.java | 2 +- .../main/java/com/external/plugins/ElasticSearchPlugin.java | 2 +- .../src/main/java/com/external/plugins/FirestorePlugin.java | 4 +--- .../src/main/java/com/external/plugins/MssqlPlugin.java | 2 +- .../src/main/java/com/external/plugins/MySqlPlugin.java | 2 +- .../src/main/java/com/external/plugins/PostgresPlugin.java | 3 +-- .../src/main/java/com/external/plugins/RedisPlugin.java | 2 +- 7 files changed, 7 insertions(+), 10 deletions(-) diff --git a/app/server/appsmith-plugins/dynamoPlugin/src/main/java/com/external/plugins/DynamoPlugin.java b/app/server/appsmith-plugins/dynamoPlugin/src/main/java/com/external/plugins/DynamoPlugin.java index dbc4c6b6577..775cea22fa5 100644 --- a/app/server/appsmith-plugins/dynamoPlugin/src/main/java/com/external/plugins/DynamoPlugin.java +++ b/app/server/appsmith-plugins/dynamoPlugin/src/main/java/com/external/plugins/DynamoPlugin.java @@ -120,7 +120,7 @@ public Mono execute(DynamoDbClient ddb, } result.setIsExecutionSuccess(true); - System.out.println(Thread.currentThread().getName() + ": In the DynamoPlugin, got action execution result: " + result.toString()); + System.out.println(Thread.currentThread().getName() + ": In the DynamoPlugin, got action execution result"); return Mono.just(result); }) .flatMap(obj -> obj) diff --git a/app/server/appsmith-plugins/elasticSearchPlugin/src/main/java/com/external/plugins/ElasticSearchPlugin.java b/app/server/appsmith-plugins/elasticSearchPlugin/src/main/java/com/external/plugins/ElasticSearchPlugin.java index 52689bcb4cc..3612e8ed1c6 100644 --- a/app/server/appsmith-plugins/elasticSearchPlugin/src/main/java/com/external/plugins/ElasticSearchPlugin.java +++ b/app/server/appsmith-plugins/elasticSearchPlugin/src/main/java/com/external/plugins/ElasticSearchPlugin.java @@ -103,7 +103,7 @@ public Mono execute(RestClient client, } result.setIsExecutionSuccess(true); - System.out.println(Thread.currentThread().getName() + ": In the Elastic Search Plugin, got action execution result: " + result.toString()); + System.out.println(Thread.currentThread().getName() + ": In the Elastic Search Plugin, got action execution result"); return Mono.just(result); }) .flatMap(obj -> obj) diff --git a/app/server/appsmith-plugins/firestorePlugin/src/main/java/com/external/plugins/FirestorePlugin.java b/app/server/appsmith-plugins/firestorePlugin/src/main/java/com/external/plugins/FirestorePlugin.java index c40524364d3..81d1822c637 100644 --- a/app/server/appsmith-plugins/firestorePlugin/src/main/java/com/external/plugins/FirestorePlugin.java +++ b/app/server/appsmith-plugins/firestorePlugin/src/main/java/com/external/plugins/FirestorePlugin.java @@ -212,9 +212,7 @@ public Mono handleDocumentLevelMethod( result.setIsExecutionSuccess(true); System.out.println( Thread.currentThread().getName() - + ": In the Firestore Plugin, got action execution result: " - + result.toString() - ); + + ": In the Firestore Plugin, got action execution result"); return Mono.just(result); }); } diff --git a/app/server/appsmith-plugins/mssqlPlugin/src/main/java/com/external/plugins/MssqlPlugin.java b/app/server/appsmith-plugins/mssqlPlugin/src/main/java/com/external/plugins/MssqlPlugin.java index 20bb08d3637..583eadf3ba5 100644 --- a/app/server/appsmith-plugins/mssqlPlugin/src/main/java/com/external/plugins/MssqlPlugin.java +++ b/app/server/appsmith-plugins/mssqlPlugin/src/main/java/com/external/plugins/MssqlPlugin.java @@ -176,7 +176,7 @@ public Mono execute(Connection connection, ActionExecutionResult result = new ActionExecutionResult(); result.setBody(objectMapper.valueToTree(rowsList)); result.setIsExecutionSuccess(true); - System.out.println(Thread.currentThread().getName() + ": In the MssqlPlugin, got action execution result: " + result.toString()); + System.out.println(Thread.currentThread().getName() + ": In the MssqlPlugin, got action execution result"); return Mono.just(result); }) .flatMap(obj -> obj) diff --git a/app/server/appsmith-plugins/mysqlPlugin/src/main/java/com/external/plugins/MySqlPlugin.java b/app/server/appsmith-plugins/mysqlPlugin/src/main/java/com/external/plugins/MySqlPlugin.java index 4de36739dcf..cf24cd4247a 100644 --- a/app/server/appsmith-plugins/mysqlPlugin/src/main/java/com/external/plugins/MySqlPlugin.java +++ b/app/server/appsmith-plugins/mysqlPlugin/src/main/java/com/external/plugins/MySqlPlugin.java @@ -234,7 +234,7 @@ public Mono execute(Connection connection, result.setBody(objectMapper.valueToTree(rowsList)); result.setIsExecutionSuccess(true); System.out.println(Thread.currentThread().getName() + " In the MySqlPlugin, got action " + - "execution result: " + result.toString()); + "execution result"); return Mono.just(result); }) .subscribeOn(scheduler); diff --git a/app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java b/app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java index 0b01615a8b4..b1e7ccf29c3 100644 --- a/app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java +++ b/app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java @@ -226,8 +226,7 @@ public Mono execute(Connection connection, ActionExecutionResult result = new ActionExecutionResult(); result.setBody(objectMapper.valueToTree(rowsList)); result.setIsExecutionSuccess(true); - System.out.println(Thread.currentThread().getName() + ": In the PostgresPlugin, got action execution result:" - + result.toString()); + System.out.println(Thread.currentThread().getName() + ": In the PostgresPlugin, got action execution result"); return Mono.just(result); }) .flatMap(obj -> obj) diff --git a/app/server/appsmith-plugins/redisPlugin/src/main/java/com/external/plugins/RedisPlugin.java b/app/server/appsmith-plugins/redisPlugin/src/main/java/com/external/plugins/RedisPlugin.java index 44817a0fbde..d2716dbb633 100644 --- a/app/server/appsmith-plugins/redisPlugin/src/main/java/com/external/plugins/RedisPlugin.java +++ b/app/server/appsmith-plugins/redisPlugin/src/main/java/com/external/plugins/RedisPlugin.java @@ -78,7 +78,7 @@ public Mono execute(Jedis jedis, actionExecutionResult.setBody(objectMapper.valueToTree(processCommandOutput(commandOutput))); actionExecutionResult.setIsExecutionSuccess(true); - System.out.println(Thread.currentThread().getName() + ": In the RedisPlugin, got action execution result: " + actionExecutionResult.toString()); + System.out.println(Thread.currentThread().getName() + ": In the RedisPlugin, got action execution result"); return Mono.just(actionExecutionResult); }) .flatMap(obj -> obj) From 746b0ab58e51c8a6532479435b1dec10e1c069a5 Mon Sep 17 00:00:00 2001 From: Trisha Anand Date: Wed, 9 Dec 2020 19:16:54 +0530 Subject: [PATCH 07/11] Changed log to sout in postgres plugin --- .../com/external/plugins/PostgresPlugin.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java b/app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java index b1e7ccf29c3..0e6f2c820cf 100644 --- a/app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java +++ b/app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java @@ -122,13 +122,13 @@ public Mono execute(Connection connection, try { if (connection == null || connection.isClosed() || !connection.isValid(VALIDITY_CHECK_TIMEOUT)) { - log.info("Encountered stale connection in Postgres plugin. Reporting back."); + System.out.println("Encountered stale connection in Postgres plugin. Reporting back."); throw new StaleConnectionException(); } } catch (SQLException error) { // This exception is thrown only when the timeout to `isValid` is negative. Since, that's not the case, // here, this should never happen. - log.error("Error checking validity of Postgres connection.", error); + System.out.println("Error checking validity of Postgres connection." + error); } String query = actionConfiguration.getBody(); @@ -209,7 +209,7 @@ public Mono execute(Connection connection, try { resultSet.close(); } catch (SQLException e) { - log.warn("Error closing Postgres ResultSet", e); + System.out.println("Error closing Postgres ResultSet" + e.getMessage()); } } @@ -217,7 +217,7 @@ public Mono execute(Connection connection, try { statement.close(); } catch (SQLException e) { - log.warn("Error closing Postgres Statement", e); + System.out.println("Error closing Postgres Statement" + e.getMessage()); } } @@ -305,7 +305,7 @@ public void datasourceDestroy(Connection connection) { connection.close(); } } catch (SQLException e) { - log.error("Error closing Postgres Connection.", e); + System.out.println("Error closing Postgres Connection." + e.getMessage()); } } @@ -360,7 +360,7 @@ public Mono testDatasource(DatasourceConfiguration datasou connection.close(); } } catch (SQLException e) { - log.warn("Error closing Postgres connection that was made for testing.", e); + System.out.println(Thread.currentThread().getName() + ": Error closing Postgres connection that was made for testing." + e.getMessage()); } return new DatasourceTestResult(); @@ -373,13 +373,13 @@ public Mono getStructure(Connection connection, DatasourceC try { if (connection == null || connection.isClosed() || !connection.isValid(VALIDITY_CHECK_TIMEOUT)) { - log.info("Encountered stale connection in Postgres plugin. Reporting back."); + System.out.println(Thread.currentThread().getName() + ": Encountered stale connection in Postgres plugin. Reporting back."); throw new StaleConnectionException(); } - } catch (SQLException error) { + } catch (SQLException e) { // This exception is thrown only when the timeout to `isValid` is negative. Since, that's not the case, // here, this should never happen. - log.error("Error checking validity of Postgres connection.", error); + System.out.println(Thread.currentThread().getName() + ": Error checking validity of Postgres connection." + e.getMessage()); } final DatasourceStructure structure = new DatasourceStructure(); From 74f8b51db3b12435235b3d187d2afb4cb7e5435e Mon Sep 17 00:00:00 2001 From: Hetu Nandu Date: Wed, 9 Dec 2020 22:25:59 +0530 Subject: [PATCH 08/11] Fix for false evaluated value showing as null --- .../editorComponents/CodeEditor/EvaluatedValuePopup.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/client/src/components/editorComponents/CodeEditor/EvaluatedValuePopup.tsx b/app/client/src/components/editorComponents/CodeEditor/EvaluatedValuePopup.tsx index 670cf8f5d40..701d3c6c303 100644 --- a/app/client/src/components/editorComponents/CodeEditor/EvaluatedValuePopup.tsx +++ b/app/client/src/components/editorComponents/CodeEditor/EvaluatedValuePopup.tsx @@ -143,7 +143,9 @@ export const CurrentValueViewer = (props: { } else { content = ( - {props.evaluatedValue ? props.evaluatedValue.toString() : "null"} + {props.evaluatedValue === null + ? "null" + : props.evaluatedValue.toString()} ); } From 9fb99c11457cd52efafdd85ed2fb4782a09ceecc Mon Sep 17 00:00:00 2001 From: NandanAnantharamu <67676905+NandanAnantharamu@users.noreply.github.com> Date: Thu, 10 Dec 2020 10:52:19 +0530 Subject: [PATCH 09/11] Added tests for Table binding with Input Widget (#1955) Co-authored-by: nandan.anantharamu Co-authored-by: Arpit Mohan --- app/client/.eslintrc.js | 37 ------------ app/client/.eslintrc.json | 41 ++++++++++++++ app/client/cypress/fixtures/testdata.json | 3 +- ...bleWidget_selectedRow_Input_widget_spec.js | 56 +++++++++++++++++++ ..._Widget_DefaultSearch_Input_widget_spec.js | 42 ++++++++++++++ .../Entity_Explorer_Query_Datasource_spec.js | 2 + .../CreateDuplicateAppWithinOrg_spec.js | 2 - .../cypress/locators/commonlocators.json | 2 + app/client/package.json | 1 + app/client/yarn.lock | 9 ++- 10 files changed, 154 insertions(+), 41 deletions(-) delete mode 100644 app/client/.eslintrc.js create mode 100644 app/client/.eslintrc.json create mode 100644 app/client/cypress/integration/Smoke_TestSuite/Binding/Bind_TableWidget_selectedRow_Input_widget_spec.js create mode 100644 app/client/cypress/integration/Smoke_TestSuite/Binding/Binding_Table_Widget_DefaultSearch_Input_widget_spec.js diff --git a/app/client/.eslintrc.js b/app/client/.eslintrc.js deleted file mode 100644 index eec93a06da4..00000000000 --- a/app/client/.eslintrc.js +++ /dev/null @@ -1,37 +0,0 @@ -module.exports = { - parser: "@typescript-eslint/parser", - plugins: ["react", "@typescript-eslint", "prettier", "react-hooks"], - extends: [ - "plugin:react/recommended", // Uses the recommended rules from @eslint-plugin-react - "plugin:@typescript-eslint/recommended", - "prettier/@typescript-eslint", - "plugin:prettier/recommended", - ], - parserOptions: { - ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features - sourceType: "module", // Allows for the use of imports - ecmaFeatures: { - jsx: true, // Allows for the parsing of JSX - }, - }, - rules: { - "@typescript-eslint/no-explicit-any": 0, - "react-hooks/rules-of-hooks": "error", - "@typescript-eslint/no-use-before-define": 0, - "@typescript-eslint/no-var-requires": 0, - "import/no-webpack-loader-syntax": 0, - "no-undef": 0, - "react/prop-types": 0, - "@typescript-eslint/explicit-module-boundary-types": 0, - }, - settings: { - react: { - pragma: "React", - version: "detect", // Tells eslint-plugin-react to automatically detect the version of React to use - }, - }, - env: { - browser: true, - node: true, - }, -}; diff --git a/app/client/.eslintrc.json b/app/client/.eslintrc.json new file mode 100644 index 00000000000..fff028a53a7 --- /dev/null +++ b/app/client/.eslintrc.json @@ -0,0 +1,41 @@ +// This JSON file configures the eslint plugin. It supports comments as well as per the JSON5 spec +{ + "parser": "@typescript-eslint/parser", + "plugins": ["react", "@typescript-eslint", "prettier", "react-hooks"], + "extends": [ + "plugin:react/recommended", // Uses the recommended rules from @eslint-plugin-react + "plugin:@typescript-eslint/recommended", + "prettier/@typescript-eslint", + "plugin:prettier/recommended", + "plugin:cypress/recommended" + ], + "parserOptions": { + "ecmaVersion": 2020, // Allows for the parsing of modern ECMAScript features + "sourceType": "module", // Allows for the use of imports + "ecmaFeatures": { + "jsx": true // Allows for the parsing of JSX + } + }, + "rules": { + "@typescript-eslint/no-explicit-any": 0, + "react-hooks/rules-of-hooks": "error", + "@typescript-eslint/no-use-before-define": 0, + "@typescript-eslint/no-var-requires": 0, + "import/no-webpack-loader-syntax": 0, + "no-undef": 0, + "react/prop-types": 0, + "@typescript-eslint/explicit-module-boundary-types": 0 + }, + "settings": { + "react": { + "pragma": "React", + // Tells eslint-plugin-react to automatically detect the version of React to use + "version": "detect" + } + }, + "env": { + "browser": true, + "node": true, + "cypress/globals": true + } +} diff --git a/app/client/cypress/fixtures/testdata.json b/app/client/cypress/fixtures/testdata.json index 6676bbdd2af..f62b32c3a62 100644 --- a/app/client/cypress/fixtures/testdata.json +++ b/app/client/cypress/fixtures/testdata.json @@ -181,5 +181,6 @@ "btoaInput": "{{btoa('A')", "defaultInputBinding": "{{Input2.text", "tabBinding": "{{Tabs1.selectedTab", - "pageloadBinding": "{{PageLoadApi.data.data[1].id}}{{Input1.text}}" + "pageloadBinding": "{{PageLoadApi.data.data[1].id}}{{Input1.text}}", + "defaultRowIndexBinding": "{{Table1.selectedRowIndex" } diff --git a/app/client/cypress/integration/Smoke_TestSuite/Binding/Bind_TableWidget_selectedRow_Input_widget_spec.js b/app/client/cypress/integration/Smoke_TestSuite/Binding/Bind_TableWidget_selectedRow_Input_widget_spec.js new file mode 100644 index 00000000000..bcd5454d1f3 --- /dev/null +++ b/app/client/cypress/integration/Smoke_TestSuite/Binding/Bind_TableWidget_selectedRow_Input_widget_spec.js @@ -0,0 +1,56 @@ +/// + +const commonlocators = require("../../../locators/commonlocators.json"); +const dsl = require("../../../fixtures/formInputTableDsl.json"); +const widgetsPage = require("../../../locators/Widgets.json"); +const publish = require("../../../locators/publishWidgetspage.json"); +const testdata = require("../../../fixtures/testdata.json"); + +describe("Binding the table widget and input Widget", function() { + before(() => { + cy.addDsl(dsl); + }); + + it("Input widget test with default value from table widget", function() { + cy.SearchEntityandOpen("Input1"); + cy.get(widgetsPage.defaultInput).type(testdata.defaultInputWidget); + cy.get(commonlocators.editPropCrossButton).click(); + cy.wait("@updateLayout").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); + }); + + it("Input widget test with default value from table widget", function() { + cy.SearchEntityandOpen("Input2"); + cy.get(widgetsPage.defaultInput).type(testdata.defaultRowIndexBinding); + cy.get(commonlocators.editPropCrossButton).click(); + cy.wait("@updateLayout").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); + }); + + it("validation of data displayed in input widgets based on selected row", function() { + cy.SearchEntityandOpen("Table1"); + cy.get(commonlocators.deflautSelectedRow) + .last() + .type("2", { force: true }); + cy.get(commonlocators.editPropCrossButton).click(); + cy.readTabledataPublish("2", "0").then(tabData => { + const tabValue = tabData; + expect(tabValue).to.be.equal("6788734"); + cy.log("the value is" + tabValue); + cy.get(publish.inputWidget + " " + "input") + .first() + .invoke("attr", "value") + .should("contain", tabValue); + cy.get(publish.inputWidget + " " + "input") + .last() + .invoke("attr", "value") + .should("contain", 2); + }); + }); +}); diff --git a/app/client/cypress/integration/Smoke_TestSuite/Binding/Binding_Table_Widget_DefaultSearch_Input_widget_spec.js b/app/client/cypress/integration/Smoke_TestSuite/Binding/Binding_Table_Widget_DefaultSearch_Input_widget_spec.js new file mode 100644 index 00000000000..82241bd5ada --- /dev/null +++ b/app/client/cypress/integration/Smoke_TestSuite/Binding/Binding_Table_Widget_DefaultSearch_Input_widget_spec.js @@ -0,0 +1,42 @@ +const commonlocators = require("../../../locators/commonlocators.json"); +const formWidgetsPage = require("../../../locators/FormWidgets.json"); +const dsl = require("../../../fixtures/formInputTableDsl.json"); +const pages = require("../../../locators/Pages.json"); +const widgetsPage = require("../../../locators/Widgets.json"); +const publish = require("../../../locators/publishWidgetspage.json"); +const testdata = require("../../../fixtures/testdata.json"); + +describe("Binding the Table and input Widget", function() { + before(() => { + cy.addDsl(dsl); + }); + + it("Input widget test with default value from table widget", function() { + cy.SearchEntityandOpen("Input1"); + cy.get(widgetsPage.defaultInput).type(testdata.defaultInputWidget); + cy.get(commonlocators.editPropCrossButton).click(); + cy.wait("@updateLayout").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); + }); + + it("validation of data displayed in input widgets based on search value set", function() { + cy.SearchEntityandOpen("Table1"); + cy.get(commonlocators.defaultSearchText) + .last() + .type("2736212", { force: true }); + cy.get(commonlocators.editPropCrossButton).click(); + cy.isSelectRow(0); + cy.readTabledataPublish("0", "0").then(tabData => { + const tabValue = tabData; + expect(tabValue).to.be.equal("2736212"); + cy.log("the value is" + tabValue); + cy.get(publish.inputWidget + " " + "input") + .first() + .invoke("attr", "value") + .should("contain", tabValue); + }); + }); +}); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ExplorerTests/Entity_Explorer_Query_Datasource_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ExplorerTests/Entity_Explorer_Query_Datasource_spec.js index 3f4dd526086..e5bbff18cfe 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ExplorerTests/Entity_Explorer_Query_Datasource_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ExplorerTests/Entity_Explorer_Query_Datasource_spec.js @@ -1,3 +1,5 @@ +/// + const queryLocators = require("../../../locators/QueryEditor.json"); const datasource = require("../../../locators/DatasourcesEditor.json"); const apiwidget = require("../../../locators/apiWidgetslocator.json"); diff --git a/app/client/cypress/integration/Smoke_TestSuite/OrganisationTests/CreateDuplicateAppWithinOrg_spec.js b/app/client/cypress/integration/Smoke_TestSuite/OrganisationTests/CreateDuplicateAppWithinOrg_spec.js index 1fe8654c910..41692b1e3c0 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/OrganisationTests/CreateDuplicateAppWithinOrg_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/OrganisationTests/CreateDuplicateAppWithinOrg_spec.js @@ -1,7 +1,5 @@ /// -const homePage = require("../../../locators/HomePage.json"); - describe("Create new org and an app within the same", function() { let orgid; let appid; diff --git a/app/client/cypress/locators/commonlocators.json b/app/client/cypress/locators/commonlocators.json index f685e3827c4..b6e49bef455 100644 --- a/app/client/cypress/locators/commonlocators.json +++ b/app/client/cypress/locators/commonlocators.json @@ -81,6 +81,8 @@ "selectedZoomlevel": ".t--property-control-maxzoomlevel button span", "imgWidget": "div[data-testid='styledImage']", "selectTab": ".t--tab-Tab", + "deflautSelectedRow": ".t--property-control-defaultselectedrow textarea", + "defaultSearchText": ".t--property-control-defaultsearchtext textarea", "entityName": ".t--entity-name", "filePickerButton": ".t--widget-filepickerwidget", "filePickerInput": ".uppy-Dashboard-input", diff --git a/app/client/package.json b/app/client/package.json index ef055c9dcab..a5f0068098b 100644 --- a/app/client/package.json +++ b/app/client/package.json @@ -189,6 +189,7 @@ "eslint-plugin-prettier": "^3.1.4", "eslint-plugin-react": "^7.21.3", "eslint-plugin-react-hooks": "^2.3.0", + "eslint-plugin-cypress": "^2.11.2", "mocha": "^7.1.0", "mocha-junit-reporter": "^1.23.3", "mochawesome": "^5.0.0", diff --git a/app/client/yarn.lock b/app/client/yarn.lock index 7c8b63f3331..097ef11d927 100644 --- a/app/client/yarn.lock +++ b/app/client/yarn.lock @@ -8476,6 +8476,13 @@ eslint-module-utils@^2.6.0: debug "^2.6.9" pkg-dir "^2.0.0" +eslint-plugin-cypress@^2.11.2: + version "2.11.2" + resolved "https://registry.yarnpkg.com/eslint-plugin-cypress/-/eslint-plugin-cypress-2.11.2.tgz#a8f3fe7ec840f55e4cea37671f93293e6c3e76a0" + integrity sha512-1SergF1sGbVhsf7MYfOLiBhdOg6wqyeV9pXUAIDIffYTGMN3dTBQS9nFAzhLsHhO+Bn0GaVM1Ecm71XUidQ7VA== + dependencies: + globals "^11.12.0" + eslint-plugin-flowtype@^5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/eslint-plugin-flowtype/-/eslint-plugin-flowtype-5.2.0.tgz#a4bef5dc18f9b2bdb41569a4ab05d73805a3d261" @@ -9753,7 +9760,7 @@ global@^4.3.2, global@^4.4.0: min-document "^2.19.0" process "^0.11.10" -globals@^11.1.0: +globals@^11.1.0, globals@^11.12.0: version "11.12.0" resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e" integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA== From 2b4e25b04a6d478018d747b8533e9c928ace0b12 Mon Sep 17 00:00:00 2001 From: Piyush Mishra Date: Thu, 10 Dec 2020 11:25:12 +0530 Subject: [PATCH 10/11] default to empty array on usage (#2074) --- app/client/src/widgets/DropdownWidget.tsx | 31 +++++++++++++---------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/app/client/src/widgets/DropdownWidget.tsx b/app/client/src/widgets/DropdownWidget.tsx index 2bd9966ee3d..ce0027a081f 100644 --- a/app/client/src/widgets/DropdownWidget.tsx +++ b/app/client/src/widgets/DropdownWidget.tsx @@ -61,22 +61,24 @@ class DropdownWidget extends BaseWidget { }; } + getSelectedOptionValueArr(): string[] { + return Array.isArray(this.props.selectedOptionValueArr) + ? this.props.selectedOptionValueArr + : []; + } + getPageView() { const options = this.props.options || []; const selectedIndex = _.findIndex(this.props.options, { value: this.props.selectedOptionValue, }); - const computedSelectedIndexArr = Array.isArray( - this.props.selectedOptionValueArr, - ) - ? this.props.selectedOptionValueArr - .map((opt: string) => - _.findIndex(this.props.options, { - value: opt, - }), - ) - .filter((i: number) => i > -1) - : []; + const computedSelectedIndexArr = this.getSelectedOptionValueArr() + .map((opt: string) => + _.findIndex(this.props.options, { + value: opt, + }), + ) + .filter((i: number) => i > -1); const { componentWidth, componentHeight } = this.getComponentDimensions(); return ( { ); } } else if (this.props.selectionType === "MULTI_SELECT") { - const isAlreadySelected = this.props.selectedOptionValueArr.includes( + const selectedOptionValueArr = this.getSelectedOptionValueArr(); + const isAlreadySelected = selectedOptionValueArr.includes( selectedOption.value, ); - let newSelectedValue = [...this.props.selectedOptionValueArr]; + let newSelectedValue = [...selectedOptionValueArr]; if (isAlreadySelected) { newSelectedValue = newSelectedValue.filter( v => v !== selectedOption.value, @@ -144,7 +147,7 @@ class DropdownWidget extends BaseWidget { }; onOptionRemoved = (removedIndex: number) => { - const newSelectedValue = this.props.selectedOptionValueArr.filter( + const newSelectedValue = this.getSelectedOptionValueArr().filter( (v: string) => _.findIndex(this.props.options, { value: v }) !== removedIndex, ); From 0e47c0a4c0d3b5452698e743b6d4f08cbc390642 Mon Sep 17 00:00:00 2001 From: Piyush Mishra Date: Thu, 10 Dec 2020 11:48:59 +0530 Subject: [PATCH 11/11] Fix brackets mismatch (#2019) --- .../CodeEditor/EditorConfig.ts | 1 + .../editorComponents/CodeEditor/index.tsx | 23 +++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/app/client/src/components/editorComponents/CodeEditor/EditorConfig.ts b/app/client/src/components/editorComponents/CodeEditor/EditorConfig.ts index f2d3f93b6f7..1f649f4cfd2 100644 --- a/app/client/src/components/editorComponents/CodeEditor/EditorConfig.ts +++ b/app/client/src/components/editorComponents/CodeEditor/EditorConfig.ts @@ -8,6 +8,7 @@ export enum EditorModes { JSON = "application/json", JSON_WITH_BINDING = "json-js", SQL_WITH_BINDING = "sql-js", + JAVASCRIPT = "javascript", } export enum EditorTheme { diff --git a/app/client/src/components/editorComponents/CodeEditor/index.tsx b/app/client/src/components/editorComponents/CodeEditor/index.tsx index 29e17b9fdbb..9220603a9e1 100644 --- a/app/client/src/components/editorComponents/CodeEditor/index.tsx +++ b/app/client/src/components/editorComponents/CodeEditor/index.tsx @@ -22,6 +22,7 @@ import AnalyticsUtil from "utils/AnalyticsUtil"; import "components/editorComponents/CodeEditor/modes"; import { EditorConfig, + EditorModes, EditorSize, EditorTheme, EditorThemes, @@ -140,6 +141,7 @@ class CodeEditor extends Component { this.editor.on("change", this.onChangeTigger); this.editor.on("keyup", this.handleAutocompleteHide); this.editor.on("focus", this.handleEditorFocus); + this.editor.on("cursorActivity", this.handleCursorMovement); this.editor.on("focus", this.onFocusTrigger); this.editor.on("blur", this.handleEditorBlur); if (this.props.height) { @@ -216,17 +218,28 @@ class CodeEditor extends Component { } }; + handleCursorMovement = (cm: CodeMirror.Editor) => { + // ignore if disabled + if (!this.props.input.onChange || this.props.disabled) { + return; + } + const mode = cm.getModeAt(cm.getCursor()); + if ( + mode && + [EditorModes.JAVASCRIPT, EditorModes.JSON].includes(mode.name) + ) { + this.editor.setOption("matchBrackets", true); + } else { + this.editor.setOption("matchBrackets", false); + } + }; + handleEditorFocus = () => { this.setState({ isFocused: true }); this.editor.refresh(); if (this.props.size === EditorSize.COMPACT) { this.editor.setOption("lineWrapping", true); } - - // Highlight matching brackets only when focused and not in readonly mode - if (this.props.input.onChange && !this.props.disabled) { - this.editor.setOption("matchBrackets", true); - } }; handleEditorBlur = () => {