From 437e1abc0d4cf693f06c784222207aba1edcb30b Mon Sep 17 00:00:00 2001 From: Raju Udava <86527202+dstala@users.noreply.github.com> Date: Thu, 22 Sep 2022 17:07:39 +0530 Subject: [PATCH 1/5] test: enable ERD for PG, SQLite Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> --- scripts/cypress/integration/test/pg-restMisc.js | 3 ++- scripts/cypress/integration/test/xcdb-restMisc.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/cypress/integration/test/pg-restMisc.js b/scripts/cypress/integration/test/pg-restMisc.js index 74cfd319c0..9eecd3c349 100644 --- a/scripts/cypress/integration/test/pg-restMisc.js +++ b/scripts/cypress/integration/test/pg-restMisc.js @@ -11,6 +11,7 @@ const { setCurrentMode, } = require("../../support/page_objects/projectConstants"); const t8a = require("../common/8a_webhook"); +const t9b = require("../common/9b_ERD"); const nocoTestSuite = (apiType, dbType) => { setCurrentMode(apiType, dbType); @@ -31,7 +32,7 @@ const nocoTestSuite = (apiType, dbType) => { t6f.genTest(apiType, dbType); // ERD: - // t9b.genTest(apiType, dbType); + t9b.genTest(apiType, dbType); // Webhook tests t8a.genTest(apiType, dbType); diff --git a/scripts/cypress/integration/test/xcdb-restMisc.js b/scripts/cypress/integration/test/xcdb-restMisc.js index 84096b84ee..e3719a0291 100644 --- a/scripts/cypress/integration/test/xcdb-restMisc.js +++ b/scripts/cypress/integration/test/xcdb-restMisc.js @@ -8,6 +8,7 @@ let t6f = require("../common/6f_attachments"); let t6g = require("../common/6g_base_share"); let t7a = require("../common/7a_create_project_from_excel"); let t8a = require("../common/8a_webhook"); +const t9b = require("../common/9b_ERD"); const { setCurrentMode, @@ -33,7 +34,7 @@ const nocoTestSuite = (apiType, dbType) => { t6f.genTest(apiType, dbType); // ERD: - // t9b.genTest(apiType, dbType); + t9b.genTest(apiType, dbType); // Webhook tests t8a.genTest(apiType, dbType); From 844c4dda0f00516d21419a5b507a1015973097ac Mon Sep 17 00:00:00 2001 From: Muhammed Mustafa Date: Fri, 23 Sep 2022 17:52:35 +0530 Subject: [PATCH 2/5] fix(cypress): Added ERD test with pg and sqlite --- scripts/cypress/integration/common/9b_ERD.js | 726 ++++++++++-------- .../support/page_objects/projectConstants.js | 263 ++++--- 2 files changed, 545 insertions(+), 444 deletions(-) diff --git a/scripts/cypress/integration/common/9b_ERD.js b/scripts/cypress/integration/common/9b_ERD.js index 5eb43c3fe3..77e477f6a2 100644 --- a/scripts/cypress/integration/common/9b_ERD.js +++ b/scripts/cypress/integration/common/9b_ERD.js @@ -1,28 +1,42 @@ -import { mainPage, settingsPage } from "../../support/page_objects/mainPage"; -import { loginPage, projectsPage } from "../../support/page_objects/navigation"; -import { - isTestSuiteActive, - sakilaSqlViews, - sakilaTables, -} from "../../support/page_objects/projectConstants"; +import { mainPage } from "../../support/page_objects/mainPage"; +import {loginPage} from "../../support/page_objects/navigation"; +import { isTestSuiteActive, mysqlSakilaSqlViews, mysqlSakilaTables, pgSakilaSqlViews, pgSakilaTables, sqliteSakilaSqlViews } from "../../support/page_objects/projectConstants"; + +import {getProjectString} from "../../support/page_objects/projectConstants"; export const genTest = (apiType, dbType) => { if (!isTestSuiteActive(apiType, dbType)) return; + let projectId; + let sakilaTables, sakilaSqlViews; + + describe(`${apiType.toUpperCase()} ERD`, () => { - // before(() => { + before(() => { // loginPage.loginAndOpenProject(apiType, dbType); // cy.openTableTab("Country", 25); - // cy.saveLocalStorage(); - // }); + projectId = getProjectString() + cy.log('erd:getProjectString' + projectId) + if (dbType === "postgres") { + sakilaTables = pgSakilaTables; + sakilaSqlViews = pgSakilaSqlViews; + } else if(dbType === "mysql") { + sakilaTables = mysqlSakilaTables; + sakilaSqlViews = mysqlSakilaSqlViews; + } else if(dbType === "xcdb") { + sakilaTables = mysqlSakilaTables.map((tableName) => `${projectId}${tableName}`); + sakilaSqlViews = sqliteSakilaSqlViews.map((viewName) => `${projectId}${viewName}`); + } + cy.saveLocalStorage(); + }); beforeEach(() => { cy.restoreLocalStorage(); - }); + }) afterEach(() => { cy.saveLocalStorage(); - }); + }) after(() => { cy.restoreLocalStorage(); @@ -35,415 +49,507 @@ export const genTest = (apiType, dbType) => { it(`Enable MM setting Open Table ERD`, () => { cy.openTableTab("Country", 25); mainPage.toggleShowMMSetting(); - + mainPage.openErdTab(); mainPage.closeMetaTab(); }); it(`Verify ERD Context menu in all table view`, () => { mainPage.openErdTab(); - cy.get(".nc-erd-context-menu").should("be.visible"); - cy.get(".nc-erd-context-menu") - .get(".nc-erd-histogram") - .should("be.visible"); - cy.get(".nc-erd-context-menu") - .find(".ant-checkbox") - .should("have.length", 3); - cy.get(".nc-erd-context-menu") - .find(".ant-checkbox") - .eq(0) - .should("have.class", "ant-checkbox-checked"); - cy.get(".nc-erd-context-menu") - .find(".ant-checkbox") - .eq(1) - .should("have.class", "ant-checkbox-checked"); - cy.get(".nc-erd-context-menu") - .find(".ant-checkbox") - .eq(2) - .should("not.have.class", "ant-checkbox-checked"); - - cy.get(".nc-erd-context-menu") - .find(".nc-erd-showColumns-label") - .dblclick(); - cy.get(".nc-erd-context-menu") - .find(".ant-checkbox") - .should("have.length", 5); + cy.get('.nc-erd-context-menu').should('be.visible'); + cy.get('.nc-erd-context-menu').get('.nc-erd-histogram').should('be.visible'); + cy.get('.nc-erd-context-menu').find('.ant-checkbox').should('have.length', 3); + cy.get('.nc-erd-context-menu').find('.ant-checkbox').eq(0).should('have.class', 'ant-checkbox-checked'); + cy.get('.nc-erd-context-menu').find('.ant-checkbox').eq(1).should('have.class', 'ant-checkbox-checked'); + cy.get('.nc-erd-context-menu').find('.ant-checkbox').eq(2).should('not.have.class', 'ant-checkbox-checked'); + + cy.get('.nc-erd-context-menu').find('.nc-erd-showColumns-label').dblclick(); + cy.get('.nc-erd-context-menu').find('.ant-checkbox').should('have.length', 5); }); it("Verify ERD of all tables view and verify columns of actor and payment with default config", () => { - cy.get(".nc-erd-vue-flow") - .find(".nc-erd-table-node") - .should("have.length", 12); - cy.get(".nc-erd-vue-flow") - .find(".vue-flow__edge") - .should("have.length", 14); - cy.get(".nc-erd-vue-flow") - .find(".nc-erd-edge-circle") - .should("have.length", 11); - cy.get(".nc-erd-vue-flow") - .find(".nc-erd-edge-rect") - .should("have.length", 17); - - for (const tableName of sakilaTables) { - cy.get(".nc-erd-vue-flow") - .find(`.nc-erd-table-node-${tableName}`) - .should("exist"); + if(dbType === "mysql") { + cy.get('.nc-erd-vue-flow').find('.nc-erd-table-node').should('have.length', 12) + cy.get('.nc-erd-vue-flow').find('.vue-flow__edge').should('have.length', 14) + cy.get('.nc-erd-vue-flow').find('.nc-erd-edge-circle').should('have.length', 11) + cy.get('.nc-erd-vue-flow').find('.nc-erd-edge-rect').should('have.length', 17) + } else if (dbType === "postgres") { + cy.get('.nc-erd-vue-flow').find('.nc-erd-table-node').should('have.length', 17) + cy.get('.nc-erd-vue-flow').find('.vue-flow__edge').should('have.length', 32) + cy.get('.nc-erd-vue-flow').find('.nc-erd-edge-circle').should('have.length', 29) + cy.get('.nc-erd-vue-flow').find('.nc-erd-edge-rect').should('have.length', 35) + } else { + cy.get('.nc-erd-vue-flow').find('.nc-erd-table-node').should('have.length', 12) + cy.get('.nc-erd-vue-flow').find('.vue-flow__edge').should('have.length', 14) + cy.get('.nc-erd-vue-flow').find('.nc-erd-edge-circle').should('have.length', 11) + cy.get('.nc-erd-vue-flow').find('.nc-erd-edge-rect').should('have.length', 17) + } + + for(const tableName of sakilaTables) { + cy.get('.nc-erd-vue-flow').find(`.nc-erd-table-node-${tableName}`).should('exist'); } // Actor table [ - "actor_id", - "first_name", - "last_name", - "last_update", - "film_list", + 'actor_id', + 'first_name', + 'last_name', + 'last_update', + 'film_list' ].forEach((colTitle) => { - cy.get(".nc-erd-vue-flow") - .find(`.nc-erd-table-node-actor`) - .find(`.nc-erd-table-node-actor-column-${colTitle}`) - .should("exist"); + if (dbType === "xcdb") { + cy.get('.nc-erd-vue-flow').find(`.nc-erd-table-node-${projectId}actor`).find(`.nc-erd-table-node-${projectId}actor-column-${colTitle}`).should('exist'); + } else { + cy.get('.nc-erd-vue-flow').find(`.nc-erd-table-node-actor`).find(`.nc-erd-table-node-actor-column-${colTitle}`).should('exist'); + } }); // Payment table - [ - "payment_id", - "customer_id", - "staff_id", - "rental_id", - "amount", - "payment_date", - "last_update", - "customer", - "rental", - "staff", - ].forEach((colTitle) => { - cy.get(".nc-erd-vue-flow") - .find(`.nc-erd-table-node-payment`) - .find(`.nc-erd-table-node-payment-column-${colTitle}`) - .should("exist"); - }); + if(dbType === "mysql") { + [ + 'payment_id', + 'customer_id', + 'staff_id', + 'rental_id', + 'amount', + 'payment_date', + 'last_update', + 'customer', + 'rental', + 'staff' + ] + .forEach((colTitle) => { + cy.get('.nc-erd-vue-flow').find(`.nc-erd-table-node-payment`).find(`.nc-erd-table-node-payment-column-${colTitle}`).should('exist'); + }); + } else if(dbType === "postgres") { + [ + 'payment_id', + 'customer_id', + 'staff_id', + 'rental_id', + 'amount', + 'payment_date', + 'customer', + 'rental', + 'staff' + ] + .forEach((colTitle) => { + cy.get('.nc-erd-vue-flow').find(`.nc-erd-table-node-payment`).find(`.nc-erd-table-node-payment-column-${colTitle}`).should('exist'); + }); + } else { + [ + 'payment_id', + 'customer_id', + 'staff_id', + 'rental_id', + 'amount', + 'payment_date', + 'last_update', + 'customer', + 'rental', + 'staff' + ] + .forEach((colTitle) => { + cy.get('.nc-erd-vue-flow').find(`.nc-erd-table-node-${projectId}payment`).find(`.nc-erd-table-node-${projectId}payment-column-${colTitle}`).should('exist'); + }); + } }); it("Verify ERD of all tables view and verify columns of actor and payment with default config with showAllColumn disabled", () => { - cy.get(".nc-erd-context-menu") - .get(".nc-erd-showColumns-checkbox") - .click(); - cy.get(".nc-erd-showPkAndFk-checkbox-disabled").should("exist"); - cy.get(".nc-erd-showPkAndFk-checkbox-unchecked").should("exist"); + cy.get('.nc-erd-context-menu').get('.nc-erd-showColumns-checkbox').click(); + cy.get('.nc-erd-showPkAndFk-checkbox-disabled').should('exist'); + cy.get('.nc-erd-showPkAndFk-checkbox-unchecked').should('exist'); // Actor table - ["film_list"].forEach((colTitle) => { - cy.get(".nc-erd-vue-flow") - .find(`.nc-erd-table-node-actor`) - .find(`.nc-erd-table-node-actor-column-${colTitle}`) - .should("exist"); + [ + 'film_list' + ].forEach((colTitle) => { + if(dbType === "xcdb") { + cy.get('.nc-erd-vue-flow').find(`.nc-erd-table-node-${projectId}actor`).find(`.nc-erd-table-node-${projectId}actor-column-${colTitle}`).should('exist'); + } else { + cy.get('.nc-erd-vue-flow').find(`.nc-erd-table-node-actor`).find(`.nc-erd-table-node-actor-column-${colTitle}`).should('exist'); + } }); // Payment table - ["customer", "rental", "staff"].forEach((colTitle) => { - cy.get(".nc-erd-vue-flow") - .find(`.nc-erd-table-node-payment`) - .find(`.nc-erd-table-node-payment-column-${colTitle}`) - .should("exist"); + [ + 'customer', + 'rental', + 'staff' + ].forEach((colTitle) => { + if(dbType === "xcdb") { + cy.get('.nc-erd-vue-flow').find(`.nc-erd-table-node-${projectId}payment`).find(`.nc-erd-table-node-${projectId}payment-column-${colTitle}`).should('exist'); + } else { + cy.get('.nc-erd-vue-flow').find(`.nc-erd-table-node-payment`).find(`.nc-erd-table-node-payment-column-${colTitle}`).should('exist'); + } }); }); it("Verify ERD of all tables view and verify columns of actor and payment with default config with showPkAndFk disabled", () => { // enable showAllColumn - cy.get(".nc-erd-context-menu") - .get(".nc-erd-showColumns-checkbox") - .click(); - cy.get(".nc-erd-context-menu") - .get(".nc-erd-showPkAndFk-checkbox") - .click(); + cy.get('.nc-erd-context-menu').get('.nc-erd-showColumns-checkbox').click(); + cy.get('.nc-erd-context-menu').get('.nc-erd-showPkAndFk-checkbox').click(); // Actor table - ["last_name", "last_update", "film_list"].forEach((colTitle) => { - cy.get(".nc-erd-vue-flow") - .find(`.nc-erd-table-node-actor`) - .find(`.nc-erd-table-node-actor-column-${colTitle}`) - .should("exist"); - }); - - // Payment table [ - "amount", - "payment_date", - "last_update", - "customer", - "rental", - "staff", + 'last_name', + 'last_update', + 'film_list' ].forEach((colTitle) => { - cy.get(".nc-erd-vue-flow") - .find(`.nc-erd-table-node-payment`) - .find(`.nc-erd-table-node-payment-column-${colTitle}`) - .should("exist"); + if(dbType === "xcdb") { + cy.get('.nc-erd-vue-flow').find(`.nc-erd-table-node-${projectId}actor`).find(`.nc-erd-table-node-${projectId}actor-column-${colTitle}`).should('exist'); + } else { + cy.get('.nc-erd-vue-flow').find(`.nc-erd-table-node-actor`).find(`.nc-erd-table-node-actor-column-${colTitle}`).should('exist'); + } }); + + // Payment table + if(dbType === "mysql") { + [ + 'amount', + 'payment_date', + 'last_update', + 'customer', + 'rental', + 'staff' + ].forEach((colTitle) => { + cy.get('.nc-erd-vue-flow').find(`.nc-erd-table-node-payment`).find(`.nc-erd-table-node-payment-column-${colTitle}`).should('exist'); + }); + } else if(dbType === "postgres") { + [ + 'amount', + 'payment_date', + 'customer', + 'rental', + 'staff' + ].forEach((colTitle) => { + cy.get('.nc-erd-vue-flow').find(`.nc-erd-table-node-payment`).find(`.nc-erd-table-node-payment-column-${colTitle}`).should('exist'); + }); + } else { + [ + 'amount', + 'payment_date', + 'last_update', + 'customer', + 'rental', + 'staff' + ].forEach((colTitle) => { + cy.get('.nc-erd-vue-flow').find(`.nc-erd-table-node-${projectId}payment`).find(`.nc-erd-table-node-${projectId}payment-column-${colTitle}`).should('exist'); + }); + } }); it("Verify ERD of all tables view with sql grid on and verify columns of ActorInfo", () => { - cy.get(".nc-erd-context-menu").get(".nc-erd-showViews-checkbox").click(); - - cy.get(".nc-erd-vue-flow") - .find(".nc-erd-table-node") - .should("have.length", 19); - cy.get(".nc-erd-vue-flow") - .find(".vue-flow__edge") - .should("have.length", 14); - cy.get(".nc-erd-vue-flow") - .find(".nc-erd-edge-circle") - .should("have.length", 11); - cy.get(".nc-erd-vue-flow") - .find(".nc-erd-edge-rect") - .should("have.length", 17); - - for (const tableName of sakilaTables) { - cy.get(".nc-erd-vue-flow") - .find(`.nc-erd-table-node-${tableName}`) - .should("exist"); + cy.get('.nc-erd-context-menu').get('.nc-erd-showViews-checkbox').click(); + + if(dbType === "mysql") { + cy.get('.nc-erd-vue-flow').find('.nc-erd-table-node').should('have.length', 19) + cy.get('.nc-erd-vue-flow').find('.vue-flow__edge').should('have.length', 14) + cy.get('.nc-erd-vue-flow').find('.nc-erd-edge-circle').should('have.length', 11) + cy.get('.nc-erd-vue-flow').find('.nc-erd-edge-rect').should('have.length', 17) + } else if(dbType === "postgres") { + cy.get('.nc-erd-vue-flow').find('.nc-erd-table-node').should('have.length', 24) + cy.get('.nc-erd-vue-flow').find('.vue-flow__edge').should('have.length', 32) + cy.get('.nc-erd-vue-flow').find('.nc-erd-edge-circle').should('have.length', 29) + cy.get('.nc-erd-vue-flow').find('.nc-erd-edge-rect').should('have.length', 35) + } else { + cy.get('.nc-erd-vue-flow').find('.nc-erd-table-node').should('have.length', 19) + cy.get('.nc-erd-vue-flow').find('.vue-flow__edge').should('have.length', 14) + cy.get('.nc-erd-vue-flow').find('.nc-erd-edge-circle').should('have.length', 11) + cy.get('.nc-erd-vue-flow').find('.nc-erd-edge-rect').should('have.length', 17) } - for (const tableName of sakilaSqlViews) { - cy.get(".nc-erd-vue-flow") - .find(`.nc-erd-table-node-${tableName}`) - .should("exist"); + for(const tableName of sakilaTables) { + cy.get('.nc-erd-vue-flow').find(`.nc-erd-table-node-${tableName}`).should('exist'); + } + + for(const tableName of sakilaSqlViews) { + cy.get('.nc-erd-vue-flow').find(`.nc-erd-table-node-${tableName}`).should('exist'); } // ActorInfo SQL View - ["actor_id", "first_name", "last_name", "film_info"].forEach( - (colTitle) => { - cy.get(".nc-erd-vue-flow") - .find(`.nc-erd-table-node-actor_info`) - .find(`.nc-erd-table-node-actor_info-column-${colTitle}`) - .should("exist"); + let actorInfoColumns; + if(dbType === "xcdb") { + actorInfoColumns = [ + 'ID', + 'name', + 'address', + 'zip_code', + 'phone', + 'city', + 'country', + 'SID', + ]; + } else { + actorInfoColumns = [ + 'actor_id', + 'first_name', + 'last_name', + 'film_info' + ]; + } + actorInfoColumns.forEach((colTitle) => { + if(dbType === "xcdb") { + cy.get('.nc-erd-vue-flow').find(`.nc-erd-table-node-${projectId}actor_info`).find(`.nc-erd-table-node-${projectId}actor_info-column-${colTitle}`).should('exist'); + } else { + cy.get('.nc-erd-vue-flow').find(`.nc-erd-table-node-actor_info`).find(`.nc-erd-table-node-actor_info-column-${colTitle}`).should('exist'); } - ); + }) + }); it("Verify show MM tables", () => { - cy.get(".nc-erd-vue-flow") - .find(`.nc-erd-table-node-store`) - .should("not.exist"); + if(dbType === "xcdb") { + cy.get('.nc-erd-vue-flow').find(`.nc-erd-table-node-${projectId}store`).should('not.exist'); + } else { + cy.get('.nc-erd-vue-flow').find(`.nc-erd-table-node-store`).should('not.exist'); + } // disable showViews - cy.get(".nc-erd-context-menu").get(".nc-erd-showViews-checkbox").click(); - cy.get(".nc-erd-context-menu") - .get(".nc-erd-showMMTables-checkbox") - .click(); - - cy.get(".nc-erd-vue-flow") - .find(".nc-erd-table-node") - .should("have.length", 16); - cy.get(".nc-erd-vue-flow") - .find(".vue-flow__edge") - .should("have.length", 26); - cy.get(".nc-erd-vue-flow") - .find(".nc-erd-edge-circle") - .should("have.length", 22); - cy.get(".nc-erd-vue-flow") - .find(".nc-erd-edge-rect") - .should("have.length", 30); - + cy.get('.nc-erd-context-menu').get('.nc-erd-showViews-checkbox').click(); + cy.get('.nc-erd-context-menu').get('.nc-erd-showMMTables-checkbox').click(); + + if(dbType === "mysql") { + cy.get('.nc-erd-vue-flow').find('.nc-erd-table-node').should('have.length', 16) + cy.get('.nc-erd-vue-flow').find('.vue-flow__edge').should('have.length', 26) + cy.get('.nc-erd-vue-flow').find('.nc-erd-edge-circle').should('have.length', 22) + cy.get('.nc-erd-vue-flow').find('.nc-erd-edge-rect').should('have.length', 30) + } else if(dbType === "postgres") { + cy.get('.nc-erd-vue-flow').find('.nc-erd-table-node').should('have.length', 21) + cy.get('.nc-erd-vue-flow').find('.vue-flow__edge').should('have.length', 44) + cy.get('.nc-erd-vue-flow').find('.nc-erd-edge-circle').should('have.length', 40) + cy.get('.nc-erd-vue-flow').find('.nc-erd-edge-rect').should('have.length', 48) + } else { + cy.get('.nc-erd-vue-flow').find('.nc-erd-table-node').should('have.length', 16) + cy.get('.nc-erd-vue-flow').find('.vue-flow__edge').should('have.length', 26) + cy.get('.nc-erd-vue-flow').find('.nc-erd-edge-circle').should('have.length', 22) + cy.get('.nc-erd-vue-flow').find('.nc-erd-edge-rect').should('have.length', 30) + } + // Check if store table is present - cy.get(".nc-erd-vue-flow") - .find(`.nc-erd-table-node-store`) - .should("exist"); - }); + if(dbType === "xcdb") { + cy.get('.nc-erd-vue-flow').find(`.nc-erd-table-node-${projectId}store`).should('exist'); + } else { + cy.get('.nc-erd-vue-flow').find(`.nc-erd-table-node-store`).should('exist'); + } + }) it("Verify show junction table names", () => { // disable showViews - cy.get(".nc-erd-context-menu") - .get(".nc-erd-showJunctionTableNames-checkbox") - .click(); + cy.get('.nc-erd-context-menu').get('.nc-erd-showJunctionTableNames-checkbox').click(); - cy.get(".nc-erd-vue-flow") - .get(".nc-erd-table-label-filmactor-film_actor") - .should("exist"); + if(dbType === "xcdb") { + cy.get('.nc-erd-vue-flow').get(`.nc-erd-table-label-filmactor-${projectId}film_actor`).should('exist'); + } else { + cy.get('.nc-erd-vue-flow').get('.nc-erd-table-label-filmactor-film_actor').should('exist'); + } mainPage.closeMetaTab(); - }); + }) - it("Verify table ERD view of country", () => { + it('Verify table ERD view of country', () => { mainPage.openTableErdView(); - cy.get(".nc-erd-vue-flow-single-table") - .find(".nc-erd-table-node") - .should("have.length", 2); - cy.get(".nc-erd-vue-flow-single-table") - .find(".vue-flow__edge") - .should("have.length", 1); - cy.get(".nc-erd-vue-flow-single-table") - .find(".nc-erd-edge-circle") - .should("have.length", 1); - cy.get(".nc-erd-vue-flow-single-table") - .find(".nc-erd-edge-rect") - .should("have.length", 1); + cy.get('.nc-erd-vue-flow-single-table').find('.nc-erd-table-node').should('have.length', 2) + cy.get('.nc-erd-vue-flow-single-table').find('.vue-flow__edge').should('have.length', 1) + cy.get('.nc-erd-vue-flow-single-table').find('.nc-erd-edge-circle').should('have.length', 1) + cy.get('.nc-erd-vue-flow-single-table').find('.nc-erd-edge-rect').should('have.length', 1) const countryColumns = [ - "country_id", - "country", - "last_update", - "city_list", - ]; + 'country_id', + 'country', + 'last_update', + 'city_list' + ] // Country table countryColumns.forEach((colTitle) => { - cy.get(".nc-erd-vue-flow-single-table") - .find(`.nc-erd-table-node-country`) - .find(`.nc-erd-table-node-country-column-${colTitle}`) - .should("exist"); + if(dbType === "xcdb") { + cy.get('.nc-erd-vue-flow-single-table').find(`.nc-erd-table-node-${projectId}country`).find(`.nc-erd-table-node-${projectId}country-column-${colTitle}`).should('exist'); + } else { + cy.get('.nc-erd-vue-flow-single-table').find(`.nc-erd-table-node-country`).find(`.nc-erd-table-node-country-column-${colTitle}`).should('exist'); + } }); const cityColumns = [ - "city_id", - "city", - "last_update", - "country", - "address_list", - ]; + 'city_id', + 'city', + 'last_update', + 'country', + 'address_list' + ] // City table cityColumns.forEach((colTitle) => { - cy.get(".nc-erd-vue-flow-single-table") - .find(`.nc-erd-table-node-city`) - .find(`.nc-erd-table-node-city-column-${colTitle}`) - .should("exist"); + if(dbType === "xcdb") { + cy.get('.nc-erd-vue-flow-single-table').find(`.nc-erd-table-node-${projectId}city`).find(`.nc-erd-table-node-${projectId}city-column-${colTitle}`).should('exist'); + } else { + cy.get('.nc-erd-vue-flow-single-table').find(`.nc-erd-table-node-city`).find(`.nc-erd-table-node-city-column-${colTitle}`).should('exist'); + } }); - }); - - it("Verify table ERD view of country showAllColumn disabled", () => { - cy.get(".nc-erd-vue-flow-single-table").within(() => { - cy.get(".nc-erd-context-menu") - .get(".nc-erd-showColumns-checkbox") - .click(); - cy.get(".nc-erd-showPkAndFk-checkbox-disabled").should("exist"); - cy.get(".nc-erd-showPkAndFk-checkbox-unchecked").should("exist"); - - const countryColumns = ["city_list"]; - + }) + + it('Verify table ERD view of country showAllColumn disabled', () => { + cy.get('.nc-erd-vue-flow-single-table').within(() => { + cy.get('.nc-erd-context-menu').get('.nc-erd-showColumns-checkbox').click(); + cy.get('.nc-erd-showPkAndFk-checkbox-disabled').should('exist'); + cy.get('.nc-erd-showPkAndFk-checkbox-unchecked').should('exist'); + + const countryColumns = [ + 'city_list' + ] + // Country table countryColumns.forEach((colTitle) => { - cy.get(`.nc-erd-table-node-country`) - .find(`.nc-erd-table-node-country-column-${colTitle}`) - .should("exist"); + if(dbType === "xcdb") { + cy.get(`.nc-erd-table-node-${projectId}country`).find(`.nc-erd-table-node-${projectId}country-column-${colTitle}`).should('exist'); + } else { + cy.get(`.nc-erd-table-node-country`).find(`.nc-erd-table-node-country-column-${colTitle}`).should('exist'); + } }); - - const cityColumns = ["country", "address_list"]; - + + const cityColumns = [ + 'country', + 'address_list' + ] + // City table cityColumns.forEach((colTitle) => { - cy.get(`.nc-erd-table-node-city`) - .find(`.nc-erd-table-node-city-column-${colTitle}`) - .should("exist"); + if(dbType === "xcdb") { + cy.get(`.nc-erd-table-node-${projectId}city`).find(`.nc-erd-table-node-${projectId}city-column-${colTitle}`).should('exist'); + } else { + cy.get(`.nc-erd-table-node-city`).find(`.nc-erd-table-node-city-column-${colTitle}`).should('exist'); + } }); - cy.get(".nc-erd-context-menu") - .get(".nc-erd-showColumns-checkbox") - .click(); - }); - }); - - it("Verify table ERD view of country show PK AND FK disabled", () => { - cy.get(".nc-erd-vue-flow-single-table").within(() => { - cy.get(".nc-erd-context-menu") - .get(".nc-erd-showPkAndFk-checkbox") - .click(); + cy.get('.nc-erd-context-menu').get('.nc-erd-showColumns-checkbox').click(); + }) + }) - const countryColumns = ["country", "last_update", "city_list"]; + it('Verify table ERD view of country show PK AND FK disabled', () => { + cy.get('.nc-erd-vue-flow-single-table').within(() => { + cy.get('.nc-erd-context-menu').get('.nc-erd-showPkAndFk-checkbox').click(); + const countryColumns = [ + 'country', + 'last_update', + 'city_list' + ] + // Country table countryColumns.forEach((colTitle) => { - cy.get(`.nc-erd-table-node-country`) - .find(`.nc-erd-table-node-country-column-${colTitle}`) - .should("exist"); + if(dbType === "xcdb") { + cy.get(`.nc-erd-table-node-${projectId}country`).find(`.nc-erd-table-node-${projectId}country-column-${colTitle}`).should('exist'); + } else { + cy.get(`.nc-erd-table-node-country`).find(`.nc-erd-table-node-country-column-${colTitle}`).should('exist'); + } }); - - const cityColumns = ["city", "last_update", "country", "address_list"]; - + + const cityColumns = [ + 'city', + 'last_update', + 'country', + 'address_list' + ] + // City table cityColumns.forEach((colTitle) => { - cy.get(`.nc-erd-table-node-city`) - .find(`.nc-erd-table-node-city-column-${colTitle}`) - .should("exist"); + if(dbType === "xcdb") { + cy.get(`.nc-erd-table-node-${projectId}city`).find(`.nc-erd-table-node-${projectId}city-column-${colTitle}`).should('exist'); + } else { + cy.get(`.nc-erd-table-node-city`).find(`.nc-erd-table-node-city-column-${colTitle}`).should('exist'); + } }); - cy.get(".nc-erd-context-menu") - .get(".nc-erd-showPkAndFk-checkbox") - .click(); - }); - cy.getActiveModal().find(".nc-modal-close").click({ force: true }); - }); + cy.get('.nc-erd-context-menu').get('.nc-erd-showPkAndFk-checkbox').click(); + + }) + cy.getActiveModal().find('.nc-modal-close').click({ force: true }); + }) - it("create column and check if the change is in the schema", () => { - mainPage.addColumn("test_column", "country"); + it('create column and check if the change is in the schema', () => { + mainPage.addColumn('test_column', 'country') // table view mainPage.openTableErdView(); - cy.get(".nc-erd-vue-flow-single-table").within(() => { - cy.get(".nc-erd-table-node-country") - .find(".nc-erd-table-node-country-column-test_column") - .should("exist"); - }); - cy.getActiveModal().find(".nc-modal-close").click({ force: true }); + cy.get('.nc-erd-vue-flow-single-table').within(() => { + if(dbType === "xcdb") { + cy.get(`.nc-erd-table-node-${projectId}country`).find(`.nc-erd-table-node-${projectId}country-column-test_column`).should('exist'); + } else { + cy.get('.nc-erd-table-node-country').find('.nc-erd-table-node-country-column-test_column').should('exist'); + } + }) + cy.getActiveModal().find('.nc-modal-close').click({ force: true }); // All table view mainPage.openErdTab(); - cy.get(".nc-erd-vue-flow").within(() => { - cy.get(".nc-erd-table-node-country") - .find(".nc-erd-table-node-country-column-test_column") - .should("exist"); - }); + cy.get('.nc-erd-vue-flow').within(() => { + if(dbType === "xcdb") { + cy.get(`.nc-erd-table-node-${projectId}country`).find(`.nc-erd-table-node-${projectId}country-column-test_column`).should('exist'); + } else { + cy.get('.nc-erd-table-node-country').find('.nc-erd-table-node-country-column-test_column').should('exist'); + } + }) mainPage.closeMetaTab(); - mainPage.deleteColumn("test_column"); + mainPage.deleteColumn('test_column') + // table view mainPage.openTableErdView(); - cy.get(".nc-erd-vue-flow-single-table").within(() => { - cy.get(".nc-erd-table-node-country") - .find(".nc-erd-table-node-country-column-test_column") - .should("not.exist"); - }); - cy.getActiveModal().find(".nc-modal-close").click({ force: true }); + cy.get('.nc-erd-vue-flow-single-table').within(() => { + if(dbType === "xcdb") { + cy.get(`.nc-erd-table-node-${projectId}country`).find(`.nc-erd-table-node-${projectId}country-column-test_column`).should('not.exist'); + } else { + cy.get('.nc-erd-table-node-country').find('.nc-erd-table-node-country-column-test_column').should('not.exist'); + } + }) + cy.getActiveModal().find('.nc-modal-close').click({ force: true }); // All table view mainPage.openErdTab(); - cy.get(".nc-erd-vue-flow").within(() => { - cy.get(".nc-erd-table-node-country") - .find(".nc-erd-table-node-country-column-test_column") - .should("not.exist"); - }); + cy.get('.nc-erd-vue-flow').within(() => { + if(dbType === "xcdb") { + cy.get(`.nc-erd-table-node-${projectId}country`).find(`.nc-erd-table-node-${projectId}country-column-test_column`).should('not.exist'); + } else { + cy.get('.nc-erd-table-node-country').find('.nc-erd-table-node-country-column-test_column').should('not.exist'); + } + }) mainPage.closeMetaTab(); - }); + }) - it("Create table should reflected in ERD", () => { - cy.createTable("new"); + it('Create table should reflected in ERD', () => { + cy.createTable('new') mainPage.openErdTab(); - cy.get(".nc-erd-vue-flow").within(() => { - cy.get(".nc-erd-table-node-new").should("exist"); - }); + cy.get('.nc-erd-vue-flow').within(() => { + if(dbType === "xcdb") { + cy.get(`.nc-erd-table-node-${projectId}new`).should('exist'); + } else { + cy.get('.nc-erd-table-node-new').should('exist'); + } + }) mainPage.closeMetaTab(); - cy.deleteTable("new"); - + cy.deleteTable('new') + mainPage.openErdTab(); - cy.get(".nc-erd-vue-flow").within(() => { - cy.get(".nc-erd-table-node-new").should("not.exist"); - }); + cy.get('.nc-erd-vue-flow').within(() => { + if(dbType === "xcdb") { + cy.get(`.nc-erd-table-node-${projectId}new`).should('not.exist'); + } else { + cy.get('.nc-erd-table-node-new').should('not.exist'); + } + }) mainPage.closeMetaTab(); - }); + }) it(`Disable MM setting Open Table ERD and check easter egg should not work`, () => { mainPage.toggleShowMMSetting(); - + mainPage.openErdTab(); - cy.get(".nc-erd-vue-flow").within(() => { - cy.get(".nc-erd-context-menu") - .find(".nc-erd-showColumns-label") - .dblclick(); - cy.get(".nc-erd-context-menu") - .find(".ant-checkbox") - .should("have.length", 3); - }); + cy.get('.nc-erd-vue-flow').within(() => { + cy.get('.nc-erd-context-menu').find('.nc-erd-showColumns-label').dblclick(); + cy.get('.nc-erd-context-menu').find('.ant-checkbox').should('have.length', 3); + }) mainPage.closeMetaTab(); }); @@ -470,4 +576,4 @@ export const genTest = (apiType, dbType) => { * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * - */ + */ \ No newline at end of file diff --git a/scripts/cypress/support/page_objects/projectConstants.js b/scripts/cypress/support/page_objects/projectConstants.js index 1111f7f597..8b7b044f27 100644 --- a/scripts/cypress/support/page_objects/projectConstants.js +++ b/scripts/cypress/support/page_objects/projectConstants.js @@ -1,19 +1,19 @@ export const defaultDbParams = { - databaseType: 0, // MySQL - hostAddress: "localhost", - portNumber: "3306", - username: "root", - password: "password", - databaseName: "sakila", + databaseType: 0, // MySQL + hostAddress: "localhost", + portNumber: "3306", + username: "root", + password: "password", + databaseName: "sakila", }; export const defaultPgDbParams = { - databaseType: 1, // Postgres - hostAddress: "localhost", - portNumber: "5432", - username: "postgres", - password: "password", - databaseName: "postgres", + databaseType: 1, // Postgres + hostAddress: "localhost", + portNumber: "5432", + username: "postgres", + password: "password", + databaseName: "postgres", }; // database @@ -24,162 +24,157 @@ export const defaultPgDbParams = { // editComment: add comment // shareView: right navigation bar (share options) export const roles = { - owner: { - name: "owner", - credentials: { username: "user@nocodb.com", password: "Password123." }, - validations: { - advSettings: true, - editSchema: true, - editData: true, - editComment: true, - shareView: true, + owner: { + name: "owner", + credentials: { username: "user@nocodb.com", password: "Password123." }, + validations: { + advSettings: true, + editSchema: true, + editData: true, + editComment: true, + shareView: true, + }, }, - }, - creator: { - name: "creator", - credentials: { - username: "creator@nocodb.com", - password: "Password123.", + creator: { + name: "creator", + credentials: { + username: "creator@nocodb.com", + password: "Password123.", + }, + validations: { + advSettings: true, + editSchema: true, + editData: true, + editComment: true, + shareView: true, + }, }, - validations: { - advSettings: true, - editSchema: true, - editData: true, - editComment: true, - shareView: true, + editor: { + name: "editor", + credentials: { + username: "editor@nocodb.com", + password: "Password123.", + }, + validations: { + advSettings: false, + editSchema: false, + editData: true, + editComment: true, + shareView: false, + }, }, - }, - editor: { - name: "editor", - credentials: { - username: "editor@nocodb.com", - password: "Password123.", + commenter: { + name: "commenter", + credentials: { + username: "commenter@nocodb.com", + password: "Password123.", + }, + validations: { + advSettings: false, + editSchema: false, + editData: false, + editComment: true, + shareView: false, + }, }, - validations: { - advSettings: false, - editSchema: false, - editData: true, - editComment: true, - shareView: false, + viewer: { + name: "viewer", + credentials: { + username: "viewer@nocodb.com", + password: "Password123.", + }, + validations: { + advSettings: false, + editSchema: false, + editData: false, + editComment: false, + shareView: false, + }, }, - }, - commenter: { - name: "commenter", - credentials: { - username: "commenter@nocodb.com", - password: "Password123.", - }, - validations: { - advSettings: false, - editSchema: false, - editData: false, - editComment: true, - shareView: false, - }, - }, - viewer: { - name: "viewer", - credentials: { - username: "viewer@nocodb.com", - password: "Password123.", - }, - validations: { - advSettings: false, - editSchema: false, - editData: false, - editComment: false, - shareView: false, - }, - }, }; // default projects // export const staticProjects = { - sampleREST: { - basic: { dbType: "none", apiType: "REST", name: "sampleREST" }, - config: {}, - }, - sampleGQL: { - basic: { dbType: "none", apiType: "GQL", name: "sampleGQL" }, - config: {}, - }, - externalREST: { - basic: { dbType: "external", apiType: "REST", name: "externalREST" }, - config: defaultDbParams, - }, - externalGQL: { - basic: { dbType: "external", apiType: "GQL", name: "externalGQL" }, - config: defaultDbParams, - }, - pgExternalREST: { - basic: { dbType: "external", apiType: "REST", name: "pgExtREST" }, - config: defaultPgDbParams, - }, - pgExternalGQL: { - basic: { dbType: "external", apiType: "GQL", name: "pgExternalGQL" }, - config: defaultPgDbParams, - }, + sampleREST: { + basic: { dbType: "none", apiType: "REST", name: "sampleREST" }, + config: {}, + }, + sampleGQL: { + basic: { dbType: "none", apiType: "GQL", name: "sampleGQL" }, + config: {}, + }, + externalREST: { + basic: { dbType: "external", apiType: "REST", name: "externalREST" }, + config: defaultDbParams, + }, + externalGQL: { + basic: { dbType: "external", apiType: "GQL", name: "externalGQL" }, + config: defaultDbParams, + }, + pgExternalREST: { + basic: { dbType: "external", apiType: "REST", name: "pgExtREST" }, + config: defaultPgDbParams, + }, + pgExternalGQL: { + basic: { dbType: "external", apiType: "GQL", name: "pgExternalGQL" }, + config: defaultPgDbParams, + }, }; // return TRUE if test suite specified is activated from env-variables // export const isTestSuiteActive = (apiType, dbType) => { - const env = Cypress.env("testMode"); - return env.some( - (element) => element.apiType === apiType && element.dbType === dbType - ); + const env = Cypress.env("testMode"); + return env.some( + (element) => element.apiType === apiType && element.dbType === dbType + ); }; let currentTestMode = { apiType: null, dbType: null }; let xcdbProjectString = ``; export function setCurrentMode(apiType, dbType) { - currentTestMode = { apiType: apiType, dbType: dbType }; + currentTestMode = { apiType: apiType, dbType: dbType }; } export function getCurrentMode() { - return currentTestMode; + return currentTestMode; } export function isXcdb() { - return currentTestMode.dbType === "xcdb"; + return currentTestMode.dbType === "xcdb"; } export function isPostgres() { - return currentTestMode.dbType === "postgres"; + return currentTestMode.dbType === "postgres"; } export function setProjectString(projStr) { - xcdbProjectString = projStr; + xcdbProjectString = projStr; } export function getProjectString() { - return xcdbProjectString; + return xcdbProjectString; } -const sakilaTables = [ - "actor", - "address", - "category", - "city", - "country", - "customer", - "film", - "film_text", - "language", - "payment", - "rental", - "staff", -]; - -const sakilaSqlViews = [ - "actor_info", - "customer_list", - "film_list", - "nicer_but_slower_film_list", - "sales_by_film_category", - "sales_by_store", - "staff_list", -]; - -export { sakilaTables, sakilaSqlViews }; +const mysqlSakilaTables = [ + 'actor', 'address', 'category', 'city', 'country', 'customer', 'film', 'film_text', 'language', 'payment', 'rental', 'staff' +] + +const mysqlSakilaSqlViews = [ + 'actor_info', 'customer_list', 'film_list', 'nicer_but_slower_film_list', 'sales_by_film_category', 'sales_by_store', 'staff_list' +] + +const pgSakilaTables = [ + 'actor', 'address', 'category', 'city', 'country', 'customer', 'film', 'language', 'payment', 'payment_p2007_01', 'payment_p2007_02', 'payment_p2007_03', 'payment_p2007_04', 'payment_p2007_05', 'payment_p2007_06', 'rental', 'staff' +] + +const pgSakilaSqlViews = [ + 'actor_info', 'customer_list', 'film_list', 'nicer_but_slower_film_list', 'sales_by_film_category', 'sales_by_store', 'staff_list' +] + +const sqliteSakilaSqlViews = [ + 'actor_info', 'customer_list', 'film_list', 'nice_but_slower_film_list', 'sales_by_film_category', 'sales_by_store', 'staff_list' +] + +export { mysqlSakilaTables, mysqlSakilaSqlViews, pgSakilaTables, pgSakilaSqlViews, sqliteSakilaSqlViews } \ No newline at end of file From 3892848ca9086f144e03027ecec2de887a63d780 Mon Sep 17 00:00:00 2001 From: Muhammed Mustafa Date: Fri, 23 Sep 2022 18:21:41 +0530 Subject: [PATCH 3/5] fix(cypress): Added login logic in beforeAll in ERD tests --- scripts/cypress/integration/common/9b_ERD.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/cypress/integration/common/9b_ERD.js b/scripts/cypress/integration/common/9b_ERD.js index 77e477f6a2..be9c1aedb3 100644 --- a/scripts/cypress/integration/common/9b_ERD.js +++ b/scripts/cypress/integration/common/9b_ERD.js @@ -13,8 +13,8 @@ export const genTest = (apiType, dbType) => { describe(`${apiType.toUpperCase()} ERD`, () => { before(() => { - // loginPage.loginAndOpenProject(apiType, dbType); - // cy.openTableTab("Country", 25); + loginPage.loginAndOpenProject(apiType, dbType); + cy.openTableTab("Country", 25); projectId = getProjectString() cy.log('erd:getProjectString' + projectId) if (dbType === "postgres") { @@ -47,7 +47,7 @@ export const genTest = (apiType, dbType) => { // Test cases it(`Enable MM setting Open Table ERD`, () => { - cy.openTableTab("Country", 25); + // cy.openTableTab("Country", 25); mainPage.toggleShowMMSetting(); mainPage.openErdTab(); From 498c67af0ae09b13f8202bce43cdd344188dbb2b Mon Sep 17 00:00:00 2001 From: Muhammed Mustafa Date: Mon, 26 Sep 2022 12:36:43 +0530 Subject: [PATCH 4/5] fix(cypress): Removed unnecessary login flow in ERD cypress tests --- scripts/cypress/integration/common/9b_ERD.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/cypress/integration/common/9b_ERD.js b/scripts/cypress/integration/common/9b_ERD.js index be9c1aedb3..601ec9b202 100644 --- a/scripts/cypress/integration/common/9b_ERD.js +++ b/scripts/cypress/integration/common/9b_ERD.js @@ -13,7 +13,10 @@ export const genTest = (apiType, dbType) => { describe(`${apiType.toUpperCase()} ERD`, () => { before(() => { - loginPage.loginAndOpenProject(apiType, dbType); + cy.restoreLocalStorage(); + + // loginPage.loginAndOpenProject(apiType, dbType); + cy.openTableTab("Country", 25); projectId = getProjectString() cy.log('erd:getProjectString' + projectId) From e09aede949e258f3e34f306bd55b1203e3606db5 Mon Sep 17 00:00:00 2001 From: Muhammed Mustafa Date: Mon, 26 Sep 2022 14:20:25 +0530 Subject: [PATCH 5/5] fix(nocodb): Minor cleanup --- scripts/cypress/integration/test/xcdb-restMisc.js | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/cypress/integration/test/xcdb-restMisc.js b/scripts/cypress/integration/test/xcdb-restMisc.js index e3719a0291..cfcb325763 100644 --- a/scripts/cypress/integration/test/xcdb-restMisc.js +++ b/scripts/cypress/integration/test/xcdb-restMisc.js @@ -13,7 +13,6 @@ const t9b = require("../common/9b_ERD"); const { setCurrentMode, } = require("../../support/page_objects/projectConstants"); -const t9b = require("../common/9b_ERD"); const nocoTestSuite = (apiType, dbType) => { setCurrentMode(apiType, dbType);