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. 257
      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. 435
      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. 232
      scripts/cypress/integration/common/5b_preview_role.js
  11. 62
      scripts/cypress/integration/common/6b_downloadCsv.js
  12. 2
      scripts/cypress/integration/test/pg-restTableOps.js
  13. 517
      scripts/cypress/support/commands.js
  14. 567
      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('graphql', false)) createProject(staticProjects.externalGQL)
if ("rest" == apiType) {
if ("rest" === apiType) {
if ("xcdb" === dbType) {
createProject(staticProjects.sampleREST);
} else {
} else if (dbType === "mysql") {
createProject(staticProjects.externalREST);
} else if (dbType === "postgres") {
createProject(staticProjects.pgExternalREST);
}
} else if ("graphql" == apiType) {
} else if ("graphql" === apiType) {
if ("xcdb" === dbType) {
createProject(staticProjects.sampleGQL);
} else {
} else if (dbType === "mysql") {
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
it("Delete Table", () => {
cy.deleteTable(name);
cy.deleteTable(name, dbType);
});
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
after(() => {
cy.deleteTable(name);
cy.deleteTable(name, dbType);
});
it("Create Table Column", () => {

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

@ -1,139 +1,148 @@
import {
isTestSuiteActive,
isXcdb,
getProjectString,
isTestSuiteActive,
isXcdb,
getProjectString,
isPostgres,
} from "../../support/page_objects/projectConstants";
export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return;
if (!isTestSuiteActive(apiType, dbType)) return;
describe(`${apiType.toUpperCase()} Table/view drag-drop reorder`, () => {
function validateTreeField(index, tblName) {
cy.get(`:nth-child(${index}) > .v-list-item__title > .caption`)
.contains(tblName)
.should("exist");
}
describe(`${apiType.toUpperCase()} Table/view drag-drop reorder`, () => {
function validateTreeField(index, tblName) {
cy.get(`:nth-child(${index}) > .v-list-item__title > .caption`)
.contains(tblName)
.should("exist");
}
/*
/*
Original order of list items
Actor, Address, Category, City, Country, Customer, FIlm, FilmText, Language, Payment, Rental Staff
ActorInfo, CustomerList, FilmList, NiceButSlowerFilmList, SalesByFilmCategory, SalesByStore, StaffList
*/
it(`Table & SQL View list, Drag/drop`, () => {
// expand tree-view menu
// cy.get(".nc-project-tree")
// .find(".v-list-item__title:contains(Tables)", { timeout: 10000 })
// .should("exist")
// .first()
// .click({ force: true });
validateTreeField(1, "Actor");
// move Actor field down, above Staff (drag, drop)
cy.get(".nc-child-draggable-icon-Actor").drag(
".nc-child-draggable-icon-Staff"
);
validateTreeField(12, "Actor");
// move ActorInfo (View) field up to first place (drag, drop)
cy.get(".nc-child-draggable-icon-ActorInfo").drag(
".nc-child-draggable-icon-Address"
);
validateTreeField(1, "ActorInfo");
validateTreeField(2, "Address");
validateTreeField(13, "Actor");
// restore ActorInfo field (drag, drop)
cy.get(".nc-child-draggable-icon-ActorInfo").drag(
".nc-child-draggable-icon-Actor"
);
// restore Actor field (drag, drop)
cy.get(".nc-child-draggable-icon-Actor").drag(
".nc-child-draggable-icon-Address"
);
validateTreeField(1, "Actor");
validateTreeField(2, "Address");
validateTreeField(12, "Staff");
validateTreeField(13, "ActorInfo");
validateTreeField(14, "CustomerList");
// undo project-tree expand operation
cy.get(".nc-project-tree")
.find(".v-list-item__title:contains(Tables)", { timeout: 10000 })
.should("exist")
.first()
.click({ force: true });
it(`Table & SQL View list, Drag/drop`, () => {
// expand tree-view menu
// cy.get(".nc-project-tree")
// .find(".v-list-item__title:contains(Tables)", { timeout: 10000 })
// .should("exist")
// .first()
// .click({ force: true });
validateTreeField(1, "Actor");
// move Actor field down, above Staff (drag, drop)
cy.get(".nc-child-draggable-icon-Actor").drag(
".nc-child-draggable-icon-Film"
);
validateTreeField(7, "Actor");
// move ActorInfo (View) field up to first place (drag, drop)
cy.get(".nc-child-draggable-icon-ActorInfo").drag(
".nc-child-draggable-icon-Address"
);
validateTreeField(1, "ActorInfo");
validateTreeField(2, "Address");
validateTreeField(8, "Actor");
// restore ActorInfo field (drag, drop)
cy.get(".nc-child-draggable-icon-ActorInfo").drag(
".nc-child-draggable-icon-Staff"
);
// restore Actor field (drag, drop)
cy.get(".nc-child-draggable-icon-Actor").drag(
".nc-child-draggable-icon-Address"
);
validateTreeField(1, "Actor");
validateTreeField(2, "Address");
if (isPostgres()) {
validateTreeField(17, "Staff");
validateTreeField(18, "ActorInfo");
validateTreeField(19, "CustomerList");
} else {
validateTreeField(12, "Staff");
validateTreeField(13, "ActorInfo");
validateTreeField(14, "CustomerList");
}
// undo project-tree expand operation
cy.get(".nc-project-tree")
.find(".v-list-item__title:contains(Tables)", {
timeout: 10000,
})
.should("exist")
.first()
.click({ force: true });
});
// create new view as specified by 'viewType'
// can be - grid/ gallery/ form
// wait for toast to appear
//
function createView(viewType) {
// click on 'Grid/Gallery' button on Views bar
cy.get(`.nc-create-${viewType}-view`).click();
// Pop up window, click Submit (accepting default name for view)
cy.getActiveModal().find("button:contains(Submit)").click();
cy.toastWait("View created successfully");
}
// verify view 'viewName' to be present at position 'index'
// index starts from 0
function validateViewField(index, viewName) {
cy.get(".nc-view-item.nc-draggable-child")
.eq(index)
.contains(viewName)
.should("exist");
}
it(`View (Gallery/ Grid/ Form) re-order`, () => {
cy.openTableTab("Actor", 25);
// create 3 views, use default names
// Actor1, Actor2, Actor3
createView("grid");
createView("gallery");
createView("form");
// validate position order
validateViewField(0, "Actor");
validateViewField(1, "Actor1");
validateViewField(2, "Actor2");
validateViewField(3, "Actor3");
// move Actor3 field on top (drag, drop)
cy.get(".nc-child-draggable-icon-Actor3").drag(
`.nc-child-draggable-icon-${
isXcdb() ? `nc_${getProjectString()}__` : ``
}actor`
);
// validate new position order, Actor3 on top
validateViewField(0, "Actor3");
validateViewField(1, "Actor");
validateViewField(2, "Actor1");
validateViewField(3, "Actor2");
// delete all created views
// click on delete icon (becomes visible on hovering mouse)
cy.get(".nc-view-delete-icon").eq(0).click({ force: true });
cy.toastWait("View deleted successfully");
cy.get(".nc-view-delete-icon").eq(0).click({ force: true });
cy.toastWait("View deleted successfully");
cy.get(".nc-view-delete-icon").eq(0).click({ force: true });
cy.toastWait("View deleted successfully");
// wind up
cy.closeTableTab("Actor");
});
});
// create new view as specified by 'viewType'
// can be - grid/ gallery/ form
// wait for toast to appear
//
function createView(viewType) {
// click on 'Grid/Gallery' button on Views bar
cy.get(`.nc-create-${viewType}-view`).click();
// Pop up window, click Submit (accepting default name for view)
cy.getActiveModal().find("button:contains(Submit)").click();
cy.toastWait("View created successfully");
}
// verify view 'viewName' to be present at position 'index'
// index starts from 0
function validateViewField(index, viewName) {
cy.get(".nc-view-item.nc-draggable-child")
.eq(index)
.contains(viewName)
.should("exist");
}
it(`View (Gallery/ Grid/ Form) re-order`, () => {
cy.openTableTab("Actor", 25);
// create 3 views, use default names
// Actor1, Actor2, Actor3
createView("grid");
createView("gallery");
createView("form");
// validate position order
validateViewField(0, "Actor");
validateViewField(1, "Actor1");
validateViewField(2, "Actor2");
validateViewField(3, "Actor3");
// move Actor3 field on top (drag, drop)
cy.get(".nc-child-draggable-icon-Actor3").drag(
`.nc-child-draggable-icon-${
isXcdb() ? `nc_${getProjectString()}__` : ``
}actor`
);
// validate new position order, Actor3 on top
validateViewField(0, "Actor3");
validateViewField(1, "Actor");
validateViewField(2, "Actor1");
validateViewField(3, "Actor2");
// delete all created views
// click on delete icon (becomes visible on hovering mouse)
cy.get(".nc-view-delete-icon").eq(0).click({ force: true });
cy.toastWait("View deleted successfully");
cy.get(".nc-view-delete-icon").eq(0).click({ force: true });
cy.toastWait("View deleted successfully");
cy.get(".nc-view-delete-icon").eq(0).click({ force: true });
cy.toastWait("View deleted successfully");
// wind up
cy.closeTableTab("Actor");
});
});
};
/**

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

@ -157,7 +157,7 @@ export const genTest = (apiType, dbType) => {
);
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/>.
*
*/

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

@ -1,221 +1,230 @@
import {
isTestSuiteActive,
isXcdb,
isTestSuiteActive,
isXcdb,
} from "../../support/page_objects/projectConstants";
export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return;
describe(`${apiType.toUpperCase()} api - FORMULA`, () => {
// Run once before test- create project (rest/graphql)
//
before(() => {
// open a table to work on views
//
cy.openTableTab("City", 25);
if (!isTestSuiteActive(apiType, dbType)) return;
describe(`${apiType.toUpperCase()} api - FORMULA`, () => {
// Run once before test- create project (rest/graphql)
//
before(() => {
// open a table to work on views
//
cy.openTableTab("City", 25);
});
after(() => {
cy.closeTableTab("City");
});
// Given rowname & expected result for first 10 entries, validate
// NOTE: Scroll issue with Cypress automation, to fix
// validating partial data, row number 5 to 9
//
const rowValidation = (rowName, result) => {
// scroll back
cy.get(
`tbody > :nth-child(1) > [data-col="City"]`
).scrollIntoView();
// for (let i = 0; i < 10; i++)
for (let i = 3; i < 6; i++)
cy.get(`tbody > :nth-child(${i + 1}) > [data-col="${rowName}"]`)
.contains(result[i].toString())
.should("exist");
};
// Routine to create a new look up column
//
const addFormulaBasedColumn = (columnName, formula) => {
// (+) icon at end of column header (to add a new column)
// opens up a pop up window
//
cy.get(".new-column-header").click();
// Column name
cy.get(".nc-column-name-input input").clear().type(`${columnName}`);
// Column data type: to be set to formula in this context
cy.get(".nc-ui-dt-dropdown").click().type("Formula");
cy.getActiveMenu().contains("Formula").click({ force: true });
// Configure formula
cy.get("label")
.contains("Formula")
.parent()
.click()
.type(formula)
.click();
// click on Save
cy.get(".nc-col-create-or-edit-card")
.contains("Save")
.click({ force: true });
cy.toastWait("Formula column saved successfully");
// Verify if column exists.
//
cy.get(`th:contains(${columnName})`).should("exist");
};
// routine to delete column
//
const deleteColumnByName = (columnName) => {
// verify if column exists before delete
cy.get(`th:contains(${columnName})`).should("exist");
// delete opiton visible on mouse-over
cy.get(`th:contains(${columnName}) .mdi-menu-down`)
.trigger("mouseover")
.click();
// delete/ confirm on pop-up
cy.get(".nc-column-delete").click();
cy.getActiveModal().find("button:contains(Confirm)").click();
// validate if deleted (column shouldnt exist)
cy.get(`th:contains(${columnName})`).should("not.exist");
};
// routine to edit column
//
const editColumnByName = (oldName, newName, newFormula) => {
// verify if column exists before delete
cy.get(`th:contains(${oldName})`).should("exist");
// delete opiton visible on mouse-over
cy.get(`th:contains(${oldName}) .mdi-menu-down`)
.trigger("mouseover")
.click();
// edit/ save on pop-up
cy.get(".nc-column-edit").click();
cy.get(".nc-column-name-input input").clear().type(newName);
cy.get("label")
.contains("Formula")
.parent()
.find("input")
.clear()
.type(newFormula)
.click();
cy.get(".nc-col-create-or-edit-card")
.contains("Save")
.click({ force: true });
cy.toastWait("Formula column updated successfully");
// validate if deleted (column shouldnt exist)
cy.get(`th:contains(${oldName})`).should("not.exist");
cy.get(`th:contains(${newName})`).should("exist");
};
///////////////////////////////////////////////////
// Test case
// On City table (from Sakila DB), first 10 entries recorded here for verification
let cityId = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
let countryId = [87, 82, 101, 60, 97, 31, 107, 44, 44, 50];
let city = [
"A corua (La Corua)",
"Abha",
"Abu Dhabi",
"Acua",
"Adana",
"Addis Abeba",
"Aden",
"Adoni",
"Ahmadnagar",
"Akishima",
];
// Temporary locally computed expected results
let RESULT_STRING = [];
let RESULT_MATH_0 = [];
let RESULT_MATH_1 = [];
let RESULT_MATH_2 = [];
for (let i = 0; i < 10; i++) {
// CONCAT, LOWER, UPPER, TRIM
RESULT_STRING[i] = `${city[i].toUpperCase()}${city[
i
].toLowerCase()}trimmed`;
// ADD, AVG, LEN
RESULT_MATH_0[i] =
cityId[i] +
countryId[i] +
(cityId[i] + countryId[i]) / 2 +
city[i].length;
// CEILING, FLOOR, ROUND, MOD, MIN, MAX
RESULT_MATH_1[i] =
Math.ceil(1.4) +
Math.floor(1.6) +
Math.round(2.5) +
(cityId[i] % 3) +
Math.min(cityId[i], countryId[i]) +
Math.max(cityId[i], countryId[i]);
// LOG, EXP, POWER, SQRT
// only integer verification being computed, hence trunc
RESULT_MATH_2[i] = Math.trunc(
Math.log(cityId[i]) +
Math.exp(cityId[i]) +
Math.pow(cityId[i], 3) +
Math.sqrt(countryId[i])
);
}
it("Formula: ADD, AVG, LEN", () => {
addFormulaBasedColumn(
"NC_MATH_0",
"ADD(CityId, CountryId) + AVG(CityId, CountryId) + LEN(City)"
);
rowValidation("NC_MATH_0", RESULT_MATH_0);
});
it("Formula: CONCAT, LOWER, UPPER, TRIM", () => {
editColumnByName(
"NC_MATH_0",
"NC_STR_1",
`CONCAT(UPPER(City), LOWER(City), TRIM(' trimmed '))`
);
rowValidation("NC_STR_1", RESULT_STRING);
});
it("Formula: CEILING, FLOOR, ROUND, MOD, MIN, MAX", () => {
editColumnByName(
"NC_STR_1",
"NC_MATH_1",
`CEILING(1.4) + FLOOR(1.6) + ROUND(2.5) + MOD(CityId, 3) + MIN(CityId, CountryId) + MAX(CityId, CountryId)`
);
rowValidation("NC_MATH_1", RESULT_MATH_1);
});
it("Formula: LOG, EXP, POWER, SQRT", () => {
if (!isXcdb()) {
// SQLITE doesnt support LOG, EXP, POWER SQRT construct
editColumnByName(
"NC_MATH_1",
"NC_MATH_2",
`LOG(CityId) + EXP(CityId) + POWER(CityId, 3) + SQRT(CountryId)`
);
rowValidation("NC_MATH_2", RESULT_MATH_2);
}
});
it("Formula: NOW, EDIT & Delete column", () => {
if (!isXcdb()) editColumnByName("NC_MATH_2", "NC_NOW", `NOW()`);
else editColumnByName("NC_MATH_1", "NC_NOW", `NOW()`);
deleteColumnByName("NC_NOW");
});
});
after(() => {
cy.closeTableTab("City");
});
// Given rowname & expected result for first 10 entries, validate
// NOTE: Scroll issue with Cypress automation, to fix
// validating partial data, row number 5 to 9
//
const rowValidation = (rowName, result) => {
// scroll back
cy.get(`tbody > :nth-child(1) > [data-col="City"]`).scrollIntoView();
// for (let i = 0; i < 10; i++)
for (let i = 3; i < 6; i++)
cy.get(`tbody > :nth-child(${i + 1}) > [data-col="${rowName}"]`)
.contains(result[i].toString())
.should("exist");
};
// Routine to create a new look up column
//
const addFormulaBasedColumn = (columnName, formula) => {
// (+) icon at end of column header (to add a new column)
// opens up a pop up window
//
cy.get(".new-column-header").click();
// Column name
cy.get(".nc-column-name-input input")
.clear()
.type(`${columnName}`);
// Column data type: to be set to formula in this context
cy.get(".nc-ui-dt-dropdown").click().type("Formula");
cy.getActiveMenu().contains("Formula").click({ force: true });
// Configure formula
cy.get("label").contains("Formula").parent().click().type(formula).click();
// click on Save
cy.get(".nc-col-create-or-edit-card").contains("Save").click({ force: true });
cy.toastWait("Formula column saved successfully");
// Verify if column exists.
//
cy.get(`th:contains(${columnName})`).should("exist");
};
// routine to delete column
//
const deleteColumnByName = (columnName) => {
// verify if column exists before delete
cy.get(`th:contains(${columnName})`).should("exist");
// delete opiton visible on mouse-over
cy.get(`th:contains(${columnName}) .mdi-menu-down`)
.trigger("mouseover")
.click();
// delete/ confirm on pop-up
cy.get(".nc-column-delete").click();
cy.getActiveModal().find("button:contains(Confirm)").click();
// validate if deleted (column shouldnt exist)
cy.get(`th:contains(${columnName})`).should("not.exist");
};
// routine to edit column
//
const editColumnByName = (oldName, newName, newFormula) => {
// verify if column exists before delete
cy.get(`th:contains(${oldName})`).should("exist");
// delete opiton visible on mouse-over
cy.get(`th:contains(${oldName}) .mdi-menu-down`)
.trigger("mouseover")
.click();
// edit/ save on pop-up
cy.get(".nc-column-edit").click();
cy.get(".nc-column-name-input input").clear().type(newName);
cy.get("label")
.contains("Formula")
.parent()
.find("input")
.clear()
.type(newFormula)
.click();
cy.get(".nc-col-create-or-edit-card").contains("Save").click({force: true});
cy.toastWait("Formula column updated successfully");
// validate if deleted (column shouldnt exist)
cy.get(`th:contains(${oldName})`).should("not.exist");
cy.get(`th:contains(${newName})`).should("exist");
};
///////////////////////////////////////////////////
// Test case
// On City table (from Sakila DB), first 10 entries recorded here for verification
let cityId = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
let countryId = [87, 82, 101, 60, 97, 31, 107, 44, 44, 50];
let city = [
"A corua (La Corua)",
"Abha",
"Abu Dhabi",
"Acua",
"Adana",
"Addis Abeba",
"Aden",
"Adoni",
"Ahmadnagar",
"Akishima",
];
// Temporary locally computed expected results
let RESULT_STRING = [];
let RESULT_MATH_0 = [];
let RESULT_MATH_1 = [];
let RESULT_MATH_2 = [];
for (let i = 0; i < 10; i++) {
// CONCAT, LOWER, UPPER, TRIM
RESULT_STRING[i] = `${city[i].toUpperCase()}${city[
i
].toLowerCase()}trimmed`;
// ADD, AVG, LEN
RESULT_MATH_0[i] =
cityId[i] +
countryId[i] +
(cityId[i] + countryId[i]) / 2 +
city[i].length;
// CEILING, FLOOR, ROUND, MOD, MIN, MAX
RESULT_MATH_1[i] =
Math.ceil(1.4) +
Math.floor(1.6) +
Math.round(2.5) +
(cityId[i] % 3) +
Math.min(cityId[i], countryId[i]) +
Math.max(cityId[i], countryId[i]);
// LOG, EXP, POWER, SQRT
// only integer verification being computed, hence trunc
RESULT_MATH_2[i] = Math.trunc(
Math.log(cityId[i]) +
Math.exp(cityId[i]) +
Math.pow(cityId[i], 3) +
Math.sqrt(countryId[i])
);
}
it("Formula: CONCAT, LOWER, UPPER, TRIM", () => {
addFormulaBasedColumn(
"NC_MATH_0",
"ADD(CityId, CountryId) + AVG(CityId, CountryId) + LEN(City)"
);
rowValidation("NC_MATH_0", RESULT_MATH_0);
});
it("Formula: ADD, AVG, LEN", () => {
editColumnByName(
"NC_MATH_0",
"NC_STR_1",
`CONCAT(UPPER(City), LOWER(City), TRIM(' trimmed '))`
);
rowValidation("NC_STR_1", RESULT_STRING);
});
it("Formula: CEILING, FLOOR, ROUND, MOD, MIN, MAX", () => {
editColumnByName(
"NC_STR_1",
"NC_MATH_1",
`CEILING(1.4) + FLOOR(1.6) + ROUND(2.5) + MOD(CityId, 3) + MIN(CityId, CountryId) + MAX(CityId, CountryId)`
);
rowValidation("NC_MATH_1", RESULT_MATH_1);
});
it("Formula: LOG, EXP, POWER, SQRT", () => {
if (!isXcdb()) {
// SQLITE doesnt support LOG, EXP, POWER SQRT construct
editColumnByName(
"NC_MATH_1",
"NC_MATH_2",
`LOG(CityId) + EXP(CityId) + POWER(CityId, 3) + SQRT(CountryId)`
);
rowValidation("NC_MATH_2", RESULT_MATH_2);
}
});
it("Formula: NOW, EDIT & Delete column", () => {
if (!isXcdb()) editColumnByName("NC_MATH_2", "NC_NOW", `NOW()`);
else editColumnByName("NC_MATH_1", "NC_NOW", `NOW()`);
deleteColumnByName("NC_NOW");
});
});
};
/**

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

@ -74,15 +74,15 @@ export const genTest = (apiType, dbType) => {
///////////////////////////////////////////////////
// Test case
it("Add Lookup column (Address, District) & Delete", () => {
addLookUpColumn("Address", "District");
it("Add Lookup column (Address, PostalCode) & Delete", () => {
addLookUpColumn("Address", "PostalCode");
// Verify first entry, will be displayed as alias here 'childColumn (from childTable)'
cy.get(`tbody > :nth-child(1) > [data-col="District"]`)
.contains("Galicia")
cy.get(`tbody > :nth-child(1) > [data-col="PostalCode"]`)
.contains("4166")
.should("exist");
deleteColumnByName("District");
deleteColumnByName("PostalCode");
});
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 { mainPage } from "../../support/page_objects/mainPage";
import {
isPostgres,
roles,
staticProjects,
} from "../../support/page_objects/projectConstants";
@ -62,7 +63,9 @@ export const genTest = (apiType, dbType) => {
cy.get(".nc-ui-acl-tab").click({ force: true });
// 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
//
@ -115,6 +118,15 @@ export const genTest = (apiType, dbType) => {
projectsPage.openProject(
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") {

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

@ -4,123 +4,131 @@
import { loginPage, projectsPage } from "../../support/page_objects/navigation";
import { mainPage } from "../../support/page_objects/mainPage";
import { isTestSuiteActive } from "../../support/page_objects/projectConstants";
import {
_advSettings,
_editSchema,
_editData,
_editComment,
_viewMenu,
_topRightMenu,
enableTableAccess,
_accessControl,
isPostgres,
isTestSuiteActive,
} from "../../support/page_objects/projectConstants";
import {
_advSettings,
_editSchema,
_editData,
_editComment,
_viewMenu,
_topRightMenu,
enableTableAccess,
_accessControl,
} from "../spec/roleValidation.spec";
export const genTest = (apiType, dbType, roleType) => {
if (!isTestSuiteActive(apiType, dbType)) return;
///////////////////////////////////////////////////////////
//// Test Suite
describe("Role preview validations", () => {
// Sign in/ open project
before(() => {
loginPage.loginAndOpenProject(apiType, dbType);
cy.openTableTab("City", 25);
if (!isTestSuiteActive(apiType, dbType)) return;
///////////////////////////////////////////////////////////
//// Test Suite
describe("Role preview validations", () => {
// Sign in/ open project
before(() => {
loginPage.loginAndOpenProject(apiType, dbType);
cy.openTableTab("City", 25);
});
after(() => {
cy.get(".nc-preview-reset").click({ force: true });
// cy.wait(20000)
// wait for page rendering to complete
cy.get(".nc-grid-row", { timeout: 25000 }).should(
"have.length",
25
);
// cy.get('.nc-preview-reset:visible').should('not-exist')
// mainPage.navigationDraw(mainPage.ROLE_VIEW).contains('Reset Preview').should('not.exist')
// cy.get('.nc-preview-reset').should('not-exist')
cy.closeTableTab("City");
// open Project metadata tab
//
mainPage.navigationDraw(mainPage.PROJ_METADATA).click();
cy.get(".nc-exp-imp-metadata").dblclick({ force: true });
cy.get(".nc-ui-acl-tab").click({ force: true });
// validate if it has 19 entries representing tables & views
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
//
enableTableAccess("language", "editor");
enableTableAccess("language", "commenter");
enableTableAccess("language", "viewer");
enableTableAccess("customerlist", "editor");
enableTableAccess("customerlist", "commenter");
enableTableAccess("customerlist", "viewer");
});
const genTestSub = (roleType) => {
it(`Role preview: ${roleType}: Enable preview`, () => {
cy.get(`.nc-preview-${roleType}`).click();
});
it(`Role preview: ${roleType}: Advance settings`, () => {
// project configuration settings
//
_advSettings(roleType, true);
});
it(`Role preview: ${roleType}: Access control`, () => {
// Access control validation
//
_accessControl(roleType, false);
});
it(`Role preview: ${roleType}: Edit data`, () => {
// Table data related validations
// - Add/delete/modify row
//
_editData(roleType, true);
});
it(`Role preview: ${roleType}: Edit comment`, () => {
// read &/ update comment
// Viewer: not allowed to read
// Everyone else: read &/ update
//
_editComment(roleType, true);
});
it(`Role preview: ${roleType}: Preview menu`, () => {
// right navigation menu bar
// Editor/Viewer/Commenter : can only view 'existing' views
// Rest: can create/edit
_viewMenu(roleType, true);
});
it(`Role preview: ${roleType}: Top Right Menu bar`, () => {
// Share button is conditional
// Rest are static/ mandatory
//
_topRightMenu(roleType, false);
});
it(`Role preview: ${roleType}: Edit Schema`, () => {
// Schema related validations
// - Add/delete table
// - Add/Update/delete column
//
_editSchema(roleType, true);
});
};
genTestSub("editor");
genTestSub("commenter");
genTestSub("viewer");
});
after(() => {
cy.get(".nc-preview-reset").click({ force: true });
// cy.wait(20000)
// wait for page rendering to complete
cy.get(".nc-grid-row", { timeout: 25000 }).should("have.length", 25);
// cy.get('.nc-preview-reset:visible').should('not-exist')
// mainPage.navigationDraw(mainPage.ROLE_VIEW).contains('Reset Preview').should('not.exist')
// cy.get('.nc-preview-reset').should('not-exist')
cy.closeTableTab("City");
// open Project metadata tab
//
mainPage.navigationDraw(mainPage.PROJ_METADATA).click();
cy.get(".nc-exp-imp-metadata").dblclick({ force: true });
cy.get(".nc-ui-acl-tab").click({ force: true });
// validate if it has 19 entries representing tables & views
cy.get(".nc-acl-table-row").should("have.length", 19);
// restore access
//
enableTableAccess("language", "editor");
enableTableAccess("language", "commenter");
enableTableAccess("language", "viewer");
enableTableAccess("customerlist", "editor");
enableTableAccess("customerlist", "commenter");
enableTableAccess("customerlist", "viewer");
});
const genTestSub = (roleType) => {
it(`Role preview: ${roleType}: Enable preview`, () => {
cy.get(`.nc-preview-${roleType}`).click();
});
it(`Role preview: ${roleType}: Advance settings`, () => {
// project configuration settings
//
_advSettings(roleType, true);
});
it(`Role preview: ${roleType}: Access control`, () => {
// Access control validation
//
_accessControl(roleType, false);
});
it(`Role preview: ${roleType}: Edit data`, () => {
// Table data related validations
// - Add/delete/modify row
//
_editData(roleType, true);
});
it(`Role preview: ${roleType}: Edit comment`, () => {
// read &/ update comment
// Viewer: not allowed to read
// Everyone else: read &/ update
//
_editComment(roleType, true);
});
it(`Role preview: ${roleType}: Preview menu`, () => {
// right navigation menu bar
// Editor/Viewer/Commenter : can only view 'existing' views
// Rest: can create/edit
_viewMenu(roleType, true);
});
it(`Role preview: ${roleType}: Top Right Menu bar`, () => {
// Share button is conditional
// Rest are static/ mandatory
//
_topRightMenu(roleType, false);
});
it(`Role preview: ${roleType}: Edit Schema`, () => {
// Schema related validations
// - Add/delete table
// - Add/Update/delete column
//
_editSchema(roleType, true);
});
};
genTestSub("editor");
genTestSub("commenter");
genTestSub("viewer");
});
};
/**

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

@ -3,43 +3,43 @@ import { loginPage } from "../../support/page_objects/navigation";
import { isTestSuiteActive } from "../../support/page_objects/projectConstants";
export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return;
if (!isTestSuiteActive(apiType, dbType)) return;
describe(`${apiType.toUpperCase()} Upload/ Download CSV`, () => {
before(() => {
// loginPage.loginAndOpenProject(type)
cy.openTableTab("Country", 25);
cy.screenshot("6b-before");
});
describe(`${apiType.toUpperCase()} Upload/ Download CSV`, () => {
before(() => {
// loginPage.loginAndOpenProject(type)
cy.openTableTab("Country", 25);
cy.screenshot("6b-before");
});
after(() => {
cy.closeTableTab("Country");
cy.screenshot('6b-after')
});
after(() => {
cy.closeTableTab("Country");
cy.screenshot("6b-after");
});
it("Download verification- base view, default columns", () => {
mainPage.hideField("LastUpdate");
const verifyCsv = (retrievedRecords) => {
// expected output, statically configured
let storedRecords = [
`Country,Country => City`,
`Afghanistan,Kabul`,
`Algeria,"Batna,Bchar,Skikda"`,
`American Samoa,Tafuna`,
`Angola,"Benguela,Namibe"`,
];
it("Download verification- base view, default columns", () => {
mainPage.hideField("LastUpdate");
const verifyCsv = (retrievedRecords) => {
// expected output, statically configured
let storedRecords = [
`Country,Country => City`,
`Afghanistan,Kabul`,
`Algeria,"Batna,Bchar,Skikda"`,
`American Samoa,Tafuna`,
`Angola,"Benguela,Namibe"`,
];
for (let i = 0; i < storedRecords.length; i++) {
cy.log(retrievedRecords[i]);
expect(retrievedRecords[i]).to.be.equal(storedRecords[i]);
}
};
for (let i = 0; i < storedRecords.length - 1; i++) {
cy.log(retrievedRecords[i]);
expect(retrievedRecords[i]).to.be.equal(storedRecords[i]);
}
};
// download & verify
mainPage.downloadAndVerifyCsv(`Country_exported_1.csv`, verifyCsv);
mainPage.unhideField("LastUpdate");
// download & verify
mainPage.downloadAndVerifyCsv(`Country_exported_1.csv`, verifyCsv);
mainPage.unhideField("LastUpdate");
});
});
});
};
/**

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 t1c = require("../common/1c_sql_view");
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 t2b = require("../common/2b_table_with_m2m_column");
let t3a = require("../common/3a_filter_sort_fields_operations");

517
scripts/cypress/support/commands.js

@ -25,335 +25,354 @@
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
import "cypress-file-upload";
import { isXcdb } from "./page_objects/projectConstants";
import { isXcdb, isPostgres } from "./page_objects/projectConstants";
require("@4tw/cypress-drag-drop");
// for waiting until page load
Cypress.Commands.add("waitForSpinners", () => {
cy.visit("http://localhost:3000", {
retryOnNetworkFailure: true,
timeout: 1200000,
headers: {
"Accept-Encoding": "gzip, deflate",
},
});
cy.get("#nuxt-loading", { timeout: 10_0000 }).should("have.length", 0);
cy.visit("http://localhost:3000", {
retryOnNetworkFailure: true,
timeout: 1200000,
headers: {
"Accept-Encoding": "gzip, deflate",
},
});
cy.get("#nuxt-loading", { timeout: 10_0000 }).should("have.length", 0);
});
Cypress.Commands.add("signinOrSignup", (_args) => {
const args = Object.assign(
{ username: "user@nocodb.com", password: "Password123." },
_args
);
// signin/signup
cy.get("body").then(($body) => {
// cy.wait(1000)
cy.url().then((url) => {
if (!url.includes("/projects")) {
// handle initial load
if ($body.find(".welcome-page").length > 0) {
cy.wait(8000);
cy.get("body").trigger("mousemove");
cy.contains("Let's Begin").click();
cy.get('input[type="text"]', { timeout: 12000 }).type(args.username);
cy.get('input[type="password"]').type(args.password);
cy.get('button:contains("SIGN UP")').click();
// handle signin
} else {
cy.get('input[type="text"]', { timeout: 12000 }).type(args.username);
cy.get('input[type="password"]').type(args.password);
cy.get('button:contains("SIGN IN")').click();
}
}
const args = Object.assign(
{ username: "user@nocodb.com", password: "Password123." },
_args
);
// signin/signup
cy.get("body").then(($body) => {
// cy.wait(1000)
cy.url().then((url) => {
if (!url.includes("/projects")) {
// handle initial load
if ($body.find(".welcome-page").length > 0) {
cy.wait(8000);
cy.get("body").trigger("mousemove");
cy.contains("Let's Begin").click();
cy.get('input[type="text"]', { timeout: 12000 }).type(
args.username
);
cy.get('input[type="password"]').type(args.password);
cy.get('button:contains("SIGN UP")').click();
// handle signin
} else {
cy.get('input[type="text"]', { timeout: 12000 }).type(
args.username
);
cy.get('input[type="password"]').type(args.password);
cy.get('button:contains("SIGN IN")').click();
}
}
});
});
});
// indicates page-load complete
cy.get(".nc-noco-brand-icon", { timeout: 12000 }).should("exist");
// indicates page-load complete
cy.get(".nc-noco-brand-icon", { timeout: 12000 }).should("exist");
});
// for opening/creating a rest project
Cypress.Commands.add("openOrCreateRestProject", (_args) => {
const args = Object.assign({ new: false }, _args);
// signin/signup
cy.signinOrSignup();
cy.get(".nc-new-project-menu").should("exist");
cy.get("body").then(($body) => {
const filter = args.meta
? ".nc-meta-project-row"
: ":not(.nc-meta-project-row)";
// if project exist open
if ($body.find(".nc-rest-project-row").filter(filter).length && !args.new) {
cy.get(".nc-rest-project-row").filter(filter).first().click();
} else {
cy.contains("New Project").trigger("onmouseover").trigger("mouseenter");
if (args.meta) {
cy.get(".nc-create-xc-db-project").click();
cy.url({ timeout: 6000 }).should("contain", "#/project/xcdb");
cy.get(".nc-metadb-project-name").type("test_proj" + Date.now());
cy.contains("button", "Create", { timeout: 3000 }).click();
} else {
cy.get(".nc-create-external-db-project").click();
cy.url({ timeout: 6000 }).should("contain", "#/project");
cy.get(".database-field input").click().clear().type("sakila");
cy.contains("Test Database Connection").click();
cy.contains("Ok & Save Project", { timeout: 3000 }).click();
}
}
});
cy.url({ timeout: 20000 }).should("contain", "#/nc/");
const args = Object.assign({ new: false }, _args);
// signin/signup
cy.signinOrSignup();
cy.get(".nc-new-project-menu").should("exist");
cy.get("body").then(($body) => {
const filter = args.meta
? ".nc-meta-project-row"
: ":not(.nc-meta-project-row)";
// if project exist open
if (
$body.find(".nc-rest-project-row").filter(filter).length &&
!args.new
) {
cy.get(".nc-rest-project-row").filter(filter).first().click();
} else {
cy.contains("New Project")
.trigger("onmouseover")
.trigger("mouseenter");
if (args.meta) {
cy.get(".nc-create-xc-db-project").click();
cy.url({ timeout: 6000 }).should("contain", "#/project/xcdb");
cy.get(".nc-metadb-project-name").type(
"test_proj" + Date.now()
);
cy.contains("button", "Create", { timeout: 3000 }).click();
} else {
cy.get(".nc-create-external-db-project").click();
cy.url({ timeout: 6000 }).should("contain", "#/project");
cy.get(".database-field input").click().clear().type("sakila");
cy.contains("Test Database Connection").click();
cy.contains("Ok & Save Project", { timeout: 3000 }).click();
}
}
});
cy.url({ timeout: 20000 }).should("contain", "#/nc/");
});
Cypress.Commands.add("refreshTableTab", () => {
cy.task("log", `[refreshTableTab]`);
cy.task("log", `[refreshTableTab]`);
cy.get(".nc-project-tree")
.find(".v-list-item__title:contains(Tables)", { timeout: 10000 })
.should("exist")
.first()
.rightclick({ force: true });
cy.get(".nc-project-tree")
.find(".v-list-item__title:contains(Tables)", { timeout: 10000 })
.should("exist")
.first()
.rightclick({ force: true });
cy.getActiveMenu()
.find('[role="menuitem"]')
.contains("Tables Refresh")
.should("exist")
.click({ force: true });
cy.getActiveMenu()
.find('[role="menuitem"]')
.contains("Tables Refresh")
.should("exist")
.click({ force: true });
cy.toastWait("Tables refreshed");
cy.toastWait("Tables refreshed");
});
// tn: table name
// rc: row count. validate row count if rc!=0
Cypress.Commands.add("openTableTab", (tn, rc) => {
cy.task("log", `[openTableTab] ${tn} ${rc}`);
cy.task("log", `[openTableTab] ${tn} ${rc}`);
cy.get(".nc-project-tree")
.find(".v-list-item__title:contains(Tables)", { timeout: 10000 })
.should("exist")
.first()
.click({ force: true });
cy.get(".nc-project-tree")
.find(".v-list-item__title:contains(Tables)", { timeout: 10000 })
.should("exist")
.first()
.click({ force: true });
cy.get(".nc-project-tree")
.contains(tn, { timeout: 6000 })
.first()
.click({ force: true });
cy.get(".nc-project-tree")
.contains(tn, { timeout: 6000 })
.first()
.click({ force: true });
cy.get(`.project-tab`).contains(tn, { timeout: 10000 }).should("exist");
cy.get(`.project-tab`).contains(tn, { timeout: 10000 }).should("exist");
cy.get(".nc-project-tree")
.find(".v-list-item__title:contains(Tables)", { timeout: 10000 })
.first()
.click({ force: true });
cy.get(".nc-project-tree")
.find(".v-list-item__title:contains(Tables)", { timeout: 10000 })
.first()
.click({ force: true });
// wait for page rendering to complete
if (rc != 0) {
cy.get(".nc-grid-row").should("have.length", rc);
}
// wait for page rendering to complete
if (rc != 0) {
cy.get(".nc-grid-row").should("have.length", rc);
}
});
Cypress.Commands.add("closeTableTab", (tn) => {
cy.task("log", `[closeTableTab] ${tn}`);
cy.get(`.project-tab`).contains(tn, { timeout: 10000 }).should("exist");
cy.get(`[href="#table||db||${tn}"]`).find("button.mdi-close").click();
cy.task("log", `[closeTableTab] ${tn}`);
cy.get(`.project-tab`).contains(tn, { timeout: 10000 }).should("exist");
cy.get(`[href="#table||db||${tn}"]`).find("button.mdi-close").click();
});
Cypress.Commands.add("openOrCreateGqlProject", (_args) => {
const args = Object.assign({ new: false, meta: false }, _args);
cy.signinOrSignup();
cy.get(".nc-new-project-menu").should("exist");
cy.get("body").then(($body) => {
const filter = args.meta
? ".nc-meta-project-row"
: ":not(.nc-meta-project-row)";
// if project exist open
if (
$body.find(".nc-graphql-project-row").filter(filter).length &&
!args.new
) {
cy.get(".nc-graphql-project-row").filter(filter).first().click();
} else {
cy.contains("New Project").trigger("onmouseover").trigger("mouseenter");
if (args.meta) {
cy.get(".nc-create-xc-db-project").click();
cy.url({ timeout: 6000 }).should("contain", "#/project/xcdb");
cy.contains("GRAPHQL APIs").closest("label").click();
cy.get(".nc-metadb-project-name").type("test_proj" + Date.now());
cy.contains("button", "Create", { timeout: 3000 }).click();
} else {
cy.get(".nc-create-external-db-project").click();
cy.url({ timeout: 6000 }).should("contain", "#/project");
cy.contains("GRAPHQL APIs").closest("label").click();
cy.get(".database-field input").click().clear().type("sakila");
cy.contains("Test Database Connection").click();
cy.contains("Ok & Save Project", { timeout: 3000 }).click();
}
}
});
cy.url({ timeout: 20000 }).should("contain", "#/nc/");
const args = Object.assign({ new: false, meta: false }, _args);
cy.signinOrSignup();
cy.get(".nc-new-project-menu").should("exist");
cy.get("body").then(($body) => {
const filter = args.meta
? ".nc-meta-project-row"
: ":not(.nc-meta-project-row)";
// if project exist open
if (
$body.find(".nc-graphql-project-row").filter(filter).length &&
!args.new
) {
cy.get(".nc-graphql-project-row").filter(filter).first().click();
} else {
cy.contains("New Project")
.trigger("onmouseover")
.trigger("mouseenter");
if (args.meta) {
cy.get(".nc-create-xc-db-project").click();
cy.url({ timeout: 6000 }).should("contain", "#/project/xcdb");
cy.contains("GRAPHQL APIs").closest("label").click();
cy.get(".nc-metadb-project-name").type(
"test_proj" + Date.now()
);
cy.contains("button", "Create", { timeout: 3000 }).click();
} else {
cy.get(".nc-create-external-db-project").click();
cy.url({ timeout: 6000 }).should("contain", "#/project");
cy.contains("GRAPHQL APIs").closest("label").click();
cy.get(".database-field input").click().clear().type("sakila");
cy.contains("Test Database Connection").click();
cy.contains("Ok & Save Project", { timeout: 3000 }).click();
}
}
});
cy.url({ timeout: 20000 }).should("contain", "#/nc/");
});
let LOCAL_STORAGE_MEMORY = {};
Cypress.Commands.add("saveLocalStorage", () => {
Object.keys(localStorage).forEach((key) => {
LOCAL_STORAGE_MEMORY[key] = localStorage[key];
});
Object.keys(localStorage).forEach((key) => {
LOCAL_STORAGE_MEMORY[key] = localStorage[key];
});
});
Cypress.Commands.add("restoreLocalStorage", () => {
Object.keys(LOCAL_STORAGE_MEMORY).forEach((key) => {
localStorage.setItem(key, LOCAL_STORAGE_MEMORY[key]);
});
Object.keys(LOCAL_STORAGE_MEMORY).forEach((key) => {
localStorage.setItem(key, LOCAL_STORAGE_MEMORY[key]);
});
});
Cypress.Commands.add("getActiveModal", () => {
return cy.get(".v-dialog.v-dialog--active").last();
return cy.get(".v-dialog.v-dialog--active").last();
});
Cypress.Commands.add("getActiveMenu", () => {
return cy.get(".menuable__content__active").last();
return cy.get(".menuable__content__active").last();
});
Cypress.Commands.add("getActiveContentModal", () => {
return cy.get(".v-dialog__content--active").last();
return cy.get(".v-dialog__content--active").last();
});
Cypress.Commands.add("createTable", (name) => {
cy.get(".add-btn").click();
cy.get('.nc-create-table-card .nc-table-name input[type="text"]')
.first()
.click()
.clear()
.type(name);
// cy.log(isXcdb());
// if (!isXcdb()) {
// cy.get('.nc-create-table-card .nc-table-name-alias input[type="text"]')
// .first()
// .should("have.value", name.toLowerCase());
// }
cy.get(".nc-create-table-card .nc-create-table-submit").first().click();
cy.toastWait(`Create table successful`);
cy.get(`.project-tab:contains(${name})`).should("exist");
cy.url().should("contain", `name=${name}`);
cy.get(".add-btn").click();
cy.get('.nc-create-table-card .nc-table-name input[type="text"]')
.first()
.click()
.clear()
.type(name);
// cy.log(isXcdb());
// if (!isXcdb()) {
// cy.get('.nc-create-table-card .nc-table-name-alias input[type="text"]')
// .first()
// .should("have.value", name.toLowerCase());
// }
cy.get(".nc-create-table-card .nc-create-table-submit").first().click();
cy.toastWait(`Create table successful`);
cy.get(`.project-tab:contains(${name})`).should("exist");
cy.url().should("contain", `name=${name}`);
});
Cypress.Commands.add("deleteTable", (name) => {
cy.get(".nc-project-tree")
.find(".v-list-item__title:contains(Tables)", { timeout: 10000 })
.first()
.click();
cy.get(".nc-project-tree")
.contains(name, { timeout: 6000 })
.first()
.click({ force: true });
cy.get(`.project-tab:contains(${name}):visible`).should("exist");
cy.get(".nc-table-delete-btn:visible").click();
cy.get("button:contains(Submit)").click();
cy.toastWait(`Delete table successful`);
Cypress.Commands.add("deleteTable", (name, dbType) => {
cy.get(".nc-project-tree")
.find(".v-list-item__title:contains(Tables)", { timeout: 10000 })
.first()
.click();
cy.get(".nc-project-tree")
.contains(name, { timeout: 6000 })
.first()
.click({ force: true });
cy.get(`.project-tab:contains(${name}):visible`).should("exist");
cy.get(".nc-table-delete-btn:visible").click();
cy.get("button:contains(Submit)").click();
// only for postgre project
if (dbType === "postgres") cy.toastWait(`Delete trigger successful`);
cy.toastWait(`Delete table successful`);
});
Cypress.Commands.add("renameTable", (oldName, newName) => {
// expand project tree
cy.get(".nc-project-tree")
.find(".v-list-item__title:contains(Tables)", { timeout: 10000 })
.first()
.click();
// right click on project table name
cy.get(".nc-project-tree")
.contains(oldName, { timeout: 6000 })
.first()
.rightclick();
// choose rename option from menu
cy.getActiveMenu()
.find('[role="menuitem"]')
.contains("Table Rename")
.click({ force: true });
// feed new name
cy.getActiveContentModal().find("input").clear().type(newName);
// submit
cy.getActiveContentModal().find("button").contains("Submit").click();
cy.toastWait("Table renamed successfully");
// close expanded project tree
cy.get(".nc-project-tree")
.find(".v-list-item__title:contains(Tables)", { timeout: 10000 })
.first()
.click();
// expand project tree
cy.get(".nc-project-tree")
.find(".v-list-item__title:contains(Tables)", { timeout: 10000 })
.first()
.click();
// right click on project table name
cy.get(".nc-project-tree")
.contains(oldName, { timeout: 6000 })
.first()
.rightclick();
// choose rename option from menu
cy.getActiveMenu()
.find('[role="menuitem"]')
.contains("Table Rename")
.click({ force: true });
// feed new name
cy.getActiveContentModal().find("input").clear().type(newName);
// submit
cy.getActiveContentModal().find("button").contains("Submit").click();
cy.toastWait("Table renamed successfully");
// close expanded project tree
cy.get(".nc-project-tree")
.find(".v-list-item__title:contains(Tables)", { timeout: 10000 })
.first()
.click();
});
Cypress.Commands.add("createColumn", (table, columnName) => {
cy.get(".nc-project-tree")
.find(".v-list-item__title:contains(Tables)", { timeout: 10000 })
.first()
.click();
cy.get(".nc-project-tree")
.contains(table, { timeout: 6000 })
.first()
.click({ force: true });
cy.get(`.project-tab:contains(${table}):visible`).should("exist");
cy.get(".v-window-item--active .nc-grid tr > th:last button").click({
force: true,
});
cy.get(".nc-column-name-input input").clear().type(columnName);
cy.get(".nc-col-create-or-edit-card").contains("Save").click();
cy.get("th:contains(new_column)").should("exist");
cy.get(".nc-project-tree")
.find(".v-list-item__title:contains(Tables)", { timeout: 10000 })
.first()
.click();
cy.get(".nc-project-tree")
.contains(table, { timeout: 6000 })
.first()
.click({ force: true });
cy.get(`.project-tab:contains(${table}):visible`).should("exist");
cy.get(".v-window-item--active .nc-grid tr > th:last button").click({
force: true,
});
cy.get(".nc-column-name-input input").clear().type(columnName);
cy.get(".nc-col-create-or-edit-card").contains("Save").click();
cy.get("th:contains(new_column)").should("exist");
});
Cypress.Commands.add("toastWait", (msg) => {
cy.get(".toasted:visible", { timout: 12000 }).contains(msg).should("exist");
cy.get(".toasted:visible", { timout: 12000 })
.contains(msg)
.should("not.exist");
cy.get(".toasted:visible", { timout: 12000 }).contains(msg).should("exist");
cy.get(".toasted:visible", { timout: 12000 })
.contains(msg)
.should("not.exist");
});
// vn: view name
// rc: expected row count. validate row count if rc!=0
Cypress.Commands.add("openViewsTab", (vn, rc) => {
cy.task("log", `[openViewsTab] ${vn} ${rc}`);
cy.task("log", `[openViewsTab] ${vn} ${rc}`);
cy.get(".nc-project-tree")
.find(".v-list-item__title:contains(Tables)", { timeout: 10000 })
.should("exist")
.first()
.click({ force: true });
cy.get(".nc-project-tree")
.find(".v-list-item__title:contains(Tables)", { timeout: 10000 })
.should("exist")
.first()
.click({ force: true });
cy.get(".nc-project-tree")
.contains(vn, { timeout: 6000 })
.first()
.click({ force: true });
cy.get(".nc-project-tree")
.contains(vn, { timeout: 6000 })
.first()
.click({ force: true });
cy.get(`.project-tab`).contains(vn, { timeout: 10000 }).should("exist");
cy.get(`.project-tab`).contains(vn, { timeout: 10000 }).should("exist");
cy.get(".nc-project-tree")
.find(".v-list-item__title:contains(Tables)", { timeout: 10000 })
.first()
.click({ force: true });
cy.get(".nc-project-tree")
.find(".v-list-item__title:contains(Tables)", { timeout: 10000 })
.first()
.click({ force: true });
// wait for page rendering to complete
if (rc != 0) {
cy.get(".nc-grid-row").should("have.length", rc);
}
// wait for page rendering to complete
if (rc != 0) {
cy.get(".nc-grid-row").should("have.length", rc);
}
});
Cypress.Commands.add("closeViewsTab", (vn) => {
cy.task("log", `[closeViewsTab] ${vn}`);
cy.get(`.project-tab`).contains(vn, { timeout: 10000 }).should("exist");
cy.get(`[href="#view||db||${vn}"]`)
.find("button.mdi-close")
.click({ force: true });
cy.task("log", `[closeViewsTab] ${vn}`);
cy.get(`.project-tab`).contains(vn, { timeout: 10000 }).should("exist");
cy.get(`[href="#view||db||${vn}"]`)
.find("button.mdi-close")
.click({ force: true });
});
// Drag n Drop

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

@ -7,295 +7,310 @@ import { roles, staticProjects, defaultDbParams } from "./projectConstants";
// suffix to baseUrl needs to be defined here
//
const urlPool = {
ncUrlBase: "/",
ncUrlSignUp: "#/user/authentication/signup",
ncUrlSignIn: "#/user/authentication/signin",
ncUrlBase: "/",
ncUrlSignUp: "#/user/authentication/signup",
ncUrlSignIn: "#/user/authentication/signin",
};
export class _loginPage {
// prefix: baseUrl
go(urlKey) {
cy.visit(urlKey);
}
// visit SignIn URL, enter credentials passed as parameters
//
signIn(userCredentials) {
this.go(urlPool.ncUrlSignIn);
cy.get('input[type="text"]', { timeout: 20000 }).type(
userCredentials.username
);
cy.get('input[type="password"]').type(userCredentials.password);
cy.get('button:contains("SIGN IN")').click();
this.waitProjectPageLoad();
}
// visit SignUp URL, enter credentials passed as parameters
//
signUp(userCredentials) {
this.go(urlPool.ncUrlSignUp);
cy.get('input[type="text"]', { timeout: 20000 }).type(
userCredentials.username
);
cy.get('input[type="password"]').type(userCredentials.password);
cy.get('button:contains("SIGN UP")').click();
this.waitProjectPageLoad();
}
// delay/ wait utility routines
//
waitProjectPageLoad() {
cy.url({ timeout: 6000 }).should("contain", "#/project");
cy.get(".nc-new-project-menu").should("exist");
}
// standard pre-project activity
//
loginAndOpenProject(apiType, dbType) {
loginPage.signIn(roles.owner.credentials);
if (dbType === "mysql") {
if ("rest" == apiType)
projectsPage.openProject(staticProjects.externalREST.basic.name);
else projectsPage.openProject(staticProjects.externalGQL.basic.name);
} else if(dbType === "xcdb") {
if ("rest" == apiType)
projectsPage.openProject(staticProjects.sampleREST.basic.name);
else projectsPage.openProject(staticProjects.sampleGQL.basic.name);
// prefix: baseUrl
go(urlKey) {
cy.visit(urlKey);
}
// visit SignIn URL, enter credentials passed as parameters
//
signIn(userCredentials) {
this.go(urlPool.ncUrlSignIn);
cy.get('input[type="text"]', { timeout: 20000 }).type(
userCredentials.username
);
cy.get('input[type="password"]').type(userCredentials.password);
cy.get('button:contains("SIGN IN")').click();
this.waitProjectPageLoad();
}
// visit SignUp URL, enter credentials passed as parameters
//
signUp(userCredentials) {
this.go(urlPool.ncUrlSignUp);
cy.get('input[type="text"]', { timeout: 20000 }).type(
userCredentials.username
);
cy.get('input[type="password"]').type(userCredentials.password);
cy.get('button:contains("SIGN UP")').click();
this.waitProjectPageLoad();
}
// delay/ wait utility routines
//
waitProjectPageLoad() {
cy.url({ timeout: 6000 }).should("contain", "#/project");
cy.get(".nc-new-project-menu").should("exist");
}
// standard pre-project activity
//
loginAndOpenProject(apiType, dbType) {
loginPage.signIn(roles.owner.credentials);
if (dbType === "mysql") {
if ("rest" == apiType)
projectsPage.openProject(
staticProjects.externalREST.basic.name
);
else
projectsPage.openProject(staticProjects.externalGQL.basic.name);
} else if (dbType === "xcdb") {
if ("rest" == apiType)
projectsPage.openProject(staticProjects.sampleREST.basic.name);
else projectsPage.openProject(staticProjects.sampleGQL.basic.name);
}
}
}
}
///////////////////////////////////////////////////////////
// Projects page
export class _projectsPage {
// Project creation options
//
// {dbType, apiType, name}
// for external database, {databaseType, hostAddress, portNumber, username, password, databaseName}
// Open existing project
// TODO: add projectName validation
//
openProject(projectName) {
cy.get("tbody").contains("tr", projectName).should("exist").click();
// takes a while to load project
this.waitHomePageLoad();
}
// Create new project
// Input:
// projectData {dbType, apiType, name}
// dbCredentials {databaseType, hostAddress, portNumber, username, password, databaseName}
// Returns: projectName
//
// To configure
// SSL & advanced parameters
// Database type selection
//
createProject(projectData, cred) {
cy.get("body", { timeout: 2000 });
let projectName = projectData.name;
if (projectData.name == "") projectName = "test_proj" + Date.now();
// click on "New Project"
cy.get(":nth-child(5) > .v-btn", { timeout: 20000 }).click();
if ("none" == projectData.dbType) {
// Subsequent form, select (+ Create) option
cy.get(".nc-create-xc-db-project", { timeout: 20000 }).click({
force: true,
});
// feed project name
cy.get(".nc-metadb-project-name", { timeout: 20000 }).type(projectName);
// Radio button: defaults to NC_REST
if ("GQL" == projectData.apiType) {
cy.contains("GRAPHQL APIs").closest("label").click();
}
// Submit
cy.contains("button", "Create", { timeout: 20000 }).click();
// takes a while to load project
this.waitHomePageLoad();
return projectName;
// Project creation options
//
// {dbType, apiType, name}
// for external database, {databaseType, hostAddress, portNumber, username, password, databaseName}
// Open existing project
// TODO: add projectName validation
//
openProject(projectName) {
cy.get("tbody").contains("tr", projectName).should("exist").click();
// takes a while to load project
this.waitHomePageLoad();
}
// Create new project
// Input:
// projectData {dbType, apiType, name}
// dbCredentials {databaseType, hostAddress, portNumber, username, password, databaseName}
// Returns: projectName
//
// To configure
// SSL & advanced parameters
// Database type selection
//
createProject(projectData, cred) {
cy.get("body", { timeout: 2000 });
let projectName = projectData.name;
if (projectData.name == "") projectName = "test_proj" + Date.now();
// click on "New Project"
cy.get(":nth-child(5) > .v-btn", { timeout: 20000 }).click();
if ("none" == projectData.dbType) {
// Subsequent form, select (+ Create) option
cy.get(".nc-create-xc-db-project", { timeout: 20000 }).click({
force: true,
});
// feed project name
cy.get(".nc-metadb-project-name", { timeout: 20000 }).type(
projectName
);
// Radio button: defaults to NC_REST
if ("GQL" == projectData.apiType) {
cy.contains("GRAPHQL APIs").closest("label").click();
}
// Submit
cy.contains("button", "Create", { timeout: 20000 }).click();
// takes a while to load project
this.waitHomePageLoad();
return projectName;
}
// dbType == 'external'
else {
// Subsequent form, select (+ Create by connection to external database) option
cy.get(".nc-create-external-db-project", { timeout: 20000 }).click({
force: true,
});
// feed project name
//cy.get('.nc-metadb-project-name').type(projectName)
cy.contains("Enter Project Name", { timeout: 20000 })
.parent()
.find("input")
.clear()
.type(projectName);
// Radio button: defaults to NC_REST
if ("GQL" == projectData.apiType) {
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 != "")
cy.contains("Host Address")
.parent()
.find("input")
.clear()
.type(cred.hostAddress);
if (cred.portNumber != "")
cy.contains("Port Number")
.parent()
.find("input")
.clear()
.type(cred.portNumber);
if (cred.username != "")
cy.contains("Username")
.parent()
.find("input")
.clear()
.type(cred.username);
if (cred.password != "")
cy.contains("Password")
.parent()
.find("input")
.clear()
.type(cred.password);
if (cred.databaseName != "")
cy.contains("Database : create if not exists")
.parent()
.find("input")
.clear()
.type(cred.databaseName);
// Test database connection
cy.contains("Test Database Connection", { timeout: 20000 }).click();
// Create project
cy.contains("Ok & Save Project", { timeout: 20000 }).click();
// takes a while to load project
this.waitHomePageLoad();
return projectName;
}
}
// create REST default project (sakila DB)
//
createDefaulRestProject() {
return this.createProject(
{ dbType: 1, apiType: 0, name: "" },
defaultDbParams
);
}
// create GraphQL default project (sakila DB)
//
createDefaultGraphQlProject() {
return this.createProject(
{ dbType: 1, apiType: 1, name: "" },
defaultDbParams
);
}
// Click on refresh key on projects page
//
refreshProject() {
cy.contains("My Projects").parent().find("button").click();
}
// search project with given key
// return project-name array
//
searchProject(projectNameKey) {
cy.get('input[placeholder="Search Project"]').type(projectNameKey);
const projectName = [];
cy.get("table tr")
.each((tableRow) => {
cy.wrap(tableRow)
.find("td")
.eq(0)
.find(".title")
.then((input) => {
projectName.push(input.text());
});
})
.then(() => {
// TBD: validate project name to contain search key
console.log(projectName);
return projectName;
});
}
// remove specified project entry
// TODO: error handling
//
deleteProject(name) {
// delete icon
cy.get("tbody")
.contains("tr", name)
.find(".mdi-delete-circle-outline")
.click();
cy.toastWait("deleted successfully");
// this.waitDeletePageLoad()
// pop-up, submit
cy.get("body").then((body) => {
cy.wrap(body).find("button").contains("Submit").click();
});
}
// dbType == 'external'
else {
// Subsequent form, select (+ Create by connection to external database) option
cy.get(".nc-create-external-db-project", { timeout: 20000 }).click({
force: true,
});
// feed project name
//cy.get('.nc-metadb-project-name').type(projectName)
cy.contains("Enter Project Name", { timeout: 20000 })
.parent()
.find("input")
.clear()
.type(projectName);
// Radio button: defaults to NC_REST
if ("GQL" == projectData.apiType) {
cy.contains("GRAPHQL APIs").closest("label").click();
}
if (cred.hostAddress != "")
cy.contains("Host Address")
.parent()
.find("input")
.clear()
.type(cred.hostAddress);
if (cred.portNumber != "")
cy.contains("Port Number")
.parent()
.find("input")
.clear()
.type(cred.portNumber);
if (cred.username != "")
cy.contains("Username")
.parent()
.find("input")
.clear()
.type(cred.username);
if (cred.password != "")
cy.contains("Password")
.parent()
.find("input")
.clear()
.type(cred.password);
if (cred.databaseName != "")
cy.contains("Database : create if not exists")
.parent()
.find("input")
.clear()
.type(cred.databaseName);
// Test database connection
cy.contains("Test Database Connection", { timeout: 20000 }).click();
// Create project
cy.contains("Ok & Save Project", { timeout: 20000 }).click();
// takes a while to load project
this.waitHomePageLoad();
return projectName;
// remove all projects created
//
// 1. read all project names to be deleted, store in array
// 2. invoke delete project for each entry in array
//
// deleteAllProject() {
// const projectName = []
// cy.get('table tr').each((tableRow) => {
// cy.wrap(tableRow).find('td').eq(0).find('.title').then((input) => {
// projectName.push(input.text())
// })
// })
// .then(() => {
// console.log(projectName)
// projectName.forEach(element => {
// // bring back the DOM to normalcy
// cy.get('div').parentsUntil('body')
// this.deleteProject(element)
// // wait needed for pop up to disapper
// this.waitDeletePageLoad()
// })
// })
// }
waitHomePageLoad() {
cy.url({ timeout: 50000 }).should("contain", "&dbalias=");
}
}
// create REST default project (sakila DB)
//
createDefaulRestProject() {
return this.createProject(
{ dbType: 1, apiType: 0, name: "" },
defaultDbParams
);
}
// create GraphQL default project (sakila DB)
//
createDefaultGraphQlProject() {
return this.createProject(
{ dbType: 1, apiType: 1, name: "" },
defaultDbParams
);
}
// Click on refresh key on projects page
//
refreshProject() {
cy.contains("My Projects").parent().find("button").click();
}
// search project with given key
// return project-name array
//
searchProject(projectNameKey) {
cy.get('input[placeholder="Search Project"]').type(projectNameKey);
const projectName = [];
cy.get("table tr")
.each((tableRow) => {
cy.wrap(tableRow)
.find("td")
.eq(0)
.find(".title")
.then((input) => {
projectName.push(input.text());
});
})
.then(() => {
// TBD: validate project name to contain search key
console.log(projectName);
return projectName;
});
}
// remove specified project entry
// TODO: error handling
//
deleteProject(name) {
// delete icon
cy.get("tbody")
.contains("tr", name)
.find(".mdi-delete-circle-outline")
.click();
cy.toastWait("deleted successfully");
// this.waitDeletePageLoad()
// pop-up, submit
cy.get("body").then((body) => {
cy.wrap(body).find("button").contains("Submit").click();
});
}
// remove all projects created
//
// 1. read all project names to be deleted, store in array
// 2. invoke delete project for each entry in array
//
// deleteAllProject() {
// const projectName = []
// cy.get('table tr').each((tableRow) => {
// cy.wrap(tableRow).find('td').eq(0).find('.title').then((input) => {
// projectName.push(input.text())
// })
// })
// .then(() => {
// console.log(projectName)
// projectName.forEach(element => {
// // bring back the DOM to normalcy
// cy.get('div').parentsUntil('body')
// this.deleteProject(element)
// // wait needed for pop up to disapper
// this.waitDeletePageLoad()
// })
// })
// }
waitHomePageLoad() {
cy.url({ timeout: 50000 }).should("contain", "&dbalias=");
}
}
export const loginPage = new _loginPage();

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

@ -7,6 +7,15 @@ export const defaultDbParams = {
databaseName: "sakila",
};
export const defaultPgDbParams = {
databaseType: 1, // Postgres
hostAddress: "localhost",
portNumber: "5432",
username: "postgres",
password: "password",
databaseName: "postgres",
};
// database
// validation details
// advSettings: left navigation bar (audit, metadata, auth, transient view modes)
@ -103,6 +112,14 @@ export const staticProjects = {
basic: { dbType: "external", apiType: "GQL", name: "externalGQL" },
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
@ -128,6 +145,10 @@ export function isXcdb() {
return currentTestMode.dbType === "xcdb";
}
export function isPostgres() {
return currentTestMode.dbType === "postgres";
}
export function setProjectString(projStr) {
xcdbProjectString = projStr;
}

Loading…
Cancel
Save