diff --git a/app/client/cypress/fixtures/formResetDsl.json b/app/client/cypress/fixtures/formResetDsl.json new file mode 100644 index 00000000000..c40bb6d5c20 --- /dev/null +++ b/app/client/cypress/fixtures/formResetDsl.json @@ -0,0 +1,297 @@ +{ + "dsl": { + "widgetName": "MainContainer", + "backgroundColor": "none", + "rightColumn": 1224, + "snapColumns": 16, + "detachFromLayout": true, + "widgetId": "0", + "topRow": 0, + "bottomRow": 1280, + "containerStyle": "none", + "snapRows": 33, + "parentRowSpace": 1, + "type": "CANVAS_WIDGET", + "canExtend": true, + "dynamicBindings": { + }, + "version": 5, + "minHeight": 1292, + "parentColumnSpace": 1, + "leftColumn": 0, + "children": [ + { + "isVisible": true, + "widgetName": "Form1", + "backgroundColor": "white", + "children": [ + { + "isVisible": true, + "widgetName": "Canvas1", + "containerStyle": "none", + "canExtend": false, + "detachFromLayout": true, + "children": [ + { + "isVisible": true, + "text": "Form", + "textStyle": "HEADING", + "textAlign": "LEFT", + "widgetName": "Text1", + "type": "TEXT_WIDGET", + "isLoading": false, + "leftColumn": 0, + "rightColumn": 12, + "topRow": 0, + "bottomRow": 1, + "parentId": "qrqizehc5b", + "widgetId": "c481ah2q0i" + }, + { + "isVisible": true, + "widgetName": "FormButton1", + "text": "Submit", + "isDefaultClickDisabled": true, + "buttonStyle": "PRIMARY_BUTTON", + "disabledWhenInvalid": true, + "resetFormOnClick": true, + "type": "FORM_BUTTON_WIDGET", + "isLoading": false, + "leftColumn": 12, + "rightColumn": 16, + "topRow": 12, + "bottomRow": 13, + "parentId": "qrqizehc5b", + "widgetId": "zsu1y41p1e" + }, + { + "isVisible": true, + "widgetName": "FormButton2", + "text": "Reset", + "isDefaultClickDisabled": true, + "buttonStyle": "SECONDARY_BUTTON", + "disabledWhenInvalid": false, + "resetFormOnClick": true, + "type": "FORM_BUTTON_WIDGET", + "isLoading": false, + "leftColumn": 8, + "rightColumn": 12, + "topRow": 12, + "bottomRow": 13, + "parentId": "qrqizehc5b", + "widgetId": "7o0r2rp3s1" + }, + { + "isVisible": true, + "label": "Data", + "widgetName": "Table1", + "searchKey": "", + "tableData": "[\n {\n \"id\": 2381224,\n \"email\": \"michael.lawson@reqres.in\",\n \"userName\": \"Michael Lawson\",\n \"productName\": \"Chicken Sandwich\",\n \"orderAmount\": 4.99\n },\n {\n \"id\": 2736212,\n \"email\": \"lindsay.ferguson@reqres.in\",\n \"userName\": \"Lindsay Ferguson\",\n \"productName\": \"Tuna Salad\",\n \"orderAmount\": 9.99\n },\n {\n \"id\": 6788734,\n \"email\": \"tobias.funke@reqres.in\",\n \"userName\": \"Tobias Funke\",\n \"productName\": \"Beef steak\",\n \"orderAmount\": 19.99\n }\n]", + "type": "TABLE_WIDGET", + "isLoading": false, + "parentColumnSpace": 71.5, + "parentRowSpace": 40, + "leftColumn": 0, + "rightColumn": 16, + "topRow": 1, + "bottomRow": 8, + "parentId": "qrqizehc5b", + "widgetId": "xptqefixji", + "dynamicBindings": { + } + }, + { + "isVisible": true, + "inputType": "TEXT", + "label": "", + "widgetName": "Input1", + "type": "INPUT_WIDGET", + "isLoading": false, + "parentColumnSpace": 71.5, + "parentRowSpace": 40, + "leftColumn": 0, + "rightColumn": 5, + "topRow": 10, + "bottomRow": 11, + "parentId": "qrqizehc5b", + "widgetId": "r3xvjtuhad", + "dynamicBindings": { + "defaultText": true, + "isValid": true, + "value": true + }, + "defaultText": "{{Table1.selectedRow.email}}" + }, + { + "isVisible": true, + "text": "Email", + "textStyle": "LABEL", + "textAlign": "LEFT", + "widgetName": "Text2", + "type": "TEXT_WIDGET", + "isLoading": false, + "parentColumnSpace": 71.5, + "parentRowSpace": 40, + "leftColumn": 0, + "rightColumn": 4, + "topRow": 9, + "bottomRow": 10, + "parentId": "qrqizehc5b", + "widgetId": "672gf8vm2q", + "dynamicBindings": { + "value": true + } + } + ], + "blueprint": { + "view": [ + { + "type": "TEXT_WIDGET", + "size": { + "rows": 1, + "cols": 12 + }, + "position": { + "top": 0, + "left": 0 + }, + "props": { + "text": "Form", + "textStyle": "HEADING" + } + }, + { + "type": "FORM_BUTTON_WIDGET", + "size": { + "rows": 1, + "cols": 4 + }, + "position": { + "top": 11, + "left": 12 + }, + "props": { + "text": "Submit", + "buttonStyle": "PRIMARY_BUTTON", + "disabledWhenInvalid": true, + "resetFormOnClick": true + } + }, + { + "type": "FORM_BUTTON_WIDGET", + "size": { + "rows": 1, + "cols": 4 + }, + "position": { + "top": 11, + "left": 8 + }, + "props": { + "text": "Reset", + "buttonStyle": "SECONDARY_BUTTON", + "disabledWhenInvalid": false, + "resetFormOnClick": true + } + } + ] + }, + "minHeight": 520, + "type": "CANVAS_WIDGET", + "isLoading": false, + "parentColumnSpace": 1, + "parentRowSpace": 1, + "leftColumn": 0, + "rightColumn": 518, + "topRow": 0, + "bottomRow": 520, + "parentId": "ozm6zwjk4b", + "widgetId": "qrqizehc5b" + } + ], + "blueprint": { + "view": [ + { + "type": "CANVAS_WIDGET", + "position": { + "top": 0, + "left": 0 + }, + "props": { + "containerStyle": "none", + "canExtend": false, + "detachFromLayout": true, + "children": [ + ], + "blueprint": { + "view": [ + { + "type": "TEXT_WIDGET", + "size": { + "rows": 1, + "cols": 12 + }, + "position": { + "top": 0, + "left": 0 + }, + "props": { + "text": "Form", + "textStyle": "HEADING" + } + }, + { + "type": "FORM_BUTTON_WIDGET", + "size": { + "rows": 1, + "cols": 4 + }, + "position": { + "top": 11, + "left": 12 + }, + "props": { + "text": "Submit", + "buttonStyle": "PRIMARY_BUTTON", + "disabledWhenInvalid": true, + "resetFormOnClick": true + } + }, + { + "type": "FORM_BUTTON_WIDGET", + "size": { + "rows": 1, + "cols": 4 + }, + "position": { + "top": 11, + "left": 8 + }, + "props": { + "text": "Reset", + "buttonStyle": "SECONDARY_BUTTON", + "disabledWhenInvalid": false, + "resetFormOnClick": true + } + } + ] + } + } + } + ] + }, + "type": "FORM_WIDGET", + "isLoading": false, + "parentColumnSpace": 74, + "parentRowSpace": 40, + "leftColumn": 0, + "rightColumn": 16, + "topRow": 0, + "bottomRow": 14, + "parentId": "0", + "widgetId": "ozm6zwjk4b" + } + ] + } +} + diff --git a/app/client/cypress/integration/Smoke_TestSuite/FormWidgets/FormReset_spec.js b/app/client/cypress/integration/Smoke_TestSuite/FormWidgets/FormReset_spec.js new file mode 100644 index 00000000000..eea5f26e118 --- /dev/null +++ b/app/client/cypress/integration/Smoke_TestSuite/FormWidgets/FormReset_spec.js @@ -0,0 +1,32 @@ +const dsl = require("../../../fixtures/formResetDsl.json"); +const widgetsPage = require("../../../locators/Widgets.json"); + +describe("Form reset functionality", function() { + before(() => { + cy.addDsl(dsl); + }); + + it("Resets the form ", () => { + cy.get(".tr") + .eq(2) + .click() + .should("have.class", "selected-row"); + + cy.get(widgetsPage.inputWidget + " " + "input") + .invoke("attr", "value") + .should("contain", "lindsay.ferguson@reqres.in"); + + cy.get(widgetsPage.formButtonWidget) + .contains("Reset") + .click(); + + cy.get(".tr") + .eq(2) + .click() + .should("not.have.class", "selected-row"); + + cy.get(widgetsPage.inputWidget + " " + "input") + .invoke("attr", "value") + .should("not.contain", "lindsay.ferguson@reqres.in"); + }); +}); diff --git a/app/client/cypress/integration/Smoke_TestSuite/QueryPane/PostgreDatasource_spec.js b/app/client/cypress/integration/Smoke_TestSuite/QueryPane/PostgreDatasource_spec.js index 80ea044b58a..83f696674d0 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/QueryPane/PostgreDatasource_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/QueryPane/PostgreDatasource_spec.js @@ -1,8 +1,10 @@ const queryLocators = require("../../../locators/QueryEditor.json"); const datasource = require("../../../locators/DatasourcesEditor.json"); +let datasourceName; + describe("Create a query with a postgres datasource, run, save and then delete the query", function() { - it("Create a query with a postgres datasource, run, save and then delete the query", function() { + it("Create a postgres datasource", function() { cy.NavigateToDatasourceEditor(); cy.get(datasource.PostgreSQL).click(); @@ -12,38 +14,43 @@ describe("Create a query with a postgres datasource, run, save and then delete t cy.testSaveDatasource(); - cy.NavigateToQueryEditor(); - cy.get("@createDatasource").then(httpResponse => { - const datasourceName = httpResponse.response.body.data.name; - - cy.get(".t--datasource-name") - .contains(datasourceName) - .click(); + datasourceName = httpResponse.response.body.data.name; }); - - cy.get("@getPluginForm").should( - "have.nested.property", - "response.body.responseMeta.status", - 200, - ); + }); + it("Create, runs and delete a query", () => { + cy.NavigateToQueryEditor(); + cy.get(".t--datasource-name") + .contains(datasourceName) + .click(); cy.get(queryLocators.templateMenu).click(); cy.get(".CodeMirror textarea") .first() .focus() - .type("select * from users"); + .type("select * from users limit 10"); - cy.EvaluateCurrentValue("select * from users"); + cy.EvaluateCurrentValue("select * from users limit 10"); cy.runAndDeleteQuery(); + }); + it("Create, runs and delete another query", () => { + cy.NavigateToQueryEditor(); + cy.get(".t--datasource-name") + .contains(datasourceName) + .click(); + cy.get(queryLocators.templateMenu).click(); + cy.get(".CodeMirror textarea") + .first() + .focus() + .type("select * from configs"); + cy.EvaluateCurrentValue("select * from configs"); + cy.runAndDeleteQuery(); + }); + it("Deletes a datasource", () => { cy.NavigateToDatasourceEditor(); cy.get(".t--entity-name:contains(PostgreSQL)").click(); - cy.get("@createDatasource").then(httpResponse => { - const datasourceName = httpResponse.response.body.data.name; - - cy.get(`.t--entity-name:contains(${datasourceName})`).click(); - }); + cy.get(`.t--entity-name:contains(${datasourceName})`).click(); cy.get(".t--delete-datasource").click(); cy.wait("@deleteDatasource").should( diff --git a/app/client/cypress/locators/Widgets.json b/app/client/cypress/locators/Widgets.json index 30d39512e6e..0888b882903 100644 --- a/app/client/cypress/locators/Widgets.json +++ b/app/client/cypress/locators/Widgets.json @@ -5,6 +5,7 @@ "inputPropsDataType": ".t--property-control-datatype", "inputdatatypeplaceholder": ".t--property-control-placeholder", "buttonWidget": ".t--draggable-buttonwidget", + "formButtonWidget": ".t--widget-formbuttonwidget", "textWidget": ".t--draggable-textwidget", "tableWidget": ".t--draggable-tablewidget", "tableOnRowSelected": ".t--property-control-onrowselected", @@ -37,4 +38,4 @@ "textInputval": ".t--draggable-textwidget span.t--widget-name", "textAlign": ".t--property-control-textalign", "ColumnAction": ".t--property-control-rowbutton button" -} \ No newline at end of file +} diff --git a/app/client/src/sagas/PageSagas.tsx b/app/client/src/sagas/PageSagas.tsx index 4c194915958..6e09af77de5 100644 --- a/app/client/src/sagas/PageSagas.tsx +++ b/app/client/src/sagas/PageSagas.tsx @@ -91,20 +91,18 @@ export function* fetchPageListSaga( isDefault: page.isDefault, })); yield put({ - type: ReduxActionTypes.FETCH_PAGE_LIST_SUCCESS, + type: ReduxActionTypes.SET_CURRENT_ORG_ID, payload: { - pages, - applicationId, + orgId, }, }); yield put({ - type: ReduxActionTypes.SET_CURRENT_ORG_ID, + type: ReduxActionTypes.FETCH_PAGE_LIST_SUCCESS, payload: { - orgId, + pages, + applicationId, }, }); - - return; } } catch (error) { yield put({ diff --git a/app/client/src/sagas/PluginSagas.ts b/app/client/src/sagas/PluginSagas.ts index 34c78a4c9fa..45bbf5d80cb 100644 --- a/app/client/src/sagas/PluginSagas.ts +++ b/app/client/src/sagas/PluginSagas.ts @@ -11,6 +11,9 @@ import { getCurrentOrgId } from "selectors/organizationSelectors"; function* fetchPluginsSaga() { try { const orgId = yield select(getCurrentOrgId); + if (!orgId) { + throw Error("Org id does not exist"); + } const pluginsResponse = yield call(PluginsApi.fetchPlugins, orgId); const isValid = yield validateResponse(pluginsResponse); if (isValid) { diff --git a/app/client/src/utils/AnalyticsUtil.tsx b/app/client/src/utils/AnalyticsUtil.tsx index ec55c2e7ed5..83b9bb58f69 100644 --- a/app/client/src/utils/AnalyticsUtil.tsx +++ b/app/client/src/utils/AnalyticsUtil.tsx @@ -200,9 +200,14 @@ class AnalyticsUtil { }); } if (windowDoc.hj) { - // eslint-disable-next-line @typescript-eslint/ban-ts-ignore - // @ts-ignore - window.hj("identify", userData.email, { email: userData.email }); + windowDoc.hj("identify", userData.email, { email: userData.email }); + } + if (windowDoc.smartLook) { + windowDoc.smartlook("identify", userId, { + email: userData.email, + name: userData.name, + userId: userId, + }); } }