From a55a68780b833de90fab5abf307cd19613a55fbb Mon Sep 17 00:00:00 2001 From: Raju Udava <86527202+dstala@users.noreply.github.com> Date: Thu, 25 Aug 2022 16:39:53 +0530 Subject: [PATCH] test: view suite, part-1 Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> --- .../common/4a_table_view_grid_gallery_form.js | 52 ++++++++++++++----- .../integration/common/4b_table_view_share.js | 15 ++++-- .../common/4c_form_view_detailed.js | 10 +++- .../support/page_objects/mainPage.js | 12 ++--- 4 files changed, 64 insertions(+), 25 deletions(-) diff --git a/scripts/cypress-v2/integration/common/4a_table_view_grid_gallery_form.js b/scripts/cypress-v2/integration/common/4a_table_view_grid_gallery_form.js index 572b881df0..d8b8b95d8e 100644 --- a/scripts/cypress-v2/integration/common/4a_table_view_grid_gallery_form.js +++ b/scripts/cypress-v2/integration/common/4a_table_view_grid_gallery_form.js @@ -1,7 +1,11 @@ import { mainPage } from "../../support/page_objects/mainPage"; import { isTestSuiteActive } from "../../support/page_objects/projectConstants"; -let viewTypeString = ["", "Form", "Gallery", "Grid"]; +// let viewTypeString = ["", "Form", "Gallery", "Grid"]; + +function capitalizeFirstLetter(string) { + return string.charAt(0).toUpperCase() + string.slice(1); +} export const genTest = (apiType, dbType) => { if (!isTestSuiteActive(apiType, dbType)) return; @@ -14,9 +18,18 @@ export const genTest = (apiType, dbType) => { before(() => { cy.fileHook(); mainPage.tabReset(); + + // // kludge: wait for page load to finish + // cy.wait(1000); + // // close team & auth tab + // cy.get('button.ant-tabs-tab-remove').should('exist').click(); + // cy.wait(1000); + // open a table to work on views // cy.openTableTab("Country", 25); + + cy.get('.nc-toggle-right-navbar').should('exist').click(); }); beforeEach(() => { @@ -40,13 +53,16 @@ export const genTest = (apiType, dbType) => { cy.getActiveModal().find(".ant-btn-primary").click(); cy.toastWait("View created successfully"); + // kludge: right navbar closes abruptly. force it open again + window.localStorage.setItem('nc-right-sidebar', '{"isOpen":true,"hasSidebar":true}') + // validate if view was created && contains default name 'Country1' cy.get(`.nc-${viewType}-view-item`) - .contains(`${viewTypeString[viewType]}-1`) + .contains(`${capitalizeFirstLetter(viewType)}-1`) .should("exist"); }); - it.skip(`Edit ${viewType} view name`, () => { + it(`Edit ${viewType} view name`, () => { // click on edit-icon (becomes visible on hovering mouse) // cy.get(".nc-view-edit-icon").last().click({ // force: true, @@ -55,11 +71,14 @@ export const genTest = (apiType, dbType) => { cy.get(`.nc-${viewType}-view-item`).last().dblclick(); // feed new name - cy.get(`.nc-${viewType}-view-item input`).type( - `${viewType}View-1{enter}` - ); + cy.get(`.nc-${viewType}-view-item input`) + .clear() + .type(`${viewType}View-1{enter}`); cy.toastWait("View renamed successfully"); + // kludge: right navbar closes abruptly. force it open again + window.localStorage.setItem('nc-right-sidebar', '{"isOpen":true,"hasSidebar":true}') + // validate cy.get(`.nc-${viewType}-view-item`) .contains(`${viewType}View-1`) @@ -70,11 +89,18 @@ export const genTest = (apiType, dbType) => { // number of view entries should be 2 before we delete cy.get(".nc-view-item").its("length").should("eq", 2); + cy.get(`.nc-${viewType}-view-item`).last().click(); + cy.wait(3000); + // click on delete icon (becomes visible on hovering mouse) - cy.get(`.nc-${viewType}-view-item`).last().trigger("mouseover").click(); - cy.get(".nc-view-delete-icon").should('exist').click({ force: true }); - cy.getActiveModal().find(".ant-btn-dangerous").click(); - cy.toastWait("View deleted successfully"); + cy.get(`.nc-${viewType}-view-item`).last().trigger("mouseover").then(() => { + cy.get(".nc-view-delete-icon").should('exist').click({force: true}); + cy.getActiveModal().find(".ant-btn-dangerous").click(); + cy.toastWait("View deleted successfully"); + }) + + // kludge: right navbar closes abruptly. force it open again + window.localStorage.setItem('nc-right-sidebar', '{"isOpen":true,"hasSidebar":true}') // confirm if the number of veiw entries is reduced by 1 cy.get(".nc-view-item").its("length").should("eq", 1); @@ -82,9 +108,9 @@ export const genTest = (apiType, dbType) => { }; // below four scenario's will be invoked twice, once for rest & then for graphql - viewTest("3"); // grid view - viewTest("2"); // gallery view - viewTest("1"); // form view + viewTest("grid"); // grid view + viewTest("gallery"); // gallery view + viewTest("form"); // form view }); }; diff --git a/scripts/cypress-v2/integration/common/4b_table_view_share.js b/scripts/cypress-v2/integration/common/4b_table_view_share.js index 6590d5c562..441f1effc8 100644 --- a/scripts/cypress-v2/integration/common/4b_table_view_share.js +++ b/scripts/cypress-v2/integration/common/4b_table_view_share.js @@ -13,7 +13,7 @@ const generateLinkWithPwd = () => { cy.getActiveModal().find('.ant-checkbox-input').should('exist').first().then(($el) => { if (!$el.prop("checked")) { cy.wrap($el).click({ force: true }); - cy.getActiveModal().find('input[type="password"]').type("1"); + cy.getActiveModal().find('input[type="password"]').clear().type("1"); cy.getActiveModal().find('button:contains("Save password")').click(); cy.toastWait("Successfully updated"); } @@ -37,6 +37,13 @@ export const genTest = (apiType, dbType) => { before(() => { cy.fileHook(); mainPage.tabReset(); + + // // kludge: wait for page load to finish + // cy.wait(1000); + // // close team & auth tab + // cy.get('button.ant-tabs-tab-remove').should('exist').click(); + // cy.wait(1000); + cy.openTableTab("City", 25); // store base URL- to re-visit and delete form view later @@ -56,7 +63,7 @@ export const genTest = (apiType, dbType) => { cy.saveLocalStorage(); }); - it.skip("Share view with incorrect password", () => { + it("Share view with incorrect password", () => { cy.visit(linkText, { baseUrl: null, }); @@ -64,7 +71,7 @@ export const genTest = (apiType, dbType) => { cy.getActiveModal().should("exist"); // feed password - cy.getActiveModal().find('input[type="password"]').type("a"); + cy.getActiveModal().find('input[type="password"]').clear().type("a"); cy.getActiveModal().find('button:contains("Unlock")').click(); // if pwd is incorrect, active modal requesting to feed in password again will persist @@ -72,7 +79,7 @@ export const genTest = (apiType, dbType) => { }); // fallover test- use previously opened view & continue verification instead of opening again - it.skip("Share view with correct password", () => { + it("Share view with correct password", () => { // feed password cy.getActiveModal() diff --git a/scripts/cypress-v2/integration/common/4c_form_view_detailed.js b/scripts/cypress-v2/integration/common/4c_form_view_detailed.js index ef55f16a5d..1882e7544d 100644 --- a/scripts/cypress-v2/integration/common/4c_form_view_detailed.js +++ b/scripts/cypress-v2/integration/common/4c_form_view_detailed.js @@ -49,6 +49,13 @@ export const genTest = (apiType, dbType) => { before(() => { cy.fileHook(); mainPage.tabReset(); + + // kludge: wait for page load to finish + cy.wait(1000); + // close team & auth tab + cy.get('button.ant-tabs-tab-remove').should('exist').click(); + cy.wait(1000); + // open a table to work on views // cy.openTableTab("Country", 25); @@ -451,8 +458,7 @@ export const genTest = (apiType, dbType) => { }; // below scenario's will be invoked twice, once for rest & then for graphql - // viewTest("form"); - viewTest("1"); + viewTest("form"); }); }; diff --git a/scripts/cypress-v2/support/page_objects/mainPage.js b/scripts/cypress-v2/support/page_objects/mainPage.js index 3e5498a807..566fbc748b 100644 --- a/scripts/cypress-v2/support/page_objects/mainPage.js +++ b/scripts/cypress-v2/support/page_objects/mainPage.js @@ -259,27 +259,27 @@ export class _mainPage { shareViewList = () => { cy.get(".nc-actions-menu-btn").click(); - return cy.getActiveMenu().find('.nc-menu-item').contains('Shared View List'); + return cy.getActiveMenu().find('.ant-dropdown-menu-item').contains('Shared View List'); }; downloadCsv = () => { cy.get(".nc-actions-menu-btn").click(); - return cy.getActiveMenu().find('.nc-menu-item').contains('Download as CSV'); + return cy.getActiveMenu().find('.ant-dropdown-menu-item').contains('Download as CSV'); }; downloadExcel = () => { cy.get(".nc-actions-menu-btn").click(); - return cy.getActiveMenu().find('.nc-menu-item').contains('Download as XLSX'); + return cy.getActiveMenu().find('.ant-dropdown-menu-item').contains('Download as XLSX'); }; uploadCsv = () => { cy.get(".nc-actions-menu-btn").click(); - return cy.getActiveMenu().find('.nc-menu-item').contains('Upload CSV'); + return cy.getActiveMenu().find('.ant-dropdown-menu-item').contains('Upload CSV'); }; automations = () => { cy.get(".nc-actions-menu-btn").click(); - return cy.getActiveMenu().find('.nc-menu-item').contains('Webhooks'); + return cy.getActiveMenu().find('.ant-dropdown-menu-item').contains('Webhooks'); }; hideField = (field) => { @@ -464,7 +464,7 @@ export class _mainPage { } toggleRightSidebar() { - cy.get(".nc-right-sidebar-toggle").should("exist").click(); + cy.get(".nc-toggle-right-navbar").should("exist").click(); } }