Skip to content

Commit

Permalink
feat: MySQL & MSSQL query generator (#24516)
Browse files Browse the repository at this point in the history
Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
  • Loading branch information
berzerkeer and Aishwarya-U-R authored Jul 6, 2023
1 parent 820beae commit f24ecc2
Show file tree
Hide file tree
Showing 14 changed files with 1,623 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import oneClickBindingLocator from "../../../../../locators/OneClickBindingLocator";
import {
agHelper,
assertHelper,
dataSources,
draggableWidgets,
entityExplorer,
table,
} from "../../../../../support/Objects/ObjectsCore";
import { OneClickBinding } from "../spec_utility";

const oneClickBinding = new OneClickBinding();

// TODO: Adds two rows on click of save row will debug and fix this in a different PR - Sangeeth
describe.skip("Table widget one click binding feature", () => {
it("1.should check that queries are created and bound to table widget properly", () => {
entityExplorer.DragDropWidgetNVerify(draggableWidgets.TABLE, 400);

dataSources.CreateDataSource("MySql");

cy.get("@dsName").then((dsName) => {
entityExplorer.NavigateToSwitcher("Widgets");

entityExplorer.SelectEntityByName("Table1", "Widgets");

oneClickBinding.ChooseAndAssertForm(
`${dsName}`,
dsName,
"configs",
"configName",
);
});

agHelper.GetNClick(oneClickBindingLocator.connectData);

assertHelper.AssertNetworkStatus("@postExecute");

agHelper.Sleep(2000);

[
"id",
"configName",
"configJson",
"configVersion",
"updatedAt",
"updatedBy",
].forEach((column) => {
agHelper.AssertElementExist(table._headerCell(column));
});

agHelper.GetNClick(table._addNewRow, 0, true);

table.EditTableCell(0, 1, "One Click Config", false);

table.UpdateTableCell(0, 2, `{{}"key":"oneClick"}`);
table.UpdateTableCell(0, 3, 36);
table.UpdateTableCell(0, 4, "2023-07-03 15:30:00", false, true);

agHelper.Sleep(2000);

agHelper.GetNClick(table._saveNewRow, 0, true);

assertHelper.AssertNetworkStatus("@postExecute");

agHelper.TypeText(table._searchInput, "One Click Config");

assertHelper.AssertNetworkStatus("@postExecute");

agHelper.AssertElementExist(table._bodyCell("One Click Config"));

agHelper.Sleep(1000);

table.EditTableCell(0, 1, "Bindings", false);
table.EditTableCell(0, 4, "2023-07-03 15:30:00", false);

agHelper.Sleep(1000);

(cy as any).AssertTableRowSavable(6, 0);

(cy as any).saveTableRow(6, 0);

assertHelper.AssertNetworkStatus("@postExecute");

assertHelper.AssertNetworkStatus("@postExecute");

agHelper.Sleep(500);

agHelper.ClearTextField(table._searchInput);

agHelper.TypeText(table._searchInput, "Bindings");

assertHelper.AssertNetworkStatus("@postExecute");

agHelper.Sleep(2000);

agHelper.AssertElementExist(table._bodyCell("Bindings"));

agHelper.ClearTextField(table._searchInput);

agHelper.TypeText(table._searchInput, "One Click Config");

assertHelper.AssertNetworkStatus("@postExecute");

agHelper.Sleep(2000);

agHelper.AssertElementAbsence(table._bodyCell("One Click Config"));
});
});
108 changes: 106 additions & 2 deletions app/client/cypress/e2e/Sanity/Datasources/MsSQL_Basic_Spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import {
agHelper,
entityExplorer,
assertHelper,
propPane,
dataSources,
entityItems,
draggableWidgets,
entityExplorer,
table,
} from "../../../support/Objects/ObjectsCore";
import { Widgets } from "../../../support/Pages/DataSources";
import oneClickBindingLocator from "../../../locators/OneClickBindingLocator";
import { OneClickBinding } from "../../Regression/ClientSide/OneClickBinding/spec_utility";

const oneClickBinding = new OneClickBinding();

describe("Validate MsSQL connection & basic querying with UI flows", () => {
let dsName: any,
Expand Down Expand Up @@ -54,7 +61,8 @@ describe("Validate MsSQL connection & basic querying with UI flows", () => {
dataSources.RunQuery();

query = `CREATE TABLE Simpsons(
episode_id VARCHAR(7) NOT NULL PRIMARY KEY
id INT NOT NULL IDENTITY PRIMARY KEY
,episode_id VARCHAR(7)
,season INTEGER NOT NULL
,episode INTEGER NOT NULL
,number_in_series INTEGER NOT NULL
Expand Down Expand Up @@ -128,6 +136,102 @@ describe("Validate MsSQL connection & basic querying with UI flows", () => {
});
});

// TODO: This fails with `Invalid Object <tablename>` error. Looks like there needs to be a delay in query exectuion. Will debug and fix this in a different PR - Sangeeth
it.skip("3.One click binding - should check that queries are created and bound to table widget properly", () => {
entityExplorer.DragDropWidgetNVerify(draggableWidgets.TABLE, 450, 200);

oneClickBinding.ChooseAndAssertForm(dsName, dsName, "Simpsons", "title");

agHelper.GetNClick(oneClickBindingLocator.connectData);

assertHelper.AssertNetworkStatus("@postExecute");

agHelper.Sleep(2000);

[
"id",
"episode_id",
"season",
"episode",
"number_in_series",
"title",
"summary",
"air_date",
"episode_image",
"rating",
"votes",
].forEach((column) => {
agHelper.AssertElementExist(table._headerCell(column));
});

agHelper.GetNClick(table._addNewRow, 0, true);

table.EditTableCell(0, 1, "S01E01", false);

table.UpdateTableCell(0, 2, "1");

table.UpdateTableCell(0, 3, " 1");

table.UpdateTableCell(0, 4, " 10");

table.UpdateTableCell(0, 5, "Expanse");
table.UpdateTableCell(0, 6, "Prime");

table.UpdateTableCell(0, 7, "2016-06-22 19:10:25-07", false, true);
agHelper.GetNClick(oneClickBindingLocator.dateInput, 0, true);
agHelper.GetNClick(oneClickBindingLocator.dayViewFromDate, 0, true);
table.UpdateTableCell(0, 8, "expanse.png", false, true);
table.UpdateTableCell(0, 9, "5");
table.UpdateTableCell(0, 10, "20");

agHelper.GetNClick(table._saveNewRow, 0, true, 2000);

assertHelper.AssertNetworkStatus("@postExecute");

agHelper.TypeText(table._searchInput, "Expanse");

assertHelper.AssertNetworkStatus("@postExecute");

agHelper.AssertElementExist(table._bodyCell("Expanse"));

agHelper.Sleep(1000);

table.EditTableCell(0, 5, "Westworld");

agHelper.Sleep(1000);

(cy as any).AssertTableRowSavable(11, 0);

(cy as any).saveTableRow(11, 0);
agHelper.Sleep(2000);

assertHelper.AssertNetworkStatus("@postExecute");

assertHelper.AssertNetworkStatus("@postExecute");

agHelper.Sleep(500);

agHelper.ClearTextField(table._searchInput);

agHelper.TypeText(table._searchInput, "Westworld");

assertHelper.AssertNetworkStatus("@postExecute");

agHelper.Sleep(2000);

agHelper.AssertElementExist(table._bodyCell("Westworld"));

agHelper.ClearTextField(table._searchInput);

agHelper.TypeText(table._searchInput, "Expanse");

assertHelper.AssertNetworkStatus("@postExecute");

agHelper.Sleep(2000);

agHelper.AssertElementAbsence(table._bodyCell("Expanse"));
});

after("Verify Deletion of the datasource", () => {
entityExplorer.SelectEntityByName(dsName, "Datasources");
entityExplorer.ActionContextMenuByEntityName({
Expand Down
4 changes: 2 additions & 2 deletions app/client/cypress/support/Pages/AggregateHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1061,11 +1061,11 @@ export class AggregateHelper extends ReusableHelper {
this.Sleep(500); //for value set to settle
}

public UpdateInputValue(selector: string, value: string) {
public UpdateInputValue(selector: string, value: string, force = false) {
this.GetElement(selector)
.closest("input")
.scrollIntoView({ easing: "linear" })
.clear()
.clear({ force })
.then(($input: any) => {
if (value !== "") {
cy.wrap($input).type(value, { delay: 3 });
Expand Down
2 changes: 2 additions & 0 deletions app/client/cypress/support/Pages/Table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -606,12 +606,14 @@ export class Table {
colIndex: number,
newValue: "" | number | string,
toSaveNewValue = false,
force = false,
) {
this.agHelper.UpdateInputValue(
this._tableRow(rowIndex, colIndex, "v2") +
" " +
this._editCellEditorInput,
newValue.toString(),
force,
);
toSaveNewValue &&
this.agHelper.TypeText(this._editCellEditorInput, "{enter}", 0, true);
Expand Down
Loading

0 comments on commit f24ecc2

Please sign in to comment.