From 13f24cbce8e7c124c30044cf99e8c1480f7673c6 Mon Sep 17 00:00:00 2001 From: Aishwarya-U-R <91450662+Aishwarya-U-R@users.noreply.github.com> Date: Tue, 21 Dec 2021 15:07:30 +0530 Subject: [PATCH] test: Automated tests for Rest Api, S3 Bugs and flakiness fixes (#9695) --- .../Bind_JSObject_Postgress_Table_spec.js | 37 +++- .../Table_Property_JsonUpdate_spec.js | 12 +- .../FormWidgets/CheckboxGroup_spec.js | 13 +- .../GenerateCRUD/Postgres_Spec.js | 26 +-- .../ClientSideTests/GenerateCRUD/S3_Spec.js | 200 +++++++++++------- .../QueryPaneTests/SwitchDatasource_spec.js | 22 +- .../ApiPaneTests/API_Bugs_Spec.js | 2 +- .../OrganisationTests/ShareAppTests_spec.js | 16 +- .../QueryPane/EmptyDataSource_spec.js | 2 +- .../ServerSideTests/QueryPane/Mongo_Spec.js | 47 ++-- .../QueryPane/Postgres_Spec.js | 3 +- .../ServerSideTests/QueryPane/S3_spec.js | 126 ++++++++--- app/client/cypress/support/commands.js | 71 ++++++- 13 files changed, 386 insertions(+), 191 deletions(-) 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 4ea5043029..76e189bebf 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 @@ -1,19 +1,20 @@ const queryLocators = require("../../../../locators/QueryEditor.json"); const queryEditor = require("../../../../locators/QueryEditor.json"); const dsl = require("../../../../fixtures/inputdsl.json"); +const homePage = require("../../../../locators/HomePage.json"); +const publish = require("../../../../locators/publishWidgetspage.json"); +const pages = require("../../../../locators/Pages.json"); let datasourceName; +let currentUrl; describe("Addwidget from Query and bind with other widgets", function() { - before(() => { - cy.addDsl(dsl); - }); - beforeEach(() => { cy.startRoutesForDatasource(); }); - it("Create a query and populate response by choosing addWidget and validate in Table Widget", () => { + it("Create a query and populate response by choosing addWidget and validate in Table Widget & Bug 7413", () => { + cy.addDsl(dsl); cy.createPostgresDatasource(); cy.get("@createDatasource").then((httpResponse) => { datasourceName = httpResponse.response.body.data.name; @@ -32,11 +33,9 @@ describe("Addwidget from Query and bind with other widgets", function() { cy.intercept("/api/v1/actions/execute", { fixture: "addWidgetTable-mock", }); - cy.onlyQueryRun(); cy.get(queryEditor.suggestedTableWidget).click(); cy.createJSObject("return Query1.data;"); - cy.SearchEntityandOpen("Table1"); cy.testJsontext("tabledata", "{{JSObject1.myFun1()}}"); cy.isSelectRow(1); @@ -45,6 +44,30 @@ describe("Addwidget from Query and bind with other widgets", function() { cy.log("the value is" + tabValue); expect(tabValue).to.be.equal("5"); }); + cy.get(homePage.shareApp).click(); + cy.enablePublicAccess(); + cy.wait(3000); + cy.PublishtheApp(); + cy.wait(3000); + cy.url().then((url) => { + currentUrl = url; + cy.log("Published url is: " + currentUrl); + cy.get(publish.backToEditor).click(); + cy.wait(2000); + cy.visit(currentUrl); + cy.wait("@getPagesForViewApp").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); + cy.wait(3000); + cy.tablefirstdataRow().then((tabValue) => { + expect(tabValue).to.be.equal("5"); + //expect(tabValue).to.have.lengthOf(0); // verification while JS Object was still Beta! + //cy.log("Verified that JSObject is not visible for Public viewing"); + cy.log("Verified that JSObject is visible for Public viewing"); + }); + }); }); }); }); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/DisplayWidgets/Table_Property_JsonUpdate_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/DisplayWidgets/Table_Property_JsonUpdate_spec.js index b6eda650dc..04e6ef76c1 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/DisplayWidgets/Table_Property_JsonUpdate_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/DisplayWidgets/Table_Property_JsonUpdate_spec.js @@ -1,21 +1,17 @@ const commonlocators = require("../../../../locators/commonlocators.json"); const dsl = require("../../../../fixtures/tableTextPaginationDsl.json"); -const pages = require("../../../../locators/Pages.json"); -const apiPage = require("../../../../locators/ApiEditor.json"); -const publishPage = require("../../../../locators/publishWidgetspage.json"); -const testdata = require("../../../../fixtures/testdata.json"); describe("Test Create Api and Bind to Table widget", function() { before(() => { cy.addDsl(dsl); }); - it("Create an API and Execute the API and bind with Table", function() { + it("1. Create an API and Execute the API and bind with Table", function() { cy.createAndFillApi(this.data.paginationUrl, this.data.paginationParam); cy.RunAPI(); }); - it("Validate Table with API data and then add a column", function() { + it("2. Validate Table with API data and then add a column", function() { // Open property pane cy.SearchEntityandOpen("Table1"); // Change the table data to Apil data users @@ -39,7 +35,7 @@ describe("Test Create Api and Bind to Table widget", function() { cy.addColumn("CustomColumn"); }); - it("Update table json data and check the column names updated and validate empty value", function() { + it("3. Update table json data and check the column names updated and validate empty value", function() { // Open property pane cy.SearchEntityandOpen("Table1"); // Change the table data @@ -68,7 +64,7 @@ describe("Test Create Api and Bind to Table widget", function() { }); }); - it("Check Selected Row(s) Resets When Table Data Changes", function() { + it("4. Check Selected Row(s) Resets When Table Data Changes", function() { // Select 1st row cy.isSelectRow(1); cy.openPropertyPane("tablewidget"); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/FormWidgets/CheckboxGroup_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/FormWidgets/CheckboxGroup_spec.js index 6ee13ff1e4..8c61b2b268 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/FormWidgets/CheckboxGroup_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/FormWidgets/CheckboxGroup_spec.js @@ -2,13 +2,13 @@ const commonlocators = require("../../../../locators/commonlocators.json"); const formWidgetsPage = require("../../../../locators/FormWidgets.json"); const publish = require("../../../../locators/publishWidgetspage.json"); const dsl = require("../../../../fixtures/checkboxgroupDsl.json"); -const pages = require("../../../../locators/Pages.json"); describe("Checkbox Group Widget Functionality", function() { before(() => { cy.addDsl(dsl); }); - it("Checkbox Group Widget Functionality", function() { + + it("1. Checkbox Group Widget Functionality", function() { cy.openPropertyPane("checkboxgroupwidget"); /** * @param{Text} Random Text @@ -59,7 +59,8 @@ describe("Checkbox Group Widget Functionality", function() { .type("2"); cy.PublishtheApp(); }); - it("Checkbox Group Functionality To Unchecked Visible Widget", function() { + + it("2. Checkbox Group Functionality To Unchecked Visible Widget", function() { cy.get(publish.backToEditor).click(); cy.openPropertyPane("checkboxgroupwidget"); cy.togglebarDisable(commonlocators.visibleCheckbox); @@ -67,7 +68,8 @@ describe("Checkbox Group Widget Functionality", function() { cy.get(publish.checkboxGroupWidget + " " + "input").should("not.exist"); cy.get(publish.backToEditor).click(); }); - it("Checkbox Group Functionality To Check Visible Widget", function() { + + it("3. Checkbox Group Functionality To Check Visible Widget", function() { cy.openPropertyPane("checkboxgroupwidget"); cy.togglebar(commonlocators.visibleCheckbox); cy.PublishtheApp(); @@ -75,7 +77,8 @@ describe("Checkbox Group Widget Functionality", function() { .eq(0) .should("exist"); }); - it("Checkbox Group Functionality To Button Text", function() { + + it("4. Checkbox Group Functionality To Button Text", function() { cy.get(publish.checkboxGroupWidget + " " + "label") .eq(1) .should("have.text", "test2"); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GenerateCRUD/Postgres_Spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GenerateCRUD/Postgres_Spec.js index dbaecc6361..1a23a6d2e2 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GenerateCRUD/Postgres_Spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GenerateCRUD/Postgres_Spec.js @@ -14,7 +14,7 @@ describe("Generate New CRUD Page Inside from entity explorer", function() { // 2. Add 2 supported datasource and 1 not supported datasource with a fixed name to search. }); - it("Add new Page and generate CRUD template using existing supported datasource & Verification of Bug 9334", function() { + it("1. Add new Page and generate CRUD template using existing supported datasource", function() { cy.NavigateToDatasourceEditor(); cy.get(datasource.PostgreSQL).click({ force: true }); cy.fillPostgresDatasourceForm(); @@ -179,21 +179,21 @@ describe("Generate New CRUD Page Inside from entity explorer", function() { cy.get("span:contains('GOT IT')").click(); - // //Navigating between CRUD (Page3) & EmptyPage (Page2): //to uncomment below lines aft this bug is fixed + //Navigating between CRUD (Page3) & EmptyPage (Page2): - // cy.selectEntityByName("Page2"); - // cy.wait(2000) - // cy.selectEntityByName("Page3"); - // cy.VerifyErrorMsgAbsence('The action "SelectQuery" has failed.') + cy.selectEntityByName("Page2"); + cy.wait(2000); + cy.selectEntityByName("Page3"); + cy.VerifyErrorMsgAbsence('The action "SelectQuery" has failed.'); - // //Navigating between CRUD (Page3) & CRUD (Page4): - // cy.selectEntityByName("Page4"); - // cy.wait(2000) - // cy.selectEntityByName("Page3"); //Back to 3 - // cy.VerifyErrorMsgAbsence('The action "SelectQuery" has failed.') + //Navigating between CRUD (Page3) & CRUD (Page4): + cy.selectEntityByName("Page4"); + cy.wait(2000); + cy.selectEntityByName("Page3"); //Back to 3 + cy.VerifyErrorMsgAbsence('The action "SelectQuery" has failed.'); }); - it("Create new app and Generate CRUD page using a new datasource", () => { + it("3. Create new app and Generate CRUD page using a new datasource", () => { cy.NavigateToHome(); cy.get(homePage.createNew) .first() @@ -256,7 +256,7 @@ describe("Generate New CRUD Page Inside from entity explorer", function() { cy.get("span:contains('GOT IT')").click(); }); - it("Generate CRUD page from datasource ACTIVE section", () => { + it("4. Generate CRUD page from datasource ACTIVE section", () => { cy.NavigateToQueryEditor(); cy.NavigateToActiveTab(); cy.wait(1000); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GenerateCRUD/S3_Spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GenerateCRUD/S3_Spec.js index 8aea4af0e5..c296cfcf9e 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GenerateCRUD/S3_Spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GenerateCRUD/S3_Spec.js @@ -2,6 +2,8 @@ const pages = require("../../../../locators/Pages.json"); const generatePage = require("../../../../locators/GeneratePage.json"); const datasourceEditor = require("../../../../locators/DatasourcesEditor.json"); import homePage from "../../../../locators/HomePage.json"; +const commonlocators = require("../../../../locators/commonlocators.json"); +const publishPage = require("../../../../locators/publishWidgetspage.json"); describe("Generate New CRUD Page Inside from entity explorer", function() { let datasourceName; @@ -11,84 +13,7 @@ describe("Generate New CRUD Page Inside from entity explorer", function() { cy.startInterceptRoutesForS3(); }); - it("Add new Page and generate CRUD template using existing supported datasource", function() { - cy.NavigateToDatasourceEditor(); - cy.get(datasourceEditor.AmazonS3) - .click({ force: true }) - .wait(1000); - - cy.generateUUID().then((uid) => { - datasourceName = `Amazon S3 MOCKDS ${uid}`; - cy.renameDatasource(datasourceName); - cy.wrap(datasourceName).as("dSName"); - }); - - cy.fillAmazonS3DatasourceForm(); - - //TestData source - cy.get(".t--test-datasource").click(); - cy.wait("@testDatasource"); - - //Save source - cy.get(".t--save-datasource").click(); - cy.wait("@createDatasource"); - - //Verify page after save clicked - // cy.get("@createDatasource").then((httpResponse) => { - // datasourceName = httpResponse.response.body.data.name; - // }); - - cy.get(pages.AddPage) - .first() - .click(); - cy.wait("@createPage").should( - "have.nested.property", - "response.body.responseMeta.status", - 201, - ); - - cy.get("@dSName").then((dbName) => { - cy.get(generatePage.generateCRUDPageActionCard).click(); - cy.get(generatePage.selectDatasourceDropdown).click(); - cy.get(generatePage.datasourceDropdownOption) - .contains(dbName) - .click(); - }); - - // fetch bucket - cy.wait("@put_datasources").should( - "have.nested.property", - "response.body.responseMeta.status", - 200, - ); - - cy.get(generatePage.selectTableDropdown).click(); - cy.get(generatePage.dropdownOption) - .contains("assets-test.appsmith.com") - .scrollIntoView() - .should("be.visible") - .click(); - // skip optional search column selection. - cy.get(generatePage.generatePageFormSubmitBtn).click(); - - cy.wait("@put_replaceLayoutCRUD").should( - "have.nested.property", - "response.body.responseMeta.status", - 201, - ); - cy.wait("@get_Actions").should( - "have.nested.property", - "response.body.responseMeta.status", - 200, - ); - - //Post Execute call not happening.. hence commenting it for this case - //cy.wait("@post_Execute").should("have.nested.property", "response.body.responseMeta.status", 200,); - - cy.get("span:contains('GOT IT')").click(); - }); - - it("Create new app and Generate CRUD page using a new datasource", function() { + it("1. Create new app and Generate CRUD page using a new datasource", function() { cy.NavigateToHome(); cy.get(homePage.createNew) .first() @@ -155,7 +80,7 @@ describe("Generate New CRUD Page Inside from entity explorer", function() { cy.get("span:contains('GOT IT')").click(); }); - it("Generate CRUD page from datasource ACTIVE section", function() { + it("2. Generate CRUD page from datasource ACTIVE section", function() { // cy.NavigateToQueryEditor(); // cy.get(pages.integrationActiveTab) // .should("be.visible") @@ -206,4 +131,121 @@ describe("Generate New CRUD Page Inside from entity explorer", function() { cy.get("span:contains('GOT IT')").click(); }); + + it("3. Add new Page and generate CRUD template using existing supported datasource & Bug 9649", function() { + cy.NavigateToDatasourceEditor(); + cy.get(datasourceEditor.AmazonS3) + .click({ force: true }) + .wait(1000); + + cy.generateUUID().then((uid) => { + datasourceName = `Amazon S3 MOCKDS ${uid}`; + cy.renameDatasource(datasourceName); + cy.wrap(datasourceName).as("dSName"); + }); + + cy.fillAmazonS3DatasourceForm(); + + //TestData source + cy.get(".t--test-datasource").click(); + cy.wait("@testDatasource"); + + //Save source + cy.get(".t--save-datasource").click(); + cy.wait("@createDatasource"); + + //Verify page after save clicked + // cy.get("@createDatasource").then((httpResponse) => { + // datasourceName = httpResponse.response.body.data.name; + // }); + + //Create Dummy Page2 : + cy.get(pages.AddPage) + .first() + .click(); + cy.wait("@createPage").should( + "have.nested.property", + "response.body.responseMeta.status", + 201, + ); + + //Creating CRUD Page3 + cy.get(pages.AddPage) + .first() + .click(); + cy.wait("@createPage").should( + "have.nested.property", + "response.body.responseMeta.status", + 201, + ); + + cy.get("@dSName").then((dbName) => { + cy.get(generatePage.generateCRUDPageActionCard).click(); + cy.get(generatePage.selectDatasourceDropdown).click(); + cy.get(generatePage.datasourceDropdownOption) + .contains(dbName) + .click(); + }); + + // fetch bucket + cy.wait("@put_datasources").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); + + cy.get(generatePage.selectTableDropdown).click(); + cy.get(generatePage.dropdownOption) + .contains("assets-test.appsmith.com") + .scrollIntoView() + .should("be.visible") + .click(); + // skip optional search column selection. + cy.get(generatePage.generatePageFormSubmitBtn).click(); + + cy.wait("@put_replaceLayoutCRUD").should( + "have.nested.property", + "response.body.responseMeta.status", + 201, + ); + cy.wait("@get_Actions").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); + + //Post Execute call not happening.. hence commenting it for this case + //cy.wait("@post_Execute").should("have.nested.property", "response.body.responseMeta.status", 200,); + + cy.wait("@postExecute", { timeout: 8000 }).then(({ response }) => { + expect(response.body.data.isExecutionSuccess).to.eq(true); + }); + cy.get("span:contains('GOT IT')").click(); + + //Bug verification starts + cy.selectEntityByName("ListFiles"); + cy.wait(2000); + cy.selectEntityByName("Page3"); + cy.wait(1000); + cy.PublishtheApp(); + cy.wait(3000); + cy.get(commonlocators.toastAction).should("not.exist"); + // .its("length") + // .should("eq", 0); // checking no error msg appears! + + //.should('not.exist') + //.should("have.length", 0) + + //cy.get('.datatable').find('tr') + + // .should("contain.text", 'The action "ListFiles" has failed.'); + + cy.get(publishPage.backToEditor).click({ force: true }); + cy.wait(2000); + + //cy.VerifyErrorMsgAbsence('The action "ListFiles" has failed.') + //cy.VerifyNoDataDisplayAbsence() + //cy.isNotInViewport("//div[text()='haiiii hello']") + //cy.isNotInViewport("//div[text()='No data to display']") + }); }); 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 6debe35adf..b8ca15d7de 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 @@ -62,24 +62,24 @@ describe("Switch datasource", function() { .find(queryLocators.createQuery) .click(); - cy.get(queryLocators.templateMenu).click(); + cy.get(queryLocators.templateMenu).click({ force: true }); cy.get(".CodeMirror textarea") .first() .focus() - .type("select * from users limit 10"); - + .type("select * from public.users limit 10"); + cy.wait(3000); cy.runQuery(); cy.get(".t--switch-datasource").click(); - cy.contains(".t--datasource-option", mongoDatasourceName).click(); + cy.contains(".t--datasource-option", mongoDatasourceName) + .click() + .wait(1000); - cy.get(".CodeMirror") - .first() - .then((editor) => { - editor[0].CodeMirror.setValue('{"find": "planets"}'); - }); - - cy.runQuery(); + cy.wait("@saveAction").should( + "have.nested.property", + "response.body.data.isValid", + true, + ); }); it("4. Delete the query and datasources", function() { diff --git a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/ApiPaneTests/API_Bugs_Spec.js b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/ApiPaneTests/API_Bugs_Spec.js index 3b4c2372ce..bacb8dbf3d 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/ApiPaneTests/API_Bugs_Spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/ApiPaneTests/API_Bugs_Spec.js @@ -38,7 +38,7 @@ describe("Rest Bugs tests", function() { cy.contains(commonlocators.entityName, "Page1").click(); cy.clickButton("Get Facts!"); - cy.wait(6000); // for all api calls to complete! + cy.wait(8000); // for all api calls to complete! cy.wait("@postExecute", { timeout: 8000 }).then(({ response }) => { expect(response.body.data.isExecutionSuccess).to.eq(true); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/OrganisationTests/ShareAppTests_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/OrganisationTests/ShareAppTests_spec.js index 5e9cc6c7e7..872684afc1 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/OrganisationTests/ShareAppTests_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/OrganisationTests/ShareAppTests_spec.js @@ -9,7 +9,7 @@ describe("Create new org and share with a user", function() { let currentUrl; let newOrganizationName; - it("create org and then share with a user from Application share option within application", function() { + it("1. Create org and then share with a user from Application share option within application", function() { cy.NavigateToHome(); cy.generateUUID().then((uid) => { orgid = uid; @@ -33,7 +33,7 @@ describe("Create new org and share with a user", function() { cy.LogOut(); }); - it("login as invited user and then validate viewer privilage", function() { + it("2. login as Invited user and then validate viewer privilage", function() { cy.LogintoApp(Cypress.env("TESTUSERNAME1"), Cypress.env("TESTPASSWORD1")); cy.get(homePage.searchInput).type(appid); // eslint-disable-next-line cypress/no-unnecessary-waiting @@ -48,7 +48,7 @@ describe("Create new org and share with a user", function() { cy.LogOut(); }); - it("Enable public access to Application", function() { + it("3. Enable public access to Application", function() { cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD")); cy.visit("/applications"); cy.wait("@applications").should( @@ -75,7 +75,7 @@ describe("Create new org and share with a user", function() { cy.LogOut(); }); - it("Open the app without login and validate public access of Application", function() { + it("4. Open the app without login and validate public access of Application", function() { cy.visit(currentUrl); cy.wait("@getPagesForViewApp").should( "have.nested.property", @@ -93,7 +93,7 @@ describe("Create new org and share with a user", function() { cy.get(".t--comment-mode-switch-toggle").should("not.exist"); }); - it("login as uninvited user and then validate public access of Application", function() { + it("5. login as uninvited user and then validate public access of Application", function() { cy.LoginFromAPI(Cypress.env("TESTUSERNAME2"), Cypress.env("TESTPASSWORD2")); cy.visit(currentUrl); cy.wait("@getPagesForViewApp").should( @@ -130,7 +130,7 @@ describe("Create new org and share with a user", function() { cy.LogOut(); }); - it("login as uninvited user and then validate public access disable feature", function() { + it("6. login as uninvited user and then validate public access disable feature", function() { cy.LoginFromAPI(Cypress.env("TESTUSERNAME2"), Cypress.env("TESTPASSWORD2")); cy.visit(currentUrl); cy.wait("@viewApp").should( @@ -141,7 +141,7 @@ describe("Create new org and share with a user", function() { cy.LogOut(); }); - it("visit the app as anonymous user and validate redirection to login page", function() { + it("7. visit the app as anonymous user and validate redirection to login page", function() { cy.visit(currentUrl); cy.wait("@viewApp").should( "have.nested.property", @@ -151,7 +151,7 @@ describe("Create new org and share with a user", function() { cy.contains("Sign in to your account").should("be.visible"); }); - it("login as owner and delete App ", function() { + it("8. login as owner and delete App ", function() { cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD")); cy.visit("/applications"); cy.wait("@applications").should( diff --git a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/EmptyDataSource_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/EmptyDataSource_spec.js index b0534c408d..9594d19a1f 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/EmptyDataSource_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/EmptyDataSource_spec.js @@ -30,7 +30,7 @@ describe("Create a query with a empty datasource, run, save the query", function .type("select * from users limit 10"); cy.EvaluateCurrentValue("select * from users limit 10"); - cy.runQuery(); + cy.runQuery(false); cy.get(".t--query-error").contains( "[Missing endpoint., Missing username for authentication., Missing password for authentication.]", ); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/Mongo_Spec.js b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/Mongo_Spec.js index 4fc049a130..38302ab97a 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/Mongo_Spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/Mongo_Spec.js @@ -2,16 +2,17 @@ const queryLocators = require("../../../../locators/QueryEditor.json"); const generatePage = require("../../../../locators/GeneratePage.json"); const datasource = require("../../../../locators/DatasourcesEditor.json"); -let datasourceName, queryName; +let datasourceName; describe("Create a query with a mongo datasource, run, save and then delete the query", function() { beforeEach(() => { cy.startRoutesForDatasource(); }); - afterEach(() => { - if (queryName) cy.deleteEntitybyName(queryName); - }); + // afterEach(() => { + // if (queryName) + // cy.deleteEntitybyName(queryName); + // }); it("1. Creates a new Mongo datasource", function() { cy.NavigateToDatasourceEditor(); @@ -27,9 +28,6 @@ describe("Create a query with a mongo datasource, run, save and then delete the it("2. Validate Raw query command, run and then delete the query", function() { cy.NavigateToActiveDSQueryPane(datasourceName); - queryName = "RawQuery"; - cy.renameWithInPane(queryName); - // cy.get("@getPluginForm").should( // "have.nested.property", // "response.body.responseMeta.status", @@ -49,13 +47,12 @@ describe("Create a query with a mongo datasource, run, save and then delete the // }); // cy.EvaluateCurrentValue(`{"find": "listingsAndReviews","limit": 10}`); - cy.runQuery(); //exeute actions & 200 response is verified in this method + cy.runAndDeleteQuery(); //exeute actions & 200 response is verified in this method }); it("3. Validate Find documents command & Run and then delete the query", function() { cy.NavigateToActiveDSQueryPane(datasourceName); - queryName = "FindQuery"; - cy.renameWithInPane(queryName); + cy.setQueryTimeout(30000); //cy.xpath(queryLocators.findDocs).should("exist"); //Verifying update is success or below line //cy.expect(queryLocators.findDocs).to.exist; @@ -63,19 +60,19 @@ describe("Create a query with a mongo datasource, run, save and then delete the cy.validateNSelectDropdown("Commands", "Find Document(s)"); cy.typeValueNValidate("listingsAndReviews", "Collection"); - cy.runQuery(); //exeute actions - 200 response is verified in this method + cy.runQuery(); cy.xpath(queryLocators.countText).should("have.text", "10 Records"); cy.typeValueNValidate("{beds : {$lte: 2}}", "Query"); - cy.runQuery(); //exeute actions - 200 response is verified in this method + cy.runQuery(); cy.xpath(queryLocators.countText).should("have.text", "10 Records"); cy.typeValueNValidate("{number_of_reviews: -1}", "Sort"); //sort descending - cy.runQuery(); //exeute actions - 200 response is verified in this method + cy.runQuery(); cy.xpath(queryLocators.countText).should("have.text", "10 Records"); cy.typeValueNValidate("{house_rules: 1, description:1}", "Projection"); //Projection field - cy.runQuery(); //exeute actions - 200 response is verified in this method + cy.runQuery(); cy.typeValueNValidate("5", "Limit"); //Limit field cy.onlyQueryRun(); @@ -97,23 +94,22 @@ describe("Create a query with a mongo datasource, run, save and then delete the ); }); 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); - queryName = "CountQuery"; - cy.renameWithInPane(queryName); + cy.setQueryTimeout(30000); cy.validateNSelectDropdown("Commands", "Find Document(s)", "Count"); cy.typeValueNValidate("listingsAndReviews", "Collection"); cy.runQuery(); cy.typeValueNValidate("{beds : {$lte: 2}}", "Query"); - cy.runQuery(); //exeute actions - 200 response is verified in this method + cy.runAndDeleteQuery(); //exeute actions - 200 response is verified in this method }); it("5. Validate Distinct command & Run and then delete the query", function() { cy.NavigateToActiveDSQueryPane(datasourceName); - queryName = "DistinctQuery"; - cy.renameWithInPane(queryName); + cy.setQueryTimeout(30000); cy.validateNSelectDropdown("Commands", "Find Document(s)", "Distinct"); cy.typeValueNValidate("listingsAndReviews", "Collection"); cy.typeValueNValidate("{beds : {$lte: 2}}", "Query"); @@ -125,12 +121,12 @@ describe("Create a query with a mongo datasource, run, save and then delete the "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); - queryName = "AggregateQuery"; - cy.renameWithInPane(queryName); + cy.setQueryTimeout(30000); cy.validateNSelectDropdown("Commands", "Find Document(s)", "Aggregate"); cy.typeValueNValidate("listingsAndReviews", "Collection"); cy.typeValueNValidate( @@ -148,10 +144,10 @@ describe("Create a query with a mongo datasource, run, save and then delete the // 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() { - queryName = ""; //Verifying Select from UI cy.NavigateToDSGeneratePage(datasourceName); cy.get(generatePage.selectTableDropdown).click(); @@ -182,7 +178,6 @@ describe("Create a query with a mongo datasource, run, save and then delete the }); it("8. Validate Deletion of the Newly Created Page", () => { - queryName = "ListingsAndReviews"; cy.NavigateToQueryEditor(); cy.NavigateToActiveTab(); cy.contains(".t--datasource-name", datasourceName).click(); @@ -192,12 +187,13 @@ describe("Create a query with a mongo datasource, run, save and then delete the "response.body.responseMeta.status", 409, ); + cy.deleteEntitybyName("ListingsAndReviews"); }); it("9. Bug 7399: Validate Form based & Raw command based templates", function() { - queryName = "Query1"; let id; cy.NavigateToActiveDSQueryPane(datasourceName); + cy.setQueryTimeout(30000); cy.validateNSelectDropdown("Commands", "Find Document(s)"); cy.xpath(queryLocators.mongoFormFind).click({ force: true }); cy.xpath("//div[text()='Find']") @@ -266,12 +262,11 @@ describe("Create a query with a mongo datasource, run, save and then delete the .replace(/['"]+/g, ""), ); }); - + cy.deleteEntitybyName("Query1"); cy.deleteEntitybyName("Query2"); }); it("10. Delete the datasource after NewPage deletion is success", () => { - queryName = ""; cy.NavigateToQueryEditor(); cy.NavigateToActiveTab(); cy.contains(".t--datasource-name", datasourceName).click(); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/Postgres_Spec.js b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/Postgres_Spec.js index 66d58cb19a..fb8b325c20 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/Postgres_Spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/Postgres_Spec.js @@ -249,7 +249,7 @@ describe("Validate CRUD queries for Postgres along with UI flow verifications", cy.get(queryLocators.templateMenu).click({ force: true }); cy.typeValueNValidate("select * from public.users limit 10"); cy.runQuery(); - cy.typeValueNValidate("select * from users_crud limit 10"); + cy.typeValueNValidate("select * from public.users_crud limit 10"); cy.onlyQueryRun(); cy.get(commonlocators.debugger) .should("be.visible") @@ -262,6 +262,7 @@ describe("Validate CRUD queries for Postgres along with UI flow verifications", .then(($text) => { expect($text).to.eq("Execution failed with status 5005"); }); + cy.deleteQueryUsingContext(); }); it("11. Deletes the datasource", () => { diff --git a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/S3_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/S3_spec.js index 567a4a14d4..3af052daa7 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/S3_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/S3_spec.js @@ -131,7 +131,7 @@ describe("Validate CRUD queries for Amazon S3 along with UI flow verifications", cy.deleteQueryUsingContext(); //exeute actions & 200 response is verified in this method }); - it("4. Validate List Files in bucket command for new file, Verify possible error msgs, run & delete the query", () => { + it("4. Validate List Files/Read files in bucket command for new file, Verify possible error msgs, run & delete the query", () => { cy.NavigateToActiveDSQueryPane(datasourceName); cy.setQueryTimeout(30000); cy.validateNSelectDropdown("Commands", "List files in bucket"); @@ -179,22 +179,22 @@ describe("Validate CRUD queries for Amazon S3 along with UI flow verifications", expect(response.body.data.body[0].signedUrl).to.exist; expect(response.body.data.body[0].url).to.not.exist; }); - cy.deleteQueryUsingContext(); //exeute actions & 200 response is verified in this method - }); + //cy.deleteQueryUsingContext(); //exeute actions & 200 response is verified in this method - it("5. Validate Read file command, Verify possible error msgs, run & delete the query", () => { - cy.NavigateToActiveDSQueryPane(datasourceName); - cy.setQueryTimeout(30000); + //Read File + + //cy.NavigateToActiveDSQueryPane(datasourceName); + //cy.setQueryTimeout(30000); cy.validateNSelectDropdown("Commands", "List files in bucket", "Read file"); - cy.onlyQueryRun(); - cy.wait("@postExecute").should(({ response }) => { - expect(response.body.data.isExecutionSuccess).to.eq(false); - expect(response.body.data.body).to.contains( - "Mandatory parameter 'Bucket Name' is missing.", - ); - }); - cy.typeValueNValidate("AutoTest", "Bucket Name"); + // cy.onlyQueryRun(); + // cy.wait("@postExecute").should(({ response }) => { + // expect(response.body.data.isExecutionSuccess).to.eq(false); + // expect(response.body.data.body).to.contains( + // "Mandatory parameter 'Bucket Name' is missing.", + // ); + // }); + // cy.typeValueNValidate("AutoTest", "Bucket Name"); cy.onlyQueryRun(); cy.wait("@postExecute").then(({ response }) => { @@ -205,16 +205,16 @@ describe("Validate CRUD queries for Amazon S3 along with UI flow verifications", }); cy.typeValueNValidate("Auto", "File Path"); - cy.onlyQueryRun(); - cy.wait("@postExecute").then(({ response }) => { - expect(response.body.data.isExecutionSuccess).to.eq(false); - expect(response.body.data.body.split("(")[0].trim()).to.be.oneOf([ - "The specified bucket does not exist", - "The specified bucket is not valid.", - ]); - }); + // cy.onlyQueryRun(); + // cy.wait("@postExecute").then(({ response }) => { + // expect(response.body.data.isExecutionSuccess).to.eq(false); + // expect(response.body.data.body.split("(")[0].trim()).to.be.oneOf([ + // "The specified bucket does not exist", + // "The specified bucket is not valid.", + // ]); + // }); - cy.typeValueNValidate("assets-test.appsmith.com", "Bucket Name"); + // cy.typeValueNValidate("assets-test.appsmith.com", "Bucket Name"); cy.onlyQueryRun(); cy.wait("@postExecute").then(({ response }) => { @@ -258,6 +258,82 @@ describe("Validate CRUD queries for Amazon S3 along with UI flow verifications", cy.deleteQueryUsingContext(); //exeute actions & 200 response is verified in this method }); + // it("5. Validate Read file command, Verify possible error msgs, run & delete the query", () => { + // cy.NavigateToActiveDSQueryPane(datasourceName); + // cy.setQueryTimeout(30000); + // cy.validateNSelectDropdown("Commands", "List files in bucket", "Read file"); + + // cy.onlyQueryRun(); + // cy.wait("@postExecute").should(({ response }) => { + // expect(response.body.data.isExecutionSuccess).to.eq(false); + // expect(response.body.data.body).to.contains( + // "Mandatory parameter 'Bucket Name' is missing.", + // ); + // }); + // cy.typeValueNValidate("AutoTest", "Bucket Name"); + + // cy.onlyQueryRun(); + // cy.wait("@postExecute").then(({ response }) => { + // expect(response.body.data.isExecutionSuccess).to.eq(false); + // expect(response.body.data.body).to.contains( + // "Required parameter 'File Path' is missing.", + // ); + // }); + // cy.typeValueNValidate("Auto", "File Path"); + + // cy.onlyQueryRun(); + // cy.wait("@postExecute").then(({ response }) => { + // expect(response.body.data.isExecutionSuccess).to.eq(false); + // expect(response.body.data.body.split("(")[0].trim()).to.be.oneOf([ + // "The specified bucket does not exist", + // "The specified bucket is not valid.", + // ]); + // }); + + // cy.typeValueNValidate("assets-test.appsmith.com", "Bucket Name"); + + // cy.onlyQueryRun(); + // cy.wait("@postExecute").then(({ response }) => { + // expect(response.body.data.isExecutionSuccess).to.eq(false); + // expect(response.body.data.body).to.contain( + // "The specified key does not exist.", + // ); + // }); + + // cy.typeValueNValidate("Autofile", "File Path"); + + // cy.onlyQueryRun(); + // cy.wait("@postExecute").then(({ response }) => { + // expect(response.body.data.isExecutionSuccess).to.eq(false); + // expect(response.body.data.body).to.contain( + // "The specified key does not exist.", + // ); + // }); + + // cy.typeValueNValidate("AutoFile", "File Path"); + + // //Commenting below since below dropdown is removed from Read + // //cy.validateNSelectDropdown("File Data Type", "Base64", "Text / Binary"); + + // cy.onlyQueryRun(); + // cy.wait("@postExecute").then(({ response }) => { + // expect(response.body.data.isExecutionSuccess).to.eq(true); + // expect(response.body.data.body.fileData).to.not.eq( + // "Hi, this is Automation script adding File!", + // ); + // }); + + // cy.validateNSelectDropdown("Base64 Encode File - Yes/No", "Yes", "No"); + // cy.onlyQueryRun(); + // cy.wait("@postExecute").then(({ response }) => { + // expect(response.body.data.isExecutionSuccess).to.eq(true); + // expect(response.body.data.body.fileData).to.eq( + // "Hi, this is Automation script adding File!", + // ); + // }); + // cy.deleteQueryUsingContext(); //exeute actions & 200 response is verified in this method + // }); + it("6. Validate Delete file command for new file, Verify possible error msgs, run & delete the query", () => { cy.NavigateToActiveDSQueryPane(datasourceName); //cy.renameWithInPane(queryName); @@ -285,7 +361,6 @@ describe("Validate CRUD queries for Amazon S3 along with UI flow verifications", ); }); cy.typeValueNValidate("Auto", "File Path"); - cy.onlyQueryRun(); cy.wait("@postExecute").then(({ response }) => { expect(response.body.data.isExecutionSuccess).to.eq(false); @@ -294,10 +369,8 @@ describe("Validate CRUD queries for Amazon S3 along with UI flow verifications", "The specified bucket is not valid.", ]); }); - cy.typeValueNValidate("assets-test.appsmith.com", "Bucket Name"); cy.typeValueNValidate("AutoFile", "File Path"); - cy.onlyQueryRun(); cy.wait("@postExecute").then(({ response }) => { expect(response.body.data.isExecutionSuccess).to.eq(true); @@ -429,6 +502,7 @@ describe("Validate CRUD queries for Amazon S3 along with UI flow verifications", "response.body.responseMeta.status", 409, ); + cy.deleteEntitybyName("Assets-test.appsmith.com"); }); it("11. Verify 'Add to widget [Widget Suggestion]' functionality - S3", () => { diff --git a/app/client/cypress/support/commands.js b/app/client/cypress/support/commands.js index a694fd439c..a1c2457c85 100644 --- a/app/client/cypress/support/commands.js +++ b/app/client/cypress/support/commands.js @@ -1347,7 +1347,7 @@ Cypress.Commands.add("EvaluateCurrentValue", (currentValue) => { //.should("be.visible") .click({ force: true }) .then(($text) => { - expect($text.text()).to.eq(currentValue); + if ($text.text()) expect($text.text()).to.eq(currentValue); }); }); @@ -2440,13 +2440,19 @@ Cypress.Commands.add("deleteDatasource", (datasourceName) => { ); }); -Cypress.Commands.add("runQuery", () => { +Cypress.Commands.add("runQuery", (expectedRes = true) => { cy.onlyQueryRun(); cy.wait("@postExecute").should( "have.nested.property", - "response.body.responseMeta.status", - 200, + "response.body.data.isExecutionSuccess", + expectedRes, ); + + // cy.wait("@postExecute").should( + // "have.nested.property", + // "response.body.responseMeta.status", + // 200, + // ); }); Cypress.Commands.add("onlyQueryRun", () => { @@ -2951,6 +2957,16 @@ Cypress.Commands.add("readTabledataPublish", (rowNum, colNum) => { return tabVal; }); +Cypress.Commands.add("tablefirstdataRow", () => { + let tabVal = cy + .xpath( + "//div[@class='tableWrap']//div[@class='table']//div[contains(@class, 'tbody')]/div[@class='tr']/div[@class ='td']", + ) + .first() + .invoke("text"); + return tabVal; +}); + Cypress.Commands.add("scrollTabledataPublish", (rowNum, colNum) => { const selector = `.t--widget-tablewidget .tbody .td[data-rowindex=${rowNum}][data-colindex=${colNum}] div`; const tabVal = cy @@ -3401,6 +3417,7 @@ Cypress.Commands.add("selectEntityByName", (entityNameinLeftSidebar) => { entityNameinLeftSidebar + "']", ) + .last() .click({ force: true }) .wait(2000); }); @@ -3479,7 +3496,7 @@ Cypress.Commands.add("getEntityName", () => { Cypress.Commands.add("VerifyErrorMsgAbsence", (errorMsgToVerifyAbsence) => { // Give this element 10 seconds to appear - //cy.wait(1000) + //cy.wait(10000) cy.xpath( "//div[@class='Toastify']//span[contains(text(),'" + errorMsgToVerifyAbsence + @@ -3497,6 +3514,50 @@ Cypress.Commands.add("setQueryTimeout", (timeout) => { cy.get(queryLocators.query).click(); }); +//Not Used! +Cypress.Commands.add("VerifyNoDataDisplayAbsence", () => { + cy.xpath("//div[text()='No data to display']", { timeout: 0 }).should( + "not.exist", + ); +}); + +// Cypress.Commands.add('isNotInViewport', element => { +// cy.xpath(element).then($el => { +// const bottom = Cypress.$(cy.state('window')).height() +// const rect = $el[0].getBoundingClientRect() + +// expect(rect.top).to.be.greaterThan(bottom) +// expect(rect.bottom).to.be.greaterThan(bottom) +// expect(rect.top).to.be.greaterThan(bottom) +// expect(rect.bottom).to.be.greaterThan(bottom) +// }) +// }) + +Cypress.Commands.add("isNotInViewport", (element) => { + cy.xpath(element).should(($el) => { + const bottom = Cypress.$(cy.state("window")).height(); + const right = Cypress.$(cy.state("window")).width(); + const rect = $el[0].getBoundingClientRect(); + + expect(rect).to.satisfy( + (rect) => + rect.top < 0 || rect.top > bottom || rect.left < 0 || rect.left > right, + ); + }); +}); + +Cypress.Commands.add("isInViewport", (element) => { + cy.xpath(element).then(($el) => { + const bottom = Cypress.$(cy.state("window")).height(); + const rect = $el[0].getBoundingClientRect(); + + expect(rect.top).not.to.be.greaterThan(bottom); + expect(rect.bottom).not.to.be.greaterThan(bottom); + expect(rect.top).not.to.be.greaterThan(bottom); + expect(rect.bottom).not.to.be.greaterThan(bottom); + }); +}); + // Cypress.Commands.overwrite("type", (originalFn, element, text, options) => { // const clearedText = '{selectall}{backspace}'+`${text}`;