Browse Source

test: cypress pg suite corrections to co-exist with mysql/xcdb suite

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
pull/1175/head
Raju Udava 3 years ago
parent
commit
45df78f934
  1. 12
      scripts/cypress/integration/common/00_pre_configurations.js
  2. 2
      scripts/cypress/integration/common/1a_table_operations.js
  3. 2
      scripts/cypress/integration/common/1b_table_column_operations.js
  4. 19
      scripts/cypress/integration/common/1d_table_view_drag_drop_reorder.js
  5. 2
      scripts/cypress/integration/common/1e_meta_sync.js
  6. 201
      scripts/cypress/integration/common/1e_pg_meta_sync.js
  7. 27
      scripts/cypress/integration/common/3b_formula_column.js
  8. 10
      scripts/cypress/integration/common/3c_lookup_column.js
  9. 14
      scripts/cypress/integration/common/5a_user_role.js
  10. 14
      scripts/cypress/integration/common/5b_preview_role.js
  11. 4
      scripts/cypress/integration/common/6b_downloadCsv.js
  12. 2
      scripts/cypress/integration/test/pg-restTableOps.js
  13. 37
      scripts/cypress/support/commands.js
  14. 21
      scripts/cypress/support/page_objects/navigation.js
  15. 21
      scripts/cypress/support/page_objects/projectConstants.js

12
scripts/cypress/integration/common/00_pre_configurations.js

@ -221,17 +221,21 @@ export const genTest = (apiType, dbType) => {
// if (isTestSuiteActive('rest', false)) createProject(staticProjects.externalREST) // if (isTestSuiteActive('rest', false)) createProject(staticProjects.externalREST)
// if (isTestSuiteActive('graphql', false)) createProject(staticProjects.externalGQL) // if (isTestSuiteActive('graphql', false)) createProject(staticProjects.externalGQL)
if ("rest" == apiType) { if ("rest" === apiType) {
if ("xcdb" === dbType) { if ("xcdb" === dbType) {
createProject(staticProjects.sampleREST); createProject(staticProjects.sampleREST);
} else { } else if (dbType === "mysql") {
createProject(staticProjects.externalREST); createProject(staticProjects.externalREST);
} else if (dbType === "postgres") {
createProject(staticProjects.pgExternalREST);
} }
} else if ("graphql" == apiType) { } else if ("graphql" === apiType) {
if ("xcdb" === dbType) { if ("xcdb" === dbType) {
createProject(staticProjects.sampleGQL); createProject(staticProjects.sampleGQL);
} else { } else if (dbType === "mysql") {
createProject(staticProjects.externalGQL); createProject(staticProjects.externalGQL);
} else if (dbType === "postgres") {
createProject(staticProjects.pgExternalGQL);
} }
} }
}); });

2
scripts/cypress/integration/common/1a_table_operations.js

@ -24,7 +24,7 @@ export const genTest = (apiType, dbType) => {
// delete newly created table // delete newly created table
it("Delete Table", () => { it("Delete Table", () => {
cy.deleteTable(name); cy.deleteTable(name, dbType);
}); });
const getAuditCell = (row, col) => { const getAuditCell = (row, col) => {

2
scripts/cypress/integration/common/1b_table_column_operations.js

@ -33,7 +33,7 @@ export const genTest = (apiType, dbType) => {
// delete table // delete table
after(() => { after(() => {
cy.deleteTable(name); cy.deleteTable(name, dbType);
}); });
it("Create Table Column", () => { it("Create Table Column", () => {

19
scripts/cypress/integration/common/1d_table_view_drag_drop_reorder.js

@ -2,6 +2,7 @@ import {
isTestSuiteActive, isTestSuiteActive,
isXcdb, isXcdb,
getProjectString, getProjectString,
isPostgres,
} from "../../support/page_objects/projectConstants"; } from "../../support/page_objects/projectConstants";
export const genTest = (apiType, dbType) => { export const genTest = (apiType, dbType) => {
@ -32,10 +33,10 @@ export const genTest = (apiType, dbType) => {
// move Actor field down, above Staff (drag, drop) // move Actor field down, above Staff (drag, drop)
cy.get(".nc-child-draggable-icon-Actor").drag( cy.get(".nc-child-draggable-icon-Actor").drag(
".nc-child-draggable-icon-Staff" ".nc-child-draggable-icon-Film"
); );
validateTreeField(12, "Actor"); validateTreeField(7, "Actor");
// move ActorInfo (View) field up to first place (drag, drop) // move ActorInfo (View) field up to first place (drag, drop)
cy.get(".nc-child-draggable-icon-ActorInfo").drag( cy.get(".nc-child-draggable-icon-ActorInfo").drag(
@ -44,11 +45,11 @@ export const genTest = (apiType, dbType) => {
validateTreeField(1, "ActorInfo"); validateTreeField(1, "ActorInfo");
validateTreeField(2, "Address"); validateTreeField(2, "Address");
validateTreeField(13, "Actor"); validateTreeField(8, "Actor");
// restore ActorInfo field (drag, drop) // restore ActorInfo field (drag, drop)
cy.get(".nc-child-draggable-icon-ActorInfo").drag( cy.get(".nc-child-draggable-icon-ActorInfo").drag(
".nc-child-draggable-icon-Actor" ".nc-child-draggable-icon-Staff"
); );
// restore Actor field (drag, drop) // restore Actor field (drag, drop)
@ -58,13 +59,21 @@ export const genTest = (apiType, dbType) => {
validateTreeField(1, "Actor"); validateTreeField(1, "Actor");
validateTreeField(2, "Address"); validateTreeField(2, "Address");
if (isPostgres()) {
validateTreeField(17, "Staff");
validateTreeField(18, "ActorInfo");
validateTreeField(19, "CustomerList");
} else {
validateTreeField(12, "Staff"); validateTreeField(12, "Staff");
validateTreeField(13, "ActorInfo"); validateTreeField(13, "ActorInfo");
validateTreeField(14, "CustomerList"); validateTreeField(14, "CustomerList");
}
// undo project-tree expand operation // undo project-tree expand operation
cy.get(".nc-project-tree") cy.get(".nc-project-tree")
.find(".v-list-item__title:contains(Tables)", { timeout: 10000 }) .find(".v-list-item__title:contains(Tables)", {
timeout: 10000,
})
.should("exist") .should("exist")
.first() .first()
.click({ force: true }); .click({ force: true });

2
scripts/cypress/integration/common/1e_meta_sync.js

@ -157,7 +157,7 @@ export const genTest = (apiType, dbType) => {
); );
cy.openTableTab("Table1", 9); cy.openTableTab("Table1", 9);
cy.deleteTable("Table1"); cy.deleteTable("Table1", dbType);
}); });
}); });
}; };

201
scripts/cypress/integration/common/1e_pg_meta_sync.js

@ -0,0 +1,201 @@
import { mainPage } from "../../support/page_objects/mainPage";
import { loginPage } from "../../support/page_objects/navigation";
import {
getCurrentMode,
getProjectString,
isTestSuiteActive,
isXcdb,
} from "../../support/page_objects/projectConstants";
export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return;
let projPrefix = `sakila.`;
let dbCmd = `pgExec`;
let tblDisplayPrefix = ``;
describe(`${apiType.toUpperCase()} api - Meta Sync`, () => {
// Run once before test- create project (rest/graphql)
//
before(() => {
mainPage.openMetaTab();
});
after(() => {
mainPage.closeMetaTab();
});
it(`Create table`, () => {
cy.log("this works");
// Create Table
cy.task(
dbCmd,
`CREATE TABLE table1( id INT NOT NULL, col1 INT NOT NULL, PRIMARY KEY(id))`
);
cy.task(
dbCmd,
`CREATE TABLE table2( id INT NOT NULL, col1 INT NOT NULL, PRIMARY KEY(id))`
);
mainPage.metaSyncValidate(`${tblDisplayPrefix}table1`, "New table");
});
it(`Add relation`, () => {
// working with relations in sqlite requires table to be deleted & recreated
//
// Add relation (FK)
cy.task(
dbCmd,
`ALTER TABLE table1 ADD CONSTRAINT fk_idx FOREIGN KEY (id) REFERENCES table2 (id);`
);
// cy.task(
// dbCmd,
// `ALTER TABLE ${projPrefix}table1 ADD CONSTRAINT fk1 FOREIGN KEY (col1) REFERENCES ${projPrefix}table2 (id) ON DELETE NO ACTION ON UPDATE NO ACTION`
// );
mainPage.metaSyncValidate(
`${tblDisplayPrefix}table1`,
"New relation added"
);
});
it(`Remove relation`, () => {
// working with relations in sqlite requires table to be deleted & recreated
//
// Remove relation (FK)
cy.task(dbCmd, `ALTER TABLE table1 DROP CONSTRAINT fk_idx`);
mainPage.metaSyncValidate(
`${tblDisplayPrefix}table1`,
"Relation removed"
);
});
it(`Add column`, () => {
// Add Column
let queryString = `ALTER TABLE table1 ADD COLUMN newCol INT`;
cy.task(dbCmd, queryString);
mainPage.metaSyncValidate(
`${tblDisplayPrefix}table1`,
"New column(newcol)"
);
});
it(`Rename column`, () => {
// Rename Column
let queryString = `ALTER TABLE table1 RENAME COLUMN newCol TO newColName`;
cy.task(dbCmd, queryString);
mainPage.metaSyncValidate(
`${tblDisplayPrefix}table1`,
"New column(newcolname), Column removed(newcol)"
);
});
it(`Delete column`, () => {
// Remove Column
cy.task(dbCmd, `ALTER TABLE table1 DROP COLUMN newColName`);
mainPage.metaSyncValidate(
`${tblDisplayPrefix}table1`,
"Column removed(newcolname)"
);
});
it(`Delete table`, () => {
// DROP TABLE
cy.task(dbCmd, `DROP TABLE IF EXISTS table1`);
cy.task(dbCmd, `DROP TABLE IF EXISTS table2`);
mainPage.metaSyncValidate(
`${tblDisplayPrefix}table1`,
"Table removed"
);
});
it(`Hide, Filter, Sort`, () => {
// kludge: bulk insert fail.
cy.task(
dbCmd,
`CREATE TABLE table1( id INT NOT NULL, col1 INT NOT NULL, col2 INT NOT NULL, col3 INT NOT NULL, col4 INT NOT NULL, PRIMARY KEY(id))`
);
cy.wait(3000);
cy.task(
dbCmd,
`INSERT INTO table1 (id, col1, col2, col3, col4) VALUES (1,1,1,1,1)`
);
cy.task(
dbCmd,
`INSERT INTO table1 (id, col1, col2, col3, col4) VALUES (2,2,2,2,2)`
);
cy.task(
dbCmd,
`INSERT INTO table1 (id, col1, col2, col3, col4) VALUES (3,3,3,3,3)`
);
cy.task(
dbCmd,
`INSERT INTO table1 (id, col1, col2, col3, col4) VALUES (4,4,4,4,4)`
);
cy.task(
dbCmd,
`INSERT INTO table1 (id, col1, col2, col3, col4) VALUES (5,5,5,5,5)`
);
cy.task(
dbCmd,
`INSERT INTO table1 (id, col1, col2, col3, col4) VALUES (6,6,6,6,6)`
);
cy.task(
dbCmd,
`INSERT INTO table1 (id, col1, col2, col3, col4) VALUES (7,7,7,7,7)`
);
cy.task(
dbCmd,
`INSERT INTO table1 (id, col1, col2, col3, col4) VALUES (8,8,8,8,8)`
);
cy.task(
dbCmd,
`INSERT INTO table1 (id, col1, col2, col3, col4) VALUES (9,9,9,9,9)`
);
mainPage.metaSyncValidate(`${tblDisplayPrefix}table1`, "New table");
mainPage.closeMetaTab();
cy.openTableTab("Table1", 9);
mainPage.hideField("Col1");
mainPage.sortField("Col1", "Z -> A");
mainPage.filterField(`Col1`, ">=", "5");
cy.get(".nc-grid-row").should("have.length", 5);
cy.closeTableTab("Table1");
});
it(`Verify`, () => {
mainPage.openMetaTab();
// Rename Column
let queryString = `ALTER TABLE table1 RENAME COLUMN col1 TO newcol`;
cy.task(dbCmd, queryString);
mainPage.metaSyncValidate(
`${tblDisplayPrefix}table1`,
"New column(newcol), Column removed(col1)"
);
cy.openTableTab("Table1", 9);
cy.deleteTable("Table1", dbType);
});
});
};
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Pranav C Balan <pranavxc@gmail.com>
* @author Raju Udava <sivadstala@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

27
scripts/cypress/integration/common/3b_formula_column.js

@ -25,7 +25,9 @@ export const genTest = (apiType, dbType) => {
// //
const rowValidation = (rowName, result) => { const rowValidation = (rowName, result) => {
// scroll back // scroll back
cy.get(`tbody > :nth-child(1) > [data-col="City"]`).scrollIntoView(); cy.get(
`tbody > :nth-child(1) > [data-col="City"]`
).scrollIntoView();
// for (let i = 0; i < 10; i++) // for (let i = 0; i < 10; i++)
for (let i = 3; i < 6; i++) for (let i = 3; i < 6; i++)
@ -43,19 +45,24 @@ export const genTest = (apiType, dbType) => {
cy.get(".new-column-header").click(); cy.get(".new-column-header").click();
// Column name // Column name
cy.get(".nc-column-name-input input") cy.get(".nc-column-name-input input").clear().type(`${columnName}`);
.clear()
.type(`${columnName}`);
// Column data type: to be set to formula in this context // Column data type: to be set to formula in this context
cy.get(".nc-ui-dt-dropdown").click().type("Formula"); cy.get(".nc-ui-dt-dropdown").click().type("Formula");
cy.getActiveMenu().contains("Formula").click({ force: true }); cy.getActiveMenu().contains("Formula").click({ force: true });
// Configure formula // Configure formula
cy.get("label").contains("Formula").parent().click().type(formula).click(); cy.get("label")
.contains("Formula")
.parent()
.click()
.type(formula)
.click();
// click on Save // click on Save
cy.get(".nc-col-create-or-edit-card").contains("Save").click({ force: true }); cy.get(".nc-col-create-or-edit-card")
.contains("Save")
.click({ force: true });
cy.toastWait("Formula column saved successfully"); cy.toastWait("Formula column saved successfully");
@ -106,7 +113,9 @@ export const genTest = (apiType, dbType) => {
.type(newFormula) .type(newFormula)
.click(); .click();
cy.get(".nc-col-create-or-edit-card").contains("Save").click({force: true}); cy.get(".nc-col-create-or-edit-card")
.contains("Save")
.click({ force: true });
cy.toastWait("Formula column updated successfully"); cy.toastWait("Formula column updated successfully");
@ -172,7 +181,7 @@ export const genTest = (apiType, dbType) => {
); );
} }
it("Formula: CONCAT, LOWER, UPPER, TRIM", () => { it("Formula: ADD, AVG, LEN", () => {
addFormulaBasedColumn( addFormulaBasedColumn(
"NC_MATH_0", "NC_MATH_0",
"ADD(CityId, CountryId) + AVG(CityId, CountryId) + LEN(City)" "ADD(CityId, CountryId) + AVG(CityId, CountryId) + LEN(City)"
@ -180,7 +189,7 @@ export const genTest = (apiType, dbType) => {
rowValidation("NC_MATH_0", RESULT_MATH_0); rowValidation("NC_MATH_0", RESULT_MATH_0);
}); });
it("Formula: ADD, AVG, LEN", () => { it("Formula: CONCAT, LOWER, UPPER, TRIM", () => {
editColumnByName( editColumnByName(
"NC_MATH_0", "NC_MATH_0",
"NC_STR_1", "NC_STR_1",

10
scripts/cypress/integration/common/3c_lookup_column.js

@ -74,15 +74,15 @@ export const genTest = (apiType, dbType) => {
/////////////////////////////////////////////////// ///////////////////////////////////////////////////
// Test case // Test case
it("Add Lookup column (Address, District) & Delete", () => { it("Add Lookup column (Address, PostalCode) & Delete", () => {
addLookUpColumn("Address", "District"); addLookUpColumn("Address", "PostalCode");
// Verify first entry, will be displayed as alias here 'childColumn (from childTable)' // Verify first entry, will be displayed as alias here 'childColumn (from childTable)'
cy.get(`tbody > :nth-child(1) > [data-col="District"]`) cy.get(`tbody > :nth-child(1) > [data-col="PostalCode"]`)
.contains("Galicia") .contains("4166")
.should("exist"); .should("exist");
deleteColumnByName("District"); deleteColumnByName("PostalCode");
}); });
it.skip("Add Lookup column (Country, CountryId) & Delete", () => { it.skip("Add Lookup column (Country, CountryId) & Delete", () => {

14
scripts/cypress/integration/common/5a_user_role.js

@ -1,6 +1,7 @@
import { loginPage, projectsPage } from "../../support/page_objects/navigation"; import { loginPage, projectsPage } from "../../support/page_objects/navigation";
import { mainPage } from "../../support/page_objects/mainPage"; import { mainPage } from "../../support/page_objects/mainPage";
import { import {
isPostgres,
roles, roles,
staticProjects, staticProjects,
} from "../../support/page_objects/projectConstants"; } from "../../support/page_objects/projectConstants";
@ -62,7 +63,9 @@ export const genTest = (apiType, dbType) => {
cy.get(".nc-ui-acl-tab").click({ force: true }); cy.get(".nc-ui-acl-tab").click({ force: true });
// validate if it has 19 entries representing tables & views // validate if it has 19 entries representing tables & views
cy.get(".nc-acl-table-row").should("have.length", 19); if (isPostgres())
cy.get(".nc-acl-table-row").should("have.length", 24);
else cy.get(".nc-acl-table-row").should("have.length", 19);
// disable table & view access // disable table & view access
// //
@ -115,6 +118,15 @@ export const genTest = (apiType, dbType) => {
projectsPage.openProject( projectsPage.openProject(
staticProjects.externalGQL.basic.name staticProjects.externalGQL.basic.name
); );
} else if (dbType === "postgres") {
if ("rest" == apiType)
projectsPage.openProject(
staticProjects.pgExternalREST.basic.name
);
else
projectsPage.openProject(
staticProjects.pgExternalGQL.basic.name
);
} }
if (roleType != "creator") { if (roleType != "creator") {

14
scripts/cypress/integration/common/5b_preview_role.js

@ -4,7 +4,10 @@
import { loginPage, projectsPage } from "../../support/page_objects/navigation"; import { loginPage, projectsPage } from "../../support/page_objects/navigation";
import { mainPage } from "../../support/page_objects/mainPage"; import { mainPage } from "../../support/page_objects/mainPage";
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"; import {
isPostgres,
isTestSuiteActive,
} from "../../support/page_objects/projectConstants";
import { import {
_advSettings, _advSettings,
_editSchema, _editSchema,
@ -34,7 +37,10 @@ export const genTest = (apiType, dbType, roleType) => {
// cy.wait(20000) // cy.wait(20000)
// wait for page rendering to complete // wait for page rendering to complete
cy.get(".nc-grid-row", { timeout: 25000 }).should("have.length", 25); cy.get(".nc-grid-row", { timeout: 25000 }).should(
"have.length",
25
);
// cy.get('.nc-preview-reset:visible').should('not-exist') // cy.get('.nc-preview-reset:visible').should('not-exist')
@ -49,7 +55,9 @@ export const genTest = (apiType, dbType, roleType) => {
cy.get(".nc-ui-acl-tab").click({ force: true }); cy.get(".nc-ui-acl-tab").click({ force: true });
// validate if it has 19 entries representing tables & views // validate if it has 19 entries representing tables & views
cy.get(".nc-acl-table-row").should("have.length", 19); if (isPostgres())
cy.get(".nc-acl-table-row").should("have.length", 24);
else cy.get(".nc-acl-table-row").should("have.length", 19);
// restore access // restore access
// //

4
scripts/cypress/integration/common/6b_downloadCsv.js

@ -14,7 +14,7 @@ export const genTest = (apiType, dbType) => {
after(() => { after(() => {
cy.closeTableTab("Country"); cy.closeTableTab("Country");
cy.screenshot('6b-after') cy.screenshot("6b-after");
}); });
it("Download verification- base view, default columns", () => { it("Download verification- base view, default columns", () => {
@ -29,7 +29,7 @@ export const genTest = (apiType, dbType) => {
`Angola,"Benguela,Namibe"`, `Angola,"Benguela,Namibe"`,
]; ];
for (let i = 0; i < storedRecords.length; i++) { for (let i = 0; i < storedRecords.length - 1; i++) {
cy.log(retrievedRecords[i]); cy.log(retrievedRecords[i]);
expect(retrievedRecords[i]).to.be.equal(storedRecords[i]); expect(retrievedRecords[i]).to.be.equal(storedRecords[i]);
} }

2
scripts/cypress/integration/test/pg-restTableOps.js

@ -4,7 +4,7 @@ let t1a = require("../common/1a_table_operations");
let t1b = require("../common/1b_table_column_operations"); let t1b = require("../common/1b_table_column_operations");
let t1c = require("../common/1c_sql_view"); let t1c = require("../common/1c_sql_view");
let t1d = require("../common/1d_table_view_drag_drop_reorder"); let t1d = require("../common/1d_table_view_drag_drop_reorder");
let t1e = require("../common/1e_meta_sync"); let t1e = require("../common/1e_pg_meta_sync");
let t2a = require("../common/2a_table_with_belongs_to_colulmn"); let t2a = require("../common/2a_table_with_belongs_to_colulmn");
let t2b = require("../common/2b_table_with_m2m_column"); let t2b = require("../common/2b_table_with_m2m_column");
let t3a = require("../common/3a_filter_sort_fields_operations"); let t3a = require("../common/3a_filter_sort_fields_operations");

37
scripts/cypress/support/commands.js

@ -25,7 +25,7 @@
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) // Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
import "cypress-file-upload"; import "cypress-file-upload";
import { isXcdb } from "./page_objects/projectConstants"; import { isXcdb, isPostgres } from "./page_objects/projectConstants";
require("@4tw/cypress-drag-drop"); require("@4tw/cypress-drag-drop");
@ -57,13 +57,17 @@ Cypress.Commands.add("signinOrSignup", (_args) => {
cy.wait(8000); cy.wait(8000);
cy.get("body").trigger("mousemove"); cy.get("body").trigger("mousemove");
cy.contains("Let's Begin").click(); cy.contains("Let's Begin").click();
cy.get('input[type="text"]', { timeout: 12000 }).type(args.username); cy.get('input[type="text"]', { timeout: 12000 }).type(
args.username
);
cy.get('input[type="password"]').type(args.password); cy.get('input[type="password"]').type(args.password);
cy.get('button:contains("SIGN UP")').click(); cy.get('button:contains("SIGN UP")').click();
// handle signin // handle signin
} else { } else {
cy.get('input[type="text"]', { timeout: 12000 }).type(args.username); cy.get('input[type="text"]', { timeout: 12000 }).type(
args.username
);
cy.get('input[type="password"]').type(args.password); cy.get('input[type="password"]').type(args.password);
cy.get('button:contains("SIGN IN")').click(); cy.get('button:contains("SIGN IN")').click();
} }
@ -87,14 +91,21 @@ Cypress.Commands.add("openOrCreateRestProject", (_args) => {
? ".nc-meta-project-row" ? ".nc-meta-project-row"
: ":not(.nc-meta-project-row)"; : ":not(.nc-meta-project-row)";
// if project exist open // if project exist open
if ($body.find(".nc-rest-project-row").filter(filter).length && !args.new) { if (
$body.find(".nc-rest-project-row").filter(filter).length &&
!args.new
) {
cy.get(".nc-rest-project-row").filter(filter).first().click(); cy.get(".nc-rest-project-row").filter(filter).first().click();
} else { } else {
cy.contains("New Project").trigger("onmouseover").trigger("mouseenter"); cy.contains("New Project")
.trigger("onmouseover")
.trigger("mouseenter");
if (args.meta) { if (args.meta) {
cy.get(".nc-create-xc-db-project").click(); cy.get(".nc-create-xc-db-project").click();
cy.url({ timeout: 6000 }).should("contain", "#/project/xcdb"); cy.url({ timeout: 6000 }).should("contain", "#/project/xcdb");
cy.get(".nc-metadb-project-name").type("test_proj" + Date.now()); cy.get(".nc-metadb-project-name").type(
"test_proj" + Date.now()
);
cy.contains("button", "Create", { timeout: 3000 }).click(); cy.contains("button", "Create", { timeout: 3000 }).click();
} else { } else {
cy.get(".nc-create-external-db-project").click(); cy.get(".nc-create-external-db-project").click();
@ -178,12 +189,16 @@ Cypress.Commands.add("openOrCreateGqlProject", (_args) => {
) { ) {
cy.get(".nc-graphql-project-row").filter(filter).first().click(); cy.get(".nc-graphql-project-row").filter(filter).first().click();
} else { } else {
cy.contains("New Project").trigger("onmouseover").trigger("mouseenter"); cy.contains("New Project")
.trigger("onmouseover")
.trigger("mouseenter");
if (args.meta) { if (args.meta) {
cy.get(".nc-create-xc-db-project").click(); cy.get(".nc-create-xc-db-project").click();
cy.url({ timeout: 6000 }).should("contain", "#/project/xcdb"); cy.url({ timeout: 6000 }).should("contain", "#/project/xcdb");
cy.contains("GRAPHQL APIs").closest("label").click(); cy.contains("GRAPHQL APIs").closest("label").click();
cy.get(".nc-metadb-project-name").type("test_proj" + Date.now()); cy.get(".nc-metadb-project-name").type(
"test_proj" + Date.now()
);
cy.contains("button", "Create", { timeout: 3000 }).click(); cy.contains("button", "Create", { timeout: 3000 }).click();
} else { } else {
cy.get(".nc-create-external-db-project").click(); cy.get(".nc-create-external-db-project").click();
@ -245,7 +260,7 @@ Cypress.Commands.add("createTable", (name) => {
cy.url().should("contain", `name=${name}`); cy.url().should("contain", `name=${name}`);
}); });
Cypress.Commands.add("deleteTable", (name) => { Cypress.Commands.add("deleteTable", (name, dbType) => {
cy.get(".nc-project-tree") cy.get(".nc-project-tree")
.find(".v-list-item__title:contains(Tables)", { timeout: 10000 }) .find(".v-list-item__title:contains(Tables)", { timeout: 10000 })
.first() .first()
@ -257,6 +272,10 @@ Cypress.Commands.add("deleteTable", (name) => {
cy.get(`.project-tab:contains(${name}):visible`).should("exist"); cy.get(`.project-tab:contains(${name}):visible`).should("exist");
cy.get(".nc-table-delete-btn:visible").click(); cy.get(".nc-table-delete-btn:visible").click();
cy.get("button:contains(Submit)").click(); cy.get("button:contains(Submit)").click();
// only for postgre project
if (dbType === "postgres") cy.toastWait(`Delete trigger successful`);
cy.toastWait(`Delete table successful`); cy.toastWait(`Delete table successful`);
}); });

21
scripts/cypress/support/page_objects/navigation.js

@ -60,8 +60,11 @@ export class _loginPage {
if (dbType === "mysql") { if (dbType === "mysql") {
if ("rest" == apiType) if ("rest" == apiType)
projectsPage.openProject(staticProjects.externalREST.basic.name); projectsPage.openProject(
else projectsPage.openProject(staticProjects.externalGQL.basic.name); staticProjects.externalREST.basic.name
);
else
projectsPage.openProject(staticProjects.externalGQL.basic.name);
} else if (dbType === "xcdb") { } else if (dbType === "xcdb") {
if ("rest" == apiType) if ("rest" == apiType)
projectsPage.openProject(staticProjects.sampleREST.basic.name); projectsPage.openProject(staticProjects.sampleREST.basic.name);
@ -117,7 +120,9 @@ export class _projectsPage {
}); });
// feed project name // feed project name
cy.get(".nc-metadb-project-name", { timeout: 20000 }).type(projectName); cy.get(".nc-metadb-project-name", { timeout: 20000 }).type(
projectName
);
// Radio button: defaults to NC_REST // Radio button: defaults to NC_REST
if ("GQL" == projectData.apiType) { if ("GQL" == projectData.apiType) {
@ -153,6 +158,16 @@ export class _projectsPage {
cy.contains("GRAPHQL APIs").closest("label").click(); cy.contains("GRAPHQL APIs").closest("label").click();
} }
// postgres project
if (cred.databaseType === 1) {
cy.get(".db-select").click();
cy.getActiveMenu()
.find(`[role="option"]`)
.contains("Postgre")
.should("exist")
.click();
}
if (cred.hostAddress != "") if (cred.hostAddress != "")
cy.contains("Host Address") cy.contains("Host Address")
.parent() .parent()

21
scripts/cypress/support/page_objects/projectConstants.js

@ -7,6 +7,15 @@ export const defaultDbParams = {
databaseName: "sakila", databaseName: "sakila",
}; };
export const defaultPgDbParams = {
databaseType: 1, // Postgres
hostAddress: "localhost",
portNumber: "5432",
username: "postgres",
password: "password",
databaseName: "postgres",
};
// database // database
// validation details // validation details
// advSettings: left navigation bar (audit, metadata, auth, transient view modes) // advSettings: left navigation bar (audit, metadata, auth, transient view modes)
@ -103,6 +112,14 @@ export const staticProjects = {
basic: { dbType: "external", apiType: "GQL", name: "externalGQL" }, basic: { dbType: "external", apiType: "GQL", name: "externalGQL" },
config: defaultDbParams, config: defaultDbParams,
}, },
pgExternalREST: {
basic: { dbType: "external", apiType: "REST", name: "pgExternalREST" },
config: defaultPgDbParams,
},
pgExternalGQL: {
basic: { dbType: "external", apiType: "GQL", name: "pgExternalGQL" },
config: defaultPgDbParams,
},
}; };
// return TRUE if test suite specified is activated from env-variables // return TRUE if test suite specified is activated from env-variables
@ -128,6 +145,10 @@ export function isXcdb() {
return currentTestMode.dbType === "xcdb"; return currentTestMode.dbType === "xcdb";
} }
export function isPostgres() {
return currentTestMode.dbType === "postgres";
}
export function setProjectString(projStr) { export function setProjectString(projStr) {
xcdbProjectString = projStr; xcdbProjectString = projStr;
} }

Loading…
Cancel
Save