diff --git a/app/client/cypress.env.json b/app/client/cypress.env.json new file mode 100644 index 0000000000..3d66c50a8c --- /dev/null +++ b/app/client/cypress.env.json @@ -0,0 +1,4 @@ +{ + "MySQL":1, + "Mongo":1 + } \ No newline at end of file diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Binding/Bind_JSObject_Postgress_Table_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Binding/Bind_JSObject_Postgress_Table_spec.js index e4ece01ae0..02044baf66 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Binding/Bind_JSObject_Postgress_Table_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Binding/Bind_JSObject_Postgress_Table_spec.js @@ -36,12 +36,8 @@ describe("Addwidget from Query and bind with other widgets", function() { cy.intercept("/api/v1/actions/execute", { fixture: "addWidgetTable-mock", }); - cy.get(queryEditor.runQuery).click(); - cy.wait("@postExecute").should( - "have.nested.property", - "response.body.responseMeta.status", - 200, - ); + + cy.runQuery(); cy.get(queryEditor.suggestedTableWidget).click(); cy.createJSObject("return Query1.data;"); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GenerateCRUD/Mongo_CRUD_Spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GenerateCRUD/Mongo_Spec.js similarity index 83% rename from app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GenerateCRUD/Mongo_CRUD_Spec.js rename to app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GenerateCRUD/Mongo_Spec.js index fbf357cc38..d9a66da8f9 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GenerateCRUD/Mongo_CRUD_Spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GenerateCRUD/Mongo_Spec.js @@ -12,13 +12,18 @@ describe("Generate New CRUD Page Inside from Mongo as Data Source", function() { }); beforeEach(function() { - cy.startInterceptRoutesForMongo(); + if (Cypress.env("Mongo") == 0) { + cy.log("Mongo DB is not found. Using intercept"); + cy.startInterceptRoutesForMongo(); + } else cy.log("Mongo DB is found, hence using actual DB"); }); it("Add new Page and generate CRUD template using existing supported datasource", function() { cy.NavigateToDatasourceEditor(); cy.get(datasource.MongoDB).click({ force: true }); - cy.fillMongoDatasourceFormWithURI(); + + if (Cypress.env("Mongo") == 0) cy.fillMongoDatasourceFormWithURI(); + else cy.fillMongoDatasourceForm(); cy.generateUUID().then((uid) => { datasourceName = `Mongo MOCKDS ${uid}`; @@ -59,7 +64,7 @@ describe("Generate New CRUD Page Inside from Mongo as Data Source", function() { .click(); }); - cy.wait("@get_selectTableDropdownStub").should( + cy.wait("@getDatasourceStructure").should( "have.nested.property", "response.body.responseMeta.status", 200, @@ -71,17 +76,17 @@ describe("Generate New CRUD Page Inside from Mongo as Data Source", function() { .click(); cy.get(generatePage.generatePageFormSubmitBtn).click(); - cy.wait("@put_replaceLayoutCRUDStub").should( + cy.wait("@replaceLayoutWithCRUDPage").should( "have.nested.property", "response.body.responseMeta.status", 201, ); - cy.wait("@get_ActionsStub").should( + cy.wait("@getActions").should( "have.nested.property", "response.body.responseMeta.status", 200, ); - cy.wait("@post_ExecuteStub").should( + cy.wait("@postExecute").should( "have.nested.property", "response.body.responseMeta.status", 200, @@ -109,7 +114,9 @@ describe("Generate New CRUD Page Inside from Mongo as Data Source", function() { cy.contains("Connect New Datasource").click(); cy.get(datasource.MongoDB).click(); - cy.fillMongoDatasourceFormWithURI(); + + if (Cypress.env("Mongo") == 0) cy.fillMongoDatasourceFormWithURI(); + else cy.fillMongoDatasourceForm(); cy.generateUUID().then((uid) => { datasourceName = `Mongo MOCKDS ${uid}`; @@ -125,7 +132,7 @@ describe("Generate New CRUD Page Inside from Mongo as Data Source", function() { cy.get(".t--save-datasource").click(); //Generate Stud for tables dropdown values also - cy.wait("@get_selectTableDropdownStub").should( + cy.wait("@getDatasourceStructure").should( "have.nested.property", "response.body.responseMeta.status", 200, @@ -137,17 +144,17 @@ describe("Generate New CRUD Page Inside from Mongo as Data Source", function() { .click(); cy.get(generatePage.generatePageFormSubmitBtn).click(); - cy.wait("@put_replaceLayoutCRUDStub").should( + cy.wait("@replaceLayoutWithCRUDPage").should( "have.nested.property", "response.body.responseMeta.status", 201, ); - cy.wait("@get_ActionsStub").should( + cy.wait("@getActions").should( "have.nested.property", "response.body.responseMeta.status", 200, ); - cy.wait("@post_ExecuteStub").should( + cy.wait("@postExecute").should( "have.nested.property", "response.body.responseMeta.status", 200, @@ -158,9 +165,7 @@ describe("Generate New CRUD Page Inside from Mongo as Data Source", function() { it("Generate CRUD page from datasource ACTIVE section", function() { cy.NavigateToQueryEditor(); - cy.get(pages.integrationActiveTab) - .should("be.visible") - .click({ force: true }); + cy.NavigateToActiveTab(); cy.wait(1000); cy.get(datasource.datasourceCard) @@ -173,7 +178,7 @@ describe("Generate New CRUD Page Inside from Mongo as Data Source", function() { }); //Generate Stub for tables dropdown values also - cy.wait("@get_selectTableDropdownStub").should( + cy.wait("@getDatasourceStructure").should( "have.nested.property", "response.body.responseMeta.status", 200, @@ -185,17 +190,17 @@ describe("Generate New CRUD Page Inside from Mongo as Data Source", function() { .click(); cy.get(generatePage.generatePageFormSubmitBtn).click(); - cy.wait("@post_replaceLayoutCRUDStub").should( + cy.wait("@replaceLayoutWithCRUDPage").should( "have.nested.property", "response.body.responseMeta.status", 201, ); - cy.wait("@get_ActionsStub").should( + cy.wait("@getActions").should( "have.nested.property", "response.body.responseMeta.status", 200, ); - cy.wait("@post_ExecuteStub").should( + cy.wait("@postExecute").should( "have.nested.property", "response.body.responseMeta.status", 200, diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GenerateCRUD/MsSQL_CRUD_Spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GenerateCRUD/MsSQL_Spec.js similarity index 98% rename from app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GenerateCRUD/MsSQL_CRUD_Spec.js rename to app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GenerateCRUD/MsSQL_Spec.js index 7f75edbec5..251ece306f 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GenerateCRUD/MsSQL_CRUD_Spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GenerateCRUD/MsSQL_Spec.js @@ -179,9 +179,8 @@ // it.skip("Generate CRUD page from datasource ACTIVE section", function() { // cy.NavigateToQueryEditor(); -// cy.get(pages.integrationActiveTab) -// .should("be.visible") -// .click({ force: true }); +// cy.NavigateToActiveTab(); + // cy.wait(1000); // cy.get(datasource.datasourceCard) diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GenerateCRUD/MySQL_CRUD_Spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GenerateCRUD/MySQL_Spec.js similarity index 88% rename from app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GenerateCRUD/MySQL_CRUD_Spec.js rename to app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GenerateCRUD/MySQL_Spec.js index 581f627c3e..9f3fb11ba7 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GenerateCRUD/MySQL_CRUD_Spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GenerateCRUD/MySQL_Spec.js @@ -12,12 +12,14 @@ describe("Generate New CRUD Page Inside from My SQL as Data Source", function() }); beforeEach(function() { - cy.startInterceptRoutesForMySQL(); + if (Cypress.env("MySQL") == 0) { + cy.log("MySQL DB is not found. Using intercept"); + cy.startInterceptRoutesForMySQL(); + } else cy.log("MySQL DB is found, hence using actual DB"); }); it("Add new Page and generate CRUD template using existing supported datasource", function() { cy.NavigateToDatasourceEditor(); - cy.get(datasource.MySQL).click(); cy.fillMySQLDatasourceForm(); @@ -72,7 +74,7 @@ describe("Generate New CRUD Page Inside from My SQL as Data Source", function() .click(); }); - cy.wait("@selectTableDropdownStub").should( + cy.wait("@getDatasourceStructure").should( "have.nested.property", "response.body.responseMeta.status", 200, @@ -84,17 +86,17 @@ describe("Generate New CRUD Page Inside from My SQL as Data Source", function() .click(); cy.get(generatePage.generatePageFormSubmitBtn).click(); - cy.wait("@put_replaceLayoutCRUDStub").should( + cy.wait("@replaceLayoutWithCRUDPage").should( "have.nested.property", "response.body.responseMeta.status", 201, ); - cy.wait("@getActionsStub").should( + cy.wait("@getActions").should( "have.nested.property", "response.body.responseMeta.status", 200, ); - cy.wait("@postExecuteStub").should( + cy.wait("@postExecute").should( "have.nested.property", "response.body.responseMeta.status", 200, @@ -149,8 +151,8 @@ describe("Generate New CRUD Page Inside from My SQL as Data Source", function() // 200, // ); - //Generate Stud for tables dropdown values also - cy.wait("@selectTableDropdownStub").should( + //Generate Stub for tables dropdown values also + cy.wait("@getDatasourceStructure").should( "have.nested.property", "response.body.responseMeta.status", 200, @@ -162,17 +164,17 @@ describe("Generate New CRUD Page Inside from My SQL as Data Source", function() .click(); cy.get(generatePage.generatePageFormSubmitBtn).click(); - cy.wait("@put_replaceLayoutCRUDStub").should( + cy.wait("@replaceLayoutWithCRUDPage").should( "have.nested.property", "response.body.responseMeta.status", 201, ); - cy.wait("@getActionsStub").should( + cy.wait("@getActions").should( "have.nested.property", "response.body.responseMeta.status", 200, ); - cy.wait("@postExecuteStub").should( + cy.wait("@postExecute").should( "have.nested.property", "response.body.responseMeta.status", 200, @@ -183,9 +185,7 @@ describe("Generate New CRUD Page Inside from My SQL as Data Source", function() it("Generate CRUD page from datasource ACTIVE section", function() { cy.NavigateToQueryEditor(); - cy.get(pages.integrationActiveTab) - .should("be.visible") - .click({ force: true }); + cy.NavigateToActiveTab(); cy.wait(1000); cy.get(datasource.datasourceCard) @@ -198,7 +198,7 @@ describe("Generate New CRUD Page Inside from My SQL as Data Source", function() }); //Generate Stub for tables dropdown values also - cy.wait("@selectTableDropdownStub").should( + cy.wait("@getDatasourceStructure").should( "have.nested.property", "response.body.responseMeta.status", 200, @@ -210,17 +210,17 @@ describe("Generate New CRUD Page Inside from My SQL as Data Source", function() .click(); cy.get(generatePage.generatePageFormSubmitBtn).click(); - cy.wait("@post_replaceLayoutCRUDStub").should( + cy.wait("@replaceLayoutWithCRUDPage").should( "have.nested.property", "response.body.responseMeta.status", 201, ); - cy.wait("@getActionsStub").should( + cy.wait("@getActions").should( "have.nested.property", "response.body.responseMeta.status", 200, ); - cy.wait("@postExecuteStub").should( + cy.wait("@postExecute").should( "have.nested.property", "response.body.responseMeta.status", 200, diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GenerateCRUD/Postgres_CRUD_Spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GenerateCRUD/Postgres_Spec.js similarity index 95% rename from app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GenerateCRUD/Postgres_CRUD_Spec.js rename to app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GenerateCRUD/Postgres_Spec.js index f08f742019..a85cafde3d 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GenerateCRUD/Postgres_CRUD_Spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GenerateCRUD/Postgres_Spec.js @@ -20,7 +20,7 @@ describe("Generate New CRUD Page Inside from entity explorer", function() { cy.fillPostgresDatasourceForm(); cy.generateUUID().then((UUID) => { - datasourceName = `PostgresSQL CRUD Demo ${UUID}`; + datasourceName = `PostgresSQL NewPage ${UUID}`; cy.renameDatasource(datasourceName); cy.wrap(datasourceName).as("dSName"); }); @@ -94,7 +94,7 @@ describe("Generate New CRUD Page Inside from entity explorer", function() { cy.fillPostgresDatasourceForm(); cy.generateUUID().then((UUID) => { - datasourceName = `PostgresSQL CRUD Demo ${UUID}`; + datasourceName = `PostgresSQL NewPage ${UUID}`; cy.renameDatasource(datasourceName); }); @@ -136,9 +136,7 @@ describe("Generate New CRUD Page Inside from entity explorer", function() { it("Generate CRUD page from datasource ACTIVE section", function() { cy.NavigateToQueryEditor(); - cy.get(pages.integrationActiveTab) - .should("be.visible") - .click({ force: true }); + cy.NavigateToActiveTab(); cy.wait(1000); cy.get(datasource.datasourceCard) @@ -164,7 +162,7 @@ describe("Generate New CRUD Page Inside from entity explorer", function() { // skip optional search column selection. cy.get(generatePage.generatePageFormSubmitBtn).click(); - cy.wait("@generateCRUDPage").should( + cy.wait("@replaceLayoutWithCRUDPage").should( "have.nested.property", "response.body.responseMeta.status", 201, diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GenerateCRUD/S3_CRUDPage_Spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GenerateCRUD/S3_Spec.js similarity index 91% rename from app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GenerateCRUD/S3_CRUDPage_Spec.js rename to app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GenerateCRUD/S3_Spec.js index 2e8d4c5cec..975c20c7af 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GenerateCRUD/S3_CRUDPage_Spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GenerateCRUD/S3_Spec.js @@ -156,20 +156,22 @@ describe("Generate New CRUD Page Inside from entity explorer", function() { }); it("Generate CRUD page from datasource ACTIVE section", function() { - cy.NavigateToQueryEditor(); - cy.get(pages.integrationActiveTab) - .should("be.visible") - .click({ force: true }); - cy.wait(1000); + // cy.NavigateToQueryEditor(); + // cy.get(pages.integrationActiveTab) + // .should("be.visible") + // .click({ force: true }); + // cy.wait(1000); - cy.get(datasourceEditor.datasourceCard) - .contains(datasourceName) - .scrollIntoView() - .should("be.visible") - .closest(datasourceEditor.datasourceCard) - .within(() => { - cy.get(datasourceEditor.datasourceCardGeneratePageBtn).click(); - }); + // cy.get(datasourceEditor.datasourceCard) + // .contains(datasourceName) + // .scrollIntoView() + // .should("be.visible") + // .closest(datasourceEditor.datasourceCard) + // .within(() => { + // cy.get(datasourceEditor.datasourceCardGeneratePageBtn).click(); + // }); + + cy.NavigateToDSGeneratePage(datasourceName); // fetch bucket cy.wait("@put_datasources").should( diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/QueryPaneTests/SwitchDatasource_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/QueryPaneTests/SwitchDatasource_spec.js index cdb81f2401..4b20c5817d 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/QueryPaneTests/SwitchDatasource_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/QueryPaneTests/SwitchDatasource_spec.js @@ -68,12 +68,7 @@ describe("Switch datasource", function() { .focus() .type("select * from users limit 10"); - cy.get(queryLocators.runQuery).click(); - cy.wait("@postExecute").should( - "have.nested.property", - "response.body.responseMeta.status", - 200, - ); + cy.runQuery(); cy.get(".t--switch-datasource").click(); cy.contains(".t--datasource-option", mongoDatasourceName).click(); @@ -84,12 +79,7 @@ describe("Switch datasource", function() { editor[0].CodeMirror.setValue('{"find": "planets"}'); }); - cy.get(queryLocators.runQuery).click(); - cy.wait("@postExecute").should( - "have.nested.property", - "response.body.responseMeta.status", - 200, - ); + cy.runQuery(); }); it("Delete the query and datasources", function() { diff --git a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/ExplorerTests/Entity_Explorer_Datasource_Structure_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/ExplorerTests/Entity_Explorer_Datasource_Structure_spec.js index 5845adde0c..099f0f21ba 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/ExplorerTests/Entity_Explorer_Datasource_Structure_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/ExplorerTests/Entity_Explorer_Datasource_Structure_spec.js @@ -114,12 +114,7 @@ describe("Entity explorer datasource structure", function() { .focus() .type(`CREATE TABLE ${tableName} ( ID int );`); - cy.get(queryEditor.runQuery).click(); - cy.wait("@postExecute").should( - "have.nested.property", - "response.body.responseMeta.status", - 200, - ); + cy.runQuery(); cy.GlobalSearchEntity(datasourceName); cy.get("@datasourceEntityCollapse") @@ -146,13 +141,7 @@ describe("Entity explorer datasource structure", function() { .then((editor) => { editor[0].CodeMirror.setValue(`DROP TABLE ${tableName}`); cy.WaitAutoSave(); - cy.get(queryEditor.runQuery).click(); - cy.wait("@postExecute").should( - "have.nested.property", - "response.body.responseMeta.status", - 200, - ); - + cy.runQuery(); cy.get(queryEditor.queryMoreAction).click(); cy.get(queryEditor.deleteUsingContext).click(); cy.wait("@deleteAction").should( diff --git a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/AddWidgetTableAndBind_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/AddWidgetTableAndBind_spec.js index e336462874..6e95fad727 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/AddWidgetTableAndBind_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/AddWidgetTableAndBind_spec.js @@ -40,12 +40,8 @@ describe("Addwidget from Query and bind with other widgets", function() { cy.intercept("/api/v1/actions/execute", { fixture: "addWidgetTable-mock", }); - cy.get(queryEditor.runQuery).click(); - cy.wait("@postExecute").should( - "have.nested.property", - "response.body.responseMeta.status", - 200, - ); + + cy.runQuery(); cy.xpath(queryEditor.queryResponse) .first() .invoke("text") diff --git a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/AddWidget_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/AddWidget_spec.js index 8aa49b2fdb..2a554c96b0 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/AddWidget_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/AddWidget_spec.js @@ -25,12 +25,8 @@ describe("Add widget", function() { .type("select * from configs"); // eslint-disable-next-line cypress/no-unnecessary-waiting cy.WaitAutoSave(); - cy.get(queryEditor.runQuery).click(); - cy.wait("@postExecute").should( - "have.nested.property", - "response.body.responseMeta.status", - 200, - ); + + cy.runQuery(); cy.get(queryEditor.suggestedTableWidget).click(); cy.SearchEntityandOpen("Table1"); cy.isSelectRow(1); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/ConfirmRunAction_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/ConfirmRunAction_spec.js index 41a2c84133..d4a13ef738 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/ConfirmRunAction_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/ConfirmRunAction_spec.js @@ -30,7 +30,7 @@ describe("Confirm run action", function() { .find(".bp3-switch") .click(); - cy.get(queryEditor.runQuery).click(); + cy.onlyQueryRun(); cy.get(".bp3-dialog") .find("button") .contains("Confirm") diff --git a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/MongoDatasource_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/MongoDatasource_spec.js index b5ce52ffb5..6a22acc142 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/MongoDatasource_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/MongoDatasource_spec.js @@ -1,6 +1,7 @@ const queryLocators = require("../../../../locators/QueryEditor.json"); -const plugins = require("../../../../fixtures/plugins.json"); +const generatePage = require("../../../../locators/GeneratePage.json"); const datasource = require("../../../../locators/DatasourcesEditor.json"); +const queryEditor = require("../../../../locators/QueryEditor.json"); let datasourceName; @@ -9,31 +10,26 @@ describe("Create a query with a mongo datasource, run, save and then delete the cy.startRoutesForDatasource(); }); - it("Create a query with a mongo datasource, run, save and then delete the query", function() { + it("1. Creates a new Mongo datasource", function() { cy.NavigateToDatasourceEditor(); cy.get(datasource.MongoDB).click(); - cy.getPluginFormsAndCreateDatasource(); - cy.fillMongoDatasourceForm(); - cy.testSaveDatasource(); - - cy.NavigateToQueryEditor(); - - cy.get("@createDatasource").then((httpResponse) => { - datasourceName = httpResponse.response.body.data.name; - - cy.contains(".t--datasource-name", datasourceName) - .find(queryLocators.createQuery) - .click(); + cy.generateUUID().then((uid) => { + datasourceName = `Mongo CRUD ds ${uid}`; + cy.renameDatasource(datasourceName); }); + }); - cy.get("@getPluginForm").should( - "have.nested.property", - "response.body.responseMeta.status", - 200, - ); + it("2. Validate Raw query command, run, save and then delete the query", function() { + cy.NavigateToActiveDSQueryPane(datasourceName); + + // cy.get("@getPluginForm").should( + // "have.nested.property", + // "response.body.responseMeta.status", + // 200, + // ); cy.xpath('//div[contains(text(),"Find Document(s)")]').click({ force: true, @@ -49,11 +45,200 @@ describe("Create a query with a mongo datasource, run, save and then delete the cy.EvaluateCurrentValue(`{"find": "listingsAndReviews","limit": 10}`); cy.runAndDeleteQuery(); + }); - cy.get("@createDatasource").then((httpResponse) => { - datasourceName = httpResponse.response.body.data.name; + it("3. Validate Find documents command & Run and then delete the query", function() { + //datasourceName = 'Mongo CRUD ds 09e54713' + cy.NavigateToActiveDSQueryPane(datasourceName); - cy.deleteDatasource(datasourceName); + //cy.xpath(queryLocators.findDocs).should("exist"); //Verifying update is success or below line + cy.expect(queryLocators.findDocs).to.exist; + + cy.xpath(queryLocators.collectionField).type("listingsAndReviews"); + cy.EvaluateCurrentValue("listingsAndReviews"); + cy.runQuery(); //exeute actions - 200 response is verified in this method + cy.xpath(queryLocators.countText).should("have.text", "10 Records"); + + cy.xpath(queryLocators.queryField).type(`{{}beds : {{}$lte: 2}}`); + cy.EvaluateCurrentValue("{beds : {$lte: 2}}"); + cy.runQuery(); //exeute actions - 200 response is verified in this method + cy.xpath(queryLocators.countText).should("have.text", "10 Records"); + + cy.xpath(queryLocators.sortField).type("{{}number_of_reviews: -1}"); //sort descending + cy.EvaluateCurrentValue("{number_of_reviews: -1}"); + cy.runQuery(); //exeute actions - 200 response is verified in this method + cy.xpath(queryLocators.countText).should("have.text", "10 Records"); + + cy.xpath(queryLocators.projectionField).type( + "{{}house_rules: 1, description:1}", + ); //Projection field + cy.EvaluateCurrentValue("{house_rules: 1, description:1}"); + cy.runQuery(); //exeute actions - 200 response is verified in this method + + cy.xpath(queryLocators.limitField).type("5"); //Projection field + cy.EvaluateCurrentValue("5"); + cy.onlyQueryRun(); + cy.wait("@postExecute").then(({ response }) => { + expect(response.body.data.body[0].house_rules).to.contains( + "There will be a packet with house rules in the unit", + "Response is not as expected for Aggregate commmand", + ); }); + + cy.xpath(queryLocators.countText).should("have.text", "5 Records"); + cy.xpath(queryLocators.skipField).type("2"); //Skip field + cy.EvaluateCurrentValue("2"); + cy.onlyQueryRun(); + + cy.wait("@postExecute").then(({ response }) => { + expect(response.body.data.body[0].house_rules).to.contains( + "Airbnb provides recommended to know the following information", + "Response is not as expected for Aggregate commmand", + ); + }); + cy.xpath(queryLocators.countText).should("have.text", "5 Records"); + + cy.deleteQueryUsingContext(); + }); + + it("4. Validate Count command & Run and then delete the query", function() { + cy.NavigateToActiveDSQueryPane(datasourceName); + + cy.xpath('//div[contains(text(),"Find Document(s)")]').click({ + force: true, + }); + cy.xpath('//div[contains(text(),"Count")]').click({ force: true }); + + cy.xpath(queryLocators.collectionField).type("listingsAndReviews"); + cy.EvaluateCurrentValue("listingsAndReviews"); + cy.runQuery(); + + cy.xpath(queryLocators.queryField).type(`{{}beds : {{}$lte: 2}}`); + cy.EvaluateCurrentValue("{beds : {$lte: 2}}"); + cy.runQuery(); //exeute actions - 200 response is verified in this method + + cy.deleteQueryUsingContext(); + }); + + it("5. Validate Distinct command & Run and then delete the query", function() { + cy.NavigateToActiveDSQueryPane(datasourceName); + + cy.xpath('//div[contains(text(),"Find Document(s)")]').click({ + force: true, + }); + cy.xpath('//div[contains(text(),"Distinct")]').click({ force: true }); + + cy.xpath(queryLocators.collectionField).type("listingsAndReviews"); + cy.EvaluateCurrentValue("listingsAndReviews"); + + cy.xpath(queryLocators.queryField).type(`{{}beds : {{}$lte: 2}}`); + cy.EvaluateCurrentValue("{beds : {$lte: 2}}"); + + cy.xpath(queryLocators.keyField).type(`property_type`); + cy.EvaluateCurrentValue("property_type"); + //cy.runQuery(); //exeute actions - 200 response is verified in this method + + cy.onlyQueryRun(); + cy.wait("@postExecute").then(({ request, response }) => { + expect(response.body.data.body.values[0]).to.eq( + "Aparthotel", + "Response is not as expected for Distint commmand", + ); + }); + + cy.deleteQueryUsingContext(); + }); + + it("6. Validate Aggregate command & Run and then delete the query", function() { + cy.NavigateToActiveDSQueryPane(datasourceName); + + cy.xpath('//div[contains(text(),"Find Document(s)")]').click({ + force: true, + }); + cy.xpath('//div[contains(text(),"Aggregate")]').click({ force: true }); + + cy.xpath(queryLocators.collectionField).type("listingsAndReviews"); + cy.EvaluateCurrentValue("listingsAndReviews"); + + cy.xpath(queryLocators.arrayOfPipelinesField).type( + `[{{} $project: {{} count: {{} $size:"$amenities" }}}]`, + ); + cy.EvaluateCurrentValue('[{ $project: { count: { $size:"$amenities" }}}]'); + + //cy.runQuery(); //exeute actions - 200 response is verified in this method + + cy.onlyQueryRun(); + cy.wait("@postExecute").then(({ request, response }) => { + // cy.log(request.method + ": is req.method") + //expect(request.method).to.equal('POST') + expect(response.body.data.body[0].count).to.eq( + 12, + "Response is not as expected for Aggregate commmand", + ); + // it is good practice to add message to the assertion + // expect(req, 'has duration in ms').to.have.property('duration').and.be.a('number') + }); + + cy.deleteQueryUsingContext(); + }); + + it("7. Verify generation of NewPage from collection [Select]", function() { + //Verifying Select from UI + cy.NavigateToDSGeneratePage(datasourceName); + cy.get(generatePage.selectTableDropdown).click(); + cy.get(generatePage.dropdownOption) + .first() + // .contains("listingsAndReviews") + // .scrollIntoView() + // .should("be.visible") + .click(); + + cy.get(generatePage.generatePageFormSubmitBtn).click(); + + cy.wait("@replaceLayoutWithCRUDPage").should( + "have.nested.property", + "response.body.responseMeta.status", + 201, + ); + + cy.wait("@getActions"); + + cy.wait("@postExecute").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); //This verifies the Select on the table, ie page is created fine + + cy.ClickGotIt(); + }); + + it("8. Validate Deletion of the Newly Created Page", () => { + cy.NavigateToQueryEditor(); + cy.NavigateToActiveTab(); + cy.contains(".t--datasource-name", datasourceName).click(); + cy.get(".t--delete-datasource").click(); + + cy.wait("@deleteDatasource").should( + "have.nested.property", + "response.body.responseMeta.status", + 409, + ); + + cy.xpath(generatePage.mongonewPageEntityMenu) + .first() + .click({ force: true }); + cy.xpath(generatePage.deleteMenuItem).click(); + }); + + it("9. Delete the datasource after NewPage deletion is success", () => { + cy.NavigateToQueryEditor(); + cy.NavigateToActiveTab(); + cy.contains(".t--datasource-name", datasourceName).click(); + cy.get(".t--delete-datasource").click(); + cy.wait("@deleteDatasource").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); }); }); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/PostgreDatasource_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/PostgreDatasource_spec.js deleted file mode 100644 index e3cb3ea96c..0000000000 --- a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/PostgreDatasource_spec.js +++ /dev/null @@ -1,72 +0,0 @@ -const queryLocators = require("../../../../locators/QueryEditor.json"); -const datasource = require("../../../../locators/DatasourcesEditor.json"); -const pages = require("../../../../locators/Pages.json"); - -let datasourceName; - -describe("Create a query with a postgres datasource, run, save and then delete the query", function() { - beforeEach(() => { - cy.startRoutesForDatasource(); - }); - - it("Create a postgres datasource", function() { - cy.NavigateToDatasourceEditor(); - cy.get(datasource.PostgreSQL).click(); - - cy.getPluginFormsAndCreateDatasource(); - - cy.fillPostgresDatasourceForm(); - - cy.testSaveDatasource(); - - cy.get("@createDatasource").then((httpResponse) => { - datasourceName = httpResponse.response.body.data.name; - }); - }); - it("Create, runs and delete a query", () => { - cy.NavigateToQueryEditor(); - cy.contains(".t--datasource-name", datasourceName) - .find(queryLocators.createQuery) - .click(); - - cy.get(queryLocators.templateMenu).click(); - cy.get(".CodeMirror textarea") - .first() - .focus() - .type("select * from users limit 10"); - - cy.EvaluateCurrentValue("select * from users limit 10"); - cy.runAndDeleteQuery(); - }); - it("Create, runs and delete another query", () => { - cy.NavigateToQueryEditor(); - cy.get(pages.integrationActiveTab) - .should("be.visible") - .click({ force: true }); - cy.contains(".t--datasource-name", datasourceName) - .find(queryLocators.createQuery) - .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.NavigateToQueryEditor(); - cy.get(pages.integrationActiveTab) - .should("be.visible") - .click({ force: true }); - cy.contains(".t--datasource-name", datasourceName).click(); - - cy.get(".t--delete-datasource").click(); - cy.wait("@deleteDatasource").should( - "have.nested.property", - "response.body.responseMeta.status", - 200, - ); - }); -}); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/PostgresCRUDOps_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/PostgresCRUDOps_spec.js new file mode 100644 index 0000000000..b212b7b42a --- /dev/null +++ b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/PostgresCRUDOps_spec.js @@ -0,0 +1,262 @@ +const queryLocators = require("../../../../locators/QueryEditor.json"); +const datasource = require("../../../../locators/DatasourcesEditor.json"); +const generatePage = require("../../../../locators/GeneratePage.json"); +let datasourceName; + +describe("Validate CRUD queries for Postgres along with UI flow verifications", function() { + beforeEach(() => { + cy.startRoutesForDatasource(); + }); + + it("1. Creates a new Postgres datasource", function() { + cy.NavigateToDatasourceEditor(); + cy.get(datasource.PostgreSQL).click(); + + cy.getPluginFormsAndCreateDatasource(); + + cy.fillPostgresDatasourceForm(); + + cy.testSaveDatasource(); + + cy.generateUUID().then((uid) => { + datasourceName = `Postgres CRUD ds ${uid}`; + cy.renameDatasource(datasourceName); + }); + + // cy.get("@createDatasource").then((httpResponse) => { + // datasourceName = httpResponse.response.body.data.name; + // }); + }); + + it("2. Create & runs existing table data and deletes the query", () => { + cy.NavigateToActiveDSQueryPane(datasourceName); + cy.get(queryLocators.templateMenu).click(); + cy.get(".CodeMirror textarea") + .first() + .focus() + .type("select * from users limit 10"); + + cy.EvaluateCurrentValue("select * from users limit 10"); + cy.runAndDeleteQuery(); + }); + + it("3. Create new CRUD Table and populate", () => { + cy.NavigateToActiveDSQueryPane(datasourceName); + cy.get(queryLocators.templateMenu).click(); + + let tableCreateQuery = `CREATE TABLE public.users_crud ( + id integer NOT NULL, + name character varying, + status character varying, + gender character varying, + email character varying, + address text, + role text); + + insert into public.users_crud (id, name, status, gender, email, address, role) values + (1, 'CRUD User1', 'PENDING', 'Male', 'cruduser1@ihg.com', '19624 Scofield Way', 'User'), + (2, 'CRUD User2', 'IN PROGRESS', 'Male','cruduser2@ihg.com', '19624 Scofield Way', 'Editor'), + (3, 'CRUD User3', 'APPROVED', 'Female','cruduser3@ihg.com', '19624 Scofield Way', 'Admin'), + (4, 'CRUD User4', 'PENDING', 'Male', 'cruduser4@ihg.com', '19624 Scofield Way', 'User'), + (5, 'CRUD User5', 'IN PROGRESS', 'Male','cruduser5@ihg.com', '19624 Scofield Way', 'Editor'), + (6, 'CRUD User6', 'APPROVED', 'Female','cruduser6@ihg.com', '19624 Scofield Way', 'Admin'), + (7, 'CRUD User7', 'PENDING', 'Male', 'cruduser7@ihg.com', '19624 Scofield Way', 'User'), + (8, 'CRUD User8', 'IN PROGRESS', 'Male','cruduser8@ihg.com', '19624 Scofield Way', 'Editor'), + (9, 'CRUD User9', 'APPROVED', 'Female','cruduser9@ihg.com', '19624 Scofield Way', 'Admin'), + (10, 'CRUD User10', 'PENDING', 'Male', 'cruduser10@ihg.com', '19624 Scofield Way', 'User'), + (11, 'CRUD User11', 'IN PROGRESS', 'Male','cruduser11@ihg.com', '19624 Scofield Way', 'Editor'), + (12, 'CRUD User12', 'APPROVED', 'Female','cruduser12@ihg.com', '19624 Scofield Way', 'Admin'), + (13, 'CRUD User13', 'PENDING', 'Male', 'cruduser13@ihg.com', '19624 Scofield Way', 'User'), + (14, 'CRUD User14', 'IN PROGRESS', 'Male','cruduser14@ihg.com', '19624 Scofield Way', 'Editor'), + (15, 'CRUD User15', 'APPROVED', 'Female','cruduser15@ihg.com', '19624 Scofield Way', 'Admin'), + (16, 'CRUD User16', 'PENDING', 'Male', 'cruduser16@ihg.com', '19624 Scofield Way', 'User'), + (17, 'CRUD User17', 'IN PROGRESS', 'Male','cruduser17@ihg.com', '19624 Scofield Way', 'Editor'), + (18, 'CRUD User18', 'APPROVED', 'Female','cruduser18@ihg.com', '19624 Scofield Way', 'Admin'), + (19, 'CRUD User19', 'PENDING', 'Male', 'cruduser19@ihg.com', '19624 Scofield Way', 'User'), + (20, 'CRUD User20', 'IN PROGRESS', 'Male','cruduser20@ihg.com', '19624 Scofield Way', 'Editor'), + (21, 'CRUD User21', 'APPROVED', 'Female','cruduser21@ihg.com', '19624 Scofield Way', 'Admin'), + (22, 'CRUD User22', 'PENDING', 'Male', 'cruduser22@ihg.com', '19624 Scofield Way', 'User'), + (23, 'CRUD User23', 'IN PROGRESS', 'Male','cruduser23@ihg.com', '19624 Scofield Way', 'Editor'), + (24, 'CRUD User24', 'APPROVED', 'Female','cruduser24@ihg.com', '19624 Scofield Way', 'Admin'), + (25, 'CRUD User25', 'PENDING', 'Male', 'cruduser25@ihg.com', '19624 Scofield Way', 'User'), + (26, 'CRUD User26', 'IN PROGRESS', 'Male','cruduser26@ihg.com', '19624 Scofield Way', 'Editor'), + (27, 'CRUD User27', 'APPROVED', 'Female','cruduser27@ihg.com', '19624 Scofield Way', 'Admin'), + (28, 'CRUD User28', 'PENDING', 'Male', 'cruduser28@ihg.com', '19624 Scofield Way', 'User'), + (29, 'CRUD User29', 'IN PROGRESS', 'Male','cruduser29@ihg.com', '19624 Scofield Way', 'Editor'), + (30, 'CRUD User30', 'APPROVED', 'Female','cruduser30@ihg.com', '19624 Scofield Way', 'Admin');`; + + cy.get(".CodeMirror textarea").paste(tableCreateQuery); + cy.get(".CodeMirror textarea").focus(); + cy.EvaluateCurrentValue(tableCreateQuery); + cy.runAndDeleteQuery(); //exeute actions - 200 response is verified in this method + }); + + it("4. Validate Select record from Postgress datasource", () => { + let selectQuery = "select * from public.users_crud"; + cy.NavigateToActiveDSQueryPane(datasourceName); + cy.xpath(queryLocators.querySelect).click(); + cy.get(queryLocators.codeTextArea).type("{cmd+a}{del}"); + cy.get(queryLocators.codeTextArea).paste(selectQuery); + + cy.EvaluateCurrentValue(selectQuery); + cy.runAndDeleteQuery(); //exeute actions - 200 response is verified in this method + }); + + it("5. Validate Create/Insert record into Postgress datasource", () => { + let insertQuery = + "INSERT INTO public.users_crud (id, name, gender, email) VALUES (31, 'CRUD User11','Male','cruduser31@ihg.com');"; + cy.NavigateToActiveDSQueryPane(datasourceName); + cy.xpath(queryLocators.queryCreate).click(); + cy.get(queryLocators.codeTextArea).type("{cmd+a}{del}"); + //.type("{selectall}{del}"); + + cy.get(queryLocators.codeTextArea).paste(insertQuery); + cy.EvaluateCurrentValue(insertQuery); + cy.runAndDeleteQuery(); + }); + + it("6. Validate Update record into Postgress datasource", () => { + let updateQuery = + "UPDATE public.users_crud SET status = 'PENDING', role = 'Viewer' WHERE id = 31;"; + cy.NavigateToActiveDSQueryPane(datasourceName); + cy.xpath(queryLocators.queryUpdate).click(); + cy.get(queryLocators.codeTextArea).type("{cmd+a}{del}"); + cy.get(queryLocators.codeTextArea).paste(updateQuery); + + cy.EvaluateCurrentValue(updateQuery); + cy.runAndDeleteQuery(); + }); + + it("7. Validate Delete record from Postgress datasource", () => { + let deleteQuery = "DELETE FROM public.users_crud WHERE id = 31;"; + cy.NavigateToActiveDSQueryPane(datasourceName); + cy.xpath(queryLocators.queryDelete).click(); + cy.get(queryLocators.codeTextArea).type("{cmd+a}{del}"); + cy.get(queryLocators.codeTextArea).paste(deleteQuery); + + cy.EvaluateCurrentValue(deleteQuery); + cy.runAndDeleteQuery(); + }); + + it("8. Verify generation of NewPage from New table & perform Add/Update/Delete operations", function() { + //Verifying Select from UI + cy.NavigateToDSGeneratePage(datasourceName); + cy.get(generatePage.selectTableDropdown).click(); + cy.get(generatePage.dropdownOption) + .contains("public.users_crud") + .scrollIntoView() + .should("be.visible") + .click(); + + cy.get(generatePage.generatePageFormSubmitBtn).click(); + + cy.wait("@replaceLayoutWithCRUDPage").should( + "have.nested.property", + "response.body.responseMeta.status", + 201, + ); + + cy.wait("@getActions"); + + cy.wait("@postExecute").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); //This verifies the Select on the table, ie page is created fine + + cy.ClickGotIt(); + + //Verifying Update from UI + cy.xpath(generatePage.selectRowinTable).click(); + cy.xpath(generatePage.currentStatusField) + .clear() + .click() + .type("APPROVED"); + cy.get(generatePage.updateBtn) + .closest("button") + .click() + .wait(2000); //Wait for update call to be success + + cy.wait("@postExecute").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); //This verifies the Update on the table + + //.should("have.nested.property", "response.body.data.request.requestParams.Query.value",); + + cy.xpath(generatePage.selectRowinTable).click(); + cy.xpath(generatePage.currentStatusField).should("have.value", "APPROVED"); //Verifying update is success + + //verifying Insert from UI + cy.xpath(generatePage.addRowIcon).click(); + cy.xpath(generatePage.idField).type("31"); + cy.xpath(generatePage.nameField).type("CRUD User31"); + cy.xpath(generatePage.statusField).type("REJECTED"); + cy.xpath(generatePage.genderField).type("Male"); + cy.xpath(generatePage.emailField) + .type("curduser31@ihg.com") + .wait(1000); //Waiting for Submit button to get enabled + cy.get(generatePage.submitBtn).click(); + + cy.xpath(generatePage.sortByDropdown).click(); //Sorting by descending to verify newly added record - also sorting is verified + cy.xpath(generatePage.descending).click(); + cy.xpath(generatePage.currentNameField).should("have.value", "CRUD User31"); //Verifying Addition is success + + //Verifying Delete from UI + cy.xpath(generatePage.deleteofSelectedRow).click(); + cy.get(generatePage.confirmBtn) + .click() + .wait(2000); //Wait for update call to be success + + cy.wait("@postExecute").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); + + cy.xpath(generatePage.currentNameField).should("have.value", "CRUD User30"); //Verifying Deletion of id # 31 is success + }); + + it("9. Validate Deletion of the Newly Created Page", () => { + cy.NavigateToQueryEditor(); + cy.NavigateToActiveTab(); + cy.contains(".t--datasource-name", datasourceName).click(); + cy.get(".t--delete-datasource").click(); + + cy.wait("@deleteDatasource").should( + "have.nested.property", + "response.body.responseMeta.status", + 409, + ); + + cy.xpath(generatePage.postgressnewPageEntityMenu) + .first() + .click({ force: true }); + cy.xpath(generatePage.deleteMenuItem).click(); + }); + + it("10. Validate Drop of the Newly Created Table from Postgress datasource", () => { + let deleteTblQuery = "DROP TABLE public.users_crud;"; + cy.NavigateToActiveDSQueryPane(datasourceName); + cy.xpath(queryLocators.queryDelete).click(); + cy.get(queryLocators.codeTextArea).type("{cmd+a}{del}"); + + cy.get(queryLocators.codeTextArea).paste(deleteTblQuery); + + cy.EvaluateCurrentValue(deleteTblQuery); + cy.runAndDeleteQuery(); + }); + + it("11. Deletes the datasource", () => { + cy.NavigateToQueryEditor(); + cy.NavigateToActiveTab(); + cy.contains(".t--datasource-name", datasourceName).click(); + cy.get(".t--delete-datasource").click(); + cy.wait("@deleteDatasource").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); + }); +}); diff --git a/app/client/cypress/locators/GeneratePage.json b/app/client/cypress/locators/GeneratePage.json index 68708b082b..5e56c9221a 100644 --- a/app/client/cypress/locators/GeneratePage.json +++ b/app/client/cypress/locators/GeneratePage.json @@ -2,9 +2,29 @@ "buildFromScratchActionCard": ".t--BuildFromScratch", "generateCRUDPageActionCard": ".t--GenerateCRUDPage", "selectDatasourceDropdown": "[data-cy=t--datasource-dropdown]", - "datasourceDropdownOption":"[data-cy=t--datasource-dropdown-option]", - "selectTableDropdown":"[data-cy=t--table-dropdown]", + "datasourceDropdownOption": "[data-cy=t--datasource-dropdown-option]", + "selectTableDropdown": "[data-cy=t--table-dropdown]", "dropdownOption": ".bp3-popover-content .t--dropdown-option", - "selectSearchColumnDropdown":"[data-cy=t--searchColumn-dropdown]", - "generatePageFormSubmitBtn":"[data-cy=t--generate-page-form-submit]" + "selectSearchColumnDropdown": "[data-cy=t--searchColumn-dropdown]", + "generatePageFormSubmitBtn": "[data-cy=t--generate-page-form-submit]", + "selectRowinTable": "//div[text()='CRUD User2']/ancestor::div[contains(@class,'tr')]", + "currentStatusField": "//div[@type='FORM_WIDGET']//span[text()='status:']//ancestor::div[contains(@class,'t--widget-textwidget')]/preceding-sibling::div[contains(@class, 't--widget-inputwidget')][1]//input", + "updateBtn": "span:contains('Update')", + "addRowIcon": "//span[@icon='add']/parent::button", + "idField": "//input[@placeholder='id']", + "nameField": "//input[@placeholder='name']", + "statusField": "//input[@placeholder='status']", + "genderField": "//input[@placeholder='gender']", + "emailField": "//input[@placeholder='email']", + "submitBtn": "span:contains('Submit')", + "sortByDropdown": "//div[@type='CANVAS_WIDGET']/div[contains(@class, 't--widget-dropdownwidget')][2]", + "ascending": "//div[text()='Ascending']", + "descending": "//div[text()='Descending']", + "currentNameField": "//div[@type='FORM_WIDGET']//span[text()='name:']//ancestor::div[contains(@class,'t--widget-textwidget')]/preceding-sibling::div[contains(@class, 't--widget-inputwidget')][1]//input", + "deleteofSelectedRow": "//div[@class='tr selected-row']//span[text()='Delete']", + "confirmBtn": "span:contains('Confirm')", + "postgressnewPageEntityMenu": "//div[text()='Public.users_crud']/ancestor::div[contains(@class, 't--entity page')]//span[contains(@class, 'entity-context-menu')]//div", + "deleteMenuItem": "//div[text()='Delete']/parent::a[contains(@class, 'single-select')]", + "mongonewPageEntityMenu": "//div[text()='ListingsAndReviews']/ancestor::div[contains(@class, 't--entity page')]//span[contains(@class, 'entity-context-menu')]//div" + } \ No newline at end of file diff --git a/app/client/cypress/locators/QueryEditor.json b/app/client/cypress/locators/QueryEditor.json index 3af81961ed..c22d6f99e6 100644 --- a/app/client/cypress/locators/QueryEditor.json +++ b/app/client/cypress/locators/QueryEditor.json @@ -2,7 +2,7 @@ "addNewQueryBtn": ".dbqueries .t--entity-add-btn", "queryEditorIcon": ".t--nav-link-query-editor", "templateMenu": ".t--template-menu", - "runQuery": ".t--run-query", + "runQuery": "//span[text()='Run']/parent::button", "saveQuery": ".t--save-query", "deleteQuery": ".t--delete-query", "queryMoreAction": ".t--more-action-menu", @@ -16,5 +16,24 @@ "query": "li:contains('Query')", "switch": ".t--form-control-SWITCH input", "suggestedTableWidget": ".t--suggested-widget-TABLE_WIDGET", - "queryResponse": "(//div[@class='table']//div[@class='tr'])[3]//div[@class='td']" -} \ No newline at end of file + "queryResponse": "(//div[@class='table']//div[@class='tr'])[3]//div[@class='td']", + "querySelect": "//div[contains(@class, 't--template-menu')]//div[text()='Select']", + "queryCreate": "//div[contains(@class, 't--template-menu')]//div[text()='Create']", + "queryUpdate": "//div[contains(@class, 't--template-menu')]//div[text()='Update']", + "queryDelete": "//div[contains(@class, 't--template-menu')]//div[text()='Delete']", + "codeTextArea": "div.CodeMirror-code", + "findDocs" : "//div[text()='Find Document(s)']", + "collectionField": "//p[text()='Collection']/following-sibling::div//div[@class='CodeMirror-code']", + "queryField": "//p[text()='Query']/following-sibling::div//div[@class='CodeMirror-code']", + "sortField": "//p[text()='Sort']/following-sibling::div//div[@class='CodeMirror-code']", + "projectionField": "//p[text()='Projection']/following-sibling::div//div[@class='CodeMirror-code']", + "limitField": "//p[text()='Limit']/following-sibling::div//div[@class='CodeMirror-code']", + "skipField": "//p[text()='Skip']/following-sibling::div//div[@class='CodeMirror-code']", + "keyField": "//p[text()='Key']/following-sibling::div//div[@class='CodeMirror-code']", + "arrayOfPipelinesField": "//p[text()='Array of Pipelines']/following-sibling::div//div[@class='CodeMirror-code']", + "countText": "//span[contains(@class, 'cs-text')][text()='Result:']/span" + + + + +} diff --git a/app/client/cypress/locators/explorerlocators.json b/app/client/cypress/locators/explorerlocators.json index bb5bb9b0ef..77b1d2a725 100644 --- a/app/client/cypress/locators/explorerlocators.json +++ b/app/client/cypress/locators/explorerlocators.json @@ -22,12 +22,13 @@ "property": ".language-appsmith-binding", "editNameField": ".editing input", "editEntityField": ".bp3-editable-text-input", - "entity":".t--entity-name", - "addWidget":".widgets .t--entity-add-btn", - "dropHere":"#canvas-dragging-0", - "closeWidgets":".t--close-widgets-sidebar", + "entity": ".t--entity-name", + "addWidget": ".widgets .t--entity-add-btn", + "dropHere": "#canvas-dragging-0", + "closeWidgets": ".t--close-widgets-sidebar", "addDBQueryEntity": ".datasources .t--entity-add-btn", "editEntity": ".t--entity-name input", "explorerSwitchId": "#switcher--explorer", - "widgetSwitchId": "#switcher--widgets" + "widgetSwitchId": "#switcher--widgets", + "activeTab": "span:contains('Active')" } \ No newline at end of file diff --git a/app/client/cypress/support/commands.js b/app/client/cypress/support/commands.js index 5fd55122ba..034d02dc61 100644 --- a/app/client/cypress/support/commands.js +++ b/app/client/cypress/support/commands.js @@ -25,6 +25,7 @@ const datasource = require("../locators/DatasourcesEditor.json"); const viewWidgetsPage = require("../locators/ViewWidgets.json"); const generatePage = require("../locators/GeneratePage.json"); const jsEditorLocators = require("../locators/JSEditor.json"); +const queryLocators = require("../locators/QueryEditor.json"); const welcomePage = require("../locators/welcomePage.json"); let pageidcopy = " "; @@ -2072,7 +2073,43 @@ Cypress.Commands.add("NavigateToDatasourceEditor", () => { }); Cypress.Commands.add("NavigateToQueryEditor", () => { - cy.get(explorer.addDBQueryEntity).click({ force: true }); + cy.get(explorer.addDBQueryEntity) + .first() + .click({ force: true }); +}); + +Cypress.Commands.add("NavigateToActiveTab", () => { + cy.get(explorer.activeTab).click({ force: true }); + + // cy.get(pages.integrationActiveTab) + // .should("be.visible") + // .click({ force: true }); +}); + +Cypress.Commands.add("NavigateToActiveDSQueryPane", (datasourceName) => { + cy.NavigateToQueryEditor(); + cy.NavigateToActiveTab(); + cy.contains(".t--datasource-name", datasourceName) + .find(queryLocators.createQuery) + .click(); +}); + +Cypress.Commands.add("NavigateToDSGeneratePage", (datasourceName) => { + cy.NavigateToQueryEditor(); + cy.NavigateToActiveTab(); + + cy.get(datasource.datasourceCard) + .contains(datasourceName) + .scrollIntoView() + .should("be.visible") + .closest(datasource.datasourceCard) + .within(() => { + cy.get(datasource.datasourceCardGeneratePageBtn).click(); + }); +}); + +Cypress.Commands.add("ClickGotIt", () => { + cy.get("span:contains('GOT IT')").click(); }); Cypress.Commands.add("testDatasource", () => { @@ -2325,7 +2362,9 @@ Cypress.Commands.add("deleteDatasource", (datasourceName) => { }); Cypress.Commands.add("runQuery", () => { - cy.get(queryEditor.runQuery).click({ force: true }); + cy.xpath(queryEditor.runQuery) + .last() + .click(); cy.wait("@postExecute").should( "have.nested.property", "response.body.responseMeta.status", @@ -2333,6 +2372,12 @@ Cypress.Commands.add("runQuery", () => { ); }); +Cypress.Commands.add("onlyQueryRun", () => { + cy.xpath(queryEditor.runQuery) + .last() + .click(); +}); + Cypress.Commands.add("hoverAndClick", () => { cy.xpath(apiwidget.popover) .last() @@ -2374,14 +2419,7 @@ Cypress.Commands.add("deleteDataSource", () => { ); }); -Cypress.Commands.add("runAndDeleteQuery", () => { - cy.get(queryEditor.runQuery).click(); - cy.wait("@postExecute").should( - "have.nested.property", - "response.body.responseMeta.status", - 200, - ); - +Cypress.Commands.add("deleteQueryUsingContext", () => { cy.get(queryEditor.queryMoreAction).click(); cy.get(queryEditor.deleteUsingContext).click(); cy.wait("@deleteAction").should( @@ -2391,6 +2429,11 @@ Cypress.Commands.add("runAndDeleteQuery", () => { ); }); +Cypress.Commands.add("runAndDeleteQuery", () => { + cy.runQuery(); + cy.deleteQueryUsingContext(); +}); + Cypress.Commands.add("dragAndDropToCanvas", (widgetType, { x, y }) => { const selector = `.t--widget-card-draggable-${widgetType}`; cy.wait(500); @@ -2699,6 +2742,7 @@ Cypress.Commands.add("startRoutesForDatasource", () => { Cypress.Commands.add("startServerAndRoutes", () => { //To update route with intercept after working on alias wrt wait and alias cy.server(); + cy.route("POST", "/api/v1/datasources/test").as("testDatasource"); cy.route("GET", "/api/v1/applications/new").as("applications"); cy.route("GET", "/api/v1/users/profile").as("getUser"); cy.route("GET", "/api/v1/plugins").as("getPlugins"); @@ -2790,7 +2834,7 @@ Cypress.Commands.add("startServerAndRoutes", () => { cy.route("POST", "/api/v1/collections/actions").as("createNewJSCollection"); cy.route("DELETE", "/api/v1/collections/actions/*").as("deleteJSCollection"); - + cy.route("POST", "/api/v1/pages/crud-page").as("replaceLayoutWithCRUDPage"); cy.intercept("POST", "/api/v1/users/super").as("createSuperUser"); }); @@ -2963,7 +3007,9 @@ Cypress.Commands.add("skipGenerateCRUDPage", () => { }); Cypress.Commands.add("fillAmazonS3DatasourceForm", () => { - cy.get(datasourceEditor.projectID).type(Cypress.env("S3_ACCESS_KEY")); + cy.get(datasourceEditor.projectID) + .clear() + .type(Cypress.env("S3_ACCESS_KEY")); cy.get(datasourceEditor.serviceAccCredential) .clear() .type(Cypress.env("S3_SECRET_KEY")); @@ -2972,9 +3018,7 @@ Cypress.Commands.add("fillAmazonS3DatasourceForm", () => { Cypress.Commands.add("createAmazonS3Datasource", () => { cy.NavigateToDatasourceEditor(); cy.get(datasourceEditor.AmazonS3).click(); - cy.fillAmazonS3DatasourceForm(); - cy.testSaveDatasource(); }); @@ -2992,84 +3036,6 @@ Cypress.Commands.add("createJSObject", (JSCode) => { .click(); }); -//Generate CRUD page methods: - -Cypress.Commands.add("fillMongoDatasourceFormWithURI", () => { - cy.xpath(datasourceEditor["mongoUriDropdown"]) - .click() - .wait(500); - cy.xpath(datasourceEditor["mongoUriYes"]) - .click() - .wait(500); - cy.xpath(datasourceEditor["mongoUriInput"]).type( - datasourceFormData["mongo-uri"], - ); -}); - -Cypress.Commands.add("startInterceptRoutesForMySQL", () => { - //All stubbing - cy.intercept("POST", "/api/v1/datasources/test", { - fixture: "testAction.json", - }).as("testDatasource"); - cy.intercept("GET", "/api/v1/datasources/*/structure?ignoreCache=*", { - fixture: "mySQL_GET_selectTableDropdown.json", - }).as("selectTableDropdownStub"); - cy.intercept("PUT", "/api/v1/pages/crud-page/*", { - fixture: "mySQL_PUT_replaceLayoutWithCRUD.json", - }).as("put_replaceLayoutCRUDStub"); - cy.intercept("GET", "/api/v1/actions*", { - fixture: "mySQL_GET_Actions.json", - }).as("getActionsStub"); - cy.intercept("POST", "/api/v1/actions/execute", { - fixture: "mySQL_POST_Execute.json", - }).as("postExecuteStub"); - cy.intercept("POST", "/api/v1/pages/crud-page", { - fixture: "mySQL_PUT_replaceLayoutWithCRUD.json", - }).as("post_replaceLayoutCRUDStub"); -}); - -Cypress.Commands.add("startInterceptRoutesForMongo", () => { - //All stubbing - cy.intercept("POST", "/api/v1/datasources/test", { - fixture: "testAction.json", - }).as("testDatasource"); - cy.intercept("GET", "/api/v1/datasources/*/structure?ignoreCache=*", { - fixture: "mongo_GET_selectTableDropdown.json", - }).as("get_selectTableDropdownStub"); - cy.intercept("PUT", "/api/v1/pages/crud-page/*", { - fixture: "mongo_PUT_replaceLayoutWithCRUD.json", - }).as("put_replaceLayoutCRUDStub"); - cy.intercept("GET", "/api/v1/actions*", { - fixture: "mongo_GET_Actions.json", - }).as("get_ActionsStub"); - cy.intercept("POST", "/api/v1/actions/execute", { - fixture: "mongo_POST_Actions.json", - }).as("post_ExecuteStub"); - cy.intercept("POST", "/api/v1/pages/crud-page", { - fixture: "mongo_PUT_replaceLayoutWithCRUD.json", - }).as("post_replaceLayoutCRUDStub"); -}); - -Cypress.Commands.add("startInterceptRoutesForS3", () => { - cy.intercept("POST", "/api/v1/datasources/test").as("testDatasource"); - cy.intercept("PUT", "/api/v1/datasources/datasource-query/*").as( - "put_datasources", - ); - cy.intercept("PUT", "/api/v1/pages/crud-page/*").as("put_replaceLayoutCRUD"); - cy.intercept("POST", "/api/v1/pages/crud-page").as("post_replaceLayoutCRUD"); - cy.intercept("GET", "/api/v1/actions*").as("get_Actions"); - cy.intercept("POST", "/api/v1/actions/execute").as("post_Execute"); -}); - -Cypress.Commands.add("fillAmazonS3DatasourceForm", () => { - cy.get(datasourceEditor.projectID) - .clear() - .type(Cypress.env("S3_ACCESS_KEY")); - cy.get(datasourceEditor.serviceAccCredential) - .clear() - .type(Cypress.env("S3_SECRET_KEY")); -}); - Cypress.Commands.add("createSuperUser", () => { cy.get(welcomePage.getStarted).should("be.visible"); cy.get(welcomePage.getStarted).should("not.be.disabled"); @@ -3129,3 +3095,118 @@ Cypress.Commands.add("SignupFromAPI", (uname, pword) => { cy.log(response.body); }); }); + +//Generate CRUD page methods: + +Cypress.Commands.add("fillMongoDatasourceFormWithURI", () => { + cy.xpath(datasourceEditor["mongoUriDropdown"]) + .click() + .wait(500); + cy.xpath(datasourceEditor["mongoUriYes"]) + .click() + .wait(500); + cy.xpath(datasourceEditor["mongoUriInput"]).type( + datasourceFormData["mongo-uri"], + ); +}); + +Cypress.Commands.add("startInterceptRoutesForMySQL", () => { + //All stubbing - updating app id to current app id for Delete app by api call to be successfull: + + cy.replaceApplicationIdForInterceptPages( + "cypress/fixtures/mySQL_PUT_replaceLayoutWithCRUD.json", + ); + + cy.intercept("POST", "/api/v1/datasources/test", { + fixture: "testAction.json", + }).as("testDatasource"); + cy.intercept("GET", "/api/v1/datasources/*/structure?ignoreCache=*", { + fixture: "mySQL_GET_selectTableDropdown.json", + }).as("getDatasourceStructure"); + cy.intercept("PUT", "/api/v1/pages/crud-page/*", { + fixture: "mySQL_PUT_replaceLayoutWithCRUD.json", + }).as("replaceLayoutWithCRUDPage"); + cy.intercept("GET", "/api/v1/actions*", { + fixture: "mySQL_GET_Actions.json", + }).as("getActions"); + cy.intercept("POST", "/api/v1/actions/execute", { + fixture: "mySQL_POST_Execute.json", + }).as("postExecute"); + cy.intercept("POST", "/api/v1/pages/crud-page", { + fixture: "mySQL_PUT_replaceLayoutWithCRUD.json", + }).as("replaceLayoutWithCRUDPage"); +}); + +Cypress.Commands.add("startInterceptRoutesForMongo", () => { + //All stubbing + cy.replaceApplicationIdForInterceptPages( + "cypress/fixtures/mongo_PUT_replaceLayoutWithCRUD.json", + ); + + cy.intercept("POST", "/api/v1/datasources/test", { + fixture: "testAction.json", + }).as("testDatasource"); + cy.intercept("GET", "/api/v1/datasources/*/structure?ignoreCache=*", { + fixture: "mongo_GET_selectTableDropdown.json", + }).as("getDatasourceStructure"); + cy.intercept("PUT", "/api/v1/pages/crud-page/*", { + fixture: "mongo_PUT_replaceLayoutWithCRUD.json", + }).as("replaceLayoutWithCRUDPage"); + cy.intercept("GET", "/api/v1/actions*", { + fixture: "mongo_GET_Actions.json", + }).as("getActions"); + cy.intercept("POST", "/api/v1/actions/execute", { + fixture: "mongo_POST_Actions.json", + }).as("postExecute"); + cy.intercept("POST", "/api/v1/pages/crud-page", { + fixture: "mongo_PUT_replaceLayoutWithCRUD.json", + }).as("post_replaceLayoutCRUDStub"); +}); + +Cypress.Commands.add("startInterceptRoutesForS3", () => { + cy.intercept("POST", "/api/v1/datasources/test").as("testDatasource"); + cy.intercept("PUT", "/api/v1/datasources/datasource-query/*").as( + "put_datasources", + ); + cy.intercept("PUT", "/api/v1/pages/crud-page/*").as("put_replaceLayoutCRUD"); + cy.intercept("POST", "/api/v1/pages/crud-page").as("post_replaceLayoutCRUD"); + cy.intercept("GET", "/api/v1/actions*").as("get_Actions"); + cy.intercept("POST", "/api/v1/actions/execute").as("post_Execute"); +}); + +Cypress.Commands.add("replaceApplicationIdForInterceptPages", (fixtureFile) => { + let currentAppId, currentURL; + cy.readFile(fixtureFile, (err, data) => { + if (err) { + return console.error(err); + } + }).then((data) => { + cy.url().then((url) => { + currentURL = url; + const myRegexp = /applications(.*)/; + const match = myRegexp.exec(currentURL); + cy.log(currentURL + "currentURL from intercept is"); + currentAppId = match ? match[1].split("/")[1] : null; + data.data.page.applicationId = currentAppId; + cy.writeFile(fixtureFile, JSON.stringify(data)); + }); + }); +}); + +Cypress.Commands.add( + "paste", + { prevSubject: true }, + (selector, pastePayload) => { + cy.wrap(selector).then(($destination) => { + const pasteEvent = Object.assign( + new Event("paste", { bubbles: true, cancelable: true }), + { + clipboardData: { + getData: () => pastePayload, + }, + }, + ); + $destination[0].dispatchEvent(pasteEvent); + }); + }, +);