Browse Source

chore(test): JS prettier for all files

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
pull/3777/head
Raju Udava 2 years ago
parent
commit
51e8a66c95
  1. 318
      scripts/cypress/integration/common/00_pre_configurations.js
  2. 180
      scripts/cypress/integration/common/1a_table_operations.js
  3. 305
      scripts/cypress/integration/common/1c_sql_view.js
  4. 266
      scripts/cypress/integration/common/1d_pg_table_view_drag_drop_reorder.js
  5. 281
      scripts/cypress/integration/common/1d_table_view_drag_drop_reorder.js
  6. 331
      scripts/cypress/integration/common/1e_meta_sync.js
  7. 348
      scripts/cypress/integration/common/1e_pg_meta_sync.js
  8. 187
      scripts/cypress/integration/common/2a_table_with_belongs_to_colulmn.js
  9. 485
      scripts/cypress/integration/common/3b_formula_column.js
  10. 170
      scripts/cypress/integration/common/4a_table_view_grid_gallery_form.js
  11. 223
      scripts/cypress/integration/common/4b_table_view_share.js
  12. 789
      scripts/cypress/integration/common/4c_form_view_detailed.js
  13. 201
      scripts/cypress/integration/common/4d_table_view_grid_locked.js
  14. 411
      scripts/cypress/integration/common/4e_form_view_share.js
  15. 855
      scripts/cypress/integration/common/4f_pg_grid_view_share.js
  16. 118
      scripts/cypress/integration/common/4g_table_view_expanded_form.js
  17. 519
      scripts/cypress/integration/common/5a_user_role.js
  18. 291
      scripts/cypress/integration/common/5b_preview_role.js
  19. 112
      scripts/cypress/integration/common/6b_downloadCsv.js
  20. 462
      scripts/cypress/integration/common/6c_swagger_api.js
  21. 179
      scripts/cypress/integration/common/6d_language_validation.js
  22. 44
      scripts/cypress/integration/common/6e_project_operations.js
  23. 251
      scripts/cypress/integration/common/6f_attachments.js
  24. 427
      scripts/cypress/integration/common/7a_create_project_from_excel.js
  25. 49
      scripts/cypress/integration/common/7b_import_from_airtable.js
  26. 813
      scripts/cypress/integration/common/9a_QuickTest.js
  27. 500
      scripts/cypress/integration/common/9b_ERD.js
  28. 48
      scripts/cypress/integration/test/explicitLogin.js
  29. 30
      scripts/cypress/integration/test/pg-restMisc.js
  30. 10
      scripts/cypress/integration/test/pg-restRoles.js
  31. 30
      scripts/cypress/integration/test/pg-restTableOps.js
  32. 22
      scripts/cypress/integration/test/pg-restViews.js
  33. 4
      scripts/cypress/integration/test/quickTest.js
  34. 44
      scripts/cypress/integration/test/restMisc.js
  35. 10
      scripts/cypress/integration/test/restRoles.js
  36. 22
      scripts/cypress/integration/test/restViews.js
  37. 32
      scripts/cypress/integration/test/xcdb-restMisc.js
  38. 10
      scripts/cypress/integration/test/xcdb-restRoles.js
  39. 30
      scripts/cypress/integration/test/xcdb-restTableOps.js
  40. 20
      scripts/cypress/integration/test/xcdb-restViews.js
  41. 359
      scripts/cypress/plugins/index.js
  42. 20
      scripts/cypress/plugins/read-xlsx.js
  43. 61
      scripts/cypress/plugins/server.js
  44. 12
      scripts/cypress/support/index.js
  45. 521
      scripts/cypress/support/page_objects/navigation.js
  46. 243
      scripts/cypress/support/page_objects/projectConstants.js

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

@ -4,33 +4,33 @@
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 {
staticProjects, staticProjects,
roles, roles,
isTestSuiteActive, isTestSuiteActive,
getCurrentMode, getCurrentMode,
isXcdb, isXcdb,
setProjectString, setProjectString,
} from "../../support/page_objects/projectConstants"; } from "../../support/page_objects/projectConstants";
function prepareSqliteQuery(projId) { function prepareSqliteQuery(projId) {
let sqliteQuery = [ let sqliteQuery = [
`ALTER TABLE "actor" RENAME TO "${projId}actor"`, `ALTER TABLE "actor" RENAME TO "${projId}actor"`,
`ALTER TABLE "address" RENAME TO "${projId}address"`, `ALTER TABLE "address" RENAME TO "${projId}address"`,
`ALTER TABLE "category" RENAME TO "${projId}category"`, `ALTER TABLE "category" RENAME TO "${projId}category"`,
`ALTER TABLE "city" RENAME TO "${projId}city"`, `ALTER TABLE "city" RENAME TO "${projId}city"`,
`ALTER TABLE "country" RENAME TO "${projId}country"`, `ALTER TABLE "country" RENAME TO "${projId}country"`,
`ALTER TABLE "customer" RENAME TO "${projId}customer"`, `ALTER TABLE "customer" RENAME TO "${projId}customer"`,
`ALTER TABLE "film" RENAME TO "${projId}film"`, `ALTER TABLE "film" RENAME TO "${projId}film"`,
`ALTER TABLE "film_actor" RENAME TO "${projId}film_actor"`, `ALTER TABLE "film_actor" RENAME TO "${projId}film_actor"`,
`ALTER TABLE "film_category" RENAME TO "${projId}film_category"`, `ALTER TABLE "film_category" RENAME TO "${projId}film_category"`,
`ALTER TABLE "film_text" RENAME TO "${projId}film_text"`, `ALTER TABLE "film_text" RENAME TO "${projId}film_text"`,
`ALTER TABLE "inventory" RENAME TO "${projId}inventory"`, `ALTER TABLE "inventory" RENAME TO "${projId}inventory"`,
`ALTER TABLE "language" RENAME TO "${projId}language"`, `ALTER TABLE "language" RENAME TO "${projId}language"`,
`ALTER TABLE "payment" RENAME TO "${projId}payment"`, `ALTER TABLE "payment" RENAME TO "${projId}payment"`,
`ALTER TABLE "rental" RENAME TO "${projId}rental"`, `ALTER TABLE "rental" RENAME TO "${projId}rental"`,
`ALTER TABLE "staff" RENAME TO "${projId}staff"`, `ALTER TABLE "staff" RENAME TO "${projId}staff"`,
`ALTER TABLE "store" RENAME TO "${projId}store"`, `ALTER TABLE "store" RENAME TO "${projId}store"`,
`CREATE VIEW ${projId}customer_list `CREATE VIEW ${projId}customer_list
AS AS
SELECT cu.customer_id AS ID, SELECT cu.customer_id AS ID,
cu.first_name||' '||cu.last_name AS name, cu.first_name||' '||cu.last_name AS name,
@ -43,7 +43,7 @@ function prepareSqliteQuery(projId) {
cu.store_id AS SID cu.store_id AS SID
FROM "${projId}customer" AS cu JOIN "${projId}address" AS a ON cu.address_id = a.address_id JOIN "${projId}city" ON a.city_id = "${projId}city".city_id FROM "${projId}customer" AS cu JOIN "${projId}address" AS a ON cu.address_id = a.address_id JOIN "${projId}city" ON a.city_id = "${projId}city".city_id
JOIN "${projId}country" ON "${projId}city".country_id = "${projId}country".country_id`, JOIN "${projId}country" ON "${projId}city".country_id = "${projId}country".country_id`,
`CREATE VIEW ${projId}film_list `CREATE VIEW ${projId}film_list
AS AS
SELECT "${projId}film".film_id AS FID, SELECT "${projId}film".film_id AS FID,
"${projId}film".title AS title, "${projId}film".title AS title,
@ -56,7 +56,7 @@ function prepareSqliteQuery(projId) {
FROM "${projId}category" LEFT JOIN "${projId}film_category" ON "${projId}category".category_id = "${projId}film_category".category_id LEFT JOIN "${projId}film" ON "${projId}Film_category".film_id = "${projId}film".film_id FROM "${projId}category" LEFT JOIN "${projId}film_category" ON "${projId}category".category_id = "${projId}film_category".category_id LEFT JOIN "${projId}film" ON "${projId}Film_category".film_id = "${projId}film".film_id
JOIN "${projId}film_actor" ON "${projId}film".film_id = "${projId}film_actor".film_id JOIN "${projId}film_actor" ON "${projId}film".film_id = "${projId}film_actor".film_id
JOIN "${projId}actor" ON "${projId}film_actor".actor_id = "${projId}actor".actor_id`, JOIN "${projId}actor" ON "${projId}film_actor".actor_id = "${projId}actor".actor_id`,
`CREATE VIEW ${projId}sales_by_film_category `CREATE VIEW ${projId}sales_by_film_category
AS AS
SELECT SELECT
c.name AS category c.name AS category
@ -68,7 +68,7 @@ function prepareSqliteQuery(projId) {
INNER JOIN "${projId}film_category" AS fc ON f.film_id = fc.film_id INNER JOIN "${projId}film_category" AS fc ON f.film_id = fc.film_id
INNER JOIN "${projId}category" AS c ON fc.category_id = c.category_id INNER JOIN "${projId}category" AS c ON fc.category_id = c.category_id
GROUP BY c.name`, GROUP BY c.name`,
`CREATE VIEW ${projId}sales_by_store `CREATE VIEW ${projId}sales_by_store
AS AS
SELECT SELECT
s.store_id s.store_id
@ -87,7 +87,7 @@ function prepareSqliteQuery(projId) {
s.store_id s.store_id
, c.city||','||cy.country , c.city||','||cy.country
, m.first_name||' '||m.last_name`, , m.first_name||' '||m.last_name`,
`CREATE VIEW ${projId}staff_list `CREATE VIEW ${projId}staff_list
AS AS
SELECT s.staff_id AS ID, SELECT s.staff_id AS ID,
s.first_name||' '||s.last_name AS name, s.first_name||' '||s.last_name AS name,
@ -99,8 +99,8 @@ function prepareSqliteQuery(projId) {
s.store_id AS SID s.store_id AS SID
FROM "${projId}staff" AS s JOIN "${projId}address" AS a ON s.address_id = a.address_id JOIN "${projId}city" ON a.city_id = "${projId}city".city_id FROM "${projId}staff" AS s JOIN "${projId}address" AS a ON s.address_id = a.address_id JOIN "${projId}city" ON a.city_id = "${projId}city".city_id
JOIN "${projId}country" ON "${projId}city".country_id = "${projId}country".country_id`, JOIN "${projId}country" ON "${projId}city".country_id = "${projId}country".country_id`,
// below two are dummy entries to ensure view record exists // below two are dummy entries to ensure view record exists
`CREATE VIEW ${projId}actor_info `CREATE VIEW ${projId}actor_info
AS AS
SELECT s.staff_id AS ID, SELECT s.staff_id AS ID,
s.first_name||' '||s.last_name AS name, s.first_name||' '||s.last_name AS name,
@ -112,7 +112,7 @@ function prepareSqliteQuery(projId) {
s.store_id AS SID s.store_id AS SID
FROM "${projId}staff" AS s JOIN "${projId}address" AS a ON s.address_id = a.address_id JOIN "${projId}city" ON a.city_id = "${projId}city".city_id FROM "${projId}staff" AS s JOIN "${projId}address" AS a ON s.address_id = a.address_id JOIN "${projId}city" ON a.city_id = "${projId}city".city_id
JOIN "${projId}country" ON "${projId}city".country_id = "${projId}country".country_id`, JOIN "${projId}country" ON "${projId}city".country_id = "${projId}country".country_id`,
`CREATE VIEW ${projId}nice_but_slower_film_list `CREATE VIEW ${projId}nice_but_slower_film_list
AS AS
SELECT s.staff_id AS ID, SELECT s.staff_id AS ID,
s.first_name||' '||s.last_name AS name, s.first_name||' '||s.last_name AS name,
@ -124,151 +124,141 @@ function prepareSqliteQuery(projId) {
s.store_id AS SID s.store_id AS SID
FROM "${projId}staff" AS s JOIN "${projId}address" AS a ON s.address_id = a.address_id JOIN "${projId}city" ON a.city_id = "${projId}city".city_id FROM "${projId}staff" AS s JOIN "${projId}address" AS a ON s.address_id = a.address_id JOIN "${projId}city" ON a.city_id = "${projId}city".city_id
JOIN "${projId}country" ON "${projId}city".country_id = "${projId}country".country_id`, JOIN "${projId}country" ON "${projId}city".country_id = "${projId}country".country_id`,
// `CREATE VIEW ${projId}actor_info // `CREATE VIEW ${projId}actor_info
// AS // AS
// SELECT // SELECT
// a.actor_id AS actor_id, // a.actor_id AS actor_id,
// a.first_name AS first_name, // a.first_name AS first_name,
// a.last_name AS last_name, // a.last_name AS last_name,
// GROUP_CONCAT(DISTINCT CONCAT(c.name, // GROUP_CONCAT(DISTINCT CONCAT(c.name,
// ': ', // ': ',
// (SELECT // (SELECT
// GROUP_CONCAT(f.title // GROUP_CONCAT(f.title
// ORDER BY f.title ASC // ORDER BY f.title ASC
// SEPARATOR ', ') // SEPARATOR ', ')
// FROM // FROM
// ((${projId}film f // ((${projId}film f
// JOIN ${projId}film_category fc ON ((f.film_id = fc.film_id))) // JOIN ${projId}film_category fc ON ((f.film_id = fc.film_id)))
// JOIN ${projId}film_actor fa ON ((f.film_id = fa.film_id))) // JOIN ${projId}film_actor fa ON ((f.film_id = fa.film_id)))
// WHERE // WHERE
// ((fc.category_id = c.category_id) // ((fc.category_id = c.category_id)
// AND (fa.actor_id = a.actor_id)))) // AND (fa.actor_id = a.actor_id))))
// ORDER BY c.name ASC // ORDER BY c.name ASC
// SEPARATOR '; ') AS ${projId}film_info // SEPARATOR '; ') AS ${projId}film_info
// FROM // FROM
// (((actor a // (((actor a
// LEFT JOIN ${projId}film_actor fa ON ((a.actor_id = fa.actor_id))) // LEFT JOIN ${projId}film_actor fa ON ((a.actor_id = fa.actor_id)))
// LEFT JOIN ${projId}film_category fc ON ((fa.film_id = fc.film_id))) // LEFT JOIN ${projId}film_category fc ON ((fa.film_id = fc.film_id)))
// LEFT JOIN ${projId}category c ON ((fc.category_id = c.category_id))) // LEFT JOIN ${projId}category c ON ((fc.category_id = c.category_id)))
// GROUP BY a.actor_id , a.first_name , a.last_name`, // GROUP BY a.actor_id , a.first_name , a.last_name`,
]; ];
return sqliteQuery; return sqliteQuery;
} }
export const genTest = (apiType, dbType) => { export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return; if (!isTestSuiteActive(apiType, dbType)) return;
describe(`Project pre-configurations`, () => { describe(`Project pre-configurations`, () => {
before(() => { before(() => {
cy.fileHook(); cy.fileHook();
}) });
it("Admin SignUp", () => {
cy.task("log", "This will be output to the terminal");
loginPage.signUp(roles.owner.credentials);
});
function cy_createProjectBlock(proj, apiType, dbType) { it("Admin SignUp", () => {
// click home button cy.task("log", "This will be output to the terminal");
cy.get(".nc-noco-brand-icon").click(); loginPage.signUp(roles.owner.credentials);
cy.get(".ant-table-content").then((obj) => { });
// if project already created, open function cy_createProjectBlock(proj, apiType, dbType) {
// else, create a new one // click home button
if (true == obj[0].innerHTML.includes(proj.basic.name)) { cy.get(".nc-noco-brand-icon").click();
projectsPage.openProject(proj.basic.name); cy.get(".ant-table-content").then((obj) => {
let projId; // if project already created, open
if (dbType === "xcdb") { // else, create a new one
let query = `SELECT prefix from nc_projects_v2 where title = "sampleREST"; `; if (true == obj[0].innerHTML.includes(proj.basic.name)) {
cy.task("sqliteExecReturnValue", query).then( projectsPage.openProject(proj.basic.name);
(resolve) => { let projId;
cy.log(resolve); if (dbType === "xcdb") {
projId = resolve.prefix; let query = `SELECT prefix from nc_projects_v2 where title = "sampleREST"; `;
setProjectString(projId); cy.task("sqliteExecReturnValue", query).then((resolve) => {
cy.log(projId); cy.log(resolve);
} projId = resolve.prefix;
); setProjectString(projId);
} cy.log(projId);
} else { });
projectsPage.createProject(proj.basic, proj.config); }
cy.wait(5000); } else {
if (dbType === "xcdb") { projectsPage.createProject(proj.basic, proj.config);
// store base URL- to re-visit and delete form view later cy.wait(5000);
let projId; if (dbType === "xcdb") {
cy.url() // store base URL- to re-visit and delete form view later
.then((url) => { let projId;
// project prefix code can include "_" cy.url()
// projId = url.split("_")[1].split("?")[0]; .then((url) => {
let startIdx = url.indexOf("_"); // project prefix code can include "_"
let endIdx = url.indexOf("?"); // projId = url.split("_")[1].split("?")[0];
projId = url.slice(startIdx + 1, endIdx); let startIdx = url.indexOf("_");
let endIdx = url.indexOf("?");
projId = url.slice(startIdx + 1, endIdx);
let query = `SELECT prefix from nc_projects_v2 where title = "sampleREST"; `; let query = `SELECT prefix from nc_projects_v2 where title = "sampleREST"; `;
cy.task("sqliteExecReturnValue", query) cy.task("sqliteExecReturnValue", query)
.then((resolve) => { .then((resolve) => {
cy.log(resolve); cy.log(resolve);
projId = resolve.prefix; projId = resolve.prefix;
cy.log(projId); cy.log(projId);
setProjectString(projId); setProjectString(projId);
}) })
.then(() => { .then(() => {
let query = let query = prepareSqliteQuery(projId);
prepareSqliteQuery(projId); for (let i = 0; i < query.length; i++) {
for ( cy.task("sqliteExec", query[i]);
let i = 0; cy.wait(1000);
i < query.length;
i++
) {
cy.task("sqliteExec", query[i]);
cy.wait(1000);
}
});
})
.then(() => {
cy.log(projId);
mainPage.openMetaTab();
mainPage.metaSyncValidate(
`${projId}actor`,
`New table, New relation added`
);
mainPage.closeMetaTab();
});
} }
} });
}); })
.then(() => {
cy.log(projId);
mainPage.openMetaTab();
mainPage.metaSyncValidate(
`${projId}actor`,
`New table, New relation added`
);
mainPage.closeMetaTab();
});
}
} }
});
}
const createProject = (proj) => { const createProject = (proj) => {
it(`Create ${proj.basic.name} project`, () => { it(`Create ${proj.basic.name} project`, () => {
if(dbType === "postgres") { if (dbType === "postgres") {
// wait for docker compose to start // wait for docker compose to start
cy.task( cy.task("pgExecTest", `SELECT 1+1`, { timeout: 120000 }).then(() =>
'pgExecTest', cy_createProjectBlock(proj, apiType, dbType)
`SELECT 1+1`, {timeout: 120000} );
).then(() => cy_createProjectBlock(proj, apiType, dbType)); } else {
} cy_createProjectBlock(proj, apiType, dbType);
else { }
cy_createProjectBlock(proj, apiType, dbType);
}
// kludge: wait for page load to finish // kludge: wait for page load to finish
cy.wait(2000); cy.wait(2000);
// close team & auth tab // close team & auth tab
cy.get('button.ant-tabs-tab-remove').should('exist').click(); cy.get("button.ant-tabs-tab-remove").should("exist").click();
cy.wait(1000); cy.wait(1000);
// first instance of updating local storage information // first instance of updating local storage information
cy.saveLocalStorage(); cy.saveLocalStorage();
}); });
}; };
if ("xcdb" === dbType) { if ("xcdb" === dbType) {
createProject(staticProjects.sampleREST); createProject(staticProjects.sampleREST);
} else if (dbType === "mysql") { } else if (dbType === "mysql") {
createProject(staticProjects.externalREST); createProject(staticProjects.externalREST);
} else if (dbType === "postgres") { } else if (dbType === "postgres") {
createProject(staticProjects.pgExternalREST); createProject(staticProjects.pgExternalREST);
} }
}); });
}; };
/** /**

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

@ -2,97 +2,97 @@ import { isTestSuiteActive } from "../../support/page_objects/projectConstants";
import { mainPage, settingsPage } from "../../support/page_objects/mainPage"; import { mainPage, settingsPage } from "../../support/page_objects/mainPage";
export const genTest = (apiType, dbType) => { export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return; if (!isTestSuiteActive(apiType, dbType)) return;
describe(`${ describe(`${
dbType === "xcdb" ? "Meta - " : "" dbType === "xcdb" ? "Meta - " : ""
}${apiType.toUpperCase()} api - Table`, () => { }${apiType.toUpperCase()} api - Table`, () => {
// before(() => { // before(() => {
// // standalone test // // standalone test
// // loginPage.loginAndOpenProject(apiType, dbType); // // loginPage.loginAndOpenProject(apiType, dbType);
// //
// // open a table to work on views // // open a table to work on views
// // // //
// // cy.restoreLocalStorage(); // // cy.restoreLocalStorage();
// }); // });
beforeEach(() => { beforeEach(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
});
afterEach(() => {
cy.saveLocalStorage();
})
// after(() => {
// });
const name = "tablex";
// create a new random table
it("Create Table", () => {
cy.createTable(name);
});
// delete newly created table
it("Delete Table", () => {
cy.deleteTable(name, dbType);
});
const getAuditCell = (row, col) => {
return cy.get("tbody > tr").eq(row).find("td.ant-table-cell").eq(col);
};
it("Open Audit tab", () => {
// mainPage.navigationDraw(mainPage.AUDIT).click();
settingsPage.openMenu(settingsPage.AUDIT);
// wait for column headers to appear
//
cy.get("thead > tr > th.ant-table-cell").should("have.length", 5);
cy.wait(3000)
// Audit table entries
// [Header] Operation Type, Operation Sub Type, Description, User, Created
// [0] TABLE, DELETED, delete table table-x, user@nocodb.com, ...
// [1] TABLE, Created, created table table-x, user@nocodb.com, ...
getAuditCell(0, 0).contains("TABLE").should("exist");
getAuditCell(0, 1).contains("DELETED").should("exist");
getAuditCell(0, 3).contains("user@nocodb.com").should("exist");
getAuditCell(1, 0).contains("TABLE").should("exist");
getAuditCell(1, 1).contains("CREATED").should("exist");
getAuditCell(1, 3).contains("user@nocodb.com").should("exist");
settingsPage.closeMenu()
});
it("Table Rename operation", () => {
cy.get(".nc-project-tree-tbl-City").should("exist").click();
cy.renameTable("City", "CityX");
// verify
// 1. Table name in project tree has changed
// cy.get(".nc-tbl-title").contains("CityX").should("exist");
cy.get(".nc-project-tree-tbl-CityX").should("exist");
// 2. Table tab name has changed
cy.get(`.ant-tabs-tab:contains('CityX'):visible`).should("exist");
// 3. contents of the table are valid
mainPage
.getCell(`City`, 1)
.contains("A Corua (La Corua)")
.should("exist");
cy.closeTableTab("CityX");
// revert re-name operation to not impact rest of test suite
cy.renameTable("CityX", "City");
});
}); });
afterEach(() => {
cy.saveLocalStorage();
});
// after(() => {
// });
const name = "tablex";
// create a new random table
it("Create Table", () => {
cy.createTable(name);
});
// delete newly created table
it("Delete Table", () => {
cy.deleteTable(name, dbType);
});
const getAuditCell = (row, col) => {
return cy.get("tbody > tr").eq(row).find("td.ant-table-cell").eq(col);
};
it("Open Audit tab", () => {
// mainPage.navigationDraw(mainPage.AUDIT).click();
settingsPage.openMenu(settingsPage.AUDIT);
// wait for column headers to appear
//
cy.get("thead > tr > th.ant-table-cell").should("have.length", 5);
cy.wait(3000);
// Audit table entries
// [Header] Operation Type, Operation Sub Type, Description, User, Created
// [0] TABLE, DELETED, delete table table-x, user@nocodb.com, ...
// [1] TABLE, Created, created table table-x, user@nocodb.com, ...
getAuditCell(0, 0).contains("TABLE").should("exist");
getAuditCell(0, 1).contains("DELETED").should("exist");
getAuditCell(0, 3).contains("user@nocodb.com").should("exist");
getAuditCell(1, 0).contains("TABLE").should("exist");
getAuditCell(1, 1).contains("CREATED").should("exist");
getAuditCell(1, 3).contains("user@nocodb.com").should("exist");
settingsPage.closeMenu();
});
it("Table Rename operation", () => {
cy.get(".nc-project-tree-tbl-City").should("exist").click();
cy.renameTable("City", "CityX");
// verify
// 1. Table name in project tree has changed
// cy.get(".nc-tbl-title").contains("CityX").should("exist");
cy.get(".nc-project-tree-tbl-CityX").should("exist");
// 2. Table tab name has changed
cy.get(`.ant-tabs-tab:contains('CityX'):visible`).should("exist");
// 3. contents of the table are valid
mainPage
.getCell(`City`, 1)
.contains("A Corua (La Corua)")
.should("exist");
cy.closeTableTab("CityX");
// revert re-name operation to not impact rest of test suite
cy.renameTable("CityX", "City");
});
});
}; };
/** /**

305
scripts/cypress/integration/common/1c_sql_view.js

@ -1,178 +1,145 @@
import { import {
isTestSuiteActive, isTestSuiteActive,
isXcdb, isXcdb,
} from "../../support/page_objects/projectConstants"; } from "../../support/page_objects/projectConstants";
import { mainPage } from "../../support/page_objects/mainPage"; import { mainPage } from "../../support/page_objects/mainPage";
export const genTest = (apiType, dbType) => { export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return; if (!isTestSuiteActive(apiType, dbType)) return;
describe(`${apiType.toUpperCase()} SQL Views`, () => { describe(`${apiType.toUpperCase()} SQL Views`, () => {
// Run once before test- create project (rest/graphql) // Run once before test- create project (rest/graphql)
// //
// before(() => { // before(() => {
// cy.fileHook(); // cy.fileHook();
// mainPage.tabReset(); // mainPage.tabReset();
// }); // });
beforeEach(() => { beforeEach(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
})
afterEach(() => {
cy.saveLocalStorage();
})
it(`XCDB: SQL View Column operations`, () => {
// Open one of the views & verify validity of first two entries
if (isXcdb()) {
cy.openViewsTab("CustomerList", 25);
// Record-1 validation
mainPage.getCell(`ID`, 1).contains("1").should("exist");
mainPage
.getCell(`Name`, 1)
.contains("MARY SMITH")
.should("exist");
mainPage
.getCell(`Address`, 1)
.contains("1913 Hanoi Way")
.should("exist");
mainPage
.getCell(`ZipCode`, 1)
.contains("35200")
.should("exist");
// Record-2 validation
mainPage.getCell(`ID`, 2).contains("2").should("exist");
mainPage
.getCell(`Name`, 2)
.contains("PATRICIA JOHNSON")
.should("exist");
mainPage
.getCell(`Address`, 2)
.contains("1121 Loja Avenue")
.should("exist");
mainPage
.getCell(`ZipCode`, 2)
.contains("17886")
.should("exist");
// Column operations: Hide
mainPage.hideField(`ZipCode`);
mainPage.unhideField(`ZipCode`);
// Column operations: Sort
mainPage.sortField("Name", "Z → A");
mainPage
.getCell(`Name`, 1)
.contains("ZACHARY HITE")
.should("exist");
mainPage.clearSort();
// Column operations: Filter
mainPage.filterField("Name", "is like", "MARY");
mainPage
.getCell(`Name`, 1)
.contains("MARY SMITH")
.should("exist");
mainPage.filterReset();
cy.closeViewsTab("CustomerList");
}
});
it(`SQL View Column operations`, () => {
if (!isXcdb()) {
// Open one of the views & verify validity of first two entries
cy.openViewsTab("ActorInfo", 25);
// Record-1 validation
mainPage.getCell(`ActorId`, 1).contains("1").should("exist");
mainPage
.getCell(`FirstName`, 1)
.contains("PENELOPE")
.should("exist");
mainPage
.getCell(`LastName`, 1)
.contains("GUINESS")
.should("exist");
mainPage
.getCell(`FilmInfo`, 1)
.contains("Animation: ANACONDA CONFESSIONS")
.should("exist");
// Record-2 validation
mainPage.getCell(`ActorId`, 2).contains("2").should("exist");
mainPage
.getCell(`FirstName`, 2)
.contains("NICK")
.should("exist");
mainPage
.getCell(`LastName`, 2)
.contains("WAHLBERG")
.should("exist");
mainPage
.getCell(`FilmInfo`, 2)
.contains("Action: BULL SHAWSHANK")
.should("exist");
// Column operations: Hide
mainPage.hideField("FilmInfo");
mainPage.unhideField("FilmInfo");
// Column operations: Sort
mainPage.sortField("FirstName", "Z → A");
mainPage
.getCell(`FirstName`, 1)
.contains("ZERO")
.should("exist");
mainPage.clearSort();
// Column operations: Filter
mainPage.filterField("FirstName", "is like", "PENELOPE");
mainPage
.getCell(`FirstName`, 1)
.contains("PENELOPE")
.should("exist");
mainPage.filterReset();
cy.closeViewsTab("ActorInfo");
}
});
it.skip(`SQL View List`, () => {
// confirm if other views exist
//
cy.openViewsTab("CustomerList", 25);
cy.closeViewsTab("CustomerList");
cy.openViewsTab("FilmList", 25);
cy.closeViewsTab("FilmList");
cy.openViewsTab("SalesByFilmCategory", 16);
cy.closeViewsTab("SalesByFilmCategory");
if (!isXcdb()) {
cy.openViewsTab("NicerButSlowerFilmList", 25);
cy.closeViewsTab("NicerButSlowerFilmList");
// SalesByStore && StaffList contain no entries. Hence marking row count to 0
cy.openViewsTab("SalesByStore", 0);
cy.closeViewsTab("SalesByStore");
cy.openViewsTab("StaffList", 0);
cy.closeViewsTab("StaffList");
} else {
cy.openViewsTab("SalesByStore", 2);
cy.closeViewsTab("SalesByStore");
cy.openViewsTab("StaffList", 2);
cy.closeViewsTab("StaffList");
}
});
}); });
afterEach(() => {
cy.saveLocalStorage();
});
it(`XCDB: SQL View Column operations`, () => {
// Open one of the views & verify validity of first two entries
if (isXcdb()) {
cy.openViewsTab("CustomerList", 25);
// Record-1 validation
mainPage.getCell(`ID`, 1).contains("1").should("exist");
mainPage.getCell(`Name`, 1).contains("MARY SMITH").should("exist");
mainPage
.getCell(`Address`, 1)
.contains("1913 Hanoi Way")
.should("exist");
mainPage.getCell(`ZipCode`, 1).contains("35200").should("exist");
// Record-2 validation
mainPage.getCell(`ID`, 2).contains("2").should("exist");
mainPage
.getCell(`Name`, 2)
.contains("PATRICIA JOHNSON")
.should("exist");
mainPage
.getCell(`Address`, 2)
.contains("1121 Loja Avenue")
.should("exist");
mainPage.getCell(`ZipCode`, 2).contains("17886").should("exist");
// Column operations: Hide
mainPage.hideField(`ZipCode`);
mainPage.unhideField(`ZipCode`);
// Column operations: Sort
mainPage.sortField("Name", "Z → A");
mainPage.getCell(`Name`, 1).contains("ZACHARY HITE").should("exist");
mainPage.clearSort();
// Column operations: Filter
mainPage.filterField("Name", "is like", "MARY");
mainPage.getCell(`Name`, 1).contains("MARY SMITH").should("exist");
mainPage.filterReset();
cy.closeViewsTab("CustomerList");
}
});
it(`SQL View Column operations`, () => {
if (!isXcdb()) {
// Open one of the views & verify validity of first two entries
cy.openViewsTab("ActorInfo", 25);
// Record-1 validation
mainPage.getCell(`ActorId`, 1).contains("1").should("exist");
mainPage.getCell(`FirstName`, 1).contains("PENELOPE").should("exist");
mainPage.getCell(`LastName`, 1).contains("GUINESS").should("exist");
mainPage
.getCell(`FilmInfo`, 1)
.contains("Animation: ANACONDA CONFESSIONS")
.should("exist");
// Record-2 validation
mainPage.getCell(`ActorId`, 2).contains("2").should("exist");
mainPage.getCell(`FirstName`, 2).contains("NICK").should("exist");
mainPage.getCell(`LastName`, 2).contains("WAHLBERG").should("exist");
mainPage
.getCell(`FilmInfo`, 2)
.contains("Action: BULL SHAWSHANK")
.should("exist");
// Column operations: Hide
mainPage.hideField("FilmInfo");
mainPage.unhideField("FilmInfo");
// Column operations: Sort
mainPage.sortField("FirstName", "Z → A");
mainPage.getCell(`FirstName`, 1).contains("ZERO").should("exist");
mainPage.clearSort();
// Column operations: Filter
mainPage.filterField("FirstName", "is like", "PENELOPE");
mainPage.getCell(`FirstName`, 1).contains("PENELOPE").should("exist");
mainPage.filterReset();
cy.closeViewsTab("ActorInfo");
}
});
it.skip(`SQL View List`, () => {
// confirm if other views exist
//
cy.openViewsTab("CustomerList", 25);
cy.closeViewsTab("CustomerList");
cy.openViewsTab("FilmList", 25);
cy.closeViewsTab("FilmList");
cy.openViewsTab("SalesByFilmCategory", 16);
cy.closeViewsTab("SalesByFilmCategory");
if (!isXcdb()) {
cy.openViewsTab("NicerButSlowerFilmList", 25);
cy.closeViewsTab("NicerButSlowerFilmList");
// SalesByStore && StaffList contain no entries. Hence marking row count to 0
cy.openViewsTab("SalesByStore", 0);
cy.closeViewsTab("SalesByStore");
cy.openViewsTab("StaffList", 0);
cy.closeViewsTab("StaffList");
} else {
cy.openViewsTab("SalesByStore", 2);
cy.closeViewsTab("SalesByStore");
cy.openViewsTab("StaffList", 2);
cy.closeViewsTab("StaffList");
}
});
});
}; };
/** /**

266
scripts/cypress/integration/common/1d_pg_table_view_drag_drop_reorder.js

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

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

@ -1,151 +1,158 @@
import { mainPage } from "../../support/page_objects/mainPage"; import { mainPage } from "../../support/page_objects/mainPage";
import { import {
isTestSuiteActive, isTestSuiteActive,
isXcdb, isXcdb,
getProjectString, getProjectString,
} from "../../support/page_objects/projectConstants"; } from "../../support/page_objects/projectConstants";
export const genTest = (apiType, dbType) => { export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return; if (!isTestSuiteActive(apiType, dbType)) return;
describe(`${apiType.toUpperCase()} Table/view drag-drop reorder`, () => { describe(`${apiType.toUpperCase()} Table/view drag-drop reorder`, () => {
function validateTreeField(index, tblName) { function validateTreeField(index, tblName) {
cy.get(`.nc-project-tree-tbl`).eq(index-1).find('.nc-tbl-title').contains(tblName).should('exist'); cy.get(`.nc-project-tree-tbl`)
} .eq(index - 1)
.find(".nc-tbl-title")
/* .contains(tblName)
.should("exist");
}
/*
Original order of list items Original order of list items
Actor, Address, Category, City, Country, Customer, FIlm, FilmText, Language, Payment, Rental Staff Actor, Address, Category, City, Country, Customer, FIlm, FilmText, Language, Payment, Rental Staff
ActorInfo, Customer List, Film List, NiceButSlowerFilm List, SalesByFilmCategory, SalesByStore, Staff List ActorInfo, Customer List, Film List, NiceButSlowerFilm List, SalesByFilmCategory, SalesByStore, Staff List
*/ */
before(() => { before(() => {
cy.fileHook(); cy.fileHook();
mainPage.tabReset(); mainPage.tabReset();
}); });
beforeEach(() => { beforeEach(() => {
cy.fileHook(); cy.fileHook();
}); });
it(`Table & SQL View list, Drag/drop`, () => { it(`Table & SQL View list, Drag/drop`, () => {
// expand tree-view menu // expand tree-view menu
// 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 });
validateTreeField(1, "Actor"); validateTreeField(1, "Actor");
// move Actor field down, above Staff (drag, drop) // move Actor field down, above Staff (drag, drop)
cy.get(".nc-child-draggable-icon-Actor").click({ force: true }); cy.get(".nc-child-draggable-icon-Actor").click({ force: true });
cy.get(".nc-child-draggable-icon-Actor").should("be.visible"); cy.get(".nc-child-draggable-icon-Actor").should("be.visible");
cy.get(".nc-child-draggable-icon-Actor").drag( cy.get(".nc-child-draggable-icon-Actor").drag(
".nc-child-draggable-icon-Staff", { force: true } ".nc-child-draggable-icon-Staff",
); { force: true }
);
validateTreeField(12, "Actor");
validateTreeField(12, "Actor");
// // move ActorInfo (View) field up to first place (drag, drop)
// cy.get(".nc-child-draggable-icon-ActorInfo").drag( // // move ActorInfo (View) field up to first place (drag, drop)
// ".nc-child-draggable-icon-Address" // cy.get(".nc-child-draggable-icon-ActorInfo").drag(
// ); // ".nc-child-draggable-icon-Address"
// // );
// validateTreeField(1, "ActorInfo"); //
// validateTreeField(2, "Address"); // validateTreeField(1, "ActorInfo");
// validateTreeField(13, "Actor"); // validateTreeField(2, "Address");
// // validateTreeField(13, "Actor");
// // restore ActorInfo field (drag, drop) //
// cy.get(".nc-child-draggable-icon-ActorInfo").drag( // // restore ActorInfo field (drag, drop)
// ".nc-child-draggable-icon-Actor" // 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( // // restore Actor field (drag, drop)
// ".nc-child-draggable-icon-Address" // cy.get(".nc-child-draggable-icon-Actor").drag(
// ); // ".nc-child-draggable-icon-Address"
// // );
// validateTreeField(1, "Actor"); //
// validateTreeField(2, "Address"); // validateTreeField(1, "Actor");
// validateTreeField(12, "Staff"); // validateTreeField(2, "Address");
// validateTreeField(13, "ActorInfo"); // validateTreeField(12, "Staff");
// validateTreeField(14, "CustomerList"); // validateTreeField(13, "ActorInfo");
// // validateTreeField(14, "CustomerList");
// // undo project-tree expand operation //
// cy.get(".nc-project-tree") // // undo project-tree expand operation
// .should("exist") // cy.get(".nc-project-tree")
// .first() // .should("exist")
// .click({ force: true }); // .first()
}); // .click({ force: true });
});
// create new view as specified by 'viewType'
// can be - grid/ gallery/ form // create new view as specified by 'viewType'
// wait for toast to appear // can be - grid/ gallery/ form
// // wait for toast to appear
function createView(viewType) { //
// click on 'Grid/Gallery' button on Views bar function createView(viewType) {
cy.get(`.nc-create-${viewType}-view`).click(); // click on 'Grid/Gallery' button on Views bar
cy.get(`.nc-create-${viewType}-view`).click();
cy.snipActiveModal(`Modal_createView_${viewType}`);
cy.snipActiveModal(`Modal_createView_${viewType}`);
// Pop up window, click Submit (accepting default name for view)
cy.getActiveModal(".nc-modal-view-create").find("button:contains(Submit)").click(); // Pop up window, click Submit (accepting default name for view)
cy.getActiveModal(".nc-modal-view-create")
cy.toastWait("View created successfully"); .find("button:contains(Submit)")
} .click();
// verify view 'viewName' to be present at position 'index' cy.toastWait("View created successfully");
// index starts from 0 }
function validateViewField(index, viewName) {
cy.get(".nc-view-item.nc-draggable-child") // verify view 'viewName' to be present at position 'index'
.eq(index) // index starts from 0
.contains(viewName) function validateViewField(index, viewName) {
.should("exist"); cy.get(".nc-view-item.nc-draggable-child")
} .eq(index)
.contains(viewName)
// exclude@ncv2: to be investigated & fixed .should("exist");
it.skip(`View (Gallery/ Grid/ Form) re-order`, () => { }
cy.openTableTab("Actor", 25);
// exclude@ncv2: to be investigated & fixed
// create 3 views, use default names it.skip(`View (Gallery/ Grid/ Form) re-order`, () => {
// Actor1, Actor2, Actor3 cy.openTableTab("Actor", 25);
createView("grid");
createView("gallery"); // create 3 views, use default names
createView("form"); // Actor1, Actor2, Actor3
createView("grid");
// validate position order createView("gallery");
validateViewField(0, "Actor"); createView("form");
validateViewField(1, "Actor1");
validateViewField(2, "Actor2"); // validate position order
validateViewField(3, "Actor3"); validateViewField(0, "Actor");
validateViewField(1, "Actor1");
// move Actor3 field on top (drag, drop) validateViewField(2, "Actor2");
cy.get(".nc-child-draggable-icon-Actor3").drag( validateViewField(3, "Actor3");
`.nc-child-draggable-icon-${
isXcdb() ? `${getProjectString()}` : `` // move Actor3 field on top (drag, drop)
}Actor` cy.get(".nc-child-draggable-icon-Actor3").drag(
); `.nc-child-draggable-icon-${
isXcdb() ? `${getProjectString()}` : ``
// validate new position order, Actor3 on top }Actor`
validateViewField(0, "Actor3"); );
validateViewField(1, "Actor");
validateViewField(2, "Actor1"); // validate new position order, Actor3 on top
validateViewField(3, "Actor2"); validateViewField(0, "Actor3");
validateViewField(1, "Actor");
// delete all created views validateViewField(2, "Actor1");
// click on delete icon (becomes visible on hovering mouse) validateViewField(3, "Actor2");
cy.get(".nc-view-delete-icon").eq(0).click({ force: true });
cy.toastWait("View deleted successfully"); // delete all created views
cy.get(".nc-view-delete-icon").eq(0).click({ force: true }); // click on delete icon (becomes visible on hovering mouse)
cy.toastWait("View deleted successfully"); cy.get(".nc-view-delete-icon").eq(0).click({ force: true });
cy.get(".nc-view-delete-icon").eq(0).click({ force: true }); cy.toastWait("View deleted successfully");
cy.toastWait("View deleted successfully"); cy.get(".nc-view-delete-icon").eq(0).click({ force: true });
cy.toastWait("View deleted successfully");
// wind up cy.get(".nc-view-delete-icon").eq(0).click({ force: true });
cy.closeTableTab("Actor"); cy.toastWait("View deleted successfully");
});
// wind up
cy.closeTableTab("Actor");
}); });
});
}; };
/** /**

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

@ -1,180 +1,171 @@
import { mainPage } from "../../support/page_objects/mainPage"; import { mainPage } from "../../support/page_objects/mainPage";
import { loginPage } from "../../support/page_objects/navigation"; import { loginPage } from "../../support/page_objects/navigation";
import { import {
getCurrentMode, getCurrentMode,
getProjectString, getProjectString,
isTestSuiteActive, isTestSuiteActive,
isXcdb, isXcdb,
} from "../../support/page_objects/projectConstants"; } from "../../support/page_objects/projectConstants";
export const genTest = (apiType, dbType) => { export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return; if (!isTestSuiteActive(apiType, dbType)) return;
let projPrefix = `sakila.`; let projPrefix = `sakila.`;
let dbCmd = `queryDb`; let dbCmd = `queryDb`;
let tblDisplayPrefix = ``; let tblDisplayPrefix = ``;
describe(`${apiType.toUpperCase()} api - Meta Sync`, () => { describe(`${apiType.toUpperCase()} api - Meta Sync`, () => {
// Run once before test- create project (rest/graphql) // Run once before test- create project (rest/graphql)
// //
before(() => { before(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
if (isXcdb()) { if (isXcdb()) {
cy.log(getProjectString()); cy.log(getProjectString());
projPrefix = `${getProjectString()}`; projPrefix = `${getProjectString()}`;
dbCmd = `sqliteExec`; dbCmd = `sqliteExec`;
tblDisplayPrefix = `${getProjectString()}`; tblDisplayPrefix = `${getProjectString()}`;
} }
mainPage.openMetaTab(); mainPage.openMetaTab();
})
beforeEach(() => {
cy.restoreLocalStorage();
})
afterEach(() => {
cy.saveLocalStorage();
})
it(`Create table`, () => {
// Create Table
cy.task(
dbCmd,
`CREATE TABLE ${projPrefix}table1 (id INT NOT NULL, col1 INT NULL, PRIMARY KEY (id))`
);
cy.task(
dbCmd,
`CREATE TABLE ${projPrefix}table2 (id INT NOT NULL, col1 INT NULL, PRIMARY KEY (id))`
);
mainPage.metaSyncValidate(`${tblDisplayPrefix}table1`, "New table");
});
it(`Add relation`, () => {
// working with relations in sqlite requires table to be deleted & recreated
//
if (!isXcdb()) {
// Add relation (FK)
cy.task(
dbCmd,
`ALTER TABLE ${projPrefix}table1 ADD INDEX fk1_idx (col1 ASC) VISIBLE`
);
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
//
if (!isXcdb()) {
// Remove relation (FK)
cy.task(
dbCmd,
`ALTER TABLE ${projPrefix}table1 DROP FOREIGN KEY fk1`
);
cy.task(
dbCmd,
`ALTER TABLE ${projPrefix}table1 DROP INDEX fk1_idx`
);
mainPage.metaSyncValidate(
`${tblDisplayPrefix}table1`,
"Relation removed"
);
}
});
it(`Add column`, () => {
// Add Column
let queryString = `ALTER TABLE ${projPrefix}table1 ADD COLUMN newCol VARCHAR(45) NULL AFTER id`;
if (isXcdb())
queryString = `ALTER TABLE ${projPrefix}table1 ADD COLUMN newCol TEXT NULL`;
cy.task(dbCmd, queryString);
mainPage.metaSyncValidate(
`${tblDisplayPrefix}table1`,
"New column(newCol)"
);
});
it(`Rename column`, () => {
// Rename Column
let queryString = `ALTER TABLE ${projPrefix}table1 CHANGE COLUMN newCol newColName VARCHAR(45) NULL DEFAULT NULL`;
if (isXcdb())
queryString = `ALTER TABLE ${projPrefix}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
// to be fixed for SQLITE
if (!isXcdb()) {
cy.task(
dbCmd,
`ALTER TABLE ${projPrefix}table1 DROP COLUMN newColName`
);
mainPage.metaSyncValidate(
`${tblDisplayPrefix}table1`,
"Column removed(newColName)"
);
}
});
it(`Delete table`, () => {
// DROP TABLE
cy.task(dbCmd, `DROP TABLE ${projPrefix}table1`);
cy.task(dbCmd, `DROP TABLE ${projPrefix}table2`);
mainPage.metaSyncValidate(
`${tblDisplayPrefix}table1`,
"Table removed"
);
});
it(`Hide, Filter, Sort`, () => {
cy.task(
dbCmd,
`CREATE TABLE ${projPrefix}table1 (id INT NOT NULL, col1 INT NULL, col2 INT NULL, col3 INT NULL, col4 INT NULL, PRIMARY KEY (id))`
);
cy.task(
dbCmd,
`INSERT INTO ${projPrefix}table1 (id, col1, col2, col3, col4) VALUES (1,1,1,1,1), (2,2,2,2,2), (3,3,3,3,3), (4,4,4,4,4), (5,5,5,5,5), (6,6,6,6,6), (7,7,7,7,7), (8,8,8,8,8), (9,9,9,9,9);`
);
mainPage.metaSyncValidate(`${tblDisplayPrefix}table1`, "New table");
mainPage.closeMetaTab();
cy.openTableTab("Table1", 9);
mainPage.hideField("Col1");
mainPage.sortField("Col1", "9 → 1");
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 ${projPrefix}table1 CHANGE COLUMN col1 newCol INT NULL DEFAULT NULL`;
if (isXcdb())
queryString = `ALTER TABLE ${projPrefix}table1 RENAME COLUMN col1 TO newCol`;
cy.task(dbCmd, queryString);
mainPage.metaSyncValidate(
`${tblDisplayPrefix}table1`,
"New column(newCol), Column removed(col1)"
);
mainPage.closeMetaTab();
cy.openTableTab("Table1", 9);
cy.deleteTable("Table1", dbType);
});
}); });
beforeEach(() => {
cy.restoreLocalStorage();
});
afterEach(() => {
cy.saveLocalStorage();
});
it(`Create table`, () => {
// Create Table
cy.task(
dbCmd,
`CREATE TABLE ${projPrefix}table1 (id INT NOT NULL, col1 INT NULL, PRIMARY KEY (id))`
);
cy.task(
dbCmd,
`CREATE TABLE ${projPrefix}table2 (id INT NOT NULL, col1 INT NULL, PRIMARY KEY (id))`
);
mainPage.metaSyncValidate(`${tblDisplayPrefix}table1`, "New table");
});
it(`Add relation`, () => {
// working with relations in sqlite requires table to be deleted & recreated
//
if (!isXcdb()) {
// Add relation (FK)
cy.task(
dbCmd,
`ALTER TABLE ${projPrefix}table1 ADD INDEX fk1_idx (col1 ASC) VISIBLE`
);
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
//
if (!isXcdb()) {
// Remove relation (FK)
cy.task(dbCmd, `ALTER TABLE ${projPrefix}table1 DROP FOREIGN KEY fk1`);
cy.task(dbCmd, `ALTER TABLE ${projPrefix}table1 DROP INDEX fk1_idx`);
mainPage.metaSyncValidate(
`${tblDisplayPrefix}table1`,
"Relation removed"
);
}
});
it(`Add column`, () => {
// Add Column
let queryString = `ALTER TABLE ${projPrefix}table1 ADD COLUMN newCol VARCHAR(45) NULL AFTER id`;
if (isXcdb())
queryString = `ALTER TABLE ${projPrefix}table1 ADD COLUMN newCol TEXT NULL`;
cy.task(dbCmd, queryString);
mainPage.metaSyncValidate(
`${tblDisplayPrefix}table1`,
"New column(newCol)"
);
});
it(`Rename column`, () => {
// Rename Column
let queryString = `ALTER TABLE ${projPrefix}table1 CHANGE COLUMN newCol newColName VARCHAR(45) NULL DEFAULT NULL`;
if (isXcdb())
queryString = `ALTER TABLE ${projPrefix}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
// to be fixed for SQLITE
if (!isXcdb()) {
cy.task(
dbCmd,
`ALTER TABLE ${projPrefix}table1 DROP COLUMN newColName`
);
mainPage.metaSyncValidate(
`${tblDisplayPrefix}table1`,
"Column removed(newColName)"
);
}
});
it(`Delete table`, () => {
// DROP TABLE
cy.task(dbCmd, `DROP TABLE ${projPrefix}table1`);
cy.task(dbCmd, `DROP TABLE ${projPrefix}table2`);
mainPage.metaSyncValidate(`${tblDisplayPrefix}table1`, "Table removed");
});
it(`Hide, Filter, Sort`, () => {
cy.task(
dbCmd,
`CREATE TABLE ${projPrefix}table1 (id INT NOT NULL, col1 INT NULL, col2 INT NULL, col3 INT NULL, col4 INT NULL, PRIMARY KEY (id))`
);
cy.task(
dbCmd,
`INSERT INTO ${projPrefix}table1 (id, col1, col2, col3, col4) VALUES (1,1,1,1,1), (2,2,2,2,2), (3,3,3,3,3), (4,4,4,4,4), (5,5,5,5,5), (6,6,6,6,6), (7,7,7,7,7), (8,8,8,8,8), (9,9,9,9,9);`
);
mainPage.metaSyncValidate(`${tblDisplayPrefix}table1`, "New table");
mainPage.closeMetaTab();
cy.openTableTab("Table1", 9);
mainPage.hideField("Col1");
mainPage.sortField("Col1", "9 → 1");
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 ${projPrefix}table1 CHANGE COLUMN col1 newCol INT NULL DEFAULT NULL`;
if (isXcdb())
queryString = `ALTER TABLE ${projPrefix}table1 RENAME COLUMN col1 TO newCol`;
cy.task(dbCmd, queryString);
mainPage.metaSyncValidate(
`${tblDisplayPrefix}table1`,
"New column(newCol), Column removed(col1)"
);
mainPage.closeMetaTab();
cy.openTableTab("Table1", 9);
cy.deleteTable("Table1", dbType);
});
});
}; };
/** /**

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

@ -1,186 +1,182 @@
import { mainPage } from "../../support/page_objects/mainPage"; import { mainPage } from "../../support/page_objects/mainPage";
import { loginPage } from "../../support/page_objects/navigation"; import { loginPage } from "../../support/page_objects/navigation";
import { import {
getCurrentMode, getCurrentMode,
getProjectString, getProjectString,
isTestSuiteActive, isTestSuiteActive,
isXcdb, isXcdb,
} from "../../support/page_objects/projectConstants"; } from "../../support/page_objects/projectConstants";
export const genTest = (apiType, dbType) => { export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return; if (!isTestSuiteActive(apiType, dbType)) return;
let projPrefix = `sakila.`; let projPrefix = `sakila.`;
let dbCmd = `pgExec`; let dbCmd = `pgExec`;
let tblDisplayPrefix = ``; let tblDisplayPrefix = ``;
describe(`${apiType.toUpperCase()} api - Meta Sync`, () => { describe(`${apiType.toUpperCase()} api - Meta Sync`, () => {
// Run once before test- create project (rest/graphql) // Run once before test- create project (rest/graphql)
// //
before(() => { before(() => {
mainPage.tabReset(); mainPage.tabReset();
mainPage.openMetaTab(); mainPage.openMetaTab();
});
beforeEach(() => {
});
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", "9 → 1");
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)"
);
mainPage.closeMetaTab();
cy.openTableTab("Table1", 9);
// kludge- delete table triggered post sql backend operations doesnt carry any trigger toast
cy.deleteTable("Table1", "mysql");
});
}); });
beforeEach(() => {});
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", "9 → 1");
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)"
);
mainPage.closeMetaTab();
cy.openTableTab("Table1", 9);
// kludge- delete table triggered post sql backend operations doesnt carry any trigger toast
cy.deleteTable("Table1", "mysql");
});
});
}; };
/** /**

187
scripts/cypress/integration/common/2a_table_with_belongs_to_colulmn.js

@ -2,108 +2,119 @@ import { mainPage } from "../../support/page_objects/mainPage";
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"; import { isTestSuiteActive } from "../../support/page_objects/projectConstants";
export const genTest = (apiType, dbType) => { export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return; if (!isTestSuiteActive(apiType, dbType)) return;
describe(`${apiType.toUpperCase()} api - Table: belongs to, link record`, () => { describe(`${apiType.toUpperCase()} api - Table: belongs to, link record`, () => {
// before(() => { // before(() => {
// cy.restoreLocalStorage(); // cy.restoreLocalStorage();
// cy.openTableTab("Country", 25); // cy.openTableTab("Country", 25);
// }); // });
beforeEach(() => { beforeEach(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
}); });
afterEach(() => {
cy.saveLocalStorage();
})
// after(() => { afterEach(() => {
// cy.closeTableTab("City"); cy.saveLocalStorage();
// }); });
it("URL validation", () => { // after(() => {
cy.openTableTab("Country", 25); // cy.closeTableTab("City");
// column name validation // });
// cy.get(`.project-tab:contains(Country):visible`).should("exist");
// URL validation
cy.url().should("contain", `table/Country`);
});
it("Grid cell chip content validation", () => { it("URL validation", () => {
// grid cell content validation cy.openTableTab("Country", 25);
mainPage.getCell("City List", 1) // column name validation
.find('.nc-virtual-cell > .chips-wrapper > .chips > .group > .name') // cy.get(`.project-tab:contains(Country):visible`).should("exist");
.contains("Kabul") // URL validation
.should('exist'); cy.url().should("contain", `table/Country`);
mainPage.getCell("City List", 2) });
.find('.nc-virtual-cell > .chips-wrapper > .chips > .group > .name')
.contains("Batna")
.should('exist');
mainPage.getCell("City List", 2)
.find('.nc-virtual-cell > .chips-wrapper > .chips > .group > .name')
.contains("Bchar")
.should('exist');
mainPage.getCell("City List", 2)
.find('.nc-virtual-cell > .chips-wrapper > .chips > .group > .name')
.contains("Skikda")
.should('exist');
})
it("Expand has-many column", () => { it("Grid cell chip content validation", () => {
mainPage.getCell("City List", 1).should("exist").trigger("mouseover").click(); // grid cell content validation
cy.get('.nc-action-icon').eq(0).should('exist').click({ force: true }); mainPage
}); .getCell("City List", 1)
.find(".nc-virtual-cell > .chips-wrapper > .chips > .group > .name")
.contains("Kabul")
.should("exist");
mainPage
.getCell("City List", 2)
.find(".nc-virtual-cell > .chips-wrapper > .chips > .group > .name")
.contains("Batna")
.should("exist");
mainPage
.getCell("City List", 2)
.find(".nc-virtual-cell > .chips-wrapper > .chips > .group > .name")
.contains("Bchar")
.should("exist");
mainPage
.getCell("City List", 2)
.find(".nc-virtual-cell > .chips-wrapper > .chips > .group > .name")
.contains("Skikda")
.should("exist");
});
it("Expand Link record, validate", () => { it("Expand has-many column", () => {
cy.getActiveModal(".nc-modal-child-list") mainPage
.find("button:contains(Link to 'City')") .getCell("City List", 1)
.click() .should("exist")
.then(() => { .trigger("mouseover")
.click();
cy.get(".nc-action-icon").eq(0).should("exist").click({ force: true });
});
// Link record form validation it("Expand Link record, validate", () => {
cy.getActiveModal(".nc-modal-link-record").contains("Link record").should("exist"); cy.getActiveModal(".nc-modal-child-list")
cy.getActiveModal(".nc-modal-link-record") .find("button:contains(Link to 'City')")
.find(".nc-reload") .click()
.should("exist"); .then(() => {
cy.getActiveModal(".nc-modal-link-record") // Link record form validation
.find('button:contains("Add new record")') cy.getActiveModal(".nc-modal-link-record")
.should("exist"); .contains("Link record")
cy.getActiveModal(".nc-modal-link-record") .should("exist");
.find(".ant-card") cy.getActiveModal(".nc-modal-link-record")
.eq(0) .find(".nc-reload")
.contains("A Corua (La Corua)") .should("exist");
.should("exist"); cy.getActiveModal(".nc-modal-link-record")
.find('button:contains("Add new record")')
.should("exist");
cy.getActiveModal(".nc-modal-link-record")
.find(".ant-card")
.eq(0)
.contains("A Corua (La Corua)")
.should("exist");
cy.getActiveModal(".nc-modal-link-record") cy.getActiveModal(".nc-modal-link-record")
.find("button.ant-modal-close") .find("button.ant-modal-close")
.click(); .click();
// .then(() => { // .then(() => {
// cy.getActiveModal() // cy.getActiveModal()
// .find("button.ant-modal-close") // .find("button.ant-modal-close")
// .click(); // .click();
// }); // });
});
}); });
});
it("Belongs to column, validate", () => { it("Belongs to column, validate", () => {
cy.closeTableTab("Country"); cy.closeTableTab("Country");
cy.openTableTab("City", 25); cy.openTableTab("City", 25);
cy.url().should("contain", `table/City`); cy.url().should("contain", `table/City`);
// grid cell content validation // grid cell content validation
mainPage.getCell("Country", 1) mainPage
.find('.nc-virtual-cell > .chips-wrapper > .chips > .group > .name') .getCell("Country", 1)
.contains("Spain") .find(".nc-virtual-cell > .chips-wrapper > .chips > .group > .name")
.should('exist'); .contains("Spain")
mainPage.getCell("Country", 2) .should("exist");
.find('.nc-virtual-cell > .chips-wrapper > .chips > .group > .name') mainPage
.contains("Saudi Arabia") .getCell("Country", 2)
.should('exist'); .find(".nc-virtual-cell > .chips-wrapper > .chips > .group > .name")
.contains("Saudi Arabia")
.should("exist");
cy.closeTableTab("City"); cy.closeTableTab("City");
})
}); });
});
}; };
/** /**

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

@ -1,251 +1,254 @@
import { mainPage } from "../../support/page_objects/mainPage"; import { mainPage } from "../../support/page_objects/mainPage";
import { loginPage } from "../../support/page_objects/navigation"; import { loginPage } from "../../support/page_objects/navigation";
import { import {
isTestSuiteActive, isTestSuiteActive,
isXcdb, isXcdb,
} from "../../support/page_objects/projectConstants"; } from "../../support/page_objects/projectConstants";
export const genTest = (apiType, dbType) => { export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return; if (!isTestSuiteActive(apiType, dbType)) return;
describe(`${apiType.toUpperCase()} api - FORMULA`, () => { describe(`${apiType.toUpperCase()} api - FORMULA`, () => {
// Run once before test- create project (rest/graphql) // Run once before test- create project (rest/graphql)
// //
// before(() => { // before(() => {
// // loginPage.loginAndOpenProject(apiType, dbType) // // loginPage.loginAndOpenProject(apiType, dbType)
// cy.openTableTab("City", 25); // cy.openTableTab("City", 25);
// }); // });
beforeEach(() => { beforeEach(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
})
afterEach(() => {
cy.saveLocalStorage();
})
// 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 < 5; i++)
mainPage.getCell(rowName, i+1).contains(result[i].toString()).should("exist");
// 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) => {
cy.get(".nc-grid tr > th:last .nc-icon").click({
force: true,
});
cy.getActiveMenu(".nc-dropdown-grid-add-column").find('input.nc-column-name-input', { timeout: 3000 })
.should('exist')
.clear()
.type(columnName);
// cy.get(".nc-column-type-input").last().click().type("Formula");
cy.getActiveMenu('.nc-dropdown-grid-add-column')
.find(".nc-column-type-input")
.last()
.click()
.type("Formula");
cy.getActiveSelection('.nc-dropdown-column-type')
.find('.ant-select-item-option')
.contains("Formula")
.click();
cy.getActiveMenu('.nc-dropdown-grid-add-column')
.find('textarea.nc-formula-input')
.click()
.type(formula, { parseSpecialCharSequences: false });
// cy.get(".ant-btn-primary").contains("Save").should('exist').click();
cy.getActiveMenu('.nc-dropdown-grid-add-column')
.find(".ant-btn-primary:visible")
.contains("Save")
.click();
// cy.toastWait(`Column created`);
cy.closeTableTab("City");
cy.openTableTab("City", 25);
cy.get(`th[data-title="${columnName}"]`).should("exist");
};
// routine to delete column
//
const deleteColumnByName = (columnName) => {
mainPage.deleteColumn(columnName);
};
// routine to edit column
//
const editColumnByName = (oldName, newName, newFormula) => {
cy.get(`th:contains(${oldName}) .nc-icon.ant-dropdown-trigger`)
.trigger("mouseover", { force: true })
.click({ force: true });
// cy.get(".nc-column-edit").click();
// cy.get(".nc-column-edit").should("not.be.visible");
cy.getActiveMenu(".nc-dropdown-column-operations")
.find(".nc-column-edit")
.click();
cy.getActiveMenu(".nc-dropdown-edit-column").find('input.nc-column-name-input', { timeout: 3000 })
.should('exist')
.clear()
.type(newName);
cy.get('textarea.nc-formula-input').click().clear().type(newFormula, { parseSpecialCharSequences: false });
cy.get(".ant-btn-primary").contains("Save").should('exist').click();
// cy.toastWait(`Column created`);
cy.get(`th[data-title="${oldName}"]`).should("not.exist");
cy.get(`th[data-title="${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 = [];
let RESULT_WEEKDAY_0 = [];
let RESULT_WEEKDAY_1 = [];
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])
);
// WEEKDAY: starts from Monday
RESULT_WEEKDAY_0[i] = 1;
// WEEKDAY: starts from Sunday
RESULT_WEEKDAY_1[i] = 2;
}
it("Formula: ADD, AVG, LEN", () => {
cy.openTableTab("City", 25);
addFormulaBasedColumn(
"NC_MATH_0",
"ADD({CityId}, {CountryId}) + AVG({CityId}, {CountryId}) + LEN({City})"
);
rowValidation("NC_MATH_0", RESULT_MATH_0);
});
it.skip("Formula: WEEKDAY", () => {
editColumnByName(
"NC_MATH_0",
"NC_WEEKDAY_0",
`WEEKDAY("2022-07-19")`
);
rowValidation("NC_WEEKDAY_0", RESULT_WEEKDAY_0);
editColumnByName(
"NC_WEEKDAY_0",
"NC_WEEKDAY_1",
`WEEKDAY("2022-07-19", "sunday")`
);
rowValidation("NC_WEEKDAY_1", RESULT_WEEKDAY_1);
});
it("Formula: CONCAT, LOWER, UPPER, TRIM", () => {
editColumnByName(
// "NC_WEEKDAY_1",
"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()) {
if(dbType === "mysql") {
// 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()`);
if (dbType === 'mysql') editColumnByName("NC_MATH_2", "NC_NOW", `NOW()`);
else editColumnByName("NC_MATH_1", "NC_NOW", `NOW()`);
deleteColumnByName("NC_NOW");
cy.closeTableTab("City");
});
}); });
afterEach(() => {
cy.saveLocalStorage();
});
// 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 < 5; i++)
mainPage
.getCell(rowName, i + 1)
.contains(result[i].toString())
.should("exist");
// 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) => {
cy.get(".nc-grid tr > th:last .nc-icon").click({
force: true,
});
cy.getActiveMenu(".nc-dropdown-grid-add-column")
.find("input.nc-column-name-input", { timeout: 3000 })
.should("exist")
.clear()
.type(columnName);
// cy.get(".nc-column-type-input").last().click().type("Formula");
cy.getActiveMenu(".nc-dropdown-grid-add-column")
.find(".nc-column-type-input")
.last()
.click()
.type("Formula");
cy.getActiveSelection(".nc-dropdown-column-type")
.find(".ant-select-item-option")
.contains("Formula")
.click();
cy.getActiveMenu(".nc-dropdown-grid-add-column")
.find("textarea.nc-formula-input")
.click()
.type(formula, { parseSpecialCharSequences: false });
// cy.get(".ant-btn-primary").contains("Save").should('exist').click();
cy.getActiveMenu(".nc-dropdown-grid-add-column")
.find(".ant-btn-primary:visible")
.contains("Save")
.click();
// cy.toastWait(`Column created`);
cy.closeTableTab("City");
cy.openTableTab("City", 25);
cy.get(`th[data-title="${columnName}"]`).should("exist");
};
// routine to delete column
//
const deleteColumnByName = (columnName) => {
mainPage.deleteColumn(columnName);
};
// routine to edit column
//
const editColumnByName = (oldName, newName, newFormula) => {
cy.get(`th:contains(${oldName}) .nc-icon.ant-dropdown-trigger`)
.trigger("mouseover", { force: true })
.click({ force: true });
// cy.get(".nc-column-edit").click();
// cy.get(".nc-column-edit").should("not.be.visible");
cy.getActiveMenu(".nc-dropdown-column-operations")
.find(".nc-column-edit")
.click();
cy.getActiveMenu(".nc-dropdown-edit-column")
.find("input.nc-column-name-input", { timeout: 3000 })
.should("exist")
.clear()
.type(newName);
cy.get("textarea.nc-formula-input")
.click()
.clear()
.type(newFormula, { parseSpecialCharSequences: false });
cy.get(".ant-btn-primary").contains("Save").should("exist").click();
// cy.toastWait(`Column created`);
cy.get(`th[data-title="${oldName}"]`).should("not.exist");
cy.get(`th[data-title="${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 = [];
let RESULT_WEEKDAY_0 = [];
let RESULT_WEEKDAY_1 = [];
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])
);
// WEEKDAY: starts from Monday
RESULT_WEEKDAY_0[i] = 1;
// WEEKDAY: starts from Sunday
RESULT_WEEKDAY_1[i] = 2;
}
it("Formula: ADD, AVG, LEN", () => {
cy.openTableTab("City", 25);
addFormulaBasedColumn(
"NC_MATH_0",
"ADD({CityId}, {CountryId}) + AVG({CityId}, {CountryId}) + LEN({City})"
);
rowValidation("NC_MATH_0", RESULT_MATH_0);
});
it.skip("Formula: WEEKDAY", () => {
editColumnByName("NC_MATH_0", "NC_WEEKDAY_0", `WEEKDAY("2022-07-19")`);
rowValidation("NC_WEEKDAY_0", RESULT_WEEKDAY_0);
editColumnByName(
"NC_WEEKDAY_0",
"NC_WEEKDAY_1",
`WEEKDAY("2022-07-19", "sunday")`
);
rowValidation("NC_WEEKDAY_1", RESULT_WEEKDAY_1);
});
it("Formula: CONCAT, LOWER, UPPER, TRIM", () => {
editColumnByName(
// "NC_WEEKDAY_1",
"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()) {
if (dbType === "mysql") {
// 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()`);
if (dbType === "mysql") editColumnByName("NC_MATH_2", "NC_NOW", `NOW()`);
else editColumnByName("NC_MATH_1", "NC_NOW", `NOW()`);
deleteColumnByName("NC_NOW");
cy.closeTableTab("City");
});
});
}; };
/** /**

170
scripts/cypress/integration/common/4a_table_view_grid_gallery_form.js

@ -2,93 +2,97 @@ import { mainPage } from "../../support/page_objects/mainPage";
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"; import { isTestSuiteActive } from "../../support/page_objects/projectConstants";
function capitalizeFirstLetter(string) { function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1); return string.charAt(0).toUpperCase() + string.slice(1);
} }
export const genTest = (apiType, dbType) => { export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return; if (!isTestSuiteActive(apiType, dbType)) return;
describe(`${apiType.toUpperCase()} api - Table views: Create/Edit/Delete`, () => { describe(`${apiType.toUpperCase()} api - Table views: Create/Edit/Delete`, () => {
const name = "Test" + Date.now(); const name = "Test" + Date.now();
// Run once before test- create project (rest/graphql) // Run once before test- create project (rest/graphql)
// //
before(() => { before(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
// open a table to work on views // open a table to work on views
// //
cy.openTableTab("Country", 25); cy.openTableTab("Country", 25);
}); });
beforeEach(() => { beforeEach(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
});
afterEach(() => {
cy.saveLocalStorage();
});
after(() => {
cy.restoreLocalStorage();
cy.closeTableTab("Country");
cy.saveLocalStorage();
});
// Common routine to create/edit/delete GRID & GALLERY view
// Input: viewType - 'grid'/'gallery'
//
const viewTest = (viewType) => {
it(`Create ${viewType} view`, () => {
// 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(".nc-modal-view-create").find(".ant-btn-primary").click();
cy.toastWait("View created successfully");
// validate if view was created && contains default name 'Country1'
cy.get(`.nc-${viewType}-view-item`)
.contains(`${capitalizeFirstLetter(viewType)}-1`)
.should("exist");
});
it(`Edit ${viewType} view name`, () => {
// click on edit-icon (becomes visible on hovering mouse)
cy.get(`.nc-${viewType}-view-item`).last().dblclick();
// feed new name
cy.get(`.nc-${viewType}-view-item input`)
.clear()
.type(`${viewType}View-1{enter}`);
cy.toastWait("View renamed successfully");
// validate
cy.get(`.nc-${viewType}-view-item`)
.contains(`${viewType}View-1`)
.should("exist");
});
it(`Delete ${viewType} view`, () => {
// number of view entries should be 2 before we delete
cy.get(".nc-view-item").its("length").should("eq", 2);
// click on delete icon (becomes visible on hovering mouse)
cy.get(".nc-view-delete-icon").click({ force: true });
cy.wait(300)
cy.getActiveModal(".nc-modal-view-delete").find('.ant-btn-dangerous').click();
cy.toastWait("View deleted successfully");
// confirm if the number of veiw entries is reduced by 1
cy.get(".nc-view-item").its("length").should("eq", 1);
});
};
// below four scenario's will be invoked twice, once for rest & then for graphql
viewTest("grid"); // grid view
viewTest("gallery"); // gallery view
viewTest("form"); // form view
}); });
afterEach(() => {
cy.saveLocalStorage();
});
after(() => {
cy.restoreLocalStorage();
cy.closeTableTab("Country");
cy.saveLocalStorage();
});
// Common routine to create/edit/delete GRID & GALLERY view
// Input: viewType - 'grid'/'gallery'
//
const viewTest = (viewType) => {
it(`Create ${viewType} view`, () => {
// 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(".nc-modal-view-create")
.find(".ant-btn-primary")
.click();
cy.toastWait("View created successfully");
// validate if view was created && contains default name 'Country1'
cy.get(`.nc-${viewType}-view-item`)
.contains(`${capitalizeFirstLetter(viewType)}-1`)
.should("exist");
});
it(`Edit ${viewType} view name`, () => {
// click on edit-icon (becomes visible on hovering mouse)
cy.get(`.nc-${viewType}-view-item`).last().dblclick();
// feed new name
cy.get(`.nc-${viewType}-view-item input`)
.clear()
.type(`${viewType}View-1{enter}`);
cy.toastWait("View renamed successfully");
// validate
cy.get(`.nc-${viewType}-view-item`)
.contains(`${viewType}View-1`)
.should("exist");
});
it(`Delete ${viewType} view`, () => {
// number of view entries should be 2 before we delete
cy.get(".nc-view-item").its("length").should("eq", 2);
// click on delete icon (becomes visible on hovering mouse)
cy.get(".nc-view-delete-icon").click({ force: true });
cy.wait(300);
cy.getActiveModal(".nc-modal-view-delete")
.find(".ant-btn-dangerous")
.click();
cy.toastWait("View deleted successfully");
// confirm if the number of veiw entries is reduced by 1
cy.get(".nc-view-item").its("length").should("eq", 1);
});
};
// below four scenario's will be invoked twice, once for rest & then for graphql
viewTest("grid"); // grid view
viewTest("gallery"); // gallery view
viewTest("form"); // form view
});
}; };
/** /**

223
scripts/cypress/integration/common/4b_table_view_share.js

@ -1,117 +1,140 @@
import { mainPage } from "../../support/page_objects/mainPage"; import { mainPage } from "../../support/page_objects/mainPage";
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"; import { isTestSuiteActive } from "../../support/page_objects/projectConstants";
import {loginPage} from "../../support/page_objects/navigation"; import { loginPage } from "../../support/page_objects/navigation";
let storedURL = ""; let storedURL = "";
let linkText = ""; let linkText = "";
const generateLinkWithPwd = () => { const generateLinkWithPwd = () => {
mainPage.shareView().click(); mainPage.shareView().click();
cy.getActiveModal(".nc-modal-share-view").find(".ant-modal-title").contains("This view is shared via a private link").should("be.visible"); cy.getActiveModal(".nc-modal-share-view")
.find(".ant-modal-title")
// enable checkbox & feed pwd, save .contains("This view is shared via a private link")
cy.getActiveModal(".nc-modal-share-view").find('.ant-collapse').should('exist').click(); .should("be.visible");
cy.getActiveModal(".nc-modal-share-view").find('.ant-checkbox-input').should('exist').first().then(($el) => {
// enable checkbox & feed pwd, save
cy.getActiveModal(".nc-modal-share-view")
.find(".ant-collapse")
.should("exist")
.click();
cy.getActiveModal(".nc-modal-share-view")
.find(".ant-checkbox-input")
.should("exist")
.first()
.then(($el) => {
if (!$el.prop("checked")) { if (!$el.prop("checked")) {
cy.wrap($el).click({ force: true }); cy.wrap($el).click({ force: true });
cy.getActiveModal(".nc-modal-share-view").find('input[type="password"]').clear().type("1"); cy.getActiveModal(".nc-modal-share-view")
cy.getActiveModal(".nc-modal-share-view").find('button:contains("Save password")').click(); .find('input[type="password"]')
cy.toastWait("Successfully updated"); .clear()
.type("1");
cy.getActiveModal(".nc-modal-share-view")
.find('button:contains("Save password")')
.click();
cy.toastWait("Successfully updated");
} }
}); });
// copy link text, visit URL // copy link text, visit URL
cy.getActiveModal(".nc-modal-share-view") cy.getActiveModal(".nc-modal-share-view")
.find(".nc-share-link-box") .find(".nc-share-link-box")
.then(($obj) => { .then(($obj) => {
linkText = $obj.text().trim(); linkText = $obj.text().trim();
cy.log(linkText); cy.log(linkText);
}); });
}; };
export const genTest = (apiType, dbType) => { export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return; if (!isTestSuiteActive(apiType, dbType)) return;
describe(`${apiType.toUpperCase()} api - Shared VIEWs (GRID)`, () => { describe(`${apiType.toUpperCase()} api - Shared VIEWs (GRID)`, () => {
// Run once before test- create project (rest/graphql) // Run once before test- create project (rest/graphql)
// //
before(() => { before(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
cy.openTableTab("City", 25); cy.openTableTab("City", 25);
}); });
beforeEach(() => { beforeEach(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
}); });
afterEach(() => { afterEach(() => {
cy.saveLocalStorage(); cy.saveLocalStorage();
}); });
after(() => { after(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
cy.closeTableTab("City"); cy.closeTableTab("City");
cy.saveLocalStorage(); cy.saveLocalStorage();
}); });
it("Generate link with password", () => { it("Generate link with password", () => {
// store base URL- to re-visit and delete form view later // store base URL- to re-visit and delete form view later
cy.url().then((url) => { cy.url().then((url) => {
storedURL = url; storedURL = url;
}); });
generateLinkWithPwd(); generateLinkWithPwd();
cy.signOut(); cy.signOut();
}); });
it("Share view with incorrect password", () => { it("Share view with incorrect password", () => {
cy.visit(linkText, { cy.visit(linkText, {
baseUrl: null, baseUrl: null,
}); });
cy.getActiveModal(".nc-modal-shared-view-password-dlg").should("exist"); cy.getActiveModal(".nc-modal-shared-view-password-dlg").should("exist");
// feed password // feed password
cy.getActiveModal(".nc-modal-shared-view-password-dlg").find('input[type="password"]').clear().type("a"); cy.getActiveModal(".nc-modal-shared-view-password-dlg")
cy.getActiveModal(".nc-modal-shared-view-password-dlg").find('button:contains("Unlock")').click(); .find('input[type="password"]')
.clear()
// if pwd is incorrect, active modal requesting to feed in password again will persist .type("a");
cy.getActiveModal(".nc-modal-shared-view-password-dlg").find('button:contains("Unlock")').should('exist'); cy.getActiveModal(".nc-modal-shared-view-password-dlg")
}); .find('button:contains("Unlock")')
.click();
// fallover test- use previously opened view & continue verification instead of opening again
it("Share view with correct password", () => { // if pwd is incorrect, active modal requesting to feed in password again will persist
cy.getActiveModal(".nc-modal-shared-view-password-dlg")
// feed password .find('button:contains("Unlock")')
cy.getActiveModal(".nc-modal-shared-view-password-dlg") .should("exist");
.find('input[type="password"]') });
.clear()
.type("1"); // fallover test- use previously opened view & continue verification instead of opening again
cy.getActiveModal(".nc-modal-shared-view-password-dlg").find('button:contains("Unlock")').click(); it("Share view with correct password", () => {
// feed password
// if pwd is incorrect, active modal requesting to feed in password again will persist cy.getActiveModal(".nc-modal-shared-view-password-dlg")
// cy.getActiveModal().find('button:contains("Unlock")').should('not.exist'); .find('input[type="password"]')
// cy.get(".ant-modal-content:visible").should("not.exist") .clear()
.type("1");
cy.wait(1000); cy.getActiveModal(".nc-modal-shared-view-password-dlg")
.find('button:contains("Unlock")')
// Verify Download as CSV is here .click();
mainPage.downloadCsv().should("exist");
cy.get(".nc-actions-menu-btn").should('exist').click(); // if pwd is incorrect, active modal requesting to feed in password again will persist
// cy.getActiveModal().find('button:contains("Unlock")').should('not.exist');
mainPage.downloadExcel().should("exist"); // cy.get(".ant-modal-content:visible").should("not.exist")
cy.get(".nc-actions-menu-btn").should('exist').click();
}); cy.wait(1000);
it("Delete view", () => { // Verify Download as CSV is here
loginPage.loginAndOpenProject(apiType, dbType); mainPage.downloadCsv().should("exist");
cy.openTableTab("City", 25); cy.get(".nc-actions-menu-btn").should("exist").click();
// wait for page load to complete mainPage.downloadExcel().should("exist");
cy.get(".nc-grid-row").should("have.length", 25); cy.get(".nc-actions-menu-btn").should("exist").click();
mainPage.deleteCreatedViews(); });
});
it("Delete view", () => {
loginPage.loginAndOpenProject(apiType, dbType);
cy.openTableTab("City", 25);
// wait for page load to complete
cy.get(".nc-grid-row").should("have.length", 25);
mainPage.deleteCreatedViews();
}); });
});
}; };
/** /**

789
scripts/cypress/integration/common/4c_form_view_detailed.js

@ -1,416 +1,417 @@
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"; import { isTestSuiteActive } from "../../support/page_objects/projectConstants";
import { mainPage, settingsPage } from "../../support/page_objects/mainPage"; import { mainPage, settingsPage } from "../../support/page_objects/mainPage";
import {loginPage} from "../../support/page_objects/navigation"; import { loginPage } from "../../support/page_objects/navigation";
let formViewURL; let formViewURL;
function verifyFormDrawerFieldLocation(fieldName, position) { function verifyFormDrawerFieldLocation(fieldName, position) {
cy.get(".nc-editable.item") cy.get(".nc-editable.item").eq(position).contains(fieldName).should("exist");
.eq(position)
.contains(fieldName)
.should("exist");
} }
function verifyFormDrawerHideObjectCount(count) { function verifyFormDrawerHideObjectCount(count) {
if(count) { if (count) {
cy.get(".nc-form") cy.get(".nc-form")
.find(".nc-field-remove-icon") .find(".nc-field-remove-icon")
.its("length") .its("length")
.should("eq", count); .should("eq", count);
} else { } else {
cy.get(".nc-form") cy.get(".nc-form").find(".nc-field-remove-icon").should("not.exist");
.find(".nc-field-remove-icon") }
.should("not.exist");
}
} }
function verifyFormMenuDrawerCardCount(cardCount) { function verifyFormMenuDrawerCardCount(cardCount) {
if(cardCount) { if (cardCount) {
cy.get('.nc-form-left-drawer').find('.ant-card').should('have.length', cardCount); cy.get(".nc-form-left-drawer")
} else { .find(".ant-card")
cy.get('.nc-form-left-drawer').find('.ant-card').should('not.exist'); .should("have.length", cardCount);
} } else {
cy.get(".nc-form-left-drawer").find(".ant-card").should("not.exist");
}
} }
function validateFormHeader() { function validateFormHeader() {
cy.get(".nc-form").should("exist"); cy.get(".nc-form").should("exist");
cy.get(".nc-form") cy.get(".nc-form")
.find('[placeholder="Form Title"]') .find('[placeholder="Form Title"]')
.should("exist").then(($el) => { .should("exist")
cy.log($el) .then(($el) => {
expect($el.val()).to.equal("A B C D"); cy.log($el);
}) expect($el.val()).to.equal("A B C D");
cy.get(".nc-form") });
.find('[placeholder="Add form description"]') cy.get(".nc-form")
.should("exist").then(($el) => { .find('[placeholder="Add form description"]')
cy.log($el) .should("exist")
expect($el.val()).to.equal("Some description about form comes here"); .then(($el) => {
}) cy.log($el);
expect($el.val()).to.equal("Some description about form comes here");
});
} }
export const genTest = (apiType, dbType) => { export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return; if (!isTestSuiteActive(apiType, dbType)) return;
describe(`${apiType.toUpperCase()} api - FORM view`, () => { describe(`${apiType.toUpperCase()} api - FORM view`, () => {
const name = "Test" + Date.now(); const name = "Test" + Date.now();
// Run once before test- create project (rest/graphql) // Run once before test- create project (rest/graphql)
// //
before(() => { before(() => {
// standalone test // standalone test
// loginPage.loginAndOpenProject(apiType, dbType); // loginPage.loginAndOpenProject(apiType, dbType);
// open a table to work on views // open a table to work on views
// //
cy.restoreLocalStorage(); cy.restoreLocalStorage();
cy.openTableTab("Country", 25); cy.openTableTab("Country", 25);
});
beforeEach(() => {
cy.restoreLocalStorage();
});
afterEach(() => {
cy.saveLocalStorage();
});
after(() => {
cy.restoreLocalStorage();
cy.closeTableTab("Country");
cy.saveLocalStorage();
});
// Common routine to create/edit/delete GRID & GALLERY view
// Input: viewType - 'grid'/'gallery'
//
const viewTest = (viewType) => {
it(`Create ${viewType} view`, () => {
// 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(".nc-modal-view-create").find("button:contains(Submit)").click();
cy.toastWait("View created successfully");
// validate if view was creted && contains default name 'Form-1'
cy.get(`.nc-view-item.nc-${viewType}-view-item`)
.contains("Form-1")
.should("exist");
});
it(`Validate ${viewType} view: Drag & drop for re-order items`, () => {
// default order: Country, LastUpdate, Country => City
verifyFormDrawerFieldLocation("Country", 0);
verifyFormDrawerFieldLocation("LastUpdate", 1);
// move Country field down (drag, drop)
cy.get(".nc-form-drag-LastUpdate").drag(
".nc-form-drag-Country"
);
cy.wait(1000);
// Verify if order is: LastUpdate, Country, Country => City
verifyFormDrawerFieldLocation("LastUpdate", 0);
verifyFormDrawerFieldLocation("Country", 1);
});
it(`Validate ${viewType} view: Drag & drop for add/remove items`, () => {
// default, only one item in menu-bar; ensure LastUpdate field was present in form view
verifyFormMenuDrawerCardCount(0)
verifyFormDrawerFieldLocation("LastUpdate", 0);
// drag 'LastUpdate' & drop into menu bar drag-drop box
cy.get(".nc-form-drag-LastUpdate").drag(
".nc-drag-n-drop-to-hide"
);
// validate- fields count in menu bar to be increased by 1 &&
// first member in 'formView' is Country
verifyFormDrawerFieldLocation("Country", 0);
verifyFormMenuDrawerCardCount(1);
});
it(`Validate ${viewType} view: Inverted order field member addition from menu`, () => {
cy.get(".nc-form-remove-all").click();
verifyFormMenuDrawerCardCount(2)
// click fields in inverted order: LastUpdate, Country => City
cy.get('.nc-form-left-drawer').find('.ant-card').eq(1).click();
verifyFormMenuDrawerCardCount(1);
cy.get('.nc-form-left-drawer').find('.ant-card').eq(0).click();
// verify if order of appearance in form is right
// Country was never removed as its required field. Other two will appear in inverted order
verifyFormMenuDrawerCardCount(0);
verifyFormDrawerFieldLocation("Country", 0);
verifyFormDrawerFieldLocation("City List", 1);
verifyFormDrawerFieldLocation("LastUpdate", 2);
});
it(`Validate ${viewType}: Form header & description validation`, () => {
// Header & description should exist
cy.get(".nc-form")
.find('[placeholder="Form Title"]')
.should("exist");
cy.get(".nc-form")
.find('[placeholder="Add form description"]')
.should("exist");
// Update header & add some description, verify
cy.get(".nc-form")
.find('[placeholder="Form Title"]')
.clear()
.type("A B C D");
cy.get(".nc-form")
.find('[placeholder="Add form description"]')
.type("Some description about form comes here");
cy.get(".nc-form").click()
// validate new contents
validateFormHeader();
});
it(`Validate ${viewType}: Add all, Remove all validation`, () => {
// ensure buttons exist on left hand menu
cy.get(".nc-form-left-drawer").find(".nc-form-add-all").should("not.exist");
cy.get(".nc-form-left-drawer").find(".nc-form-remove-all").should("be.visible");
// click: remove-all
cy.get(".nc-form-left-drawer").find(".nc-form-remove-all").click();
cy.wait(1000);
// form should not contain any "field remove icons"
verifyFormDrawerHideObjectCount(0);
// menu bar should contain 2 .pointer.item (LastUpdate, County->City)
verifyFormMenuDrawerCardCount(2);
// click: Add all
cy.get(".nc-form-left-drawer").find(".nc-form-add-all").should('be.visible').click();
cy.get(".nc-form-left-drawer").find(".nc-form-remove-all").should("be.visible");
// form should contain "field remove icons"
verifyFormDrawerHideObjectCount(2);
// menu bar should not contain .pointer.item (column name/ field name add options)
verifyFormMenuDrawerCardCount(0);
});
it(`Validate ${viewType}: Submit default, empty show this message textbox`, () => {
// fill up mandatory fields
cy.get(".nc-form-input-Country").type("_abc");
cy.get(".nc-form-input-LastUpdate").click();
cy.get(".ant-picker-now-btn:visible").contains("Now").click();
cy.get(".ant-btn-primary:visible").contains("Ok").click();
// default message, no update
// submit button & validate
cy.get(".nc-form").find("button").contains("Submit").click();
cy.get(".ant-alert-message")
.contains("Successfully submitted form data")
.should("exist");
// end of test removes newly added rows from table. that step validates if row was successfully added.
});
it(`Validate ${viewType}: Submit default, with valid Show message entry`, () => {
// clicking again on view name shows blank still. work around- toggling between two views
cy.get(`.nc-view-item.nc-${viewType}-view-item`)
.contains("Form-1")
.click();
// fill up mandatory fields
cy.get(".nc-form-input-Country").should('exist').type("_abc");
cy.get(".nc-form-input-LastUpdate").click();
cy.get(".ant-picker-now-btn:visible").contains("Now").click();
cy.get(".ant-btn-primary:visible").contains("Ok").click();
// add message
cy.get("textarea.nc-form-after-submit-msg")
.type("Congratulations!");
// submit button & validate
cy.get(".nc-form").find("button").contains("Submit").click();
cy.get(".ant-alert-message").contains("Congratulations!").should("exist");
// end of test removes newly added rows from table. that step validates if row was successfully added.
});
it(`Validate ${viewType}: Submit default, Enable checkbox "Submit another form`, () => {
// clicking again on view name shows blank still. work around- toggling between two views
cy.get(`.nc-view-item.nc-${viewType}-view-item`)
.contains("Form-1")
.click();
// fill up mandatory fields
cy.get(".nc-form-input-Country").type("_abc");
cy.get(".nc-form-input-LastUpdate").click();
cy.get(".ant-picker-now-btn:visible").contains("Now").click();
cy.get(".ant-btn-primary:visible").contains("Ok").click();
// enable "Submit another form" check box
cy.get("button.nc-form-checkbox-submit-another-form").click();
// submit button & validate
cy.get(".nc-form").find("button").contains("Submit").click();
cy.get(".ant-alert-message").contains("Congratulations").should("exist");
cy.get("button")
.contains("Submit Another Form")
.should("exist")
.click();
// New form appeared? Header & description should exist
validateFormHeader();
// end of test removes newly added rows from table. that step validates if row was successfully added.
});
it(`Validate ${viewType}: Submit default, Enable checkbox "blank form after 5 seconds"`, () => {
cy.get(".nc-form-input-Country").type("_abc");
cy.get(".nc-form-input-LastUpdate").click();
cy.get(".ant-picker-now-btn:visible").contains("Now").click();
cy.get(".ant-btn-primary:visible").contains("Ok").click();
// enable "New form after 5 seconds" button
cy.get("button.nc-form-checkbox-submit-another-form")
.click();
cy.get("button.nc-form-checkbox-show-blank-form")
.click();
// submit button & validate
cy.get(".nc-form").find("button").contains("Submit").click();
cy.get(".ant-alert-message")
.contains("Congratulations")
.should("exist")
.then(() => {
// validate if form has appeared again
validateFormHeader();
});
// end of test removes newly added rows from table. that step validates if row was successfully added.
});
it(`Validate ${viewType}: Email me verification, without SMTP configuration`, () => {
// open formview & enable "email me" option
cy.get(`.nc-view-item.nc-${viewType}-view-item`)
.contains("Form-1")
.click();
// validate if form has appeared again
cy.wait(1000);
validateFormHeader();
cy.get(".nc-form-remove-all").click();
cy.get(".nc-form-checkbox-send-email").click();
// validate if toaster pops up requesting to activate SMTP
cy.toastWait(
"Please activate SMTP plugin in App store for enabling email notification"
);
});
it(`Validate ${viewType}: Email me verification, with SMTP configuration`, () => {
// activate SMTP, dummy profile
settingsPage.openMenu(settingsPage.APPSTORE)
mainPage.configureSMTP(
"admin@ex.com",
"smtp.ex.com",
"8080",
"TLS"
);
// open form view & enable "email me" option
cy.openTableTab("Country", 25);
cy.wait(1000);
cy.get(`.nc-view-item.nc-${viewType}-view-item`)
.contains("Form-1")
.click();
// validate if form has appeared again
validateFormHeader();
cy.get(".nc-form-checkbox-send-email")
.click();
settingsPage.openMenu(settingsPage.APPSTORE)
mainPage.resetSMTP();
cy.wait(300);
cy.openTableTab("Country", 25);
});
it(`Validate ${viewType}: Add/ remove field verification"`, () => {
cy.get(`.nc-view-item.nc-${viewType}-view-item`)
.contains("Form-1")
.click();
cy.get(".nc-form-add-all").click();
cy.wait(300);
// validate if form has appeared again
validateFormHeader();
cy.get(".nc-form-input-LastUpdate").should("exist");
// remove "LastUpdate field"
cy.get(".nc-form").find(".nc-field-remove-icon").eq(1).click();
cy.get(".nc-form-input-LastUpdate").should("not.exist");
cy.get('.nc-form-left-drawer').find('.ant-card').contains('LastUpdate').should('exist').click();
cy.get(".nc-form-input-LastUpdate").should("exist");
cy.wait(300);
});
it(`Validate ${viewType}: URL verification`, () => {
cy.get(`.nc-view-item.nc-${viewType}-view-item`)
.contains("Form-1")
.click();
// validate if form has appeared again
validateFormHeader();
});
it(`Delete ${viewType} view`, () => {
// number of view entries should be 2 before we delete
cy.get(".nc-view-item").its("length").should("eq", 2);
// click on delete icon (becomes visible on hovering mouse)
cy.get(".nc-view-delete-icon").click({ force: true });
cy.wait(1000)
cy.getActiveModal(".nc-modal-view-delete").find('.ant-btn-dangerous').click();
cy.toastWait("View deleted successfully");
// confirm if the number of veiw entries is reduced by 1
cy.get(".nc-view-item").its("length").should("eq", 1);
// clean up newly added rows into Country table operations
// this auto verifies successfull addition of rows to table as well
mainPage.getPagination(5).click();
cy.get(".nc-grid-row").should("have.length", 13);
cy.get(".ant-checkbox").should('exist').eq(10).click({ force: true });
cy.get(".ant-checkbox").should('exist').eq(11).click({ force: true });
cy.get(".ant-checkbox").should('exist').eq(12).click({ force: true });
cy.get(".ant-checkbox").should('exist').eq(13).click({ force: true });
mainPage.getCell("Country", 10).rightclick({ force: true });
cy.getActiveMenu(".nc-dropdown-grid-context-menu")
.contains("Delete Selected Rows")
.click({ force: true });
});
};
// below scenario's will be invoked twice, once for rest & then for graphql
viewTest("form");
}); });
beforeEach(() => {
cy.restoreLocalStorage();
});
afterEach(() => {
cy.saveLocalStorage();
});
after(() => {
cy.restoreLocalStorage();
cy.closeTableTab("Country");
cy.saveLocalStorage();
});
// Common routine to create/edit/delete GRID & GALLERY view
// Input: viewType - 'grid'/'gallery'
//
const viewTest = (viewType) => {
it(`Create ${viewType} view`, () => {
// 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(".nc-modal-view-create")
.find("button:contains(Submit)")
.click();
cy.toastWait("View created successfully");
// validate if view was creted && contains default name 'Form-1'
cy.get(`.nc-view-item.nc-${viewType}-view-item`)
.contains("Form-1")
.should("exist");
});
it(`Validate ${viewType} view: Drag & drop for re-order items`, () => {
// default order: Country, LastUpdate, Country => City
verifyFormDrawerFieldLocation("Country", 0);
verifyFormDrawerFieldLocation("LastUpdate", 1);
// move Country field down (drag, drop)
cy.get(".nc-form-drag-LastUpdate").drag(".nc-form-drag-Country");
cy.wait(1000);
// Verify if order is: LastUpdate, Country, Country => City
verifyFormDrawerFieldLocation("LastUpdate", 0);
verifyFormDrawerFieldLocation("Country", 1);
});
it(`Validate ${viewType} view: Drag & drop for add/remove items`, () => {
// default, only one item in menu-bar; ensure LastUpdate field was present in form view
verifyFormMenuDrawerCardCount(0);
verifyFormDrawerFieldLocation("LastUpdate", 0);
// drag 'LastUpdate' & drop into menu bar drag-drop box
cy.get(".nc-form-drag-LastUpdate").drag(".nc-drag-n-drop-to-hide");
// validate- fields count in menu bar to be increased by 1 &&
// first member in 'formView' is Country
verifyFormDrawerFieldLocation("Country", 0);
verifyFormMenuDrawerCardCount(1);
});
it(`Validate ${viewType} view: Inverted order field member addition from menu`, () => {
cy.get(".nc-form-remove-all").click();
verifyFormMenuDrawerCardCount(2);
// click fields in inverted order: LastUpdate, Country => City
cy.get(".nc-form-left-drawer").find(".ant-card").eq(1).click();
verifyFormMenuDrawerCardCount(1);
cy.get(".nc-form-left-drawer").find(".ant-card").eq(0).click();
// verify if order of appearance in form is right
// Country was never removed as its required field. Other two will appear in inverted order
verifyFormMenuDrawerCardCount(0);
verifyFormDrawerFieldLocation("Country", 0);
verifyFormDrawerFieldLocation("City List", 1);
verifyFormDrawerFieldLocation("LastUpdate", 2);
});
it(`Validate ${viewType}: Form header & description validation`, () => {
// Header & description should exist
cy.get(".nc-form").find('[placeholder="Form Title"]').should("exist");
cy.get(".nc-form")
.find('[placeholder="Add form description"]')
.should("exist");
// Update header & add some description, verify
cy.get(".nc-form")
.find('[placeholder="Form Title"]')
.clear()
.type("A B C D");
cy.get(".nc-form")
.find('[placeholder="Add form description"]')
.type("Some description about form comes here");
cy.get(".nc-form").click();
// validate new contents
validateFormHeader();
});
it(`Validate ${viewType}: Add all, Remove all validation`, () => {
// ensure buttons exist on left hand menu
cy.get(".nc-form-left-drawer")
.find(".nc-form-add-all")
.should("not.exist");
cy.get(".nc-form-left-drawer")
.find(".nc-form-remove-all")
.should("be.visible");
// click: remove-all
cy.get(".nc-form-left-drawer").find(".nc-form-remove-all").click();
cy.wait(1000);
// form should not contain any "field remove icons"
verifyFormDrawerHideObjectCount(0);
// menu bar should contain 2 .pointer.item (LastUpdate, County->City)
verifyFormMenuDrawerCardCount(2);
// click: Add all
cy.get(".nc-form-left-drawer")
.find(".nc-form-add-all")
.should("be.visible")
.click();
cy.get(".nc-form-left-drawer")
.find(".nc-form-remove-all")
.should("be.visible");
// form should contain "field remove icons"
verifyFormDrawerHideObjectCount(2);
// menu bar should not contain .pointer.item (column name/ field name add options)
verifyFormMenuDrawerCardCount(0);
});
it(`Validate ${viewType}: Submit default, empty show this message textbox`, () => {
// fill up mandatory fields
cy.get(".nc-form-input-Country").type("_abc");
cy.get(".nc-form-input-LastUpdate").click();
cy.get(".ant-picker-now-btn:visible").contains("Now").click();
cy.get(".ant-btn-primary:visible").contains("Ok").click();
// default message, no update
// submit button & validate
cy.get(".nc-form").find("button").contains("Submit").click();
cy.get(".ant-alert-message")
.contains("Successfully submitted form data")
.should("exist");
// end of test removes newly added rows from table. that step validates if row was successfully added.
});
it(`Validate ${viewType}: Submit default, with valid Show message entry`, () => {
// clicking again on view name shows blank still. work around- toggling between two views
cy.get(`.nc-view-item.nc-${viewType}-view-item`)
.contains("Form-1")
.click();
// fill up mandatory fields
cy.get(".nc-form-input-Country").should("exist").type("_abc");
cy.get(".nc-form-input-LastUpdate").click();
cy.get(".ant-picker-now-btn:visible").contains("Now").click();
cy.get(".ant-btn-primary:visible").contains("Ok").click();
// add message
cy.get("textarea.nc-form-after-submit-msg").type("Congratulations!");
// submit button & validate
cy.get(".nc-form").find("button").contains("Submit").click();
cy.get(".ant-alert-message")
.contains("Congratulations!")
.should("exist");
// end of test removes newly added rows from table. that step validates if row was successfully added.
});
it(`Validate ${viewType}: Submit default, Enable checkbox "Submit another form`, () => {
// clicking again on view name shows blank still. work around- toggling between two views
cy.get(`.nc-view-item.nc-${viewType}-view-item`)
.contains("Form-1")
.click();
// fill up mandatory fields
cy.get(".nc-form-input-Country").type("_abc");
cy.get(".nc-form-input-LastUpdate").click();
cy.get(".ant-picker-now-btn:visible").contains("Now").click();
cy.get(".ant-btn-primary:visible").contains("Ok").click();
// enable "Submit another form" check box
cy.get("button.nc-form-checkbox-submit-another-form").click();
// submit button & validate
cy.get(".nc-form").find("button").contains("Submit").click();
cy.get(".ant-alert-message")
.contains("Congratulations")
.should("exist");
cy.get("button")
.contains("Submit Another Form")
.should("exist")
.click();
// New form appeared? Header & description should exist
validateFormHeader();
// end of test removes newly added rows from table. that step validates if row was successfully added.
});
it(`Validate ${viewType}: Submit default, Enable checkbox "blank form after 5 seconds"`, () => {
cy.get(".nc-form-input-Country").type("_abc");
cy.get(".nc-form-input-LastUpdate").click();
cy.get(".ant-picker-now-btn:visible").contains("Now").click();
cy.get(".ant-btn-primary:visible").contains("Ok").click();
// enable "New form after 5 seconds" button
cy.get("button.nc-form-checkbox-submit-another-form").click();
cy.get("button.nc-form-checkbox-show-blank-form").click();
// submit button & validate
cy.get(".nc-form").find("button").contains("Submit").click();
cy.get(".ant-alert-message")
.contains("Congratulations")
.should("exist")
.then(() => {
// validate if form has appeared again
validateFormHeader();
});
// end of test removes newly added rows from table. that step validates if row was successfully added.
});
it(`Validate ${viewType}: Email me verification, without SMTP configuration`, () => {
// open formview & enable "email me" option
cy.get(`.nc-view-item.nc-${viewType}-view-item`)
.contains("Form-1")
.click();
// validate if form has appeared again
cy.wait(1000);
validateFormHeader();
cy.get(".nc-form-remove-all").click();
cy.get(".nc-form-checkbox-send-email").click();
// validate if toaster pops up requesting to activate SMTP
cy.toastWait(
"Please activate SMTP plugin in App store for enabling email notification"
);
});
it(`Validate ${viewType}: Email me verification, with SMTP configuration`, () => {
// activate SMTP, dummy profile
settingsPage.openMenu(settingsPage.APPSTORE);
mainPage.configureSMTP("admin@ex.com", "smtp.ex.com", "8080", "TLS");
// open form view & enable "email me" option
cy.openTableTab("Country", 25);
cy.wait(1000);
cy.get(`.nc-view-item.nc-${viewType}-view-item`)
.contains("Form-1")
.click();
// validate if form has appeared again
validateFormHeader();
cy.get(".nc-form-checkbox-send-email").click();
settingsPage.openMenu(settingsPage.APPSTORE);
mainPage.resetSMTP();
cy.wait(300);
cy.openTableTab("Country", 25);
});
it(`Validate ${viewType}: Add/ remove field verification"`, () => {
cy.get(`.nc-view-item.nc-${viewType}-view-item`)
.contains("Form-1")
.click();
cy.get(".nc-form-add-all").click();
cy.wait(300);
// validate if form has appeared again
validateFormHeader();
cy.get(".nc-form-input-LastUpdate").should("exist");
// remove "LastUpdate field"
cy.get(".nc-form").find(".nc-field-remove-icon").eq(1).click();
cy.get(".nc-form-input-LastUpdate").should("not.exist");
cy.get(".nc-form-left-drawer")
.find(".ant-card")
.contains("LastUpdate")
.should("exist")
.click();
cy.get(".nc-form-input-LastUpdate").should("exist");
cy.wait(300);
});
it(`Validate ${viewType}: URL verification`, () => {
cy.get(`.nc-view-item.nc-${viewType}-view-item`)
.contains("Form-1")
.click();
// validate if form has appeared again
validateFormHeader();
});
it(`Delete ${viewType} view`, () => {
// number of view entries should be 2 before we delete
cy.get(".nc-view-item").its("length").should("eq", 2);
// click on delete icon (becomes visible on hovering mouse)
cy.get(".nc-view-delete-icon").click({ force: true });
cy.wait(1000);
cy.getActiveModal(".nc-modal-view-delete")
.find(".ant-btn-dangerous")
.click();
cy.toastWait("View deleted successfully");
// confirm if the number of veiw entries is reduced by 1
cy.get(".nc-view-item").its("length").should("eq", 1);
// clean up newly added rows into Country table operations
// this auto verifies successfull addition of rows to table as well
mainPage.getPagination(5).click();
cy.get(".nc-grid-row").should("have.length", 13);
cy.get(".ant-checkbox").should("exist").eq(10).click({ force: true });
cy.get(".ant-checkbox").should("exist").eq(11).click({ force: true });
cy.get(".ant-checkbox").should("exist").eq(12).click({ force: true });
cy.get(".ant-checkbox").should("exist").eq(13).click({ force: true });
mainPage.getCell("Country", 10).rightclick({ force: true });
cy.getActiveMenu(".nc-dropdown-grid-context-menu")
.contains("Delete Selected Rows")
.click({ force: true });
});
};
// below scenario's will be invoked twice, once for rest & then for graphql
viewTest("form");
});
}; };
/** /**

201
scripts/cypress/integration/common/4d_table_view_grid_locked.js

@ -2,110 +2,107 @@ import { isTestSuiteActive } from "../../support/page_objects/projectConstants";
import { mainPage } from "../../support/page_objects/mainPage"; import { mainPage } from "../../support/page_objects/mainPage";
export const genTest = (apiType, dbType) => { export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return; if (!isTestSuiteActive(apiType, dbType)) return;
describe(`${apiType.toUpperCase()} api - Lock view`, () => {
// Run once before test- create project (rest/graphql)
//
before(() => {
cy.restoreLocalStorage();
cy.openTableTab("Country", 25);
});
describe(`${apiType.toUpperCase()} api - Lock view`, () => { beforeEach(() => {
// Run once before test- create project (rest/graphql) cy.restoreLocalStorage();
// });
before(() => {
cy.restoreLocalStorage(); afterEach(() => {
cy.openTableTab("Country", 25); cy.saveLocalStorage();
});
beforeEach(() => {
cy.restoreLocalStorage();
});
afterEach(() => {
cy.saveLocalStorage();
});
after(() => {
cy.restoreLocalStorage();
cy.closeTableTab("Country");
cy.saveLocalStorage();
});
const lockViewTest = (enabled) => {
it(`Grid: lock view set to ${enabled}: validation`, () => {
let vString = enabled ? "not." : "";
let menuOption = enabled ? 'Locked View' : 'Collaborative View';
// on menu, collaboration view appears first (at index 0)
// followed by Locked view (at index 1)
cy.get(".nc-actions-menu-btn").click();
cy.getActiveMenu(".nc-dropdown-actions-menu").find('.ant-dropdown-menu-submenu').eq(0).click();
cy.wait(1000);
cy.get('.nc-locked-menu-item').contains(menuOption).should('exist').click();
// cy.get(".nc-sidebar-lock-menu")
// .click();
// cy.getActiveMenu()
// .find('.nc-menu-item:visible')
// .eq(menuOption)
// .click();
if(enabled) {
cy.toastWait('Successfully Switched to locked view')
cy.get(".nc-icon-locked").should("exist");
} else {
cy.toastWait('Successfully Switched to collaborative view')
cy.get(".nc-icon-collaborative").should("exist");
}
// expected toolbar for Lock view: Only lock-view menu, reload, toggle-nav-drawer to be enabled
//
// cy.get(".nc-sidebar-lock-menu:enabled")
// .should("exist");
cy.get(".nc-toolbar-reload-btn")
.should("exist");
cy.get(".nc-add-new-row-btn > .cursor-pointer")
.should(`${vString}exist`);
cy.get(".nc-fields-menu-btn:enabled")
.should(`${vString}exist`);
cy.get(".nc-sort-menu-btn:enabled")
.should(`${vString}exist`);
cy.get(".nc-filter-menu-btn:enabled")
.should(`${vString}exist`);
// dblClick on a cell & see if we can edit
mainPage.getCell("Country", 1).dblclick();
mainPage
.getCell("Country", 1)
.find("input")
.should(`${vString}exist`);
cy.get(".nc-row-expand")
.should(`${vString}exist`);
// check if add/ expand options available for 'has many' column type
// GUI-v2: TBD
mainPage
.getCell("City List", 1)
.click()
.find(".nc-action-icon.nc-plus")
.should(`${vString}exist`);
mainPage
.getCell("City List", 1)
.click()
.find(".nc-action-icon.nc-arrow-expand")
.should(`${vString}exist`);
// update row option (right click) - should not be available for Lock view
mainPage.getCell("City List", 1).rightclick();
cy.get(".ant-dropdown-content").should(
`${vString}be.visible`
);
});
};
// Locked view
lockViewTest(true);
// collaboration view
lockViewTest(false);
}); });
after(() => {
cy.restoreLocalStorage();
cy.closeTableTab("Country");
cy.saveLocalStorage();
});
const lockViewTest = (enabled) => {
it(`Grid: lock view set to ${enabled}: validation`, () => {
let vString = enabled ? "not." : "";
let menuOption = enabled ? "Locked View" : "Collaborative View";
// on menu, collaboration view appears first (at index 0)
// followed by Locked view (at index 1)
cy.get(".nc-actions-menu-btn").click();
cy.getActiveMenu(".nc-dropdown-actions-menu")
.find(".ant-dropdown-menu-submenu")
.eq(0)
.click();
cy.wait(1000);
cy.get(".nc-locked-menu-item")
.contains(menuOption)
.should("exist")
.click();
// cy.get(".nc-sidebar-lock-menu")
// .click();
// cy.getActiveMenu()
// .find('.nc-menu-item:visible')
// .eq(menuOption)
// .click();
if (enabled) {
cy.toastWait("Successfully Switched to locked view");
cy.get(".nc-icon-locked").should("exist");
} else {
cy.toastWait("Successfully Switched to collaborative view");
cy.get(".nc-icon-collaborative").should("exist");
}
// expected toolbar for Lock view: Only lock-view menu, reload, toggle-nav-drawer to be enabled
//
// cy.get(".nc-sidebar-lock-menu:enabled")
// .should("exist");
cy.get(".nc-toolbar-reload-btn").should("exist");
cy.get(".nc-add-new-row-btn > .cursor-pointer").should(
`${vString}exist`
);
cy.get(".nc-fields-menu-btn:enabled").should(`${vString}exist`);
cy.get(".nc-sort-menu-btn:enabled").should(`${vString}exist`);
cy.get(".nc-filter-menu-btn:enabled").should(`${vString}exist`);
// dblClick on a cell & see if we can edit
mainPage.getCell("Country", 1).dblclick();
mainPage.getCell("Country", 1).find("input").should(`${vString}exist`);
cy.get(".nc-row-expand").should(`${vString}exist`);
// check if add/ expand options available for 'has many' column type
// GUI-v2: TBD
mainPage
.getCell("City List", 1)
.click()
.find(".nc-action-icon.nc-plus")
.should(`${vString}exist`);
mainPage
.getCell("City List", 1)
.click()
.find(".nc-action-icon.nc-arrow-expand")
.should(`${vString}exist`);
// update row option (right click) - should not be available for Lock view
mainPage.getCell("City List", 1).rightclick();
cy.get(".ant-dropdown-content").should(`${vString}be.visible`);
});
};
// Locked view
lockViewTest(true);
// collaboration view
lockViewTest(false);
});
}; };
/** /**

411
scripts/cypress/integration/common/4e_form_view_share.js

@ -1,220 +1,223 @@
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"; import { isTestSuiteActive } from "../../support/page_objects/projectConstants";
import { mainPage } from "../../support/page_objects/mainPage"; import { mainPage } from "../../support/page_objects/mainPage";
import {loginPage} from "../../support/page_objects/navigation"; import { loginPage } from "../../support/page_objects/navigation";
let storedURL = ""; let storedURL = "";
export const genTest = (apiType, dbType) => { export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return; if (!isTestSuiteActive(apiType, dbType)) return;
describe(`${apiType.toUpperCase()} api - FORM view (Share)`, () => { describe(`${apiType.toUpperCase()} api - FORM view (Share)`, () => {
const name = "Test" + Date.now(); const name = "Test" + Date.now();
// Run once before test- create project (rest/graphql) // Run once before test- create project (rest/graphql)
// //
before(() => { before(() => {
// loginPage.loginAndOpenProject(apiType, dbType); // loginPage.loginAndOpenProject(apiType, dbType);
cy.restoreLocalStorage(); cy.restoreLocalStorage();
cy.openTableTab("City", 25); cy.openTableTab("City", 25);
}); });
beforeEach(() => {
cy.restoreLocalStorage();
});
afterEach(() => {
cy.saveLocalStorage();
});
after(() => { beforeEach(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
cy.closeTableTab("City"); });
cy.saveLocalStorage();
});
// Common routine to create/edit/delete GRID & GALLERY view afterEach(() => {
// Input: viewType - 'grid'/'gallery' cy.saveLocalStorage();
// });
const viewTest = (viewType) => {
it(`Create ${viewType} view`, () => {0
// click on create grid view button
cy.get(`.nc-create-${viewType}-view`).click();
// Pop up window, click Submit (accepting default name for view)
cy.getActiveModal(".nc-modal-view-create").find("button:contains(Submit)").click();
cy.toastWait("View created successfully");
// validate if view was creted && contains default name 'Country1'
cy.get(`.nc-view-item.nc-${viewType}-view-item`)
.contains("Form-1")
.should("exist");
// Prepare form
// add header, description
// add post submission message
// swap position for City, LastUpdate fields
// remove City=>Address field
// enable "Submit another form" check box
cy.get("button.nc-form-checkbox-show-blank-form").click();
// Update header & add some description, verify
cy.get(".nc-form")
.find('[placeholder="Form Title"]')
.clear()
.type("A B C D");
cy.get(".nc-form")
.find('[placeholder="Add form description"]')
.type("Some description about form comes here");
// add message
cy.get("textarea.nc-form-after-submit-msg")
.type("Congratulations!");
// move Country field down (drag, drop)
cy.get(".nc-form-drag-LastUpdate").drag(
".nc-form-drag-City");
cy.get('[title="Address List"]').drag(".nc-drag-n-drop-to-hide");
// store base URL- to re-visit and delete form view later
cy.url().then((url) => {
storedURL = url;
});
});
it(`Share form view`, () => { after(() => {
cy.restoreLocalStorage();
cy.get(`.nc-view-item.nc-${viewType}-view-item`) cy.closeTableTab("City");
.contains("Form-1") cy.saveLocalStorage();
.click(); });
cy.wait(2000);
mainPage.shareView().click();
// copy link text, visit URL
cy.getActiveModal(".nc-modal-share-view")
.should('exist')
.find(".share-link-box")
.contains("/nc/form/", { timeout: 10000 })
.should("exist")
.then(($obj) => {
let linkText = $obj.text().trim();
cy.log(linkText);
cy.signOut();
cy.visit(linkText, {
baseUrl: null,
});
cy.wait(5000);
// wait for share view page to load!
cy.get(".nc-form").should("exist");
// New form appeared? Header & description should exist
cy.get(".nc-form-view", { timeout: 10000 })
.find("h1")
.contains("A B C D")
.should("exist");
cy.get(".nc-form-view", { timeout: 10000 })
.find("h2")
.contains("Some description about form comes here")
.should("exist");
// all fields, barring removed field should exist
cy.get('[title="City"]').should("exist");
cy.get('[title="LastUpdate"]').should("exist");
cy.get('[title="Country"]').should("exist");
cy.get('[title="Address List"]').should("not.exist");
// order of LastUpdate & City field is retained
cy.get(".nc-form-column-label")
.eq(0)
.contains("LastUpdate")
.should("exist");
cy.get(".nc-form-column-label")
.eq(1)
.contains("City")
.should("exist");
// submit form, to read message
cy.get(".nc-form-input-City").type("_abc");
cy.get(".nc-form-input-LastUpdate").click();
cy.get(".ant-picker-now-btn:visible").contains("Now").click();
cy.get(".ant-btn-primary:visible").contains("Ok").click();
// cy.get('.nc-form-field-Country')
// .trigger('mouseover')
// .click()
// .find('.nc-action-icon')
// .click();
// // cy.get("button").contains("Link to 'Country'").click();
// cy.getActiveModal()
// .find(".ant-card")
// .contains("Afghanistan")
// .click();
//
// // submit button & validate
// cy.get(".nc-form")
// .find("button")
// .contains("Submit")
// .click();
//
// cy.get(".ant-alert-message")
// .contains("Congratulations")
// .should("exist")
// .then(() => {
// cy.get(".nc-form").should("exist");
//
// // validate if form has appeared again
// cy.get(".nc-share-form-title")
// .contains("A B C D")
// .should("exist");
// cy.get(".nc-share-form-desc")
// .contains("Some description about form comes here")
// .should("exist");
// });
});
});
it(`Delete ${viewType} view`, () => { // Common routine to create/edit/delete GRID & GALLERY view
// go back to base page // Input: viewType - 'grid'/'gallery'
loginPage.loginAndOpenProject(apiType, dbType); //
cy.openTableTab("City", 25); const viewTest = (viewType) => {
it(`Create ${viewType} view`, () => {
// number of view entries should be 2 before we delete 0;
cy.get(".nc-view-item").its("length").should("eq", 2);
// click on create grid view button
// click on delete icon (becomes visible on hovering mouse) cy.get(`.nc-create-${viewType}-view`).click();
cy.get(".nc-view-delete-icon").click({ force: true });
cy.wait(1000); // Pop up window, click Submit (accepting default name for view)
cy.getActiveModal(".nc-modal-view-delete").find('.ant-btn-dangerous').should('exist').click(); cy.getActiveModal(".nc-modal-view-create")
cy.toastWait("View deleted successfully"); .find("button:contains(Submit)")
.click();
// confirm if the number of veiw entries is reduced by 1
cy.get(".nc-view-item").its("length").should("eq", 1); cy.toastWait("View created successfully");
// // clean up newly added rows into Country table operations // validate if view was creted && contains default name 'Country1'
// // this auto verifies successfull addition of rows to table as well cy.get(`.nc-view-item.nc-${viewType}-view-item`)
// mainPage.getPagination(25).click(); .contains("Form-1")
// // kludge: flicker on load .should("exist");
// cy.wait(3000)
// // Prepare form
// cy.get(".nc-grid-row").should("have.length", 1); // add header, description
// cy.get(".ant-checkbox").should('exist').eq(1).click({ force: true }); // add post submission message
// mainPage.getCell("Country", 1).rightclick({ force: true }); // swap position for City, LastUpdate fields
// cy.getActiveMenu() // remove City=>Address field
// .contains("Delete Selected Rows") // enable "Submit another form" check box
// .click({ force: true }); cy.get("button.nc-form-checkbox-show-blank-form").click();
// Update header & add some description, verify
cy.get(".nc-form")
.find('[placeholder="Form Title"]')
.clear()
.type("A B C D");
cy.get(".nc-form")
.find('[placeholder="Add form description"]')
.type("Some description about form comes here");
// add message
cy.get("textarea.nc-form-after-submit-msg").type("Congratulations!");
// move Country field down (drag, drop)
cy.get(".nc-form-drag-LastUpdate").drag(".nc-form-drag-City");
cy.get('[title="Address List"]').drag(".nc-drag-n-drop-to-hide");
// store base URL- to re-visit and delete form view later
cy.url().then((url) => {
storedURL = url;
});
});
it(`Share form view`, () => {
cy.get(`.nc-view-item.nc-${viewType}-view-item`)
.contains("Form-1")
.click();
cy.wait(2000);
mainPage.shareView().click();
// copy link text, visit URL
cy.getActiveModal(".nc-modal-share-view")
.should("exist")
.find(".share-link-box")
.contains("/nc/form/", { timeout: 10000 })
.should("exist")
.then(($obj) => {
let linkText = $obj.text().trim();
cy.log(linkText);
cy.signOut();
cy.visit(linkText, {
baseUrl: null,
}); });
}; cy.wait(5000);
// below scenario's will be invoked twice, once for rest & then for graphql // wait for share view page to load!
viewTest("form");
}); cy.get(".nc-form").should("exist");
// New form appeared? Header & description should exist
cy.get(".nc-form-view", { timeout: 10000 })
.find("h1")
.contains("A B C D")
.should("exist");
cy.get(".nc-form-view", { timeout: 10000 })
.find("h2")
.contains("Some description about form comes here")
.should("exist");
// all fields, barring removed field should exist
cy.get('[title="City"]').should("exist");
cy.get('[title="LastUpdate"]').should("exist");
cy.get('[title="Country"]').should("exist");
cy.get('[title="Address List"]').should("not.exist");
// order of LastUpdate & City field is retained
cy.get(".nc-form-column-label")
.eq(0)
.contains("LastUpdate")
.should("exist");
cy.get(".nc-form-column-label")
.eq(1)
.contains("City")
.should("exist");
// submit form, to read message
cy.get(".nc-form-input-City").type("_abc");
cy.get(".nc-form-input-LastUpdate").click();
cy.get(".ant-picker-now-btn:visible").contains("Now").click();
cy.get(".ant-btn-primary:visible").contains("Ok").click();
// cy.get('.nc-form-field-Country')
// .trigger('mouseover')
// .click()
// .find('.nc-action-icon')
// .click();
// // cy.get("button").contains("Link to 'Country'").click();
// cy.getActiveModal()
// .find(".ant-card")
// .contains("Afghanistan")
// .click();
//
// // submit button & validate
// cy.get(".nc-form")
// .find("button")
// .contains("Submit")
// .click();
//
// cy.get(".ant-alert-message")
// .contains("Congratulations")
// .should("exist")
// .then(() => {
// cy.get(".nc-form").should("exist");
//
// // validate if form has appeared again
// cy.get(".nc-share-form-title")
// .contains("A B C D")
// .should("exist");
// cy.get(".nc-share-form-desc")
// .contains("Some description about form comes here")
// .should("exist");
// });
});
});
it(`Delete ${viewType} view`, () => {
// go back to base page
loginPage.loginAndOpenProject(apiType, dbType);
cy.openTableTab("City", 25);
// number of view entries should be 2 before we delete
cy.get(".nc-view-item").its("length").should("eq", 2);
// click on delete icon (becomes visible on hovering mouse)
cy.get(".nc-view-delete-icon").click({ force: true });
cy.wait(1000);
cy.getActiveModal(".nc-modal-view-delete")
.find(".ant-btn-dangerous")
.should("exist")
.click();
cy.toastWait("View deleted successfully");
// confirm if the number of veiw entries is reduced by 1
cy.get(".nc-view-item").its("length").should("eq", 1);
// // clean up newly added rows into Country table operations
// // this auto verifies successfull addition of rows to table as well
// mainPage.getPagination(25).click();
// // kludge: flicker on load
// cy.wait(3000)
//
// cy.get(".nc-grid-row").should("have.length", 1);
// cy.get(".ant-checkbox").should('exist').eq(1).click({ force: true });
// mainPage.getCell("Country", 1).rightclick({ force: true });
// cy.getActiveMenu()
// .contains("Delete Selected Rows")
// .click({ force: true });
});
};
// below scenario's will be invoked twice, once for rest & then for graphql
viewTest("form");
});
}; };
/** /**

855
scripts/cypress/integration/common/4f_pg_grid_view_share.js

@ -12,455 +12,454 @@ let storedURL = "";
let viewURL = {}; let viewURL = {};
export const genTest = (apiType, dbType) => { export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return; if (!isTestSuiteActive(apiType, dbType)) return;
const generateViewLink = (viewName) => {
// click on share view
// cy.get(".v-navigation-drawer__content > .container")
// .find(".v-list > .v-list-item")
// .contains("Share View")
// .click();
mainPage.shareView().click({ force: true });
cy.wait(5000);
// wait, as URL initially will be /undefined
cy.getActiveModal(".nc-modal-share-view")
.find(".share-link-box")
.contains("/nc/view/", { timeout: 10000 })
.should("exist");
// copy link text, visit URL
cy.getActiveModal(".nc-modal-share-view")
.find(".share-link-box")
.contains("/nc/view/", { timeout: 10000 })
.then(($obj) => {
cy.get("body").type("{esc}");
// viewURL.push($obj.text())
viewURL[viewName] = $obj.text().trim();
});
};
describe(`${apiType.toUpperCase()} api - GRID view (Share)`, () => {
// Run once before test- create project (rest/graphql)
//
before(() => {
cy.fileHook();
mainPage.tabReset();
// open a table to work on views
//
cy.openTableTab("Address", 25);
cy.saveLocalStorage();
});
beforeEach(() => {
cy.restoreLocalStorage();
});
afterEach(() => {
cy.saveLocalStorage();
});
const generateViewLink = (viewName) => { after(() => {
// click on share view // close table
// mainPage.deleteCreatedViews()
cy.closeTableTab("Address");
});
// Common routine to create/edit/delete GRID & GALLERY view
// Input: viewType - 'grid'/'gallery'
//
const viewTest = (viewType) => {
it(`Create ${viewType.toUpperCase()} view`, () => {
// create a normal public view
cy.get(`.nc-create-${viewType}-view`).click();
cy.getActiveModal(".nc-modal-view-create")
.find("button:contains(Submit)")
.click();
cy.toastWait("View created successfully");
// store base URL- to re-visit and delete form view later
cy.url().then((url) => {
storedURL = url;
});
});
it(`Share ${viewType.toUpperCase()} hide, sort, filter & verify`, () => {
cy.get(`.nc-view-item.nc-${viewType}-view-item`)
.contains("Address1")
.click();
mainPage.hideField("Address2");
mainPage.sortField("Address", "Z → A");
mainPage.filterField("Address", "is like", "Ab");
generateViewLink("combined");
cy.log(viewURL["combined"]);
});
it(`Share GRID view : ensure we have only one link even if shared multiple times`, () => {
// generate view link multiple times
generateViewLink("combined");
generateViewLink("combined");
// verify if only one link exists in table
// cy.get(".v-navigation-drawer__content > .container") // cy.get(".v-navigation-drawer__content > .container")
// .find(".v-list > .v-list-item") // .find(".v-list > .v-list-item")
// .contains("Share View") // .contains("Share View")
// .parent()
// .find("button.mdi-dots-vertical")
// .click(); // .click();
mainPage.shareView().click({ force: true }); mainPage.shareViewList().click();
cy.wait(5000); // cy.getActiveMenu().find(".v-list-item").contains("Views List").click();
// wait, as URL initially will be /undefined cy.get('th:contains("View Link")').should("exist");
cy.getActiveModal(".nc-modal-share-view")
.find(".share-link-box") cy.get('th:contains("View Link")')
.contains("/nc/view/", { timeout: 10000 }) .parent()
.should("exist"); .parent()
.next()
// copy link text, visit URL .find("tr")
cy.getActiveModal(".nc-modal-share-view") .its("length")
.find(".share-link-box") .should("eq", 1)
.contains("/nc/view/", { timeout: 10000 }) .then(() => {
.then(($obj) => { // cy.get(".v-overlay__content > .d-flex > .v-icon").click();
cy.get("body").type("{esc}"); // close modal (fix me! add a close button to share view list modal)
// viewURL.push($obj.text()) cy.get(".v-overlay--active > .v-overlay__scrim").click({
viewURL[viewName] = $obj.text().trim(); force: true,
}); });
}; });
});
describe(`${apiType.toUpperCase()} api - GRID view (Share)`, () => {
// Run once before test- create project (rest/graphql)
//
before(() => {
cy.fileHook();
mainPage.tabReset();
// open a table to work on views
//
cy.openTableTab("Address", 25);
cy.saveLocalStorage();
});
beforeEach(() => { it(`Share ${viewType.toUpperCase()} view : Visit URL, Verify title`, () => {
cy.restoreLocalStorage(); // visit public view
cy.visit(viewURL["combined"], {
baseUrl: null,
}); });
cy.wait(5000);
afterEach(() => { // wait for page rendering to complete
cy.saveLocalStorage(); cy.get(".nc-grid-row").should("have.length", 18);
});
// verify title
cy.get("div.model-name").contains("Address1").should("exist");
});
it(`Share ${viewType.toUpperCase()} view : verify fields hidden/open`, () => {
// verify column headers
cy.get('[data-col="Address"]').should("exist");
cy.get('[data-col="Address2"]').should("not.exist");
cy.get('[data-col="District"]').should("exist");
});
it(`Share ${viewType.toUpperCase()} view : verify fields sort/ filter`, () => {
// country column content verification before sort
mainPage
.getCell("Address", 1)
.contains("669 Firozabad Loop")
.should("exist");
mainPage
.getCell("Address", 2)
.contains("48 Maracabo Place")
.should("exist");
mainPage
.getCell("Address", 3)
.contains("44 Najafabad Way")
.should("exist");
});
it(`Share ${viewType.toUpperCase()} view : verify download CSV`, () => {
mainPage.hideField("LastUpdate");
const verifyCsv = (retrievedRecords) => {
// expected output, statically configured
let storedRecords = [
`Address,District,PostalCode,Phone`,
`669 Firozabad Loop,,92265,,[object Object],2,,Kanchrapara,`,
`48 Maracabo Place,,1570,,[object Object],2,,Tafuna,`,
`44 Najafabad Way,,61391,,[object Object],2,,Tambaram,`,
`381 Kabul Way,,87272,,[object Object],1,,Pudukkottai,`,
];
for (let i = 0; i < storedRecords.length; i++) {
let strCol = storedRecords[i].split(",");
let retCol = retrievedRecords[i].split(",");
expect(strCol[0]).to.be.equal(retCol[0]);
expect(strCol[2]).to.be.equal(retCol[2]);
// expect(retrievedRecords[i]).to.be.equal(storedRecords[i])
}
};
after(() => { // download & verify
// close table mainPage.downloadAndVerifyCsv(`Address_exported_1.csv`, verifyCsv);
// mainPage.deleteCreatedViews() mainPage.unhideField("LastUpdate");
cy.closeTableTab("Address"); });
it(`Share ${viewType.toUpperCase()} view : Disable sort`, () => {
// remove sort and validate
mainPage.clearSort();
mainPage
.getCell("Address", 1)
//ncv2@fixme
.contains("669 Firozabad Loop")
//.contains("217 Botshabelo Place")
.should("exist");
});
it(`Share ${viewType.toUpperCase()} view : Enable sort`, () => {
// Sort menu operations (Country Column, Z->A)
mainPage.sortField("Address", "Z → A");
mainPage
.getCell("Address", 1)
.contains("669 Firozabad Loop")
.should("exist");
});
it(`Share ${viewType.toUpperCase()} view : Create Filter`, () => {
// add filter & validate
mainPage.filterField("Address", "is like", "drive");
// wait for page rendering to complete
cy.get(".nc-grid-row").should("have.length", 3);
mainPage
.getCell("Address", 1)
.contains("1888 Kabul Drive")
.should("exist");
});
it(`Share ${viewType.toUpperCase()} view : verify download CSV after local filter`, () => {
mainPage.hideField("LastUpdate");
const verifyCsv = (retrievedRecords) => {
// expected output, statically configured
let storedRecords = [
`Address,District,PostalCode,Phone,Location,Customer List,Staff List,City,Staff List`,
`1888 Kabul Drive,,20936,,1,,Ife,,`,
`1661 Abha Drive,,14400,,1,,Pudukkottai,,`,
];
// for (let i = 0; i < storedRecords.length; i++) {
// expect(retrievedRecords[i]).to.be.equal(storedRecords[i])
// }
for (let i = 0; i < storedRecords.length; i++) {
let strCol = storedRecords[i].split(",");
let retCol = retrievedRecords[i].split(",");
expect(strCol[0]).to.be.equal(retCol[0]);
expect(strCol[2]).to.be.equal(retCol[2]);
}
};
mainPage.downloadAndVerifyCsv(`Address_exported_1.csv`, verifyCsv);
mainPage.unhideField("LastUpdate");
});
it(`Share ${viewType.toUpperCase()} view : Delete Filter`, () => {
// Remove sort and Validate
mainPage.filterReset();
mainPage
.getCell("Address", 1)
.contains("669 Firozabad Loop")
.should("exist");
});
it(`Share GRID view : Virtual column validation > has many`, () => {
// verify column headers
cy.get('[data-col="Customer List"]').should("exist");
cy.get('[data-col="Staff List"]').should("exist");
cy.get('[data-col="City"]').should("exist");
cy.get('[data-col="Staff List"]').should("exist");
// has many field validation
mainPage
.getCell("Customer List", 3)
.click()
.find("button.mdi-close-thick")
.should("not.exist");
mainPage
.getCell("Customer List", 3)
.click()
.find("button.mdi-plus")
.should("not.exist");
mainPage
.getCell("Customer List", 3)
.click()
.find("button.mdi-arrow-expand")
.click();
cy.getActiveModal(".nc-modal-child-list")
.find("button.mdi-reload")
.should("exist");
cy.getActiveModal(".nc-modal-child-list")
.find("button")
.contains("Link to")
.should("not.exist");
cy.getActiveModal(".nc-modal-child-list")
.find(".child-card")
.contains("2")
.should("exist");
cy.getActiveModal(".nc-modal-child-list")
.find(".child-card")
.find("button")
.should("not.exist");
cy.get("body").type("{esc}");
});
it(`Share GRID view : Virtual column validation > belongs to`, () => {
// belongs to field validation
mainPage
.getCell("City", 1)
.click()
.find("button.mdi-close-thick")
.should("not.exist");
mainPage
.getCell("City", 1)
.click()
.find("button.mdi-arrow-expand")
.should("not.exist");
mainPage
.getCell("City", 1)
.find(".v-chip")
.contains("al-Ayn")
.should("exist");
});
it(`Share GRID view : Virtual column validation > many to many`, () => {
// many-to-many field validation
mainPage
.getCell("Staff List", 1)
.click()
.find("button.mdi-close-thick")
.should("not.exist");
mainPage
.getCell("Staff List", 1)
.click()
.find("button.mdi-plus")
.should("not.exist");
mainPage
.getCell("Staff List", 1)
.click()
.find("button.mdi-arrow-expand")
.click();
cy.getActiveModal(".nc-modal-child-list")
.find("button.mdi-reload")
.should("exist");
cy.getActiveModal(".nc-modal-child-list")
.find("button")
.contains("Link to")
.should("not.exist");
cy.get("body").type("{esc}");
});
it(`Delete ${viewType.toUpperCase()} view`, () => {
// go back to base page
cy.visit(storedURL, {
baseUrl: null,
}); });
cy.wait(5000);
// Common routine to create/edit/delete GRID & GALLERY view // number of view entries should be 2 before we delete
// Input: viewType - 'grid'/'gallery' cy.get(".nc-view-item").its("length").should("eq", 2);
//
const viewTest = (viewType) => {
it(`Create ${viewType.toUpperCase()} view`, () => {
// create a normal public view
cy.get(`.nc-create-${viewType}-view`).click();
cy.getActiveModal(".nc-modal-view-create").find("button:contains(Submit)").click();
cy.toastWait("View created successfully");
// store base URL- to re-visit and delete form view later
cy.url().then((url) => {
storedURL = url;
});
});
it(`Share ${viewType.toUpperCase()} hide, sort, filter & verify`, () => {
cy.get(`.nc-view-item.nc-${viewType}-view-item`)
.contains("Address1")
.click();
mainPage.hideField("Address2");
mainPage.sortField("Address", "Z → A");
mainPage.filterField("Address", "is like", "Ab");
generateViewLink("combined");
cy.log(viewURL["combined"]);
});
it(`Share GRID view : ensure we have only one link even if shared multiple times`, () => {
// generate view link multiple times
generateViewLink("combined");
generateViewLink("combined");
// verify if only one link exists in table
// cy.get(".v-navigation-drawer__content > .container")
// .find(".v-list > .v-list-item")
// .contains("Share View")
// .parent()
// .find("button.mdi-dots-vertical")
// .click();
mainPage.shareViewList().click();
// cy.getActiveMenu().find(".v-list-item").contains("Views List").click();
cy.get('th:contains("View Link")').should("exist");
cy.get('th:contains("View Link")')
.parent()
.parent()
.next()
.find("tr")
.its("length")
.should("eq", 1)
.then(() => {
// cy.get(".v-overlay__content > .d-flex > .v-icon").click();
// close modal (fix me! add a close button to share view list modal)
cy.get(".v-overlay--active > .v-overlay__scrim").click({
force: true,
});
});
});
it(`Share ${viewType.toUpperCase()} view : Visit URL, Verify title`, () => {
// visit public view
cy.visit(viewURL["combined"], {
baseUrl: null,
});
cy.wait(5000);
// wait for page rendering to complete
cy.get(".nc-grid-row").should("have.length", 18);
// verify title
cy.get("div.model-name").contains("Address1").should("exist");
});
it(`Share ${viewType.toUpperCase()} view : verify fields hidden/open`, () => {
// verify column headers
cy.get('[data-col="Address"]').should("exist");
cy.get('[data-col="Address2"]').should("not.exist");
cy.get('[data-col="District"]').should("exist");
});
it(`Share ${viewType.toUpperCase()} view : verify fields sort/ filter`, () => {
// country column content verification before sort
mainPage
.getCell("Address", 1)
.contains("669 Firozabad Loop")
.should("exist");
mainPage
.getCell("Address", 2)
.contains("48 Maracabo Place")
.should("exist");
mainPage
.getCell("Address", 3)
.contains("44 Najafabad Way")
.should("exist");
});
it(`Share ${viewType.toUpperCase()} view : verify download CSV`, () => {
mainPage.hideField("LastUpdate");
const verifyCsv = (retrievedRecords) => {
// expected output, statically configured
let storedRecords = [
`Address,District,PostalCode,Phone`,
`669 Firozabad Loop,,92265,,[object Object],2,,Kanchrapara,`,
`48 Maracabo Place,,1570,,[object Object],2,,Tafuna,`,
`44 Najafabad Way,,61391,,[object Object],2,,Tambaram,`,
`381 Kabul Way,,87272,,[object Object],1,,Pudukkottai,`,
];
for (let i = 0; i < storedRecords.length; i++) {
let strCol = storedRecords[i].split(",");
let retCol = retrievedRecords[i].split(",");
expect(strCol[0]).to.be.equal(retCol[0]);
expect(strCol[2]).to.be.equal(retCol[2]);
// expect(retrievedRecords[i]).to.be.equal(storedRecords[i])
}
};
// download & verify
mainPage.downloadAndVerifyCsv(
`Address_exported_1.csv`,
verifyCsv
);
mainPage.unhideField("LastUpdate");
});
it(`Share ${viewType.toUpperCase()} view : Disable sort`, () => {
// remove sort and validate
mainPage.clearSort();
mainPage
.getCell("Address", 1)
//ncv2@fixme
.contains("669 Firozabad Loop")
//.contains("217 Botshabelo Place")
.should("exist");
});
it(`Share ${viewType.toUpperCase()} view : Enable sort`, () => {
// Sort menu operations (Country Column, Z->A)
mainPage.sortField("Address", "Z → A");
mainPage
.getCell("Address", 1)
.contains("669 Firozabad Loop")
.should("exist");
});
it(`Share ${viewType.toUpperCase()} view : Create Filter`, () => {
// add filter & validate
mainPage.filterField("Address", "is like", "drive");
// wait for page rendering to complete
cy.get(".nc-grid-row").should("have.length", 3);
mainPage
.getCell("Address", 1)
.contains("1888 Kabul Drive")
.should("exist");
});
it(`Share ${viewType.toUpperCase()} view : verify download CSV after local filter`, () => {
mainPage.hideField("LastUpdate");
const verifyCsv = (retrievedRecords) => {
// expected output, statically configured
let storedRecords = [
`Address,District,PostalCode,Phone,Location,Customer List,Staff List,City,Staff List`,
`1888 Kabul Drive,,20936,,1,,Ife,,`,
`1661 Abha Drive,,14400,,1,,Pudukkottai,,`,
];
// for (let i = 0; i < storedRecords.length; i++) {
// expect(retrievedRecords[i]).to.be.equal(storedRecords[i])
// }
for (let i = 0; i < storedRecords.length; i++) {
let strCol = storedRecords[i].split(",");
let retCol = retrievedRecords[i].split(",");
expect(strCol[0]).to.be.equal(retCol[0]);
expect(strCol[2]).to.be.equal(retCol[2]);
}
};
mainPage.downloadAndVerifyCsv(
`Address_exported_1.csv`,
verifyCsv
);
mainPage.unhideField("LastUpdate");
});
it(`Share ${viewType.toUpperCase()} view : Delete Filter`, () => {
// Remove sort and Validate
mainPage.filterReset();
mainPage
.getCell("Address", 1)
.contains("669 Firozabad Loop")
.should("exist");
});
it(`Share GRID view : Virtual column validation > has many`, () => {
// verify column headers
cy.get('[data-col="Customer List"]').should("exist");
cy.get('[data-col="Staff List"]').should("exist");
cy.get('[data-col="City"]').should("exist");
cy.get('[data-col="Staff List"]').should("exist");
// has many field validation
mainPage
.getCell("Customer List", 3)
.click()
.find("button.mdi-close-thick")
.should("not.exist");
mainPage
.getCell("Customer List", 3)
.click()
.find("button.mdi-plus")
.should("not.exist");
mainPage
.getCell("Customer List", 3)
.click()
.find("button.mdi-arrow-expand")
.click();
cy.getActiveModal(".nc-modal-child-list").find("button.mdi-reload").should("exist");
cy.getActiveModal(".nc-modal-child-list")
.find("button")
.contains("Link to")
.should("not.exist");
cy.getActiveModal(".nc-modal-child-list")
.find(".child-card")
.contains("2")
.should("exist");
cy.getActiveModal(".nc-modal-child-list")
.find(".child-card")
.find("button")
.should("not.exist");
cy.get("body").type("{esc}");
});
it(`Share GRID view : Virtual column validation > belongs to`, () => {
// belongs to field validation
mainPage
.getCell("City", 1)
.click()
.find("button.mdi-close-thick")
.should("not.exist");
mainPage
.getCell("City", 1)
.click()
.find("button.mdi-arrow-expand")
.should("not.exist");
mainPage
.getCell("City", 1)
.find(".v-chip")
.contains("al-Ayn")
.should("exist");
});
it(`Share GRID view : Virtual column validation > many to many`, () => {
// many-to-many field validation
mainPage
.getCell("Staff List", 1)
.click()
.find("button.mdi-close-thick")
.should("not.exist");
mainPage
.getCell("Staff List", 1)
.click()
.find("button.mdi-plus")
.should("not.exist");
mainPage
.getCell("Staff List", 1)
.click()
.find("button.mdi-arrow-expand")
.click();
cy.getActiveModal(".nc-modal-child-list").find("button.mdi-reload").should("exist");
cy.getActiveModal(".nc-modal-child-list")
.find("button")
.contains("Link to")
.should("not.exist");
cy.get("body").type("{esc}");
});
it(`Delete ${viewType.toUpperCase()} view`, () => {
// go back to base page
cy.visit(storedURL, {
baseUrl: null,
});
cy.wait(5000);
// number of view entries should be 2 before we delete
cy.get(".nc-view-item").its("length").should("eq", 2);
cy.get(".nc-view-delete-icon").eq(0).click({ force: true }); cy.get(".nc-view-delete-icon").eq(0).click({ force: true });
cy.toastWait("View deleted successfully"); cy.toastWait("View deleted successfully");
// confirm if the number of veiw entries is reduced by 1 // confirm if the number of veiw entries is reduced by 1
cy.get(".nc-view-item").its("length").should("eq", 1); cy.get(".nc-view-item").its("length").should("eq", 1);
}); });
}; };
// below scenario's will be invoked twice, once for rest & then for graphql // below scenario's will be invoked twice, once for rest & then for graphql
viewTest("grid"); viewTest("grid");
});
describe(`${apiType.toUpperCase()} api - Grid view/ row-column update verification`, () => {
before(() => {
cy.fileHook();
// Address table has belongs to, has many & many-to-many
cy.openTableTab("Country", 25);
cy.saveLocalStorage();
// store base URL- to re-visit and delete form view later
cy.url().then((url) => {
storedURL = url;
generateViewLink("rowColUpdate");
});
}); });
describe(`${apiType.toUpperCase()} api - Grid view/ row-column update verification`, () => { after(() => {
before(() => { // close table
cy.fileHook(); cy.restoreLocalStorage();
// Address table has belongs to, has many & many-to-many cy.visit(storedURL, {
cy.openTableTab("Country", 25); baseUrl: null,
});
cy.saveLocalStorage(); cy.wait(5000);
// store base URL- to re-visit and delete form view later
cy.url().then((url) => { // delete row
storedURL = url; mainPage.getPagination(5).click();
generateViewLink("rowColUpdate"); // kludge: flicker on load
}); cy.wait(3000);
});
// wait for page rendering to complete
after(() => { cy.get(".nc-grid-row").should("have.length", 10);
// close table mainPage
cy.restoreLocalStorage(); .getRow(10)
cy.visit(storedURL, { .find(".mdi-checkbox-blank-outline")
baseUrl: null, .click({ force: true });
}); mainPage.getCell("Country", 10).rightclick();
cy.wait(5000); cy.getActiveMenu(".nc-dropdown-grid-context-menu")
.contains("Delete Selected Row")
// delete row .click();
mainPage.getPagination(5).click();
// kludge: flicker on load // delete column
cy.wait(3000) cy.get(`th:contains('dummy') .mdi-menu-down`)
.trigger("mouseover")
// wait for page rendering to complete .click();
cy.get(".nc-grid-row").should("have.length", 10); cy.get(".nc-column-delete").click();
mainPage cy.get("button:contains(Confirm)").click();
.getRow(10)
.find(".mdi-checkbox-blank-outline") cy.toastWait("Update table successful");
.click({ force: true });
mainPage.getCell("Country", 10).rightclick(); mainPage.deleteCreatedViews();
cy.getActiveMenu(".nc-dropdown-grid-context-menu").contains("Delete Selected Row").click();
// close table
// delete column cy.closeTableTab("Country");
cy.get(`th:contains('dummy') .mdi-menu-down`) });
.trigger("mouseover")
.click();
cy.get(".nc-column-delete").click();
cy.get("button:contains(Confirm)").click();
cy.toastWait("Update table successful");
mainPage.deleteCreatedViews();
// close table
cy.closeTableTab("Country");
});
it(`Generate default Shared GRID view URL`, () => {
// add row
cy.get(".nc-add-new-row-btn").click();
cy.get("#data-table-form-Country > input")
.first()
.click()
.type("a");
cy.contains("Save row").filter("button").click({ force: true });
cy.toastWait("updated successfully");
// add column
mainPage.addColumn("dummy", "Country");
// visit public view
cy.log(viewURL["rowColUpdate"]);
cy.restoreLocalStorage();
cy.visit(viewURL["rowColUpdate"], {
baseUrl: null,
});
cy.wait(5000);
//5 it(`Generate default Shared GRID view URL`, () => {
// wait for public view page to load! // add row
// wait for page rendering to complete cy.get(".nc-add-new-row-btn").click();
cy.get(".nc-grid-row").should("have.length", 25); cy.get("#data-table-form-Country > input").first().click().type("a");
}); cy.contains("Save row").filter("button").click({ force: true });
cy.toastWait("updated successfully");
// add column
mainPage.addColumn("dummy", "Country");
// visit public view
cy.log(viewURL["rowColUpdate"]);
cy.restoreLocalStorage();
cy.visit(viewURL["rowColUpdate"], {
baseUrl: null,
});
cy.wait(5000);
//5
// wait for public view page to load!
// wait for page rendering to complete
cy.get(".nc-grid-row").should("have.length", 25);
});
it(`Share GRID view : new row visible`, () => { it(`Share GRID view : new row visible`, () => {
// verify row // verify row
cy.get(`.v-pagination > li:contains('5') button`).click(); cy.get(`.v-pagination > li:contains('5') button`).click();
// wait for page rendering to complete // wait for page rendering to complete
cy.get(".nc-grid-row").should("have.length", 10); cy.get(".nc-grid-row").should("have.length", 10);
mainPage.getCell("Country", 10).contains("a").should("exist"); mainPage.getCell("Country", 10).contains("a").should("exist");
}); });
it.skip(`Share GRID view : new column visible`, () => { it.skip(`Share GRID view : new column visible`, () => {
// verify column headers // verify column headers
cy.get('[data-col="dummy"]').should("exist"); cy.get('[data-col="dummy"]').should("exist");
});
}); });
});
}; };
/** /**

118
scripts/cypress/integration/common/4g_table_view_expanded_form.js

@ -1,6 +1,6 @@
import { isTestSuiteActive } from '../../support/page_objects/projectConstants'; import { isTestSuiteActive } from "../../support/page_objects/projectConstants";
import { loginPage } from '../../support/page_objects/navigation'; import { loginPage } from "../../support/page_objects/navigation";
import { mainPage } from '../../support/page_objects/mainPage'; import { mainPage } from "../../support/page_objects/mainPage";
function capitalizeFirstLetter(string) { function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1); return string.charAt(0).toUpperCase() + string.slice(1);
@ -17,7 +17,7 @@ function capitalizeFirstLetter(string) {
function verifyExpandFormHeader(title) { function verifyExpandFormHeader(title) {
cy.get( cy.get(
`.nc-drawer-expanded-form .nc-expanded-form-header :contains("${title}")` `.nc-drawer-expanded-form .nc-expanded-form-header :contains("${title}")`
).should('exist'); ).should("exist");
} }
export const genTest = (apiType, dbType) => { export const genTest = (apiType, dbType) => {
@ -29,7 +29,7 @@ export const genTest = (apiType, dbType) => {
// open a table to work on views // open a table to work on views
// //
cy.openTableTab('Country', 25); cy.openTableTab("Country", 25);
}); });
beforeEach(() => { beforeEach(() => {
@ -42,7 +42,7 @@ export const genTest = (apiType, dbType) => {
after(() => { after(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
cy.closeTableTab('Country'); cy.closeTableTab("Country");
cy.saveLocalStorage(); cy.saveLocalStorage();
}); });
@ -55,27 +55,27 @@ export const genTest = (apiType, dbType) => {
cy.get(`.nc-create-${viewType}-view`).click(); cy.get(`.nc-create-${viewType}-view`).click();
// Pop up window, click Submit (accepting default name for view) // Pop up window, click Submit (accepting default name for view)
cy.getActiveModal('.nc-modal-view-create') cy.getActiveModal(".nc-modal-view-create")
.find('.ant-btn-primary') .find(".ant-btn-primary")
.click(); .click();
cy.toastWait('View created successfully'); cy.toastWait("View created successfully");
// validate if view was created && contains default name 'Country1' // validate if view was created && contains default name 'Country1'
cy.get(`.nc-${viewType}-view-item`) cy.get(`.nc-${viewType}-view-item`)
.contains(`${capitalizeFirstLetter(viewType)}-1`) .contains(`${capitalizeFirstLetter(viewType)}-1`)
.should('exist'); .should("exist");
if (viewType === 'gallery') { if (viewType === "gallery") {
// cy.intercept('/api/v1/db/meta/galleries/*').as('getGalleryView'); // cy.intercept('/api/v1/db/meta/galleries/*').as('getGalleryView');
// mainPage.unhideField("City List"); // mainPage.unhideField("City List");
cy.get('.nc-fields-menu-btn').click(); cy.get(".nc-fields-menu-btn").click();
cy.getActiveMenu('.nc-dropdown-fields-menu') cy.getActiveMenu(".nc-dropdown-fields-menu")
.find(`.nc-fields-list label:contains("City List"):visible`) .find(`.nc-fields-list label:contains("City List"):visible`)
.click(); .click();
cy.get('.nc-fields-menu-btn').click(); cy.get(".nc-fields-menu-btn").click();
cy.get('.ant-card-body [title="City List"]').should('exist'); cy.get('.ant-card-body [title="City List"]').should("exist");
cy.wait(1000); cy.wait(1000);
// cy.wait(['@getGalleryView']) // cy.wait(['@getGalleryView'])
} }
@ -83,64 +83,64 @@ export const genTest = (apiType, dbType) => {
it(`Expand a row in ${viewType} and verify url`, () => { it(`Expand a row in ${viewType} and verify url`, () => {
// click on first row-expand if grid & first card if its gallery // click on first row-expand if grid & first card if its gallery
if (viewType === 'grid') { if (viewType === "grid") {
cy.get('.nc-row-expand').first().click({ force: true }); cy.get(".nc-row-expand").first().click({ force: true });
} else if (viewType === 'gallery') { } else if (viewType === "gallery") {
cy.get('.nc-gallery-container .ant-card').first().click(); cy.get(".nc-gallery-container .ant-card").first().click();
} }
// ensure expand draw is open // ensure expand draw is open
verifyExpandFormHeader('Afghanistan'); verifyExpandFormHeader("Afghanistan");
cy.url().should('include', 'rowId=1'); cy.url().should("include", "rowId=1");
// spy on clipboard to verify copied text // spy on clipboard to verify copied text
// creating alias for clipboard // creating alias for clipboard
cy.window().then((win) => { cy.window().then((win) => {
cy.spy(win.navigator.clipboard, 'writeText').as('copy'); cy.spy(win.navigator.clipboard, "writeText").as("copy");
}); });
// copy url // copy url
cy.getActiveDrawer('.nc-drawer-expanded-form') cy.getActiveDrawer(".nc-drawer-expanded-form")
.should('exist') .should("exist")
.find('.nc-copy-row-url') .find(".nc-copy-row-url")
.click(); .click();
// use alias; verify if clipboard was called with correct text // use alias; verify if clipboard was called with correct text
cy.get('@copy').should('be.calledWithMatch', `?rowId=1`); cy.get("@copy").should("be.calledWithMatch", `?rowId=1`);
// close expanded form // close expanded form
cy.getActiveDrawer('.nc-drawer-expanded-form') cy.getActiveDrawer(".nc-drawer-expanded-form")
.find('.nc-expand-form-close-btn') .find(".nc-expand-form-close-btn")
.click(); .click();
}); });
it(`Visit a ${viewType} row url and verify expanded form`, () => { it(`Visit a ${viewType} row url and verify expanded form`, () => {
cy.url().then((url) => { cy.url().then((url) => {
cy.visit( cy.visit(
'/' + url.split('/').slice(3).join('/').split('?')[0] + '?rowId=2' "/" + url.split("/").slice(3).join("/").split("?")[0] + "?rowId=2"
); );
verifyExpandFormHeader('Algeria'); verifyExpandFormHeader("Algeria");
}); });
}); });
it(`Visit an invalid ${viewType} row url and verify expanded form`, () => { it(`Visit an invalid ${viewType} row url and verify expanded form`, () => {
cy.url().then((url) => { cy.url().then((url) => {
cy.visit( cy.visit(
'/' + "/" +
url.split('/').slice(3).join('/').split('?')[0] + url.split("/").slice(3).join("/").split("?")[0] +
'?rowId=99999999' "?rowId=99999999"
); );
cy.toastWait('Record not found'); cy.toastWait("Record not found");
cy.get(`.nc-drawer-expanded-form .ant-drawer-content:visible`).should( cy.get(`.nc-drawer-expanded-form .ant-drawer-content:visible`).should(
'not.exist' "not.exist"
); );
// defaults to corresponding grid / gallery view // defaults to corresponding grid / gallery view
cy.get(viewType === 'grid' ? '.nc-grid' : '.nc-gallery').should( cy.get(viewType === "grid" ? ".nc-grid" : ".nc-gallery").should(
'exist' "exist"
); );
}); });
}); });
@ -148,54 +148,54 @@ export const genTest = (apiType, dbType) => {
it(`Visit a ${viewType} row url and verify nested expanded form`, () => { it(`Visit a ${viewType} row url and verify nested expanded form`, () => {
cy.url().then((url) => { cy.url().then((url) => {
cy.visit( cy.visit(
'/' + url.split('/').slice(3).join('/').split('?')[0] + '?rowId=1' "/" + url.split("/").slice(3).join("/").split("?")[0] + "?rowId=1"
); );
verifyExpandFormHeader('Afghanistan'); verifyExpandFormHeader("Afghanistan");
cy.get('.nc-drawer-expanded-form .ant-drawer-content').should( cy.get(".nc-drawer-expanded-form .ant-drawer-content").should(
'exist' "exist"
); );
cy.getActiveDrawer('.nc-drawer-expanded-form') cy.getActiveDrawer(".nc-drawer-expanded-form")
.find('.ant-card-body') .find(".ant-card-body")
.first() .first()
.click(); .click();
cy.get('.nc-drawer-expanded-form .ant-drawer-content').should( cy.get(".nc-drawer-expanded-form .ant-drawer-content").should(
'have.length', "have.length",
2 2
); );
cy.wait(1000); cy.wait(1000);
verifyExpandFormHeader('Kabul'); verifyExpandFormHeader("Kabul");
// close expanded forms // close expanded forms
cy.getActiveDrawer('.nc-drawer-expanded-form') cy.getActiveDrawer(".nc-drawer-expanded-form")
.find('.ant-btn') .find(".ant-btn")
.contains('Cancel') .contains("Cancel")
.click(); .click();
verifyExpandFormHeader('Afghanistan'); verifyExpandFormHeader("Afghanistan");
cy.getActiveDrawer('.nc-drawer-expanded-form') cy.getActiveDrawer(".nc-drawer-expanded-form")
.find('.ant-btn') .find(".ant-btn")
.contains('Cancel') .contains("Cancel")
.click(); .click();
}); });
}); });
it('Delete view', () => { it("Delete view", () => {
cy.get('.nc-view-delete-icon').click({ force: true }); cy.get(".nc-view-delete-icon").click({ force: true });
cy.getActiveModal('.nc-modal-view-delete') cy.getActiveModal(".nc-modal-view-delete")
.find('.ant-btn-dangerous') .find(".ant-btn-dangerous")
.click(); .click();
cy.toastWait('View deleted successfully'); cy.toastWait("View deleted successfully");
}); });
}; };
// viewTest("grid"); // grid view // viewTest("grid"); // grid view
viewTest('gallery'); // gallery view viewTest("gallery"); // gallery view
}); });
}; };

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

@ -1,285 +1,266 @@
import { loginPage, projectsPage } from "../../support/page_objects/navigation"; import { loginPage, projectsPage } from "../../support/page_objects/navigation";
import { mainPage, settingsPage } from "../../support/page_objects/mainPage"; import { mainPage, settingsPage } from "../../support/page_objects/mainPage";
import { import {
isPostgres, isPostgres,
isXcdb, isXcdb,
roles, roles,
staticProjects, staticProjects,
} from "../../support/page_objects/projectConstants"; } from "../../support/page_objects/projectConstants";
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"; import { isTestSuiteActive } from "../../support/page_objects/projectConstants";
import { import {
_advSettings, _advSettings,
_editSchema, _editSchema,
_editData, _editData,
_editComment, _editComment,
_viewMenu, _viewMenu,
_topRightMenu, _topRightMenu,
disableTableAccess, disableTableAccess,
_accessControl, _accessControl,
} from "../spec/roleValidation.spec"; } from "../spec/roleValidation.spec";
export const genTest = (apiType, dbType) => { export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return; if (!isTestSuiteActive(apiType, dbType)) return;
describe("Static user creations (different roles)", () => { describe("Static user creations (different roles)", () => {
before(() => { before(() => {
// standalone test // standalone test
// loginPage.loginAndOpenProject(apiType, dbType); // loginPage.loginAndOpenProject(apiType, dbType);
// open a table to work on views // open a table to work on views
// //
cy.restoreLocalStorage(); cy.restoreLocalStorage();
settingsPage.openMenu(settingsPage.TEAM_N_AUTH) settingsPage.openMenu(settingsPage.TEAM_N_AUTH);
}); });
beforeEach(() => { beforeEach(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
}); });
afterEach(() => { afterEach(() => {
cy.saveLocalStorage(); cy.saveLocalStorage();
})
after(() => {
cy.restoreLocalStorage();
cy.signOut();
cy.saveLocalStorage();
});
const addUser = (user) => {
it(`RoleType: ${user.name}`, () => {
// for first project, users need to be added explicitly using "New User" button
// for subsequent projects, they will be required to just add to this project
// using ROW count to identify if its former or latter scenario
// 5 users (owner, creator, editor, viewer, commenter) = 5
// cy.get(`.nc-user-row`).then((obj) => {
// cy.log(obj.length);
// if (obj.length == 5) {
// mainPage.addExistingUserToProject(
// user.credentials.username,
// user.name
// );
// } else {
// mainPage.addNewUserToProject(
// user.credentials,
// user.name
// );
// }
// });
cy.get(`.nc-user-row`).should('exist')
mainPage.addNewUserToProject(
user.credentials,
user.name
);
});
};
addUser(roles.creator);
addUser(roles.editor);
addUser(roles.commenter);
addUser(roles.viewer);
// Access control list- configuration
//
it(`Access control list- configuration`, () => {
mainPage.closeMetaTab();
// open Project metadata tab
//
settingsPage.openMenu(settingsPage.PROJ_METADATA);
settingsPage.openTab(settingsPage.UI_ACCESS_CONTROL);
// validate if it has 19 entries representing tables & views
if (isPostgres())
cy.get(".nc-acl-table-row").should("have.length", 24);
else if (isXcdb())
cy.get(".nc-acl-table-row").should("have.length", 19);
else cy.get(".nc-acl-table-row").should("have.length", 19);
// disable table & view access
//
disableTableAccess("Language", "editor");
disableTableAccess("Language", "commenter");
disableTableAccess("Language", "viewer");
disableTableAccess("CustomerList", "editor");
disableTableAccess("CustomerList", "commenter");
disableTableAccess("CustomerList", "viewer");
cy.get("button.nc-acl-save").click({ force: true });
cy.toastWait("Updated UI ACL for tables successfully");
mainPage.closeMetaTab();
});
}); });
const roleValidation = (roleType) => { after(() => {
describe(`User role validation`, () => { cy.restoreLocalStorage();
cy.signOut();
before(() => { cy.saveLocalStorage();
cy.restoreLocalStorage(); });
cy.visit(mainPage.roleURL[roleType])
cy.wait(5000); const addUser = (user) => {
it(`RoleType: ${user.name}`, () => {
cy.get('button:contains("SIGN UP")').should('exist') // for first project, users need to be added explicitly using "New User" button
cy.get('input[type="text"]', { timeout: 20000 }).type( // for subsequent projects, they will be required to just add to this project
roles[roleType].credentials.username // using ROW count to identify if its former or latter scenario
); // 5 users (owner, creator, editor, viewer, commenter) = 5
cy.get('input[type="password"]').type(roles[roleType].credentials.password); // cy.get(`.nc-user-row`).then((obj) => {
cy.get('button:contains("SIGN UP")').click(); // cy.log(obj.length);
// if (obj.length == 5) {
cy.wait(3000); // mainPage.addExistingUserToProject(
// user.credentials.username,
cy.get('.nc-project-page-title').contains("My Projects").should("be.visible"); // user.name
// );
if (dbType === "xcdb") { // } else {
if ("rest" == apiType) // mainPage.addNewUserToProject(
projectsPage.openProject( // user.credentials,
staticProjects.sampleREST.basic.name // user.name
); // );
else // }
projectsPage.openProject( // });
staticProjects.sampleGQL.basic.name
); cy.get(`.nc-user-row`).should("exist");
} else if (dbType === "mysql") { mainPage.addNewUserToProject(user.credentials, user.name);
if ("rest" == apiType) });
projectsPage.openProject(
staticProjects.externalREST.basic.name
);
else
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") {
// kludge: wait for page load to finish
// close team & auth tab
cy.wait(2000);
cy.get('button.ant-tabs-tab-remove').should('exist').click();
cy.wait(1000);
}
cy.saveLocalStorage();
})
beforeEach(() => {
cy.restoreLocalStorage();
});
afterEach(() => {
cy.saveLocalStorage();
})
after(() => {
cy.restoreLocalStorage();
cy.signOut();
cy.saveLocalStorage();
});
///////////////////////////////////////////////////////
// Test suite
it(`[${roles[roleType].name}] Left navigation menu, New User add`, () => {
// project configuration settings
//
_advSettings(roleType, "userRole");
});
it(`[${roles[roleType].name}] Access control`, () => {
// Access control validation
//
_accessControl(roleType, "userRole");
});
it(`[${roles[roleType].name}] Schema: create table, add/modify/delete column`, () => {
// Schema related validations
// - Add/delete table
// - Add/Update/delete column
//
_editSchema(roleType, "userRole");
});
it(`[${roles[roleType].name}] Data: add/modify/delete row, update cell contents`, () => {
// Table data related validations
// - Add/delete/modify row
//
_editData(roleType, "userRole");
});
it(`[${roles[roleType].name}] Comments: view/add`, () => {
// read &/ update comment
// Viewer: only allowed to read
// Everyone else: read &/ update
//
_editComment(roleType, "userRole");
});
it(`[${roles[roleType].name}] Right navigation menu, share view`, () => {
// right navigation menu bar
// Editor/Viewer/Commenter : can only view 'existing' views
// Rest: can create/edit
_viewMenu(roleType, "userRole");
});
it(`[${roles[roleType].name}] Download files`, () => {
// to be fixed
if(roleType === 'commenter' || roleType === 'viewer') {}
else {
// viewer & commenter doesn't contain hideField option in ncv2
// #ID, City, LastUpdate, City => Address, Country <= City, +
mainPage.hideField("LastUpdate");
const verifyCsv = (retrievedRecords) => {
// expected output, statically configured
let storedRecords = [
`City,Address List,Country`,
`A Corua (La Corua),939 Probolinggo Loop,Spain`,
`Abha,733 Mandaluyong Place,Saudi Arabia`,
`Abu Dhabi,535 Ahmadnagar Manor,United Arab Emirates`,
`Acua,1789 Saint-Denis Parkway,Mexico`,
];
// skip if xcdb
if (!isXcdb()) {
for (let i = 0; i < storedRecords.length; i++) {
// cy.log(retrievedRecords[i])
expect(retrievedRecords[i]).to.be.equal(
storedRecords[i]
);
}
}
};
// download & verify
mainPage.downloadAndVerifyCsv(
`City_exported_1.csv`,
verifyCsv,
roleType
);
mainPage.unhideField("LastUpdate");
}
});
});
}; };
// skip owner validation as rest of the cases pretty much cover the same addUser(roles.creator);
// roleValidation('owner') addUser(roles.editor);
roleValidation("creator"); addUser(roles.commenter);
roleValidation("editor"); addUser(roles.viewer);
roleValidation("commenter");
roleValidation("viewer"); // Access control list- configuration
//
it(`Access control list- configuration`, () => {
mainPage.closeMetaTab();
// open Project metadata tab
//
settingsPage.openMenu(settingsPage.PROJ_METADATA);
settingsPage.openTab(settingsPage.UI_ACCESS_CONTROL);
// validate if it has 19 entries representing tables & views
if (isPostgres()) cy.get(".nc-acl-table-row").should("have.length", 24);
else if (isXcdb()) cy.get(".nc-acl-table-row").should("have.length", 19);
else cy.get(".nc-acl-table-row").should("have.length", 19);
// disable table & view access
//
disableTableAccess("Language", "editor");
disableTableAccess("Language", "commenter");
disableTableAccess("Language", "viewer");
disableTableAccess("CustomerList", "editor");
disableTableAccess("CustomerList", "commenter");
disableTableAccess("CustomerList", "viewer");
cy.get("button.nc-acl-save").click({ force: true });
cy.toastWait("Updated UI ACL for tables successfully");
mainPage.closeMetaTab();
});
});
const roleValidation = (roleType) => {
describe(`User role validation`, () => {
before(() => {
cy.restoreLocalStorage();
cy.visit(mainPage.roleURL[roleType]);
cy.wait(5000);
cy.get('button:contains("SIGN UP")').should("exist");
cy.get('input[type="text"]', { timeout: 20000 }).type(
roles[roleType].credentials.username
);
cy.get('input[type="password"]').type(
roles[roleType].credentials.password
);
cy.get('button:contains("SIGN UP")').click();
cy.wait(3000);
cy.get(".nc-project-page-title")
.contains("My Projects")
.should("be.visible");
if (dbType === "xcdb") {
if ("rest" == apiType)
projectsPage.openProject(staticProjects.sampleREST.basic.name);
else projectsPage.openProject(staticProjects.sampleGQL.basic.name);
} else if (dbType === "mysql") {
if ("rest" == apiType)
projectsPage.openProject(staticProjects.externalREST.basic.name);
else 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") {
// kludge: wait for page load to finish
// close team & auth tab
cy.wait(2000);
cy.get("button.ant-tabs-tab-remove").should("exist").click();
cy.wait(1000);
}
cy.saveLocalStorage();
});
beforeEach(() => {
cy.restoreLocalStorage();
});
afterEach(() => {
cy.saveLocalStorage();
});
after(() => {
cy.restoreLocalStorage();
cy.signOut();
cy.saveLocalStorage();
});
///////////////////////////////////////////////////////
// Test suite
it(`[${roles[roleType].name}] Left navigation menu, New User add`, () => {
// project configuration settings
//
_advSettings(roleType, "userRole");
});
it(`[${roles[roleType].name}] Access control`, () => {
// Access control validation
//
_accessControl(roleType, "userRole");
});
it(`[${roles[roleType].name}] Schema: create table, add/modify/delete column`, () => {
// Schema related validations
// - Add/delete table
// - Add/Update/delete column
//
_editSchema(roleType, "userRole");
});
it(`[${roles[roleType].name}] Data: add/modify/delete row, update cell contents`, () => {
// Table data related validations
// - Add/delete/modify row
//
_editData(roleType, "userRole");
});
it(`[${roles[roleType].name}] Comments: view/add`, () => {
// read &/ update comment
// Viewer: only allowed to read
// Everyone else: read &/ update
//
_editComment(roleType, "userRole");
});
it(`[${roles[roleType].name}] Right navigation menu, share view`, () => {
// right navigation menu bar
// Editor/Viewer/Commenter : can only view 'existing' views
// Rest: can create/edit
_viewMenu(roleType, "userRole");
});
it(`[${roles[roleType].name}] Download files`, () => {
// to be fixed
if (roleType === "commenter" || roleType === "viewer") {
} else {
// viewer & commenter doesn't contain hideField option in ncv2
// #ID, City, LastUpdate, City => Address, Country <= City, +
mainPage.hideField("LastUpdate");
const verifyCsv = (retrievedRecords) => {
// expected output, statically configured
let storedRecords = [
`City,Address List,Country`,
`A Corua (La Corua),939 Probolinggo Loop,Spain`,
`Abha,733 Mandaluyong Place,Saudi Arabia`,
`Abu Dhabi,535 Ahmadnagar Manor,United Arab Emirates`,
`Acua,1789 Saint-Denis Parkway,Mexico`,
];
// skip if xcdb
if (!isXcdb()) {
for (let i = 0; i < storedRecords.length; i++) {
// cy.log(retrievedRecords[i])
expect(retrievedRecords[i]).to.be.equal(storedRecords[i]);
}
}
};
// download & verify
mainPage.downloadAndVerifyCsv(
`City_exported_1.csv`,
verifyCsv,
roleType
);
mainPage.unhideField("LastUpdate");
}
});
});
};
// skip owner validation as rest of the cases pretty much cover the same
// roleValidation('owner')
roleValidation("creator");
roleValidation("editor");
roleValidation("commenter");
roleValidation("viewer");
}; };
/** /**

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

@ -5,156 +5,159 @@
import { loginPage, projectsPage } from "../../support/page_objects/navigation"; import { loginPage, projectsPage } from "../../support/page_objects/navigation";
import { mainPage, settingsPage } from "../../support/page_objects/mainPage"; import { mainPage, settingsPage } from "../../support/page_objects/mainPage";
import { import {
isPostgres, isPostgres,
isTestSuiteActive, isTestSuiteActive,
isXcdb, roles isXcdb,
roles,
} from "../../support/page_objects/projectConstants"; } from "../../support/page_objects/projectConstants";
import { import {
_advSettings, _advSettings,
_editSchema, _editSchema,
_editData, _editData,
_editComment, _editComment,
_viewMenu, _viewMenu,
_topRightMenu, _topRightMenu,
enableTableAccess, enableTableAccess,
_accessControl, _accessControl,
} from "../spec/roleValidation.spec"; } from "../spec/roleValidation.spec";
export const genTest = (apiType, dbType, roleType) => { export const genTest = (apiType, dbType, roleType) => {
if (!isTestSuiteActive(apiType, dbType)) return; if (!isTestSuiteActive(apiType, dbType)) return;
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
//// Test Suite //// Test Suite
describe("Role preview validations", () => { describe("Role preview validations", () => {
// Sign in/ open project // Sign in/ open project
before(() => { before(() => {
loginPage.loginAndOpenProject(apiType, dbType); loginPage.loginAndOpenProject(apiType, dbType);
cy.openTableTab("City", 25); cy.openTableTab("City", 25);
cy.wait(3000); cy.wait(3000);
settingsPage.openProjectMenu(); settingsPage.openProjectMenu();
cy.getActiveMenu(".nc-dropdown-project-menu").find(`[data-submenu-id="preview-as"]`).should('exist').click() cy.getActiveMenu(".nc-dropdown-project-menu")
cy.wait(1000) .find(`[data-submenu-id="preview-as"]`)
cy.get('.ant-dropdown-menu-submenu').eq(4).find(`[data-menu-id="editor"]`).should('exist').click() .should("exist")
.click();
cy.wait(10000) cy.wait(1000);
cy.get(".ant-dropdown-menu-submenu")
cy.saveLocalStorage(); .eq(4)
}); .find(`[data-menu-id="editor"]`)
.should("exist")
beforeEach(() => { .click();
cy.restoreLocalStorage();
}); cy.wait(10000);
after(() => { cy.saveLocalStorage();
// cy.get(".nc-preview-reset").click({ force: true });
cy.get(".mdi-exit-to-app").click();
// 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 if (isXcdb())
cy.get(".nc-acl-table-row").should("have.length", 19);
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-floating-preview-btn", {timeout: 30000}).should("exist");
cy.get('.nc-floating-preview-btn')
.find(`[type="radio"][value="${roleType}"]`)
.should('exist')
.click();
cy.wait(5000)
cy.saveLocalStorage();
});
it(`Role preview: ${roleType}: Advance settings`, () => {
// project configuration settings
//
_advSettings(roleType, "preview");
});
it(`Role preview: ${roleType}: Access control`, () => {
// Access control validation
//
_accessControl(roleType, "preview");
});
it(`Role preview: ${roleType}: Edit data`, () => {
// Table data related validations
// - Add/delete/modify row
//
_editData(roleType, "preview");
});
it(`Role preview: ${roleType}: Edit comment`, () => {
// read &/ update comment
// Viewer: not allowed to read
// Everyone else: read &/ update
//
_editComment(roleType, "preview");
});
it(`Role preview: ${roleType}: Preview menu`, () => {
// right navigation menu bar
// Editor/Viewer/Commenter : can only view 'existing' views
// Rest: can create/edit
_viewMenu(roleType, "preview");
});
it(`Role preview: ${roleType}: Top Right Menu bar`, () => {
// Share button is conditional
// Rest are static/ mandatory
//
_topRightMenu(roleType, "preview");
});
it(`Role preview: ${roleType}: Edit Schema`, () => {
// Schema related validations
// - Add/delete table
// - Add/Update/delete column
//
_editSchema(roleType, "preview");
});
};
genTestSub("editor");
genTestSub("commenter");
genTestSub("viewer");
}); });
beforeEach(() => {
cy.restoreLocalStorage();
});
after(() => {
// cy.get(".nc-preview-reset").click({ force: true });
cy.get(".mdi-exit-to-app").click();
// 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 if (isXcdb()) cy.get(".nc-acl-table-row").should("have.length", 19);
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-floating-preview-btn", { timeout: 30000 }).should("exist");
cy.get(".nc-floating-preview-btn")
.find(`[type="radio"][value="${roleType}"]`)
.should("exist")
.click();
cy.wait(5000);
cy.saveLocalStorage();
});
it(`Role preview: ${roleType}: Advance settings`, () => {
// project configuration settings
//
_advSettings(roleType, "preview");
});
it(`Role preview: ${roleType}: Access control`, () => {
// Access control validation
//
_accessControl(roleType, "preview");
});
it(`Role preview: ${roleType}: Edit data`, () => {
// Table data related validations
// - Add/delete/modify row
//
_editData(roleType, "preview");
});
it(`Role preview: ${roleType}: Edit comment`, () => {
// read &/ update comment
// Viewer: not allowed to read
// Everyone else: read &/ update
//
_editComment(roleType, "preview");
});
it(`Role preview: ${roleType}: Preview menu`, () => {
// right navigation menu bar
// Editor/Viewer/Commenter : can only view 'existing' views
// Rest: can create/edit
_viewMenu(roleType, "preview");
});
it(`Role preview: ${roleType}: Top Right Menu bar`, () => {
// Share button is conditional
// Rest are static/ mandatory
//
_topRightMenu(roleType, "preview");
});
it(`Role preview: ${roleType}: Edit Schema`, () => {
// Schema related validations
// - Add/delete table
// - Add/Update/delete column
//
_editSchema(roleType, "preview");
});
};
genTestSub("editor");
genTestSub("commenter");
genTestSub("viewer");
});
}; };
/** /**

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

@ -1,76 +1,76 @@
import { mainPage } from "../../support/page_objects/mainPage"; import { mainPage } from "../../support/page_objects/mainPage";
import { loginPage } from "../../support/page_objects/navigation"; import { loginPage } from "../../support/page_objects/navigation";
import { import {
isPostgres, isPostgres,
isTestSuiteActive, isTestSuiteActive,
} from "../../support/page_objects/projectConstants"; } from "../../support/page_objects/projectConstants";
export const genTest = (apiType, dbType) => { export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return; if (!isTestSuiteActive(apiType, dbType)) return;
describe(`${apiType.toUpperCase()} Upload/ Download CSV`, () => { describe(`${apiType.toUpperCase()} Upload/ Download CSV`, () => {
// before(() => { // before(() => {
// // standalone test // // standalone test
// // loginPage.loginAndOpenProject(apiType, dbType); // // loginPage.loginAndOpenProject(apiType, dbType);
// }); // });
beforeEach(() => { beforeEach(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
}); });
afterEach(() => { afterEach(() => {
cy.saveLocalStorage(); cy.saveLocalStorage();
}) });
it("Download verification- base view, default columns", () => { it("Download verification- base view, default columns", () => {
cy.openTableTab("Country", 25); cy.openTableTab("Country", 25);
mainPage.hideField("LastUpdate"); mainPage.hideField("LastUpdate");
const verifyCsv = (retrievedRecords) => { const verifyCsv = (retrievedRecords) => {
// expected output, statically configured // expected output, statically configured
// let storedRecords = [ // let storedRecords = [
// `Country,CityList`, // `Country,CityList`,
// `Afghanistan,Kabul`, // `Afghanistan,Kabul`,
// `Algeria,"Batna, Bchar, Skikda"`, // `Algeria,"Batna, Bchar, Skikda"`,
// `American Samoa,Tafuna`, // `American Samoa,Tafuna`,
// `Angola,"Benguela, Namibe"`, // `Angola,"Benguela, Namibe"`,
// ]; // ];
let storedRecords = [ let storedRecords = [
['Country','City List'], ["Country", "City List"],
['Afghanistan','Kabul'], ["Afghanistan", "Kabul"],
['Algeria','Skikda', 'Bchar', 'Batna'], ["Algeria", "Skikda", "Bchar", "Batna"],
['American Samoa','Tafuna'], ["American Samoa", "Tafuna"],
['Angola','Benguela', 'Namibe'], ["Angola", "Benguela", "Namibe"],
]; ];
// if (isPostgres()) { // if (isPostgres()) {
// // order of second entry is different // // order of second entry is different
// storedRecords = [ // storedRecords = [
// `Country,City List`, // `Country,City List`,
// `Afghanistan,Kabul`, // `Afghanistan,Kabul`,
// `Algeria,"Skikda, Bchar, Batna"`, // `Algeria,"Skikda, Bchar, Batna"`,
// `American Samoa,Tafuna`, // `American Samoa,Tafuna`,
// `Angola,"Benguela, Namibe"`, // `Angola,"Benguela, Namibe"`,
// ]; // ];
// } // }
for (let i = 0; i < storedRecords.length - 1; i++) { for (let i = 0; i < storedRecords.length - 1; i++) {
for(let j=0; j<storedRecords[i].length; j++) for (let j = 0; j < storedRecords[i].length; j++)
expect(retrievedRecords[i]).to.have.string(storedRecords[i][j]) expect(retrievedRecords[i]).to.have.string(storedRecords[i][j]);
// often, the order in which records "Skikda, Bchar, Batna" appear, used to toggle // often, the order in which records "Skikda, Bchar, Batna" appear, used to toggle
// hence verifying record contents separately // hence verifying record contents separately
// expect(retrievedRecords[i]).to.be.equal(storedRecords[i]); // expect(retrievedRecords[i]).to.be.equal(storedRecords[i]);
} }
}; };
// download & verify // download & verify
mainPage.downloadAndVerifyCsv(`Country_exported_1.csv`, verifyCsv); mainPage.downloadAndVerifyCsv(`Country_exported_1.csv`, verifyCsv);
mainPage.unhideField("LastUpdate"); mainPage.unhideField("LastUpdate");
cy.closeTableTab("Country"); cy.closeTableTab("Country");
});
}); });
});
}; };
/** /**

462
scripts/cypress/integration/common/6c_swagger_api.js

@ -4,253 +4,233 @@ import { roles } from "../../support/page_objects/projectConstants";
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"; import { isTestSuiteActive } from "../../support/page_objects/projectConstants";
export const genTest = (apiType, dbType) => { export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return; if (!isTestSuiteActive(apiType, dbType)) return;
describe(`${apiType.toUpperCase()} : API List - Test preparation`, () => { describe(`${apiType.toUpperCase()} : API List - Test preparation`, () => {
before(() => { before(() => {
cy.fileHook(); cy.fileHook();
loginPage.loginAndOpenProject(apiType, dbType); loginPage.loginAndOpenProject(apiType, dbType);
}); });
it("Open project & record swagger URL, AuthToken", () => { it("Open project & record swagger URL, AuthToken", () => {
let authToken = mainPage.getAuthToken(); let authToken = mainPage.getAuthToken();
cy.url().then((url) => { cy.url().then((url) => {
// retrieve project name from URL & use it to construct Swagger URL // retrieve project name from URL & use it to construct Swagger URL
// URL on homepage: http://localhost:3000/#/nc/externalrest_weUO?type=roles&dbalias=&name=Team%20%26%20Auth%20 // URL on homepage: http://localhost:3000/#/nc/externalrest_weUO?type=roles&dbalias=&name=Team%20%26%20Auth%20
// [REST] Swagger URL: http://localhost:8080/nc/externalrest_weUO/db/swagger // [REST] Swagger URL: http://localhost:8080/nc/externalrest_weUO/db/swagger
// [GQL] http://localhost:8080/nc/externalgql_dgwx/v1/graphql // [GQL] http://localhost:8080/nc/externalgql_dgwx/v1/graphql
const projectName = url.split("/")[5].split("?")[0]; const projectName = url.split("/")[5].split("?")[0];
let swaggerURL = ``; let swaggerURL = ``;
if ("rest" == apiType) { if ("rest" == apiType) {
swaggerURL = `http://localhost:8080/nc/${projectName}/db/swagger`; swaggerURL = `http://localhost:8080/nc/${projectName}/db/swagger`;
} else { } else {
swaggerURL = `http://localhost:8080/nc/${projectName}/v1/graphql`; swaggerURL = `http://localhost:8080/nc/${projectName}/v1/graphql`;
} }
// exchange information between two tests using a file // exchange information between two tests using a file
// https://stackoverflow.com/questions/52050657/what-is-the-best-practice-of-pass-states-between-tests-in-cypress // https://stackoverflow.com/questions/52050657/what-is-the-best-practice-of-pass-states-between-tests-in-cypress
// //
cy.writeFile("shared.json", { cy.writeFile("shared.json", {
SWAGGER_URL: swaggerURL, SWAGGER_URL: swaggerURL,
AUTH_TOKEN: authToken, AUTH_TOKEN: authToken,
});
});
}); });
});
}); });
});
if ("rest" == apiType) {
describe(`Swagger page, base verification`, () => { if ("rest" == apiType) {
before(() => { describe(`Swagger page, base verification`, () => {
cy.fileHook(); before(() => {
cy.fileHook();
});
// returns swagger button intended for
//
const getSwaggerButton = (tag, idx, desc) => {
return cy
.get(`#operations-tag-${tag}`)
.next()
.find(".opblock")
.eq(idx)
.find(`button:contains(${desc})`);
};
let Token;
// basic authentication tag verification
//
it("Swagger URL access & basic validation", () => {
// retrieve information stored in previous IT block
//
cy.readFile("shared.json").then((jsonPayload) => {
let URL = jsonPayload.SWAGGER_URL;
Token = jsonPayload.AUTH_TOKEN;
cy.visit(URL, {
baseUrl: null,
}).then(() => {
// wait to allow time for SWAGGER Library loading to finish
cy.log(Token);
// cy.snip("Swagger");
// validate; API order assumed
cy.get("#operations-tag-Authentication", {
timeout: 20000,
}) })
.should("exist")
// returns swagger button intended for .next()
// .find(".opblock")
const getSwaggerButton = (tag, idx, desc) => { .should("has.length", 9);
return cy getSwaggerButton("Authentication", 0, "User login").should("exist");
.get(`#operations-tag-${tag}`) getSwaggerButton("Authentication", 1, "User signup").should(
.next() "exist"
.find(".opblock") );
.eq(idx) getSwaggerButton("Authentication", 2, "Password Forgot").should(
.find(`button:contains(${desc})`); "exist"
}; );
getSwaggerButton("Authentication", 3, "Email validate link").should(
let Token; "exist"
);
// basic authentication tag verification getSwaggerButton(
// "Authentication",
it("Swagger URL access & basic validation", () => { 4,
// retrieve information stored in previous IT block "Validate password reset token"
// ).should("exist");
cy.readFile("shared.json").then((jsonPayload) => { getSwaggerButton("Authentication", 5, "Password reset").should(
let URL = jsonPayload.SWAGGER_URL; "exist"
Token = jsonPayload.AUTH_TOKEN; );
getSwaggerButton("Authentication", 6, "User details").should(
cy.visit(URL, { "exist"
baseUrl: null, );
}).then(() => { getSwaggerButton("Authentication", 7, "Update user details").should(
// wait to allow time for SWAGGER Library loading to finish "exist"
cy.log(Token); );
getSwaggerButton("Authentication", 8, "Update user details").should(
// cy.snip("Swagger"); "exist"
);
// validate; API order assumed });
cy.get("#operations-tag-Authentication", {
timeout: 20000,
})
.should("exist")
.next()
.find(".opblock")
.should("has.length", 9);
getSwaggerButton(
"Authentication",
0,
"User login"
).should("exist");
getSwaggerButton(
"Authentication",
1,
"User signup"
).should("exist");
getSwaggerButton(
"Authentication",
2,
"Password Forgot"
).should("exist");
getSwaggerButton(
"Authentication",
3,
"Email validate link"
).should("exist");
getSwaggerButton(
"Authentication",
4,
"Validate password reset token"
).should("exist");
getSwaggerButton(
"Authentication",
5,
"Password reset"
).should("exist");
getSwaggerButton(
"Authentication",
6,
"User details"
).should("exist");
getSwaggerButton(
"Authentication",
7,
"Update user details"
).should("exist");
getSwaggerButton(
"Authentication",
8,
"Update user details"
).should("exist");
});
});
});
it("Authorize success: Valid token", () => {
// authorize button, feed token, click authorize
cy.get('[class="btn authorize unlocked"]').click();
cy.get("input").type(Token);
cy.get(".auth-btn-wrapper > .authorize").click();
// Response: "Authorized" should exist on DOM
cy.get(".auth-container")
.contains("Authorized")
.should("exist");
cy.get(".btn-done").click();
// Authorize button is LOCKED now
cy.get('[class="btn authorize locked"]').should("exist");
});
it("Execute Authentication (valid token case) > GET: User details API", () => {
// Auth> User details API
getSwaggerButton("Authentication", 6, "User details").click();
// "Try it out" button, followed by "Execute"
cy.get(".try-out > .btn").click();
cy.get(".execute-wrapper > .btn").click();
// check response: validate email credentials
cy.get(".highlight-code > .microlight")
.contains("email")
.should("exist");
cy.get(".highlight-code > .microlight")
.contains(roles.owner.credentials.username)
.should("exist");
// reset operations (clear, cancel, windback User details tab)
cy.get(".btn-clear").click();
cy.get(".try-out > .btn").click();
getSwaggerButton("Authentication", 6, "User details").click();
});
it("Logout post authorization", () => {
// authorize button, logout
cy.get('[class="btn authorize locked"]').click();
cy.get('.auth-btn-wrapper > button:contains("Logout")').click();
cy.get(".btn-done").click();
// Authorize button is UNLOCKED now
cy.get('[class="btn authorize unlocked"]').should("exist");
});
it("Execute Authentication (logout case) > GET: User details API", () => {
// Auth> User details API
getSwaggerButton("Authentication", 6, "User details").click();
// "Try it out" button, followed by "Execute"
cy.get(".try-out > .btn").click();
cy.get(".execute-wrapper > .btn").click();
// check response: email credentials shouldnt exist. should display 'guest:true'
cy.get(".highlight-code > .microlight")
.contains("guest")
.should("exist");
cy.get(".highlight-code > .microlight")
.contains("email")
.should("not.exist");
cy.get(".highlight-code > .microlight")
.contains(roles.owner.credentials.username)
.should("not.exist");
// reset operations (clear, cancel, windback User details tab)
cy.get(".btn-clear").click();
cy.get(".try-out > .btn").click();
getSwaggerButton("Authentication", 6, "User details").click();
});
it("Authorize failure: invalid token", () => {
// authorize button, feed *invalid* token, click authorize
cy.get('[class="btn authorize unlocked"]').click();
cy.get("input").type("xyz");
cy.get(".auth-btn-wrapper > .authorize").click();
// Response: "Authorized" should *not* exist on DOM
// TBD: cy.get('.auth-container').contains('Authorized').should('not.exist')
cy.get(".btn-done").click();
// Authorize button should be UNLOCKED now
// TBD: cy.get('[class="btn authorize unlocked"]').should('exist')
});
it("Execute Authentication (invalid token case) > GET: User details API", () => {
// Auth> User details API
getSwaggerButton("Authentication", 6, "User details").click();
// "Try it out" button, followed by "Execute"
cy.get(".try-out > .btn").click();
cy.get(".execute-wrapper > .btn").click();
// check response: email credentials shouldnt exist. should display 'guest:true'
cy.get(".highlight-code > .microlight")
.contains("guest")
.should("exist");
cy.get(".highlight-code > .microlight")
.contains("email")
.should("not.exist");
cy.get(".highlight-code > .microlight")
.contains(roles.owner.credentials.username)
.should("not.exist");
// reset operations (clear, cancel, windback User details tab)
cy.get(".btn-clear").click();
cy.get(".try-out > .btn").click();
getSwaggerButton("Authentication", 6, "User details").click();
});
// clean-up created file (shared.json)
// after(() => {
// cy.exec("del shared.json").then(()=> {
// cy.log("file cleaned up!")
// })
// })
}); });
} });
it("Authorize success: Valid token", () => {
// authorize button, feed token, click authorize
cy.get('[class="btn authorize unlocked"]').click();
cy.get("input").type(Token);
cy.get(".auth-btn-wrapper > .authorize").click();
// Response: "Authorized" should exist on DOM
cy.get(".auth-container").contains("Authorized").should("exist");
cy.get(".btn-done").click();
// Authorize button is LOCKED now
cy.get('[class="btn authorize locked"]').should("exist");
});
it("Execute Authentication (valid token case) > GET: User details API", () => {
// Auth> User details API
getSwaggerButton("Authentication", 6, "User details").click();
// "Try it out" button, followed by "Execute"
cy.get(".try-out > .btn").click();
cy.get(".execute-wrapper > .btn").click();
// check response: validate email credentials
cy.get(".highlight-code > .microlight")
.contains("email")
.should("exist");
cy.get(".highlight-code > .microlight")
.contains(roles.owner.credentials.username)
.should("exist");
// reset operations (clear, cancel, windback User details tab)
cy.get(".btn-clear").click();
cy.get(".try-out > .btn").click();
getSwaggerButton("Authentication", 6, "User details").click();
});
it("Logout post authorization", () => {
// authorize button, logout
cy.get('[class="btn authorize locked"]').click();
cy.get('.auth-btn-wrapper > button:contains("Logout")').click();
cy.get(".btn-done").click();
// Authorize button is UNLOCKED now
cy.get('[class="btn authorize unlocked"]').should("exist");
});
it("Execute Authentication (logout case) > GET: User details API", () => {
// Auth> User details API
getSwaggerButton("Authentication", 6, "User details").click();
// "Try it out" button, followed by "Execute"
cy.get(".try-out > .btn").click();
cy.get(".execute-wrapper > .btn").click();
// check response: email credentials shouldnt exist. should display 'guest:true'
cy.get(".highlight-code > .microlight")
.contains("guest")
.should("exist");
cy.get(".highlight-code > .microlight")
.contains("email")
.should("not.exist");
cy.get(".highlight-code > .microlight")
.contains(roles.owner.credentials.username)
.should("not.exist");
// reset operations (clear, cancel, windback User details tab)
cy.get(".btn-clear").click();
cy.get(".try-out > .btn").click();
getSwaggerButton("Authentication", 6, "User details").click();
});
it("Authorize failure: invalid token", () => {
// authorize button, feed *invalid* token, click authorize
cy.get('[class="btn authorize unlocked"]').click();
cy.get("input").type("xyz");
cy.get(".auth-btn-wrapper > .authorize").click();
// Response: "Authorized" should *not* exist on DOM
// TBD: cy.get('.auth-container').contains('Authorized').should('not.exist')
cy.get(".btn-done").click();
// Authorize button should be UNLOCKED now
// TBD: cy.get('[class="btn authorize unlocked"]').should('exist')
});
it("Execute Authentication (invalid token case) > GET: User details API", () => {
// Auth> User details API
getSwaggerButton("Authentication", 6, "User details").click();
// "Try it out" button, followed by "Execute"
cy.get(".try-out > .btn").click();
cy.get(".execute-wrapper > .btn").click();
// check response: email credentials shouldnt exist. should display 'guest:true'
cy.get(".highlight-code > .microlight")
.contains("guest")
.should("exist");
cy.get(".highlight-code > .microlight")
.contains("email")
.should("not.exist");
cy.get(".highlight-code > .microlight")
.contains(roles.owner.credentials.username)
.should("not.exist");
// reset operations (clear, cancel, windback User details tab)
cy.get(".btn-clear").click();
cy.get(".try-out > .btn").click();
getSwaggerButton("Authentication", 6, "User details").click();
});
// clean-up created file (shared.json)
// after(() => {
// cy.exec("del shared.json").then(()=> {
// cy.log("file cleaned up!")
// })
// })
});
}
}; };
/** /**

179
scripts/cypress/integration/common/6d_language_validation.js

@ -4,104 +4,109 @@ const { roles } = require("../../support/page_objects/projectConstants");
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"; import { isTestSuiteActive } from "../../support/page_objects/projectConstants";
export const genTest = (apiType, dbType) => { export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return; if (!isTestSuiteActive(apiType, dbType)) return;
describe(`Language support`, () => { describe(`Language support`, () => {
before(() => { before(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
cy.visit("/") cy.visit("/");
cy.wait(5000); cy.wait(5000);
}); });
beforeEach(() => { beforeEach(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
}) });
afterEach(() => { afterEach(() => {
cy.saveLocalStorage(); cy.saveLocalStorage();
}) });
after(() => { after(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
cy.get('.nc-menu-accounts').should('exist').click(); cy.get(".nc-menu-accounts").should("exist").click();
cy.getActiveMenu('.nc-dropdown-user-accounts-menu').find('.ant-dropdown-menu-item').eq(1).click(); cy.getActiveMenu(".nc-dropdown-user-accounts-menu")
.find(".ant-dropdown-menu-item")
.eq(1)
.click();
cy.wait(5000); cy.wait(5000);
cy.get('button:contains("SIGN")').should('exist') cy.get('button:contains("SIGN")').should("exist");
cy.saveLocalStorage(); cy.saveLocalStorage();
}) });
const langVerification = (idx, lang) => { const langVerification = (idx, lang) => {
// pick json from the file specified // pick json from the file specified
it(`Language verification: ${lang} > Projects page`, () => { it(`Language verification: ${lang} > Projects page`, () => {
let json = require(`../../../../packages/nc-gui/lang/${lang}`); let json = require(`../../../../packages/nc-gui/lang/${lang}`);
cy.wait(500); cy.wait(500);
// toggle menu as per index // toggle menu as per index
cy.get(".nc-menu-translate").should('exist').last().click(); cy.get(".nc-menu-translate").should("exist").last().click();
cy.wait(500); cy.wait(500);
cy.getActiveMenu(".nc-dropdown-menu-translate").find(".ant-dropdown-menu-item").eq(idx).click(); cy.getActiveMenu(".nc-dropdown-menu-translate")
cy.wait(200); .find(".ant-dropdown-menu-item")
.eq(idx)
.click();
cy.wait(200);
// basic validations // basic validations
// 1. Page title: "My Projects" // 1. Page title: "My Projects"
// 2. Button: "New Project" // 2. Button: "New Project"
// 3. Search box palceholder text: "Search Projects" // 3. Search box palceholder text: "Search Projects"
// cy.get("b").contains(json.title.myProject).should("exist"); // cy.get("b").contains(json.title.myProject).should("exist");
cy.get(".nc-project-page-title") cy.get(".nc-project-page-title")
.contains(json.title.myProject) .contains(json.title.myProject)
.should("exist"); .should("exist");
cy.get(".nc-new-project-menu") cy.get(".nc-new-project-menu")
.contains(json.title.newProj) .contains(json.title.newProj)
.should("exist"); .should("exist");
cy.get(`[placeholder="${json.activity.searchProject}"]`).should( cy.get(`[placeholder="${json.activity.searchProject}"]`).should(
"exist" "exist"
); );
}); });
}; };
let langMenu = [ let langMenu = [
"help-translate", "help-translate",
"ar.json", "ar.json",
"bn_IN.json", "bn_IN.json",
"da.json", "da.json",
"de.json", "de.json",
"en.json", "en.json",
"es.json", "es.json",
"fa.json", "fa.json",
"fi.json", "fi.json",
"fr.json", "fr.json",
"he.json", "he.json",
"hi.json", "hi.json",
"hr.json", "hr.json",
"id.json", "id.json",
"it.json", "it.json",
"ja.json", "ja.json",
"ko.json", "ko.json",
"lv.json", "lv.json",
"nl.json", "nl.json",
"no.json", "no.json",
"pl.json", "pl.json",
"pt.json", "pt.json",
"pt_BR.json", "pt_BR.json",
"ru.json", "ru.json",
"sl.json", "sl.json",
"sv.json", "sv.json",
"th.json", "th.json",
"tr.json", "tr.json",
"uk.json", "uk.json",
"vi.json", "vi.json",
"zh-Hans.json", "zh-Hans.json",
"zh-Hant.json", "zh-Hant.json",
]; ];
// Index is the order in which menu options appear // Index is the order in which menu options appear
for (let i = 1; i < langMenu.length; i++) for (let i = 1; i < langMenu.length; i++) langVerification(i, langMenu[i]);
langVerification(i, langMenu[i]);
// reset to English // reset to English
langVerification(5, langMenu[5]); langVerification(5, langMenu[5]);
}); });
}; };
/** /**

44
scripts/cypress/integration/common/6e_project_operations.js

@ -3,36 +3,32 @@ import { isXcdb, roles } from "../../support/page_objects/projectConstants";
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"; import { isTestSuiteActive } from "../../support/page_objects/projectConstants";
export const genTest = (apiType, dbType) => { export const genTest = (apiType, dbType) => {
describe(`${apiType.toUpperCase()} Project operations`, () => { describe(`${apiType.toUpperCase()} Project operations`, () => {
if (!isTestSuiteActive(apiType, dbType)) return; if (!isTestSuiteActive(apiType, dbType)) return;
before(() => { before(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
cy.visit("/"); cy.visit("/");
cy.wait(4000); cy.wait(4000);
}); });
beforeEach(() => {
cy.restoreLocalStorage();
})
afterEach(() => { beforeEach(() => {
cy.saveLocalStorage(); cy.restoreLocalStorage();
}) });
it("Delete Project", () => { afterEach(() => {
cy.saveLocalStorage();
});
cy.get(`.nc-action-btn`) it("Delete Project", () => {
.should("exist") cy.get(`.nc-action-btn`).should("exist").last().click();
.last()
.click();
cy.getActiveModal(".nc-modal-project-delete") cy.getActiveModal(".nc-modal-project-delete")
.find(".ant-btn-dangerous") .find(".ant-btn-dangerous")
.should("exist") .should("exist")
.click(); .click();
});
}); });
});
}; };
/** /**

251
scripts/cypress/integration/common/6f_attachments.js

@ -1,157 +1,162 @@
import { mainPage } from "../../support/page_objects/mainPage"; import { mainPage } from "../../support/page_objects/mainPage";
import {loginPage, projectsPage} from "../../support/page_objects/navigation"; import { loginPage, projectsPage } from "../../support/page_objects/navigation";
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"; import { isTestSuiteActive } from "../../support/page_objects/projectConstants";
export const genTest = (apiType, dbType) => { export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return; if (!isTestSuiteActive(apiType, dbType)) return;
describe(`${apiType.toUpperCase()} Columns of type attachment`, () => { describe(`${apiType.toUpperCase()} Columns of type attachment`, () => {
before(() => { before(() => {
loginPage.loginAndOpenProject(apiType, dbType); loginPage.loginAndOpenProject(apiType, dbType);
cy.openTableTab("Country", 25); cy.openTableTab("Country", 25);
cy.saveLocalStorage(); cy.saveLocalStorage();
}); });
beforeEach(() => { beforeEach(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
}) });
afterEach(() => { afterEach(() => {
cy.saveLocalStorage(); cy.saveLocalStorage();
}) });
after(() => { after(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
// clean up // clean up
mainPage.deleteColumn("testAttach"); mainPage.deleteColumn("testAttach");
// clean up newly added rows into Country table operations // clean up newly added rows into Country table operations
// this auto verifies successfull addition of rows to table as well // this auto verifies successfull addition of rows to table as well
mainPage.getPagination(5).click(); mainPage.getPagination(5).click();
// kludge: flicker on load // kludge: flicker on load
cy.wait(3000) cy.wait(3000);
// wait for page rendering to complete // wait for page rendering to complete
cy.get(".nc-grid-row").should("have.length", 10); cy.get(".nc-grid-row").should("have.length", 10);
// mainPage // mainPage
// .getRow(10) // .getRow(10)
// .find(".mdi-checkbox-blank-outline") // .find(".mdi-checkbox-blank-outline")
// .click({ force: true }); // .click({ force: true });
mainPage.getCell("Country", 10).rightclick(); mainPage.getCell("Country", 10).rightclick();
cy.getActiveMenu(".nc-dropdown-grid-context-menu").contains("Delete Row").click(); cy.getActiveMenu(".nc-dropdown-grid-context-menu")
.contains("Delete Row")
.click();
cy.closeTableTab("Country"); cy.closeTableTab("Country");
cy.saveLocalStorage(); cy.saveLocalStorage();
}); });
it(`Add column of type attachments`, () => { it(`Add column of type attachments`, () => {
mainPage.addColumnWithType("testAttach", "Attachment", "Country"); mainPage.addColumnWithType("testAttach", "Attachment", "Country");
for (let i = 4; i <= 6; i++) { for (let i = 4; i <= 6; i++) {
let filepath = `sampleFiles/${i}.json`; let filepath = `sampleFiles/${i}.json`;
cy.get('.nc-attachment-cell') cy.get(".nc-attachment-cell")
.eq(i) .eq(i)
.attachFile(filepath, { subjectType: 'drag-n-drop' }); .attachFile(filepath, { subjectType: "drag-n-drop" });
cy.get('.nc-attachment-cell') cy.get(".nc-attachment-cell")
.eq(i) .eq(i)
.find(".nc-attachment") .find(".nc-attachment")
.should("exist"); .should("exist");
} }
}); });
it(`Form view with Attachment field- Submit & verify`, () => { it(`Form view with Attachment field- Submit & verify`, () => {
// // open right navbar // // open right navbar
// cy.get('.nc-toggle-right-navbar').should('exist').click(); // cy.get('.nc-toggle-right-navbar').should('exist').click();
// create form-view // create form-view
cy.get(`.nc-create-form-view`).click(); cy.get(`.nc-create-form-view`).click();
cy.getActiveModal(".nc-modal-view-create").find("button:contains(Submit)").click(); cy.getActiveModal(".nc-modal-view-create")
.find("button:contains(Submit)")
.click();
cy.toastWait("View created successfully"); cy.toastWait("View created successfully");
mainPage.shareView().click(); mainPage.shareView().click();
cy.wait(5000); cy.wait(5000);
// copy link text, visit URL // copy link text, visit URL
cy.getActiveModal(".nc-modal-share-view") cy.getActiveModal(".nc-modal-share-view")
.find(".share-link-box") .find(".share-link-box")
.contains("/nc/form/", { timeout: 10000 }) .contains("/nc/form/", { timeout: 10000 })
.should('exist') .should("exist")
.then(($obj) => { .then(($obj) => {
let linkText = $obj.text().trim(); let linkText = $obj.text().trim();
cy.log(linkText); cy.log(linkText);
cy.signOut(); cy.signOut();
cy.visit(linkText, { cy.visit(linkText, {
baseUrl: null, baseUrl: null,
}); });
cy.wait(5000); cy.wait(5000);
// wait for share view page to load! // wait for share view page to load!
cy.get(".nc-form").should("exist"); cy.get(".nc-form").should("exist");
// fill form // fill form
// 0: Country // 0: Country
// 1: LastUpdate // 1: LastUpdate
cy.get(".nc-input").eq(0).type("_abc"); cy.get(".nc-input").eq(0).type("_abc");
cy.get(".nc-input").eq(1).click(); cy.get(".nc-input").eq(1).click();
cy.get('.ant-picker-dropdown').find(".ant-picker-now-btn").click(); cy.get(".ant-picker-dropdown").find(".ant-picker-now-btn").click();
cy.get('.ant-picker-dropdown').find("button.ant-btn-primary").click(); cy.get(".ant-picker-dropdown").find("button.ant-btn-primary").click();
cy.get('.nc-attachment-cell') cy.get(".nc-attachment-cell").attachFile(`sampleFiles/1.json`, {
.attachFile(`sampleFiles/1.json`, { subjectType: 'drag-n-drop' }); subjectType: "drag-n-drop",
});
cy.get(".nc-form").find("button").contains("Submit").click(); cy.get(".nc-form").find("button").contains("Submit").click();
cy.get(".ant-alert-message") cy.get(".ant-alert-message")
.contains("Successfully submitted form data") .contains("Successfully submitted form data")
.should("exist"); .should("exist");
cy.toastWait("Saved successfully"); cy.toastWait("Saved successfully");
});
}); });
});
it(`Filter column which contain only attachments, download CSV`, () => { it(`Filter column which contain only attachments, download CSV`, () => {
// come back to main window // come back to main window
loginPage.loginAndOpenProject(apiType, dbType); loginPage.loginAndOpenProject(apiType, dbType);
// cy.visit('/') // cy.visit('/')
// cy.wait(5000) // cy.wait(5000)
// projectsPage.openConfiguredProject(apiType, dbType); // projectsPage.openConfiguredProject(apiType, dbType);
cy.openTableTab("Country", 25); cy.openTableTab("Country", 25);
cy.wait(1000); cy.wait(1000);
mainPage.filterField("testAttach", "is not null", null); mainPage.filterField("testAttach", "is not null", null);
mainPage.hideField("LastUpdate"); mainPage.hideField("LastUpdate");
const verifyCsv = (retrievedRecords) => { const verifyCsv = (retrievedRecords) => {
let storedRecords = [ let storedRecords = [
`Country,City List,testAttach`, `Country,City List,testAttach`,
`Afghanistan,Kabul,1.json(http://localhost:8080/download/p_h0wxjx5kgoq3w4/vw_skyvc7hsp9i34a/2HvU8R.json)`, `Afghanistan,Kabul,1.json(http://localhost:8080/download/p_h0wxjx5kgoq3w4/vw_skyvc7hsp9i34a/2HvU8R.json)`,
]; ];
expect(retrievedRecords[0]).to.be.equal(storedRecords[0]); expect(retrievedRecords[0]).to.be.equal(storedRecords[0]);
for (let i = 1; i < storedRecords.length; i++) { for (let i = 1; i < storedRecords.length; i++) {
const columns = retrievedRecords[i].split(","); const columns = retrievedRecords[i].split(",");
expect(columns[2]).to.contain( expect(columns[2]).to.contain(
".json(http://localhost:8080/download/" ".json(http://localhost:8080/download/"
); );
} }
cy.log(retrievedRecords[109]); cy.log(retrievedRecords[109]);
cy.log(retrievedRecords[110]); cy.log(retrievedRecords[110]);
cy.log(retrievedRecords[111]); cy.log(retrievedRecords[111]);
}; };
mainPage.downloadAndVerifyCsv(`Country_exported_1.csv`, verifyCsv); mainPage.downloadAndVerifyCsv(`Country_exported_1.csv`, verifyCsv);
mainPage.unhideField("LastUpdate"); mainPage.unhideField("LastUpdate");
mainPage.filterReset(); mainPage.filterReset();
});
}); });
});
}; };
/** /**

427
scripts/cypress/integration/common/7a_create_project_from_excel.js

@ -4,8 +4,8 @@
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 {
roles, roles,
isTestSuiteActive, isTestSuiteActive,
} from "../../support/page_objects/projectConstants"; } from "../../support/page_objects/projectConstants";
// stores sheet names (table name) // stores sheet names (table name)
@ -21,29 +21,29 @@ let filepath = `sampleFiles/simple.xlsx`;
// let UrlFilePath = `sampleFiles/Financial Sample.xlsx` // let UrlFilePath = `sampleFiles/Financial Sample.xlsx`
let expectedData = { let expectedData = {
0: ["number", "Number", "Number"], 0: ["number", "Number", "Number"],
1: ["float", "Decimal", "Float"], 1: ["float", "Decimal", "Float"],
2: ["text", "SingleLineText", "Text"], 2: ["text", "SingleLineText", "Text"],
}; };
// column names with spaces will be converted to include _ // column names with spaces will be converted to include _
let UrlFileExpectedData = { let UrlFileExpectedData = {
0: ["Segment", "SingleSelect", ["Government"]], 0: ["Segment", "SingleSelect", ["Government"]],
1: ["Country", "SingleSelect", ["Canada"]], 1: ["Country", "SingleSelect", ["Canada"]],
2: ["Product", "SingleSelect", ["Carretera"]], 2: ["Product", "SingleSelect", ["Carretera"]],
3: ["Discount_Band", "SingleSelect", ["None"]], 3: ["Discount_Band", "SingleSelect", ["None"]],
4: ["Units_Sold", "Decimal", [1618.5]], 4: ["Units_Sold", "Decimal", [1618.5]],
5: ["Manufacturing_Price", "Number", [3]], 5: ["Manufacturing_Price", "Number", [3]],
6: ["Sale_Price", "Number", [20]], 6: ["Sale_Price", "Number", [20]],
7: ["Gross_Sales", "Decimal", [32370]], 7: ["Gross_Sales", "Decimal", [32370]],
8: ["Discounts", "Decimal", [0]], 8: ["Discounts", "Decimal", [0]],
9: ["Sales", "Decimal", [32370]], 9: ["Sales", "Decimal", [32370]],
10: ["COGS", "Decimal", [16185]], 10: ["COGS", "Decimal", [16185]],
11: ["Profit", "Decimal", [16185]], 11: ["Profit", "Decimal", [16185]],
12: ["Date", "Date", ["2014-01-01"]], 12: ["Date", "Date", ["2014-01-01"]],
13: ["Month_Number", "Number", [1]], 13: ["Month_Number", "Number", [1]],
14: ["Month_Name", "SingleSelect", ["January"]], 14: ["Month_Name", "SingleSelect", ["January"]],
15: ["Year", "SingleSelect", [2014]], 15: ["Year", "SingleSelect", [2014]],
}; };
// let filepath = `sampleFiles/sample.xlsx` // let filepath = `sampleFiles/sample.xlsx`
@ -64,208 +64,223 @@ let UrlFileExpectedData = {
// } // }
export const genTest = (apiType, dbType) => { export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return; if (!isTestSuiteActive(apiType, dbType)) return;
describe(`Import from excel`, () => { describe(`Import from excel`, () => {
before(() => { before(() => {
// loginPage.signIn(roles.owner.credentials); // loginPage.signIn(roles.owner.credentials);
cy.restoreLocalStorage(); cy.restoreLocalStorage();
cy.task("readSheetList", { cy.task("readSheetList", {
file: `./scripts/cypress/fixtures/${filepath}`, file: `./scripts/cypress/fixtures/${filepath}`,
}).then((rows) => { }).then((rows) => {
cy.log(rows); cy.log(rows);
sheetList = rows; sheetList = rows;
}); });
cy.task("readXlsx", { cy.task("readXlsx", {
file: `./scripts/cypress/fixtures/${filepath}`, file: `./scripts/cypress/fixtures/${filepath}`,
sheet: "Sheet2", sheet: "Sheet2",
}).then((rows) => { }).then((rows) => {
cy.log(rows); cy.log(rows);
sheetData = rows; sheetData = rows;
}); });
cy.visit("/") cy.visit("/");
projectsPage.createProject({ dbType: "none", apiType: "REST", name: "importSample" }, {}) projectsPage.createProject(
cy.wait(4000); { dbType: "none", apiType: "REST", name: "importSample" },
{}
cy.saveLocalStorage(); );
}); cy.wait(4000);
beforeEach(() => { cy.saveLocalStorage();
cy.restoreLocalStorage(); });
});
afterEach(() => {
cy.saveLocalStorage();
})
it("File Upload: Upload excel as template", () => {
cy.get('.nc-add-new-table').should('exist').trigger('mouseover')
cy.get('.nc-import-menu').should('exist').click()
cy.getActiveMenu(".nc-dropdown-import-menu").find('.ant-dropdown-menu-item').contains('Microsoft Excel').click()
cy.get(".nc-input-import").should('exist').find('input').attachFile(filepath); beforeEach(() => {
cy.toastWait("Uploaded file simple.xlsx successfully"); cy.restoreLocalStorage();
cy.get(".nc-btn-import").should('exist').click(); });
});
it("File Upload: Verify pre-load template page", () => { afterEach(() => {
cy.getActiveModal() cy.saveLocalStorage();
.find(".ant-collapse-item") });
.then((sheets) => {
// hardcoded. fix me. it("File Upload: Upload excel as template", () => {
let sheetList = ["Sheet2", "Sheet3", "Sheet4"]; cy.get(".nc-add-new-table").should("exist").trigger("mouseover");
cy.get(".nc-import-menu").should("exist").click();
cy.getActiveMenu(".nc-dropdown-import-menu")
.find(".ant-dropdown-menu-item")
.contains("Microsoft Excel")
.click();
cy.get(".nc-input-import")
.should("exist")
.find("input")
.attachFile(filepath);
cy.toastWait("Uploaded file simple.xlsx successfully");
cy.get(".nc-btn-import").should("exist").click();
});
for (let i = 0; i < sheets.length; i++) { it("File Upload: Verify pre-load template page", () => {
cy.wrap(sheets[i]) cy.getActiveModal()
.find('.ant-collapse-header') .find(".ant-collapse-item")
.contains(sheetList[i]) .then((sheets) => {
// hardcoded. fix me.
let sheetList = ["Sheet2", "Sheet3", "Sheet4"];
for (let i = 0; i < sheets.length; i++) {
cy.wrap(sheets[i])
.find(".ant-collapse-header")
.contains(sheetList[i])
.should("exist");
// for each sheet, expand to verify table names & their data types
if (i !== 0) cy.wrap(sheets[i]).find(".ant-collapse-arrow").click();
// sheet > tables > rows > cells > inputs
cy.wrap(sheets[i])
.find(".ant-table-tbody")
.then((tables) => {
cy.wrap(tables)
.find(".ant-table-row:visible")
.should("have.length", 3)
.then((rows) => {
// cy.log(rows)
for (let j = 0; j < rows.length; j++) {
cy.wrap(rows[j])
.find(".ant-table-cell")
.then((cells) => {
cy.wrap(cells[0])
.find("input")
.then((input) => {
expect(input.val()).to.equal(expectedData[j][0]);
});
cy.wrap(cells[1])
.find(".ant-select-selection-item")
.contains(expectedData[j][1])
.should("exist"); .should("exist");
});
// for each sheet, expand to verify table names & their data types
if(i!==0)
cy.wrap(sheets[i]).find(".ant-collapse-arrow").click();
// sheet > tables > rows > cells > inputs
cy.wrap(sheets[i]).find(".ant-table-tbody").then((tables) => {
cy.wrap(tables).find(".ant-table-row:visible")
.should("have.length", 3)
.then((rows) => {
// cy.log(rows)
for (let j = 0; j < rows.length; j++) {
cy.wrap(rows[j]).find(".ant-table-cell")
.then((cells) => {
cy.wrap(cells[0]).find("input")
.then((input) => {
expect(input.val()).to.equal(expectedData[j][0])
})
cy.wrap(cells[1]).find(".ant-select-selection-item")
.contains(expectedData[j][1])
.should("exist")
})
}
})
})
// unwind
cy.wrap(sheets[i]).find(".ant-collapse-arrow").click();
} }
}); });
cy.getActiveModal().find(".ant-btn-primary").click(); });
// wait for page to get loaded (issue observed in CI-CD) // unwind
cy.wait(5000); cy.wrap(sheets[i]).find(".ant-collapse-arrow").click();
}
}); });
cy.getActiveModal().find(".ant-btn-primary").click();
it("File Upload: Verify loaded data", () => { // wait for page to get loaded (issue observed in CI-CD)
cy.wait(5000);
cy.openTableTab("Sheet2", 2); });
for (const [key, value] of Object.entries(expectedData)) {
mainPage
.getCell(value[2], 1)
.contains(sheetData[0][value[0]])
.should("exist");
mainPage
.getCell(value[2], 2)
.contains(sheetData[1][value[0]])
.should("exist");
}
cy.closeTableTab("Sheet2");
cy.openTableTab("Sheet3", 2);
for (const [key, value] of Object.entries(expectedData)) {
mainPage
.getCell(value[2], 1)
.contains(sheetData[0][value[0]])
.should("exist");
mainPage
.getCell(value[2], 2)
.contains(sheetData[1][value[0]])
.should("exist");
}
cy.closeTableTab("Sheet3");
});
it.skip("URL: Upload excel as template", () => { it("File Upload: Verify loaded data", () => {
// trigger import cy.openTableTab("Sheet2", 2);
cy.get(`[data-menu-id="addORImport"]`).click(); for (const [key, value] of Object.entries(expectedData)) {
cy.getActivePopUp().contains("Microsoft Excel").should('exist').click(); mainPage
.getCell(value[2], 1)
.contains(sheetData[0][value[0]])
.should("exist");
mainPage
.getCell(value[2], 2)
.contains(sheetData[1][value[0]])
.should("exist");
}
cy.closeTableTab("Sheet2");
cy.openTableTab("Sheet3", 2);
for (const [key, value] of Object.entries(expectedData)) {
mainPage
.getCell(value[2], 1)
.contains(sheetData[0][value[0]])
.should("exist");
mainPage
.getCell(value[2], 2)
.contains(sheetData[1][value[0]])
.should("exist");
}
cy.closeTableTab("Sheet3");
});
cy.getActiveModal().find('.ant-tabs-tab').last().click() it.skip("URL: Upload excel as template", () => {
// trigger import
cy.get(`[data-menu-id="addORImport"]`).click();
cy.getActivePopUp().contains("Microsoft Excel").should("exist").click();
cy.get("input[type=\"text\"]") cy.getActiveModal().find(".ant-tabs-tab").last().click();
.last()
.click()
.type(URL);
cy.get(".nc-btn-primary").should('exist').click();
});
it.skip("URL: Verify pre-load template page", () => { cy.get('input[type="text"]').last().click().type(URL);
cy.getActiveModal() cy.get(".nc-btn-primary").should("exist").click();
.find(".ant-collapse-item") });
.then((sheets) => {
it.skip("URL: Verify pre-load template page", () => {
let sheetList = ["Sheet1"]; cy.getActiveModal()
.find(".ant-collapse-item")
for (let i = 0; i < sheets.length; i++) { .then((sheets) => {
cy.wrap(sheets[i]) let sheetList = ["Sheet1"];
.find('.ant-collapse-header')
.contains(sheetList[i]) for (let i = 0; i < sheets.length; i++) {
.should("exist"); cy.wrap(sheets[i])
.find(".ant-collapse-header")
cy.wrap(sheets[i]).find(".ant-table-tbody").then((tables) => { .contains(sheetList[i])
cy.wrap(tables).find(".ant-table-row:visible") .should("exist");
.then((rows) => {
// cy.log(rows) cy.wrap(sheets[i])
for (let j = 0; j < 10; j++) { .find(".ant-table-tbody")
cy.wrap(rows[j]).find(".ant-table-cell").then((cells) => { .then((tables) => {
// cy.log(cells) cy.wrap(tables)
for (let k = 0; k < 2; k++) { .find(".ant-table-row:visible")
cy.wrap(cells[k]).find("input").then((input) => { .then((rows) => {
// cy.log(input) // cy.log(rows)
expect(input.val()).to.equal(UrlFileExpectedData[j][k]) for (let j = 0; j < 10; j++) {
}) cy.wrap(rows[j])
} .find(".ant-table-cell")
}) .then((cells) => {
} // cy.log(cells)
}) for (let k = 0; k < 2; k++) {
}) cy.wrap(cells[k])
.find("input")
// unwind .then((input) => {
cy.wrap(sheets[i]).find(".ant-collapse-arrow").click(); // cy.log(input)
} expect(input.val()).to.equal(
UrlFileExpectedData[j][k]
);
});
}
});
}
});
}); });
cy.getActiveModal().find(".ant-btn-primary").click(); // unwind
}) cy.wrap(sheets[i]).find(".ant-collapse-arrow").click();
}
it.skip("URL: Verify loaded data", () => {
// wait for loading to be completed
projectsPage.waitHomePageLoad();
// open sheet & validate contents
// sheetData contains data read from excel in format
// 0: { float: 1.1, number: 1, text: "abc" }
// 1: { float: 1.2, number: 0, text: "def" }
cy.openTableTab("Sheet1", 25);
let idx = 0;
for (const [key, value] of Object.entries(UrlFileExpectedData)) {
if (UrlFileExpectedData[idx][1] != "Date")
mainPage
.getCell(value[0], 1)
.contains(UrlFileExpectedData[idx++][2][0])
.should("exist");
}
cy.closeTableTab("Sheet1");
}); });
cy.getActiveModal().find(".ant-btn-primary").click();
});
it.skip("URL: Verify loaded data", () => {
// wait for loading to be completed
projectsPage.waitHomePageLoad();
// open sheet & validate contents
// sheetData contains data read from excel in format
// 0: { float: 1.1, number: 1, text: "abc" }
// 1: { float: 1.2, number: 0, text: "def" }
cy.openTableTab("Sheet1", 25);
let idx = 0;
for (const [key, value] of Object.entries(UrlFileExpectedData)) {
if (UrlFileExpectedData[idx][1] != "Date")
mainPage
.getCell(value[0], 1)
.contains(UrlFileExpectedData[idx++][2][0])
.should("exist");
}
cy.closeTableTab("Sheet1");
}); });
});
}; };
/** /**

49
scripts/cypress/integration/common/7b_import_from_airtable.js

@ -1,12 +1,15 @@
// Cypress test suite: Project import from Airtable // Cypress test suite: Project import from Airtable
// //
import { isTestSuiteActive, roles } from "../../support/page_objects/projectConstants"; import {
isTestSuiteActive,
roles,
} from "../../support/page_objects/projectConstants";
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";
let apiKey = "" let apiKey = "";
let sharedBase = "" let sharedBase = "";
export const genTest = (apiType, dbType) => { export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return; if (!isTestSuiteActive(apiType, dbType)) return;
@ -17,7 +20,10 @@ export const genTest = (apiType, dbType) => {
sharedBase = Cypress.env("airtable").sharedBase; sharedBase = Cypress.env("airtable").sharedBase;
loginPage.signIn(roles.owner.credentials); loginPage.signIn(roles.owner.credentials);
projectsPage.createProject({ dbType: "none", apiType: "REST", name: "importSample" }, {}) projectsPage.createProject(
{ dbType: "none", apiType: "REST", name: "importSample" },
{}
);
cy.saveLocalStorage(); cy.saveLocalStorage();
}); });
@ -37,25 +43,40 @@ export const genTest = (apiType, dbType) => {
cy.log(apiKey, sharedBase); cy.log(apiKey, sharedBase);
// trigger import // trigger import
cy.get('.nc-add-new-table').should('exist').trigger('mouseover') cy.get(".nc-add-new-table").should("exist").trigger("mouseover");
cy.get('.nc-import-menu').should('exist').click() cy.get(".nc-import-menu").should("exist").click();
cy.getActiveMenu(".nc-dropdown-import-menu").find('.ant-dropdown-menu-item').contains('Airtable').click() cy.getActiveMenu(".nc-dropdown-import-menu")
.find(".ant-dropdown-menu-item")
.contains("Airtable")
.click();
cy.getActiveModal(".nc-modal-airtable-import").find(".nc-input-api-key").should('exist').clear().type(apiKey) cy.getActiveModal(".nc-modal-airtable-import")
cy.getActiveModal(".nc-modal-airtable-import").find(".nc-input-shared-base").should('exist').clear().type(sharedBase) .find(".nc-input-api-key")
cy.getActiveModal(".nc-modal-airtable-import").find(".nc-btn-airtable-import").should('exist').click() .should("exist")
.clear()
.type(apiKey);
cy.getActiveModal(".nc-modal-airtable-import")
.find(".nc-input-shared-base")
.should("exist")
.clear()
.type(sharedBase);
cy.getActiveModal(".nc-modal-airtable-import")
.find(".nc-btn-airtable-import")
.should("exist")
.click();
// it will take a while for import to finish // it will take a while for import to finish
// cy.getActiveModal().find(".nc-btn-go-dashboard", {timeout: 180000}).should('exist').click() // cy.getActiveModal().find(".nc-btn-go-dashboard", {timeout: 180000}).should('exist').click()
// wait for import to finish (kludge/hardcoded) // wait for import to finish (kludge/hardcoded)
cy.get(':nth-child(51) > .flex', {timeout: 180000}).contains('Complete!').should('exist') cy.get(":nth-child(51) > .flex", { timeout: 180000 })
cy.get('.ant-modal-close-x').should('exist').click() .contains("Complete!")
.should("exist");
cy.get(".ant-modal-close-x").should("exist").click();
}); });
}); });
}; };
/** /**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd * @copyright Copyright (c) 2021, Xgene Cloud Ltd
* *
@ -76,4 +97,4 @@ export const genTest = (apiType, dbType) => {
* You should have received a copy of the GNU Affero General Public License * 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/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */

813
scripts/cypress/integration/common/9a_QuickTest.js

@ -1,425 +1,488 @@
import { import {
isTestSuiteActive, isTestSuiteActive,
roles, roles,
} from "../../support/page_objects/projectConstants"; } from "../../support/page_objects/projectConstants";
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";
// normal fields // normal fields
let records = { let records = {
Name: "Movie-1", Name: "Movie-1",
Notes: "Good", Notes: "Good",
Status: "Todo", Status: "Todo",
Tags: "Jan", Tags: "Jan",
Phone: "123123123", Phone: "123123123",
Email: "a@b.com", Email: "a@b.com",
URL: "www.a.com", URL: "www.a.com",
Number: "1", Number: "1",
Value: "$1.00", Value: "$1.00",
Percent: "0.01", Percent: "0.01",
}; };
// links/ computed fields // links/ computed fields
let records2 = { let records2 = {
Duration: "00:01", Duration: "00:01",
Done: true, Done: true,
Date: "2022-05-31", Date: "2022-05-31",
Rating: "1", Rating: "1",
Actor: ["Actor1", "Actor2"], Actor: ["Actor1", "Actor2"],
"Status (from Actor)": ["Todo", "In progress"], "Status (from Actor)": ["Todo", "In progress"],
RollUp: "128", RollUp: "128",
Computation: "4.04", Computation: "4.04",
Producer: ["P1", "P2"] Producer: ["P1", "P2"],
}; };
let tn = [ "Film", "Actor", "Producer", ] let tn = ["Film", "Actor", "Producer"];
let cn = [ "Name", "Notes", "Status", "Tags", "Done", "Date", "Phone", let cn = [
"Email", "URL", "Number", "Percent", "Duration", "Rating", "Name",
"Actor", "Status (from Actor)", "RollUp", "Computation", "Producer" ] "Notes",
"Status",
"Tags",
"Done",
"Date",
"Phone",
"Email",
"URL",
"Number",
"Percent",
"Duration",
"Rating",
"Actor",
"Status (from Actor)",
"RollUp",
"Computation",
"Producer",
];
function openWebhook(index) { function openWebhook(index) {
cy.get('.nc-actions-menu-btn').should('exist').click(); cy.get(".nc-actions-menu-btn").should("exist").click();
cy.getActiveMenu(".nc-dropdown-actions-menu").find('.ant-dropdown-menu-title-content').contains('Webhooks').click() cy.getActiveMenu(".nc-dropdown-actions-menu")
.find(".ant-dropdown-menu-title-content")
.contains("Webhooks")
.click();
cy.get(".nc-hook").eq(index).click(); cy.get(".nc-hook").eq(index).click();
} }
// to be invoked after open // to be invoked after open
function verifyWebhook(config) { function verifyWebhook(config) {
cy.get(".nc-text-field-hook-title").then(($element) => { cy.get(".nc-text-field-hook-title").then(($element) => {
expect($element[0].value).to.have.string(config.title) expect($element[0].value).to.have.string(config.title);
}) });
cy.get(".nc-text-field-hook-event") cy.get(".nc-text-field-hook-event")
.find('.ant-select-selection-item') .find(".ant-select-selection-item")
.contains(config.event) .contains(config.event)
.should('exist') .should("exist");
cy.get(".nc-select-hook-notification-type") cy.get(".nc-select-hook-notification-type")
.find('.ant-select-selection-item') .find(".ant-select-selection-item")
.contains(config.notification) .contains(config.notification)
.should('exist') .should("exist");
cy.get('.nc-select-hook-url-method') cy.get(".nc-select-hook-url-method")
.find('.ant-select-selection-item') .find(".ant-select-selection-item")
.contains(config.type) .contains(config.type)
.should('exist') .should("exist");
cy.get(".nc-text-field-hook-url-path") cy.get(".nc-text-field-hook-url-path").then(($element) => {
.then(($element) => { expect($element[0].value).to.have.string(config.url);
expect($element[0].value).to.have.string(config.url) });
}) cy.get(".nc-icon-hook-navigate-left").click({ force: true });
cy.get(".nc-icon-hook-navigate-left").click({force:true})
} }
export const genTest = (apiType, dbType, testMode) => { export const genTest = (apiType, dbType, testMode) => {
if (!isTestSuiteActive(apiType, dbType)) return; if (!isTestSuiteActive(apiType, dbType)) return;
describe(`Quick Tests`, () => { describe(`Quick Tests`, () => {
let cellIdx = 1;
let cellIdx = 1; let columnCount = cn.length;
let columnCount = cn.length if (testMode === "AT_IMPORT") {
if(testMode === 'AT_IMPORT') { cellIdx = 3;
cellIdx = 3; columnCount -= 3;
columnCount -= 3; }
}
before(() => {
before(() => { if (testMode === "CY_QUICK") {
if( testMode === 'CY_QUICK') { // cy.task("copyFile")
// cy.task("copyFile") loginPage.signIn(roles.owner.credentials);
loginPage.signIn(roles.owner.credentials); projectsPage.openProject("sample");
projectsPage.openProject("sample");
// kludge: wait for page load to finish
// kludge: wait for page load to finish cy.wait(2000);
cy.wait(2000); // close team & auth tab
// close team & auth tab cy.get("button.ant-tabs-tab-remove").should("exist").click();
cy.get('button.ant-tabs-tab-remove').should('exist').click(); cy.wait(1000);
cy.wait(1000); } else {
} cy.restoreLocalStorage();
else { }
cy.restoreLocalStorage();
} cy.openTableTab("Film", 3);
cy.saveLocalStorage();
cy.openTableTab("Film", 3) });
cy.saveLocalStorage();
});
beforeEach(() => { beforeEach(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
}) });
afterEach(() => { afterEach(() => {
cy.saveLocalStorage(); cy.saveLocalStorage();
}) });
after(() => { after(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
cy.signOut(); cy.signOut();
cy.saveLocalStorage(); cy.saveLocalStorage();
}); });
it("Verify Schema", () => { it("Verify Schema", () => {
// verify if all tables exist
for (let i = 0; i < tn.length; i++) {
cy.get(`.nc-project-tree-tbl-${tn[i]}`).should("exist");
}
// verify if all tables exist // for Film table, verify columns
for(let i=0; i<tn.length; i++) { for (let i = 0; i < columnCount; i++) {
cy.get(`.nc-project-tree-tbl-${tn[i]}`).should('exist') cy.get(`th[data-title="${cn[i]}"]`).should("exist");
} }
});
// for Film table, verify columns it("Verify Data types", () => {
for(let i=0; i<columnCount; i++) { // normal cells
cy.get(`th[data-title="${cn[i]}"]`).should("exist"); for (let [key, value] of Object.entries(records)) {
} mainPage.getCell(key, cellIdx).contains(value).should("exist");
}
// checkbox
mainPage
.getCell("Done", cellIdx)
.find(".nc-cell-hover-show")
.should(records2.Done ? "not.exist" : "exist");
// date
// duration
mainPage
.getCell("Duration", cellIdx)
.contains(records2.Duration)
.should("exist");
// rating
mainPage
.getCell("Rating", cellIdx)
.find(".ant-rate-star-full")
.should("have.length", records2.Rating);
// verifying only one instance as its different for PG & SQLite
// for PG: its Actor1, Actor1
// for SQLite: its Actor1, Actor2
// LinkToAnotherRecord
mainPage.getCell("Actor", cellIdx).scrollIntoView();
cy.get(`:nth-child(${cellIdx}) > [data-title="Actor"]`)
.find(".chip")
.eq(0)
.contains(records2.Actor[0])
.should("exist");
// lookup
mainPage.getCell("Status (from Actor)", cellIdx).scrollIntoView();
cy.get(`:nth-child(${cellIdx}) > [data-title="Status (from Actor)"]`)
.find(".nc-cell")
.eq(0)
.contains(records2["Status (from Actor)"][0])
.should("exist");
// rollup
if (testMode === "CY_QUICK") {
mainPage.getCell("RollUp", cellIdx).scrollIntoView();
mainPage
.getCell("RollUp", cellIdx)
.contains(records2.RollUp)
.should("exist");
// formula
mainPage.getCell("Computation", cellIdx).scrollIntoView();
mainPage
.getCell("Computation", cellIdx)
.contains(records2.Computation)
.should("exist");
// ltar hm relation
mainPage.getCell("Producer", cellIdx).scrollIntoView();
mainPage
.getCell("Producer", cellIdx)
.find(".chip")
.eq(0)
.contains(records2.Producer[0])
.should("exist");
mainPage
.getCell("Producer", cellIdx)
.find(".chip")
.eq(1)
.contains(records2.Producer[1])
.should("exist");
}
});
it("Verify Views & Shared base", () => {
cy.get(".nc-form-view-item:visible")
.should("exist")
.eq(0)
.click({ force: true });
// Header & description should exist
// cy.get(".nc-form")
// .find('[placeholder="Form Title"]')
// .contains("FormTitle")
// .should("exist");
// cy.get(".nc-form")
// .find('[placeholder="Add form description"]')
// .contains("FormDescription")
// .should("exist");
cy.get(".nc-form").should("exist");
cy.get(".nc-form")
.find('[placeholder="Form Title"]')
.should("exist")
.then(($el) => {
cy.log($el);
expect($el.val()).to.equal("FormTitle");
});
cy.get(".nc-form")
.find('[placeholder="Add form description"]')
.should("exist")
.then(($el) => {
cy.log($el);
expect($el.val()).to.equal("FormDescription");
}); });
it("Verify Data types", () => { // modified column name & help text
cy.get(".nc-editable")
// normal cells .eq(0)
for (let [key, value] of Object.entries(records)) { .find(".name")
mainPage.getCell(key, cellIdx).contains(value).should("exist"); .contains("DisplayName")
} .should("exist");
cy.get(".nc-editable")
// checkbox .eq(0)
mainPage .find(".text-gray-500")
.getCell("Done", cellIdx) .contains("HelpText")
.find(".nc-cell-hover-show") .should("exist");
.should(records2.Done ? "not.exist" : "exist");
cy.get(".nc-editable")
// date .eq(1)
.find(".name")
// duration .contains("Email")
mainPage.getCell("Duration", cellIdx).contains(records2.Duration).should("exist"); .should("exist");
// rating // add message
mainPage cy.get("textarea.nc-form-after-submit-msg").then(($element) => {
.getCell("Rating", cellIdx) expect($element[0].value).to.have.string(
.find(".ant-rate-star-full") "Thank you for submitting the form!"
.should("have.length", records2.Rating); );
});
// verifying only one instance as its different for PG & SQLite // cy.get(".nc-form > .mx-auto")
// for PG: its Actor1, Actor1 // .find("textarea").then(($element) => {
// for SQLite: its Actor1, Actor2 // expect($element[0].value).to.have.string("Thank you for submitting the form!")
// LinkToAnotherRecord // })
mainPage.getCell("Actor", cellIdx).scrollIntoView();
cy.get(`:nth-child(${cellIdx}) > [data-title="Actor"]`) cy.get(
.find('.chip') "button.nc-form-checkbox-submit-another-form.ant-switch-checked"
.eq(0) ).should("exist");
.contains(records2.Actor[0]) cy.get(
.should("exist"); "button.nc-form-checkbox-show-blank-form.ant-switch-checked"
).should("exist");
// lookup cy.get("button.nc-form-checkbox-send-email.ant-switch-checked").should(
mainPage.getCell("Status (from Actor)", cellIdx).scrollIntoView(); "not.exist"
cy.get(`:nth-child(${cellIdx}) > [data-title="Status (from Actor)"]`) );
.find('.nc-cell')
.eq(0) // // submit another form button
.contains(records2["Status (from Actor)"][0]) // cy.get(".nc-form > .mx-auto")
.should("exist"); // .find('[type="checkbox"]')
// .eq(0)
// rollup // .should('be.checked')
if( testMode === 'CY_QUICK') { // // "New form after 5 seconds" button
// cy.get(".nc-form > .mx-auto")
mainPage.getCell("RollUp", cellIdx).scrollIntoView(); // .find('[type="checkbox"]')
mainPage.getCell("RollUp", cellIdx).contains(records2.RollUp).should("exist"); // .eq(1)
// .should('be.checked')
// formula // // email me
mainPage.getCell("Computation", cellIdx).scrollIntoView(); // cy.get(".nc-form > .mx-auto")
mainPage.getCell("Computation", cellIdx).contains(records2.Computation).should("exist"); // .find('[type="checkbox"]')
// .eq(2)
// ltar hm relation // .should('not.be.checked')
mainPage.getCell("Producer", cellIdx).scrollIntoView();
mainPage.getCell("Producer", cellIdx).find('.chip').eq(0).contains(records2.Producer[0]).should('exist') cy.closeTableTab("Film");
mainPage.getCell("Producer", cellIdx).find('.chip').eq(1).contains(records2.Producer[1]).should('exist') });
}
it("Verify Webhooks", () => {
if (testMode === "CY_QUICK") {
cy.openTableTab("Actor", 25);
openWebhook(0);
verifyWebhook({
title: "Webhook-1",
event: "After Insert",
notification: "URL",
type: "POST",
url: "http://localhost:9090/hook",
condition: false,
}); });
cy.get("body").type("{esc}");
it("Verify Views & Shared base", () => {
cy.get('.nc-form-view-item:visible') openWebhook(1);
.should('exist') verifyWebhook({
.eq(0) title: "Webhook-2",
.click({ force: true }) event: "After Update",
notification: "URL",
// Header & description should exist type: "POST",
// cy.get(".nc-form") url: "http://localhost:9090/hook",
// .find('[placeholder="Form Title"]') condition: false,
// .contains("FormTitle")
// .should("exist");
// cy.get(".nc-form")
// .find('[placeholder="Add form description"]')
// .contains("FormDescription")
// .should("exist");
cy.get(".nc-form").should("exist");
cy.get(".nc-form")
.find('[placeholder="Form Title"]')
.should("exist").then(($el) => {
cy.log($el)
expect($el.val()).to.equal("FormTitle");
})
cy.get(".nc-form")
.find('[placeholder="Add form description"]')
.should("exist").then(($el) => {
cy.log($el)
expect($el.val()).to.equal("FormDescription");
})
// modified column name & help text
cy.get(".nc-editable").eq(0)
.find('.name')
.contains("DisplayName")
.should('exist')
cy.get(".nc-editable").eq(0)
.find('.text-gray-500')
.contains('HelpText')
.should('exist')
cy.get(".nc-editable").eq(1)
.find('.name')
.contains("Email")
.should('exist')
// add message
cy.get("textarea.nc-form-after-submit-msg").then(($element) => {
expect($element[0].value).to.have.string("Thank you for submitting the form!")
})
// cy.get(".nc-form > .mx-auto")
// .find("textarea").then(($element) => {
// expect($element[0].value).to.have.string("Thank you for submitting the form!")
// })
cy.get("button.nc-form-checkbox-submit-another-form.ant-switch-checked").should('exist')
cy.get("button.nc-form-checkbox-show-blank-form.ant-switch-checked").should('exist')
cy.get("button.nc-form-checkbox-send-email.ant-switch-checked").should('not.exist')
// // submit another form button
// cy.get(".nc-form > .mx-auto")
// .find('[type="checkbox"]')
// .eq(0)
// .should('be.checked')
// // "New form after 5 seconds" button
// cy.get(".nc-form > .mx-auto")
// .find('[type="checkbox"]')
// .eq(1)
// .should('be.checked')
// // email me
// cy.get(".nc-form > .mx-auto")
// .find('[type="checkbox"]')
// .eq(2)
// .should('not.be.checked')
cy.closeTableTab("Film");
}); });
cy.get("body").type("{esc}");
it("Verify Webhooks", () => {
if( testMode === 'CY_QUICK') { openWebhook(2);
cy.openTableTab("Actor", 25); verifyWebhook({
openWebhook(0) title: "Webhook-3",
verifyWebhook({ event: "After Delete",
title: "Webhook-1", notification: "URL",
event: "After Insert", type: "POST",
notification: "URL", url: "http://localhost:9090/hook",
type: "POST", condition: false,
url: "http://localhost:9090/hook",
condition: false
})
cy.get("body").type("{esc}");
openWebhook(1)
verifyWebhook({
title: "Webhook-2",
event: "After Update",
notification: "URL",
type: "POST",
url: "http://localhost:9090/hook",
condition: false
})
cy.get("body").type("{esc}");
openWebhook(2)
verifyWebhook({
title: "Webhook-3",
event: "After Delete",
notification: "URL",
type: "POST",
url: "http://localhost:9090/hook",
condition: false
})
cy.get("body").type("{esc}");
cy.closeTableTab("Actor");
}
}); });
cy.get("body").type("{esc}");
it("Pagination", () => { cy.closeTableTab("Actor");
cy.openTableTab("Actor", 25); }
});
cy.get(".nc-pagination").should("exist");
// verify > pagination option it("Pagination", () => {
mainPage.getPagination(">").click(); cy.openTableTab("Actor", 25);
mainPage
.getPagination(2)
.should("have.class", "ant-pagination-item-active");
// verify < pagination option cy.get(".nc-pagination").should("exist");
mainPage.getPagination("<").click();
mainPage
.getPagination(1)
.should("have.class", "ant-pagination-item-active");
cy.closeTableTab("Actor"); // verify > pagination option
}); mainPage.getPagination(">").click();
mainPage
.getPagination(2)
.should("have.class", "ant-pagination-item-active");
it("Verify Fields, Filter & Sort", () => { // verify < pagination option
cy.openTableTab("Actor", 25); mainPage.getPagination("<").click();
mainPage
cy.get(".nc-grid-view-item").eq(1).click() .getPagination(1)
.should("have.class", "ant-pagination-item-active");
cy.wait(3000)
cy.get(".nc-grid-header").find(`th[data-title="Name"]`).should("be.visible");
cy.get(".nc-grid-header").find(`th[data-title="Notes"]`).should("be.visible");
cy.get(".nc-grid-header").find(`th[data-title="Attachments"]`).should("not.exist");
cy.get(".nc-grid-header").find(`th[data-title="Status"]`).should("be.visible");
cy.get(".nc-grid-header").find(`th[data-title="Film"]`).should("be.visible");
cy.wait(2000);
cy.get(".nc-fields-menu-btn").click()
cy.getActiveMenu(".nc-dropdown-fields-menu").find(`[type="checkbox"]`).eq(0).should('be.checked')
cy.getActiveMenu(".nc-dropdown-fields-menu").find(`[type="checkbox"]`).eq(1).should('be.checked')
cy.getActiveMenu(".nc-dropdown-fields-menu").find(`[type="checkbox"]`).eq(2).should('not.be.checked')
cy.getActiveMenu(".nc-dropdown-fields-menu").find(`[type="checkbox"]`).eq(3).should('be.checked')
cy.getActiveMenu(".nc-dropdown-fields-menu").find(`[type="checkbox"]`).eq(4).should('be.checked')
cy.get(".nc-fields-menu-btn").click();
cy.get(".nc-sort-menu-btn").click();
cy.get(".nc-sort-field-select").eq(0)
.contains('Name')
.should("exist");
cy.get(".nc-sort-dir-select").eq(0)
.contains('A → Z')
.should("exist");
cy.get(".nc-sort-menu-btn").click();
cy.get(".nc-filter-menu-btn").click();
cy.get(".nc-filter-field-select").eq(0)
.contains('Name')
.should("exist");
cy.get(".nc-filter-operation-select").eq(0)
.contains('is like')
.should("exist");
cy.get(".nc-filter-field-select").eq(1)
.contains('Name')
.should("exist");
cy.get(".nc-filter-operation-select").eq(1)
.contains('is like')
.should("exist");
cy.get(".nc-filter-menu-btn").click();
cy.closeTableTab("Actor");
});
it("Views, bt relation", () => { cy.closeTableTab("Actor");
if( testMode === 'CY_QUICK') { });
cy.openTableTab("Producer", 3)
cy.get('.nc-grid-view-item').should('have.length', 4) it("Verify Fields, Filter & Sort", () => {
cy.get('.nc-form-view-item').should('have.length', 4) cy.openTableTab("Actor", 25);
cy.get('.nc-gallery-view-item').should('have.length', 3)
cy.get(".nc-grid-view-item").eq(1).click();
cy.wait(3000);
cy.get(".nc-grid-header")
.find(`th[data-title="Name"]`)
.should("be.visible");
cy.get(".nc-grid-header")
.find(`th[data-title="Notes"]`)
.should("be.visible");
cy.get(".nc-grid-header")
.find(`th[data-title="Attachments"]`)
.should("not.exist");
cy.get(".nc-grid-header")
.find(`th[data-title="Status"]`)
.should("be.visible");
cy.get(".nc-grid-header")
.find(`th[data-title="Film"]`)
.should("be.visible");
cy.wait(2000);
cy.get(".nc-fields-menu-btn").click();
cy.getActiveMenu(".nc-dropdown-fields-menu")
.find(`[type="checkbox"]`)
.eq(0)
.should("be.checked");
cy.getActiveMenu(".nc-dropdown-fields-menu")
.find(`[type="checkbox"]`)
.eq(1)
.should("be.checked");
cy.getActiveMenu(".nc-dropdown-fields-menu")
.find(`[type="checkbox"]`)
.eq(2)
.should("not.be.checked");
cy.getActiveMenu(".nc-dropdown-fields-menu")
.find(`[type="checkbox"]`)
.eq(3)
.should("be.checked");
cy.getActiveMenu(".nc-dropdown-fields-menu")
.find(`[type="checkbox"]`)
.eq(4)
.should("be.checked");
cy.get(".nc-fields-menu-btn").click();
cy.get(".nc-sort-menu-btn").click();
cy.get(".nc-sort-field-select").eq(0).contains("Name").should("exist");
cy.get(".nc-sort-dir-select").eq(0).contains("A → Z").should("exist");
cy.get(".nc-sort-menu-btn").click();
cy.get(".nc-filter-menu-btn").click();
cy.get(".nc-filter-field-select").eq(0).contains("Name").should("exist");
cy.get(".nc-filter-operation-select")
.eq(0)
.contains("is like")
.should("exist");
cy.get(".nc-filter-field-select").eq(1).contains("Name").should("exist");
cy.get(".nc-filter-operation-select")
.eq(1)
.contains("is like")
.should("exist");
cy.get(".nc-filter-menu-btn").click();
cy.closeTableTab("Actor");
});
// LinkToAnotherRecord hm relation it("Views, bt relation", () => {
mainPage.getCell("FilmRead", 1).scrollIntoView(); if (testMode === "CY_QUICK") {
cy.get('[data-title="FilmRead"] > .h-full > .nc-virtual-cell > .w-full > .chips > .chip > .name') cy.openTableTab("Producer", 3);
// cy.get(
// ':nth-child(1) > [data-col="FilmRead"] > .nc-virtual-cell > .v-lazy > .d-100 > .chips > :nth-child(1) > .v-chip__content > .name' cy.get(".nc-grid-view-item").should("have.length", 4);
// ) cy.get(".nc-form-view-item").should("have.length", 4);
.contains('Movie-1') cy.get(".nc-gallery-view-item").should("have.length", 3);
.should("exist");
// LinkToAnotherRecord hm relation
mainPage.getCell("FilmRead", 1).scrollIntoView();
cy.get(
'[data-title="FilmRead"] > .h-full > .nc-virtual-cell > .w-full > .chips > .chip > .name'
)
// cy.get(
// ':nth-child(1) > [data-col="FilmRead"] > .nc-virtual-cell > .v-lazy > .d-100 > .chips > :nth-child(1) > .v-chip__content > .name'
// )
.contains("Movie-1")
.should("exist");
cy.closeTableTab("Producer");
}
});
cy.closeTableTab("Producer") it.skip("Delete Project", () => {
} if (testMode === "AT_IMPORT") {
mainPage.toolBarTopLeft(mainPage.HOME).click({ force: true });
cy.get(`.mdi-delete-outline`, {
timeout: 10000,
}) })
.should("exist")
it.skip("Delete Project", () => { .last()
if( testMode === 'AT_IMPORT') { .click();
mainPage.toolBarTopLeft(mainPage.HOME).click({force:true})
cy.get(`.mdi-delete-outline`, { cy.getActiveModal(".nc-modal-project-delete")
timeout: 10000, .find("button")
}) .contains("Submit")
.should("exist") .should("exist")
.last() .click();
.click(); cy.toastWait("deleted successfully");
}
cy.getActiveModal(".nc-modal-project-delete")
.find("button")
.contains("Submit")
.should("exist")
.click();
cy.toastWait("deleted successfully");
}
});
}); });
});
}; };
// genTest("rest", "xcdb"); // genTest("rest", "xcdb");

500
scripts/cypress/integration/common/9b_ERD.js

@ -1,6 +1,10 @@
import { mainPage, settingsPage } from "../../support/page_objects/mainPage"; import { mainPage, settingsPage } from "../../support/page_objects/mainPage";
import {loginPage, projectsPage} from "../../support/page_objects/navigation"; import { loginPage, projectsPage } from "../../support/page_objects/navigation";
import { isTestSuiteActive, sakilaSqlViews, sakilaTables } from "../../support/page_objects/projectConstants"; import {
isTestSuiteActive,
sakilaSqlViews,
sakilaTables,
} from "../../support/page_objects/projectConstants";
export const genTest = (apiType, dbType) => { export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return; if (!isTestSuiteActive(apiType, dbType)) return;
@ -14,11 +18,11 @@ export const genTest = (apiType, dbType) => {
beforeEach(() => { beforeEach(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
}) });
afterEach(() => { afterEach(() => {
cy.saveLocalStorage(); cy.saveLocalStorage();
}) });
after(() => { after(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
@ -31,319 +35,415 @@ export const genTest = (apiType, dbType) => {
it(`Enable MM setting Open Table ERD`, () => { it(`Enable MM setting Open Table ERD`, () => {
cy.openTableTab("Country", 25); cy.openTableTab("Country", 25);
mainPage.toggleShowMMSetting(); mainPage.toggleShowMMSetting();
mainPage.openErdTab(); mainPage.openErdTab();
mainPage.closeMetaTab(); mainPage.closeMetaTab();
}); });
it(`Verify ERD Context menu in all table view`, () => { it(`Verify ERD Context menu in all table view`, () => {
mainPage.openErdTab(); mainPage.openErdTab();
cy.get('.nc-erd-context-menu').should('be.visible'); cy.get(".nc-erd-context-menu").should("be.visible");
cy.get('.nc-erd-context-menu').get('.nc-erd-histogram').should('be.visible'); cy.get(".nc-erd-context-menu")
cy.get('.nc-erd-context-menu').find('.ant-checkbox').should('have.length', 3); .get(".nc-erd-histogram")
cy.get('.nc-erd-context-menu').find('.ant-checkbox').eq(0).should('have.class', 'ant-checkbox-checked'); .should("be.visible");
cy.get('.nc-erd-context-menu').find('.ant-checkbox').eq(1).should('have.class', 'ant-checkbox-checked'); cy.get(".nc-erd-context-menu")
cy.get('.nc-erd-context-menu').find('.ant-checkbox').eq(2).should('not.have.class', 'ant-checkbox-checked'); .find(".ant-checkbox")
.should("have.length", 3);
cy.get('.nc-erd-context-menu').find('.nc-erd-showColumns-label').dblclick(); cy.get(".nc-erd-context-menu")
cy.get('.nc-erd-context-menu').find('.ant-checkbox').should('have.length', 5); .find(".ant-checkbox")
.eq(0)
.should("have.class", "ant-checkbox-checked");
cy.get(".nc-erd-context-menu")
.find(".ant-checkbox")
.eq(1)
.should("have.class", "ant-checkbox-checked");
cy.get(".nc-erd-context-menu")
.find(".ant-checkbox")
.eq(2)
.should("not.have.class", "ant-checkbox-checked");
cy.get(".nc-erd-context-menu")
.find(".nc-erd-showColumns-label")
.dblclick();
cy.get(".nc-erd-context-menu")
.find(".ant-checkbox")
.should("have.length", 5);
}); });
it("Verify ERD of all tables view and verify columns of actor and payment with default config", () => { it("Verify ERD of all tables view and verify columns of actor and payment with default config", () => {
cy.get('.nc-erd-vue-flow').find('.nc-erd-table-node').should('have.length', 12) cy.get(".nc-erd-vue-flow")
cy.get('.nc-erd-vue-flow').find('.vue-flow__edge').should('have.length', 14) .find(".nc-erd-table-node")
cy.get('.nc-erd-vue-flow').find('.nc-erd-edge-circle').should('have.length', 11) .should("have.length", 12);
cy.get('.nc-erd-vue-flow').find('.nc-erd-edge-rect').should('have.length', 17) cy.get(".nc-erd-vue-flow")
.find(".vue-flow__edge")
for(const tableName of sakilaTables) { .should("have.length", 14);
cy.get('.nc-erd-vue-flow').find(`.nc-erd-table-node-${tableName}`).should('exist'); cy.get(".nc-erd-vue-flow")
.find(".nc-erd-edge-circle")
.should("have.length", 11);
cy.get(".nc-erd-vue-flow")
.find(".nc-erd-edge-rect")
.should("have.length", 17);
for (const tableName of sakilaTables) {
cy.get(".nc-erd-vue-flow")
.find(`.nc-erd-table-node-${tableName}`)
.should("exist");
} }
// Actor table // Actor table
[ [
'actor_id', "actor_id",
'first_name', "first_name",
'last_name', "last_name",
'last_update', "last_update",
'film_list' "film_list",
].forEach((colTitle) => { ].forEach((colTitle) => {
cy.get('.nc-erd-vue-flow').find(`.nc-erd-table-node-actor`).find(`.nc-erd-table-node-actor-column-${colTitle}`).should('exist'); cy.get(".nc-erd-vue-flow")
.find(`.nc-erd-table-node-actor`)
.find(`.nc-erd-table-node-actor-column-${colTitle}`)
.should("exist");
}); });
// Payment table // Payment table
[ [
'payment_id', "payment_id",
'customer_id', "customer_id",
'staff_id', "staff_id",
'rental_id', "rental_id",
'amount', "amount",
'payment_date', "payment_date",
'last_update', "last_update",
'customer', "customer",
'rental', "rental",
'staff' "staff",
].forEach((colTitle) => { ].forEach((colTitle) => {
cy.get('.nc-erd-vue-flow').find(`.nc-erd-table-node-payment`).find(`.nc-erd-table-node-payment-column-${colTitle}`).should('exist'); cy.get(".nc-erd-vue-flow")
.find(`.nc-erd-table-node-payment`)
.find(`.nc-erd-table-node-payment-column-${colTitle}`)
.should("exist");
}); });
}); });
it("Verify ERD of all tables view and verify columns of actor and payment with default config with showAllColumn disabled", () => { it("Verify ERD of all tables view and verify columns of actor and payment with default config with showAllColumn disabled", () => {
cy.get('.nc-erd-context-menu').get('.nc-erd-showColumns-checkbox').click(); cy.get(".nc-erd-context-menu")
cy.get('.nc-erd-showPkAndFk-checkbox-disabled').should('exist'); .get(".nc-erd-showColumns-checkbox")
cy.get('.nc-erd-showPkAndFk-checkbox-unchecked').should('exist'); .click();
cy.get(".nc-erd-showPkAndFk-checkbox-disabled").should("exist");
cy.get(".nc-erd-showPkAndFk-checkbox-unchecked").should("exist");
// Actor table // Actor table
[ ["film_list"].forEach((colTitle) => {
'film_list' cy.get(".nc-erd-vue-flow")
].forEach((colTitle) => { .find(`.nc-erd-table-node-actor`)
cy.get('.nc-erd-vue-flow').find(`.nc-erd-table-node-actor`).find(`.nc-erd-table-node-actor-column-${colTitle}`).should('exist'); .find(`.nc-erd-table-node-actor-column-${colTitle}`)
.should("exist");
}); });
// Payment table // Payment table
[ ["customer", "rental", "staff"].forEach((colTitle) => {
'customer', cy.get(".nc-erd-vue-flow")
'rental', .find(`.nc-erd-table-node-payment`)
'staff' .find(`.nc-erd-table-node-payment-column-${colTitle}`)
].forEach((colTitle) => { .should("exist");
cy.get('.nc-erd-vue-flow').find(`.nc-erd-table-node-payment`).find(`.nc-erd-table-node-payment-column-${colTitle}`).should('exist');
}); });
}); });
it("Verify ERD of all tables view and verify columns of actor and payment with default config with showPkAndFk disabled", () => { it("Verify ERD of all tables view and verify columns of actor and payment with default config with showPkAndFk disabled", () => {
// enable showAllColumn // enable showAllColumn
cy.get('.nc-erd-context-menu').get('.nc-erd-showColumns-checkbox').click(); cy.get(".nc-erd-context-menu")
cy.get('.nc-erd-context-menu').get('.nc-erd-showPkAndFk-checkbox').click(); .get(".nc-erd-showColumns-checkbox")
.click();
cy.get(".nc-erd-context-menu")
.get(".nc-erd-showPkAndFk-checkbox")
.click();
// Actor table // Actor table
[ ["last_name", "last_update", "film_list"].forEach((colTitle) => {
'last_name', cy.get(".nc-erd-vue-flow")
'last_update', .find(`.nc-erd-table-node-actor`)
'film_list' .find(`.nc-erd-table-node-actor-column-${colTitle}`)
].forEach((colTitle) => { .should("exist");
cy.get('.nc-erd-vue-flow').find(`.nc-erd-table-node-actor`).find(`.nc-erd-table-node-actor-column-${colTitle}`).should('exist');
}); });
// Payment table // Payment table
[ [
'amount', "amount",
'payment_date', "payment_date",
'last_update', "last_update",
'customer', "customer",
'rental', "rental",
'staff' "staff",
].forEach((colTitle) => { ].forEach((colTitle) => {
cy.get('.nc-erd-vue-flow').find(`.nc-erd-table-node-payment`).find(`.nc-erd-table-node-payment-column-${colTitle}`).should('exist'); cy.get(".nc-erd-vue-flow")
.find(`.nc-erd-table-node-payment`)
.find(`.nc-erd-table-node-payment-column-${colTitle}`)
.should("exist");
}); });
}); });
it("Verify ERD of all tables view with sql grid on and verify columns of ActorInfo", () => { it("Verify ERD of all tables view with sql grid on and verify columns of ActorInfo", () => {
cy.get('.nc-erd-context-menu').get('.nc-erd-showViews-checkbox').click(); cy.get(".nc-erd-context-menu").get(".nc-erd-showViews-checkbox").click();
cy.get('.nc-erd-vue-flow').find('.nc-erd-table-node').should('have.length', 19) cy.get(".nc-erd-vue-flow")
cy.get('.nc-erd-vue-flow').find('.vue-flow__edge').should('have.length', 14) .find(".nc-erd-table-node")
cy.get('.nc-erd-vue-flow').find('.nc-erd-edge-circle').should('have.length', 11) .should("have.length", 19);
cy.get('.nc-erd-vue-flow').find('.nc-erd-edge-rect').should('have.length', 17) cy.get(".nc-erd-vue-flow")
.find(".vue-flow__edge")
for(const tableName of sakilaTables) { .should("have.length", 14);
cy.get('.nc-erd-vue-flow').find(`.nc-erd-table-node-${tableName}`).should('exist'); cy.get(".nc-erd-vue-flow")
.find(".nc-erd-edge-circle")
.should("have.length", 11);
cy.get(".nc-erd-vue-flow")
.find(".nc-erd-edge-rect")
.should("have.length", 17);
for (const tableName of sakilaTables) {
cy.get(".nc-erd-vue-flow")
.find(`.nc-erd-table-node-${tableName}`)
.should("exist");
} }
for(const tableName of sakilaSqlViews) { for (const tableName of sakilaSqlViews) {
cy.get('.nc-erd-vue-flow').find(`.nc-erd-table-node-${tableName}`).should('exist'); cy.get(".nc-erd-vue-flow")
.find(`.nc-erd-table-node-${tableName}`)
.should("exist");
} }
// ActorInfo SQL View // ActorInfo SQL View
[ ["actor_id", "first_name", "last_name", "film_info"].forEach(
'actor_id', (colTitle) => {
'first_name', cy.get(".nc-erd-vue-flow")
'last_name', .find(`.nc-erd-table-node-actor_info`)
'film_info' .find(`.nc-erd-table-node-actor_info-column-${colTitle}`)
].forEach((colTitle) => { .should("exist");
cy.get('.nc-erd-vue-flow').find(`.nc-erd-table-node-actor_info`).find(`.nc-erd-table-node-actor_info-column-${colTitle}`).should('exist'); }
}) );
}); });
it("Verify show MM tables", () => { it("Verify show MM tables", () => {
cy.get('.nc-erd-vue-flow').find(`.nc-erd-table-node-store`).should('not.exist'); cy.get(".nc-erd-vue-flow")
.find(`.nc-erd-table-node-store`)
.should("not.exist");
// disable showViews // disable showViews
cy.get('.nc-erd-context-menu').get('.nc-erd-showViews-checkbox').click(); cy.get(".nc-erd-context-menu").get(".nc-erd-showViews-checkbox").click();
cy.get('.nc-erd-context-menu').get('.nc-erd-showMMTables-checkbox').click(); cy.get(".nc-erd-context-menu")
.get(".nc-erd-showMMTables-checkbox")
cy.get('.nc-erd-vue-flow').find('.nc-erd-table-node').should('have.length', 16) .click();
cy.get('.nc-erd-vue-flow').find('.vue-flow__edge').should('have.length', 26)
cy.get('.nc-erd-vue-flow').find('.nc-erd-edge-circle').should('have.length', 22) cy.get(".nc-erd-vue-flow")
cy.get('.nc-erd-vue-flow').find('.nc-erd-edge-rect').should('have.length', 30) .find(".nc-erd-table-node")
.should("have.length", 16);
cy.get(".nc-erd-vue-flow")
.find(".vue-flow__edge")
.should("have.length", 26);
cy.get(".nc-erd-vue-flow")
.find(".nc-erd-edge-circle")
.should("have.length", 22);
cy.get(".nc-erd-vue-flow")
.find(".nc-erd-edge-rect")
.should("have.length", 30);
// Check if store table is present // Check if store table is present
cy.get('.nc-erd-vue-flow').find(`.nc-erd-table-node-store`).should('exist'); cy.get(".nc-erd-vue-flow")
}) .find(`.nc-erd-table-node-store`)
.should("exist");
});
it("Verify show junction table names", () => { it("Verify show junction table names", () => {
// disable showViews // disable showViews
cy.get('.nc-erd-context-menu').get('.nc-erd-showJunctionTableNames-checkbox').click(); cy.get(".nc-erd-context-menu")
.get(".nc-erd-showJunctionTableNames-checkbox")
.click();
cy.get('.nc-erd-vue-flow').get('.nc-erd-table-label-filmactor-film_actor').should('exist'); cy.get(".nc-erd-vue-flow")
.get(".nc-erd-table-label-filmactor-film_actor")
.should("exist");
mainPage.closeMetaTab(); mainPage.closeMetaTab();
}) });
it('Verify table ERD view of country', () => { it("Verify table ERD view of country", () => {
mainPage.openTableErdView(); mainPage.openTableErdView();
cy.get('.nc-erd-vue-flow-single-table').find('.nc-erd-table-node').should('have.length', 2) cy.get(".nc-erd-vue-flow-single-table")
cy.get('.nc-erd-vue-flow-single-table').find('.vue-flow__edge').should('have.length', 1) .find(".nc-erd-table-node")
cy.get('.nc-erd-vue-flow-single-table').find('.nc-erd-edge-circle').should('have.length', 1) .should("have.length", 2);
cy.get('.nc-erd-vue-flow-single-table').find('.nc-erd-edge-rect').should('have.length', 1) cy.get(".nc-erd-vue-flow-single-table")
.find(".vue-flow__edge")
.should("have.length", 1);
cy.get(".nc-erd-vue-flow-single-table")
.find(".nc-erd-edge-circle")
.should("have.length", 1);
cy.get(".nc-erd-vue-flow-single-table")
.find(".nc-erd-edge-rect")
.should("have.length", 1);
const countryColumns = [ const countryColumns = [
'country_id', "country_id",
'country', "country",
'last_update', "last_update",
'city_list' "city_list",
] ];
// Country table // Country table
countryColumns.forEach((colTitle) => { countryColumns.forEach((colTitle) => {
cy.get('.nc-erd-vue-flow-single-table').find(`.nc-erd-table-node-country`).find(`.nc-erd-table-node-country-column-${colTitle}`).should('exist'); cy.get(".nc-erd-vue-flow-single-table")
.find(`.nc-erd-table-node-country`)
.find(`.nc-erd-table-node-country-column-${colTitle}`)
.should("exist");
}); });
const cityColumns = [ const cityColumns = [
'city_id', "city_id",
'city', "city",
'last_update', "last_update",
'country', "country",
'address_list' "address_list",
] ];
// City table // City table
cityColumns.forEach((colTitle) => { cityColumns.forEach((colTitle) => {
cy.get('.nc-erd-vue-flow-single-table').find(`.nc-erd-table-node-city`).find(`.nc-erd-table-node-city-column-${colTitle}`).should('exist'); cy.get(".nc-erd-vue-flow-single-table")
.find(`.nc-erd-table-node-city`)
.find(`.nc-erd-table-node-city-column-${colTitle}`)
.should("exist");
}); });
}) });
it('Verify table ERD view of country showAllColumn disabled', () => { it("Verify table ERD view of country showAllColumn disabled", () => {
cy.get('.nc-erd-vue-flow-single-table').within(() => { cy.get(".nc-erd-vue-flow-single-table").within(() => {
cy.get('.nc-erd-context-menu').get('.nc-erd-showColumns-checkbox').click(); cy.get(".nc-erd-context-menu")
cy.get('.nc-erd-showPkAndFk-checkbox-disabled').should('exist'); .get(".nc-erd-showColumns-checkbox")
cy.get('.nc-erd-showPkAndFk-checkbox-unchecked').should('exist'); .click();
cy.get(".nc-erd-showPkAndFk-checkbox-disabled").should("exist");
const countryColumns = [ cy.get(".nc-erd-showPkAndFk-checkbox-unchecked").should("exist");
'city_list'
] const countryColumns = ["city_list"];
// Country table // Country table
countryColumns.forEach((colTitle) => { countryColumns.forEach((colTitle) => {
cy.get(`.nc-erd-table-node-country`).find(`.nc-erd-table-node-country-column-${colTitle}`).should('exist'); cy.get(`.nc-erd-table-node-country`)
.find(`.nc-erd-table-node-country-column-${colTitle}`)
.should("exist");
}); });
const cityColumns = [ const cityColumns = ["country", "address_list"];
'country',
'address_list'
]
// City table // City table
cityColumns.forEach((colTitle) => { cityColumns.forEach((colTitle) => {
cy.get(`.nc-erd-table-node-city`).find(`.nc-erd-table-node-city-column-${colTitle}`).should('exist'); cy.get(`.nc-erd-table-node-city`)
.find(`.nc-erd-table-node-city-column-${colTitle}`)
.should("exist");
}); });
cy.get('.nc-erd-context-menu').get('.nc-erd-showColumns-checkbox').click(); cy.get(".nc-erd-context-menu")
}) .get(".nc-erd-showColumns-checkbox")
}) .click();
});
});
it("Verify table ERD view of country show PK AND FK disabled", () => {
cy.get(".nc-erd-vue-flow-single-table").within(() => {
cy.get(".nc-erd-context-menu")
.get(".nc-erd-showPkAndFk-checkbox")
.click();
it('Verify table ERD view of country show PK AND FK disabled', () => { const countryColumns = ["country", "last_update", "city_list"];
cy.get('.nc-erd-vue-flow-single-table').within(() => {
cy.get('.nc-erd-context-menu').get('.nc-erd-showPkAndFk-checkbox').click();
const countryColumns = [
'country',
'last_update',
'city_list'
]
// Country table // Country table
countryColumns.forEach((colTitle) => { countryColumns.forEach((colTitle) => {
cy.get(`.nc-erd-table-node-country`).find(`.nc-erd-table-node-country-column-${colTitle}`).should('exist'); cy.get(`.nc-erd-table-node-country`)
.find(`.nc-erd-table-node-country-column-${colTitle}`)
.should("exist");
}); });
const cityColumns = [ const cityColumns = ["city", "last_update", "country", "address_list"];
'city',
'last_update',
'country',
'address_list'
]
// City table // City table
cityColumns.forEach((colTitle) => { cityColumns.forEach((colTitle) => {
cy.get(`.nc-erd-table-node-city`).find(`.nc-erd-table-node-city-column-${colTitle}`).should('exist'); cy.get(`.nc-erd-table-node-city`)
.find(`.nc-erd-table-node-city-column-${colTitle}`)
.should("exist");
}); });
cy.get('.nc-erd-context-menu').get('.nc-erd-showPkAndFk-checkbox').click(); cy.get(".nc-erd-context-menu")
.get(".nc-erd-showPkAndFk-checkbox")
}) .click();
cy.getActiveModal().find('.nc-modal-close').click({ force: true }); });
}) cy.getActiveModal().find(".nc-modal-close").click({ force: true });
});
it('create column and check if the change is in the schema', () => { it("create column and check if the change is in the schema", () => {
mainPage.addColumn('test_column', 'country') mainPage.addColumn("test_column", "country");
// table view // table view
mainPage.openTableErdView(); mainPage.openTableErdView();
cy.get('.nc-erd-vue-flow-single-table').within(() => { cy.get(".nc-erd-vue-flow-single-table").within(() => {
cy.get('.nc-erd-table-node-country').find('.nc-erd-table-node-country-column-test_column').should('exist'); cy.get(".nc-erd-table-node-country")
}) .find(".nc-erd-table-node-country-column-test_column")
cy.getActiveModal().find('.nc-modal-close').click({ force: true }); .should("exist");
});
cy.getActiveModal().find(".nc-modal-close").click({ force: true });
// All table view // All table view
mainPage.openErdTab(); mainPage.openErdTab();
cy.get('.nc-erd-vue-flow').within(() => { cy.get(".nc-erd-vue-flow").within(() => {
cy.get('.nc-erd-table-node-country').find('.nc-erd-table-node-country-column-test_column').should('exist'); cy.get(".nc-erd-table-node-country")
}) .find(".nc-erd-table-node-country-column-test_column")
.should("exist");
});
mainPage.closeMetaTab(); mainPage.closeMetaTab();
mainPage.deleteColumn("test_column");
mainPage.deleteColumn('test_column')
// table view // table view
mainPage.openTableErdView(); mainPage.openTableErdView();
cy.get('.nc-erd-vue-flow-single-table').within(() => { cy.get(".nc-erd-vue-flow-single-table").within(() => {
cy.get('.nc-erd-table-node-country').find('.nc-erd-table-node-country-column-test_column').should('not.exist'); cy.get(".nc-erd-table-node-country")
}) .find(".nc-erd-table-node-country-column-test_column")
cy.getActiveModal().find('.nc-modal-close').click({ force: true }); .should("not.exist");
});
cy.getActiveModal().find(".nc-modal-close").click({ force: true });
// All table view // All table view
mainPage.openErdTab(); mainPage.openErdTab();
cy.get('.nc-erd-vue-flow').within(() => { cy.get(".nc-erd-vue-flow").within(() => {
cy.get('.nc-erd-table-node-country').find('.nc-erd-table-node-country-column-test_column').should('not.exist'); cy.get(".nc-erd-table-node-country")
}) .find(".nc-erd-table-node-country-column-test_column")
.should("not.exist");
});
mainPage.closeMetaTab(); mainPage.closeMetaTab();
}) });
it('Create table should reflected in ERD', () => { it("Create table should reflected in ERD", () => {
cy.createTable('new') cy.createTable("new");
mainPage.openErdTab(); mainPage.openErdTab();
cy.get('.nc-erd-vue-flow').within(() => { cy.get(".nc-erd-vue-flow").within(() => {
cy.get('.nc-erd-table-node-new').should('exist'); cy.get(".nc-erd-table-node-new").should("exist");
}) });
mainPage.closeMetaTab(); mainPage.closeMetaTab();
cy.deleteTable('new') cy.deleteTable("new");
mainPage.openErdTab(); mainPage.openErdTab();
cy.get('.nc-erd-vue-flow').within(() => { cy.get(".nc-erd-vue-flow").within(() => {
cy.get('.nc-erd-table-node-new').should('not.exist'); cy.get(".nc-erd-table-node-new").should("not.exist");
}) });
mainPage.closeMetaTab(); mainPage.closeMetaTab();
}) });
it(`Disable MM setting Open Table ERD and check easter egg should not work`, () => { it(`Disable MM setting Open Table ERD and check easter egg should not work`, () => {
mainPage.toggleShowMMSetting(); mainPage.toggleShowMMSetting();
mainPage.openErdTab(); mainPage.openErdTab();
cy.get('.nc-erd-vue-flow').within(() => { cy.get(".nc-erd-vue-flow").within(() => {
cy.get('.nc-erd-context-menu').find('.nc-erd-showColumns-label').dblclick(); cy.get(".nc-erd-context-menu")
cy.get('.nc-erd-context-menu').find('.ant-checkbox').should('have.length', 3); .find(".nc-erd-showColumns-label")
}) .dblclick();
cy.get(".nc-erd-context-menu")
.find(".ant-checkbox")
.should("have.length", 3);
});
mainPage.closeMetaTab(); mainPage.closeMetaTab();
}); });

48
scripts/cypress/integration/test/explicitLogin.js

@ -2,35 +2,35 @@ import { loginPage } from "../../support/page_objects/navigation";
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"; import { isTestSuiteActive } from "../../support/page_objects/projectConstants";
export const genTest = (apiType, dbType) => { export const genTest = (apiType, dbType) => {
// if (!isTestSuiteActive(apiType, dbType)) return; // if (!isTestSuiteActive(apiType, dbType)) return;
describe(`${apiType.toUpperCase()} api - Login & Open project`, () => { describe(`${apiType.toUpperCase()} api - Login & Open project`, () => {
// Run once before test- create project (rest/graphql) // Run once before test- create project (rest/graphql)
// //
before(() => { before(() => {
// loginPage.loginAndOpenProject(apiType, dbType); // loginPage.loginAndOpenProject(apiType, dbType);
// open a table to work on views // open a table to work on views
// cy.openTableTab('City'); // cy.openTableTab('City');
}); });
it(``, () => { it(``, () => {
cy.log("Test-1"); cy.log("Test-1");
let projId = ""; let projId = "";
let query = `SELECT prefix from nc_projects_v2 where title = "sampleREST"; `; let query = `SELECT prefix from nc_projects_v2 where title = "sampleREST"; `;
cy.task("sqliteExecReturnValue", query) cy.task("sqliteExecReturnValue", query)
.then((resolve) => { .then((resolve) => {
cy.log(resolve); cy.log(resolve);
projId = resolve.prefix.split("_")[1]; projId = resolve.prefix.split("_")[1];
cy.log(projId); cy.log(projId);
}) })
.then(() => { .then(() => {
let query = `ALTER TABLE "actor" RENAME TO "${projId}actor"`; let query = `ALTER TABLE "actor" RENAME TO "${projId}actor"`;
cy.task("sqliteExec", query); cy.task("sqliteExec", query);
cy.wait(1000); cy.wait(1000);
});
}); });
}); });
});
}; };
// genTest("rest", "mysql"); // genTest("rest", "mysql");

30
scripts/cypress/integration/test/pg-restMisc.js

@ -8,29 +8,29 @@ let t6f = require("../common/6f_attachments");
let t6g = require("../common/6g_base_share"); let t6g = require("../common/6g_base_share");
let t7a = require("../common/7a_create_project_from_excel"); let t7a = require("../common/7a_create_project_from_excel");
const { const {
setCurrentMode, setCurrentMode,
} = require("../../support/page_objects/projectConstants"); } = require("../../support/page_objects/projectConstants");
const t8a = require("../common/8a_webhook"); const t8a = require("../common/8a_webhook");
const nocoTestSuite = (apiType, dbType) => { const nocoTestSuite = (apiType, dbType) => {
setCurrentMode(apiType, dbType); setCurrentMode(apiType, dbType);
t01.genTest(apiType, dbType); t01.genTest(apiType, dbType);
t6b.genTest(apiType, dbType); t6b.genTest(apiType, dbType);
t6d.genTest(apiType, dbType); t6d.genTest(apiType, dbType);
// exclude@ncv2 t6c.genTest(apiType, dbType); // exclude@ncv2 t6c.genTest(apiType, dbType);
t6f.genTest(apiType, dbType); t6f.genTest(apiType, dbType);
t6g.genTest(apiType, dbType); t6g.genTest(apiType, dbType);
// webhook tests // webhook tests
t8a.genTest(apiType, dbType) t8a.genTest(apiType, dbType);
// **deletes created project, hence place it @ end // **deletes created project, hence place it @ end
t6e.genTest(apiType, dbType); t6e.genTest(apiType, dbType);
// intended to keep this after earlier project deletion // intended to keep this after earlier project deletion
// creates project using excel & deletes it // creates project using excel & deletes it
t7a.genTest(apiType, dbType); t7a.genTest(apiType, dbType);
}; };
nocoTestSuite("rest", "postgres"); nocoTestSuite("rest", "postgres");

10
scripts/cypress/integration/test/pg-restRoles.js

@ -3,15 +3,15 @@ let t01 = require("../common/00_pre_configurations");
let t5a = require("../common/5a_user_role"); let t5a = require("../common/5a_user_role");
let t5b = require("../common/5b_preview_role"); let t5b = require("../common/5b_preview_role");
const { const {
setCurrentMode, setCurrentMode,
} = require("../../support/page_objects/projectConstants"); } = require("../../support/page_objects/projectConstants");
const nocoTestSuite = (apiType, dbType) => { const nocoTestSuite = (apiType, dbType) => {
setCurrentMode(apiType, dbType); setCurrentMode(apiType, dbType);
t01.genTest(apiType, dbType); t01.genTest(apiType, dbType);
t5a.genTest(apiType, dbType); t5a.genTest(apiType, dbType);
// t5b.genTest(apiType, dbType); // t5b.genTest(apiType, dbType);
}; };
nocoTestSuite("rest", "postgres"); nocoTestSuite("rest", "postgres");

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

@ -13,25 +13,25 @@ let t3c = require("../common/3c_lookup_column");
let t3d = require("../common/3d_rollup_column"); let t3d = require("../common/3d_rollup_column");
let t3e = require("../common/3e_duration_column"); let t3e = require("../common/3e_duration_column");
const { const {
setCurrentMode, setCurrentMode,
} = require("../../support/page_objects/projectConstants"); } = require("../../support/page_objects/projectConstants");
const nocoTestSuite = (apiType, dbType) => { const nocoTestSuite = (apiType, dbType) => {
setCurrentMode(apiType, dbType); setCurrentMode(apiType, dbType);
t01.genTest(apiType, dbType); t01.genTest(apiType, dbType);
t1a.genTest(apiType, dbType); t1a.genTest(apiType, dbType);
t1b.genTest(apiType, dbType); t1b.genTest(apiType, dbType);
t1c.genTest(apiType, dbType); t1c.genTest(apiType, dbType);
// NcGUI v2 t1d.genTest(apiType, dbType); // NcGUI v2 t1d.genTest(apiType, dbType);
t1e.genTest(apiType, dbType); t1e.genTest(apiType, dbType);
t2a.genTest(apiType, dbType); t2a.genTest(apiType, dbType);
t2b.genTest(apiType, dbType); t2b.genTest(apiType, dbType);
t3a.genTest(apiType, dbType); t3a.genTest(apiType, dbType);
t3b.genTest(apiType, dbType); t3b.genTest(apiType, dbType);
t3c.genTest(apiType, dbType); t3c.genTest(apiType, dbType);
t3d.genTest(apiType, dbType); t3d.genTest(apiType, dbType);
// NcGUI v2 t3e.genTest(apiType, dbType); // NcGUI v2 t3e.genTest(apiType, dbType);
}; };
nocoTestSuite("rest", "postgres"); nocoTestSuite("rest", "postgres");

22
scripts/cypress/integration/test/pg-restViews.js

@ -8,21 +8,21 @@ let t4e = require("../common/4e_form_view_share");
let t4f = require("../common/4f_pg_grid_view_share"); let t4f = require("../common/4f_pg_grid_view_share");
let t4g = require("../common/4g_table_view_expanded_form"); let t4g = require("../common/4g_table_view_expanded_form");
const { const {
setCurrentMode, setCurrentMode,
} = require("../../support/page_objects/projectConstants"); } = require("../../support/page_objects/projectConstants");
const nocoTestSuite = (apiType, dbType) => { const nocoTestSuite = (apiType, dbType) => {
setCurrentMode(apiType, dbType); setCurrentMode(apiType, dbType);
t01.genTest(apiType, dbType); t01.genTest(apiType, dbType);
// place plugin related activities at top // place plugin related activities at top
t4c.genTest(apiType, dbType); t4c.genTest(apiType, dbType);
t4a.genTest(apiType, dbType); t4a.genTest(apiType, dbType);
t4b.genTest(apiType, dbType); t4b.genTest(apiType, dbType);
t4d.genTest(apiType, dbType); t4d.genTest(apiType, dbType);
t4e.genTest(apiType, dbType); t4e.genTest(apiType, dbType);
t4g.genTest(apiType, dbType); t4g.genTest(apiType, dbType);
// tbd t4f.genTest(apiType, dbType); // tbd t4f.genTest(apiType, dbType);
}; };
nocoTestSuite("rest", "postgres"); nocoTestSuite("rest", "postgres");

4
scripts/cypress/integration/test/quickTest.js

@ -10,7 +10,7 @@ const nocoTestSuite = (apiType, dbType) => {
t9a.genTest(apiType, dbType, "CY_QUICK"); t9a.genTest(apiType, dbType, "CY_QUICK");
// AT Import verification // AT Import verification
t7b.genTest(apiType, dbType) t7b.genTest(apiType, dbType);
t9a.genTest(apiType, dbType, "AT_IMPORT"); t9a.genTest(apiType, dbType, "AT_IMPORT");
}; };
@ -36,4 +36,4 @@ nocoTestSuite("rest", "xcdb");
* You should have received a copy of the GNU Affero General Public License * 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/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */

44
scripts/cypress/integration/test/restMisc.js

@ -10,31 +10,31 @@ let t7a = require("../common/7a_create_project_from_excel");
let t8a = require("../common/8a_webhook"); let t8a = require("../common/8a_webhook");
let t9b = require("../common/9b_ERD"); let t9b = require("../common/9b_ERD");
const { const {
setCurrentMode, setCurrentMode,
} = require("../../support/page_objects/projectConstants"); } = require("../../support/page_objects/projectConstants");
const nocoTestSuite = (apiType, dbType) => { const nocoTestSuite = (apiType, dbType) => {
setCurrentMode(apiType, dbType); setCurrentMode(apiType, dbType);
t01.genTest(apiType, dbType); t01.genTest(apiType, dbType);
t6b.genTest(apiType, dbType); t6b.genTest(apiType, dbType);
t6d.genTest(apiType, dbType); t6d.genTest(apiType, dbType);
// exclude@ncv2 t6c.genTest(apiType, dbType); // exclude@ncv2 t6c.genTest(apiType, dbType);
t6f.genTest(apiType, dbType); t6f.genTest(apiType, dbType);
t9b.genTest(apiType, dbType); t9b.genTest(apiType, dbType);
t6g.genTest(apiType, dbType); t6g.genTest(apiType, dbType);
// webhook tests // webhook tests
t8a.genTest(apiType, dbType) t8a.genTest(apiType, dbType);
// **deletes created project, hence place it @ end // **deletes created project, hence place it @ end
t6e.genTest(apiType, dbType); t6e.genTest(apiType, dbType);
// intended to keep this after earlier project deletion // intended to keep this after earlier project deletion
// creates project using excel & deletes it // creates project using excel & deletes it
t7a.genTest(apiType, dbType); t7a.genTest(apiType, dbType);
}; };
nocoTestSuite("rest", "mysql"); nocoTestSuite("rest", "mysql");

10
scripts/cypress/integration/test/restRoles.js

@ -3,15 +3,15 @@ let t01 = require("../common/00_pre_configurations");
let t5a = require("../common/5a_user_role"); let t5a = require("../common/5a_user_role");
let t5b = require("../common/5b_preview_role"); let t5b = require("../common/5b_preview_role");
const { const {
setCurrentMode, setCurrentMode,
} = require("../../support/page_objects/projectConstants"); } = require("../../support/page_objects/projectConstants");
const nocoTestSuite = (apiType, dbType) => { const nocoTestSuite = (apiType, dbType) => {
setCurrentMode(apiType, dbType); setCurrentMode(apiType, dbType);
t01.genTest(apiType, dbType); t01.genTest(apiType, dbType);
t5a.genTest(apiType, dbType); t5a.genTest(apiType, dbType);
// t5b.genTest(apiType, dbType); // t5b.genTest(apiType, dbType);
}; };
nocoTestSuite("rest", "mysql"); nocoTestSuite("rest", "mysql");

22
scripts/cypress/integration/test/restViews.js

@ -8,21 +8,21 @@ let t4e = require("../common/4e_form_view_share");
let t4f = require("../common/4f_grid_view_share"); let t4f = require("../common/4f_grid_view_share");
let t4g = require("../common/4g_table_view_expanded_form"); let t4g = require("../common/4g_table_view_expanded_form");
const { const {
setCurrentMode, setCurrentMode,
} = require("../../support/page_objects/projectConstants"); } = require("../../support/page_objects/projectConstants");
const nocoTestSuite = (apiType, dbType) => { const nocoTestSuite = (apiType, dbType) => {
setCurrentMode(apiType, dbType); setCurrentMode(apiType, dbType);
t01.genTest(apiType, dbType); t01.genTest(apiType, dbType);
// place plugin related activities at top // place plugin related activities at top
t4c.genTest(apiType, dbType); t4c.genTest(apiType, dbType);
t4a.genTest(apiType, dbType); t4a.genTest(apiType, dbType);
t4b.genTest(apiType, dbType); t4b.genTest(apiType, dbType);
t4d.genTest(apiType, dbType); t4d.genTest(apiType, dbType);
t4e.genTest(apiType, dbType); t4e.genTest(apiType, dbType);
t4f.genTest(apiType, dbType); t4f.genTest(apiType, dbType);
t4g.genTest(apiType, dbType); t4g.genTest(apiType, dbType);
}; };
nocoTestSuite("rest", "mysql"); nocoTestSuite("rest", "mysql");

32
scripts/cypress/integration/test/xcdb-restMisc.js

@ -7,31 +7,31 @@ let t6e = require("../common/6e_project_operations");
let t6f = require("../common/6f_attachments"); let t6f = require("../common/6f_attachments");
let t6g = require("../common/6g_base_share"); let t6g = require("../common/6g_base_share");
let t7a = require("../common/7a_create_project_from_excel"); let t7a = require("../common/7a_create_project_from_excel");
let t8a = require("../common/8a_webhook") let t8a = require("../common/8a_webhook");
const { const {
setCurrentMode, setCurrentMode,
} = require("../../support/page_objects/projectConstants"); } = require("../../support/page_objects/projectConstants");
const nocoTestSuite = (apiType, dbType) => { const nocoTestSuite = (apiType, dbType) => {
setCurrentMode(apiType, dbType); setCurrentMode(apiType, dbType);
t01.genTest(apiType, dbType); t01.genTest(apiType, dbType);
t6b.genTest(apiType, dbType); t6b.genTest(apiType, dbType);
t6d.genTest(apiType, dbType); t6d.genTest(apiType, dbType);
// exclude@ncv2 t6c.genTest(apiType, dbType); // exclude@ncv2 t6c.genTest(apiType, dbType);
t6f.genTest(apiType, dbType); t6f.genTest(apiType, dbType);
t6g.genTest(apiType, dbType); t6g.genTest(apiType, dbType);
// webhook tests // webhook tests
t8a.genTest(apiType, dbType) t8a.genTest(apiType, dbType);
// **deletes created project, hence place it @ end // **deletes created project, hence place it @ end
t6e.genTest(apiType, dbType); t6e.genTest(apiType, dbType);
// intended to keep this after earlier project deletion // intended to keep this after earlier project deletion
// creates project using excel & deletes it // creates project using excel & deletes it
t7a.genTest(apiType, dbType); t7a.genTest(apiType, dbType);
}; };
nocoTestSuite("rest", "xcdb"); nocoTestSuite("rest", "xcdb");

10
scripts/cypress/integration/test/xcdb-restRoles.js

@ -3,15 +3,15 @@ let t01 = require("../common/00_pre_configurations");
let t5a = require("../common/5a_user_role"); let t5a = require("../common/5a_user_role");
let t5b = require("../common/5b_preview_role"); let t5b = require("../common/5b_preview_role");
const { const {
setCurrentMode, setCurrentMode,
} = require("../../support/page_objects/projectConstants"); } = require("../../support/page_objects/projectConstants");
const nocoTestSuite = (apiType, dbType) => { const nocoTestSuite = (apiType, dbType) => {
setCurrentMode(apiType, dbType); setCurrentMode(apiType, dbType);
t01.genTest(apiType, dbType); t01.genTest(apiType, dbType);
t5a.genTest(apiType, dbType); t5a.genTest(apiType, dbType);
// t5b.genTest(apiType, dbType); // t5b.genTest(apiType, dbType);
}; };
nocoTestSuite("rest", "xcdb"); nocoTestSuite("rest", "xcdb");

30
scripts/cypress/integration/test/xcdb-restTableOps.js

@ -12,25 +12,25 @@ let t3c = require("../common/3c_lookup_column");
let t3d = require("../common/3d_rollup_column"); let t3d = require("../common/3d_rollup_column");
let t3e = require("../common/3e_duration_column"); let t3e = require("../common/3e_duration_column");
const { const {
setCurrentMode, setCurrentMode,
} = require("../../support/page_objects/projectConstants"); } = require("../../support/page_objects/projectConstants");
const nocoTestSuite = (apiType, dbType) => { const nocoTestSuite = (apiType, dbType) => {
setCurrentMode(apiType, dbType); setCurrentMode(apiType, dbType);
t01.genTest(apiType, dbType); t01.genTest(apiType, dbType);
t1a.genTest(apiType, dbType); t1a.genTest(apiType, dbType);
t1b.genTest(apiType, dbType); t1b.genTest(apiType, dbType);
t1c.genTest(apiType, dbType); t1c.genTest(apiType, dbType);
// NcGUI v2 t1d.genTest(apiType, dbType); // NcGUI v2 t1d.genTest(apiType, dbType);
t1e.genTest(apiType, dbType); t1e.genTest(apiType, dbType);
t2a.genTest(apiType, dbType); t2a.genTest(apiType, dbType);
t2b.genTest(apiType, dbType); t2b.genTest(apiType, dbType);
t3a.genTest(apiType, dbType); t3a.genTest(apiType, dbType);
t3b.genTest(apiType, dbType); t3b.genTest(apiType, dbType);
t3c.genTest(apiType, dbType); t3c.genTest(apiType, dbType);
t3d.genTest(apiType, dbType); t3d.genTest(apiType, dbType);
// NcGUI v2 t3e.genTest(apiType, dbType); // NcGUI v2 t3e.genTest(apiType, dbType);
}; };
nocoTestSuite("rest", "xcdb"); nocoTestSuite("rest", "xcdb");

20
scripts/cypress/integration/test/xcdb-restViews.js

@ -7,20 +7,20 @@ let t4d = require("../common/4d_table_view_grid_locked");
let t4e = require("../common/4e_form_view_share"); let t4e = require("../common/4e_form_view_share");
let t4f = require("../common/4f_grid_view_share"); let t4f = require("../common/4f_grid_view_share");
const { const {
setCurrentMode, setCurrentMode,
} = require("../../support/page_objects/projectConstants"); } = require("../../support/page_objects/projectConstants");
const nocoTestSuite = (apiType, dbType) => { const nocoTestSuite = (apiType, dbType) => {
setCurrentMode(apiType, dbType); setCurrentMode(apiType, dbType);
t01.genTest(apiType, dbType); t01.genTest(apiType, dbType);
// place plugin related activities at top // place plugin related activities at top
t4c.genTest(apiType, dbType); t4c.genTest(apiType, dbType);
t4a.genTest(apiType, dbType); t4a.genTest(apiType, dbType);
t4b.genTest(apiType, dbType); t4b.genTest(apiType, dbType);
t4d.genTest(apiType, dbType); t4d.genTest(apiType, dbType);
// to be fixed t4e.genTest(apiType, dbType); // to be fixed t4e.genTest(apiType, dbType);
t4f.genTest(apiType, dbType); t4f.genTest(apiType, dbType);
}; };
nocoTestSuite("rest", "xcdb"); nocoTestSuite("rest", "xcdb");

359
scripts/cypress/plugins/index.js

@ -15,93 +15,93 @@ const { rmdir, copyFile } = require("fs");
// https://stackoverflow.com/questions/61934443/read-excel-files-in-cypress // https://stackoverflow.com/questions/61934443/read-excel-files-in-cypress
const readXlsx = require("./read-xlsx"); const readXlsx = require("./read-xlsx");
const makeServer = require('./server') const makeServer = require("./server");
/** /**
* @type {Cypress.PluginConfig} * @type {Cypress.PluginConfig}
*/ */
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
module.exports = (on, config) => { module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits // `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config // `config` is the resolved Cypress config
// register utility tasks to read and parse Excel files // register utility tasks to read and parse Excel files
on("task", { on("task", {
copyFile() { copyFile() {
console.log("copyFile", __dirname) console.log("copyFile", __dirname);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
copyFile("./scripts/cypress/fixtures/quickTest/noco_0_91_7.db", "./packages/nocodb/noco.db", (err) => { copyFile(
if(err) { "./scripts/cypress/fixtures/quickTest/noco_0_91_7.db",
console.log(err) "./packages/nocodb/noco.db",
return reject(err) (err) => {
} if (err) {
resolve(null); console.log(err);
}) return reject(err);
}) }
}, resolve(null);
deleteFolder(folderName) { }
console.log("deleting folder %s", folderName); );
});
return new Promise((resolve, reject) => { },
rmdir( deleteFolder(folderName) {
folderName, console.log("deleting folder %s", folderName);
{ maxRetries: 10, recursive: true },
(err) => { return new Promise((resolve, reject) => {
if (err) { rmdir(folderName, { maxRetries: 10, recursive: true }, (err) => {
console.error(err); if (err) {
console.error(err);
return reject(err);
} return reject(err);
}
resolve(null);
} resolve(null);
); });
}); });
}, },
readXlsx: readXlsx.read, readXlsx: readXlsx.read,
readSheetList: readXlsx.sheetList, readSheetList: readXlsx.sheetList,
log(message) { log(message) {
console.log(`##Cypress>> ${message}`); console.log(`##Cypress>> ${message}`);
return null; return null;
}, },
queryDb: (query) => { queryDb: (query) => {
return queryTestDb(query, config); return queryTestDb(query, config);
}, },
sqliteExec: (query) => { sqliteExec: (query) => {
_sqliteExec(query); _sqliteExec(query);
return null; return null;
}, },
sqliteExecReturnValue: (query) => { sqliteExecReturnValue: (query) => {
return _sqliteExecReturnValue(query); return _sqliteExecReturnValue(query);
}, },
pgExec: (query) => { pgExec: (query) => {
_pgExec(query); _pgExec(query);
return null; return null;
}, },
pgExecTest: (query) => { pgExecTest: (query) => {
return _pgExecTest(query); return _pgExecTest(query);
} },
}); });
let server, port, close let server, port, close;
on('before:spec', async (spec) => { on("before:spec", async (spec) => {
// we can customize the server based on the spec about to run // we can customize the server based on the spec about to run
const info = await makeServer() const info = await makeServer();
// save the server instance information // save the server instance information
server = info.server server = info.server;
port = info.port port = info.port;
close = info.close close = info.close;
console.log('started the server on port %d', port) console.log("started the server on port %d", port);
}) });
on('after:spec', async (spec) => { on("after:spec", async (spec) => {
if (!server) { if (!server) {
console.log('no server to close') console.log("no server to close");
return return;
} }
await close() await close();
console.log('closed the server running on port %d', port) console.log("closed the server running on port %d", port);
}) });
}; };
// mysql connection // mysql connection
@ -109,126 +109,127 @@ module.exports = (on, config) => {
const mysql = require("mysql2"); const mysql = require("mysql2");
function queryTestDb(query, config) { function queryTestDb(query, config) {
// creates a new mysql connection using credentials from cypress.json env's // creates a new mysql connection using credentials from cypress.json env's
const connection = mysql.createConnection(config.env.db); const connection = mysql.createConnection(config.env.db);
// start connection to db // start connection to db
connection.connect(); connection.connect();
// exec query + disconnect to db as a Promise // exec query + disconnect to db as a Promise
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
connection.query(query, (error, results) => { connection.query(query, (error, results) => {
if (error) reject(error); if (error) reject(error);
else { else {
connection.end(); connection.end();
// console.log(results) // console.log(results)
return resolve(results); return resolve(results);
} }
});
}); });
});
} }
// sqlite connection // sqlite connection
const sqlite3 = require("sqlite3").verbose(); const sqlite3 = require("sqlite3").verbose();
function _sqliteExecReturnValue(query) { function _sqliteExecReturnValue(query) {
// open the database // open the database
console.log("Current directory: " + process.cwd()); console.log("Current directory: " + process.cwd());
let db = new sqlite3.Database( let db = new sqlite3.Database(
"./scripts/cypress/fixtures/sqlite-sakila/sakila.db", "./scripts/cypress/fixtures/sqlite-sakila/sakila.db",
sqlite3.OPEN_READWRITE, sqlite3.OPEN_READWRITE,
(err) => { (err) => {
if (err) { if (err) {
console.error(err.message); console.error(err.message);
} else { } else {
console.log("Connected to the noco xcdb database."); console.log("Connected to the noco xcdb database.");
} }
} }
); );
// exec query + disconnect to db as a Promise // exec query + disconnect to db as a Promise
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
db.get(query, [], (err, row) => { db.get(query, [], (err, row) => {
db.close(); db.close();
if (err) { if (err) {
reject(err); reject(err);
} else { } else {
return resolve(row); return resolve(row);
} }
});
}); });
});
} }
function _sqliteExec(query) { function _sqliteExec(query) {
// open the database // open the database
console.log("Current directory: " + process.cwd()); console.log("Current directory: " + process.cwd());
let db = new sqlite3.Database( let db = new sqlite3.Database(
"./scripts/cypress/fixtures/sqlite-sakila/sakila.db", "./scripts/cypress/fixtures/sqlite-sakila/sakila.db",
sqlite3.OPEN_READWRITE, sqlite3.OPEN_READWRITE,
(err) => { (err) => {
if (err) { if (err) {
console.error(err.message); console.error(err.message);
} else { } else {
console.log("Connected to the noco xcdb database."); console.log("Connected to the noco xcdb database.");
} }
} }
); );
db.serialize(() => { db.serialize(() => {
db.run(query); db.run(query);
}); });
db.close((err) => { db.close((err) => {
if (err) { if (err) {
console.error(err.message); console.error(err.message);
} else { } else {
console.log("Close the database connection."); console.log("Close the database connection.");
} }
}); });
} }
// pg connection // pg connection
const { Pool, Client } = require("pg"); const { Pool, Client } = require("pg");
const pg_credentials = { const pg_credentials = {
user: "postgres", user: "postgres",
host: "localhost", host: "localhost",
database: "postgres", database: "postgres",
password: "password", password: "password",
port: 5432, port: 5432,
}; };
function _pgExec(query) { function _pgExec(query) {
// open pg client connection // open pg client connection
const client = new Client(pg_credentials); const client = new Client(pg_credentials);
client.connect(); client.connect();
// query & terminate // query & terminate
client.query(query, (err, res) => { client.query(query, (err, res) => {
console.log(err, res); console.log(err, res);
client.end(); client.end();
}); });
} }
function _pgExecTest(query, retryCount = 60) { function _pgExecTest(query, retryCount = 60) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
// open pg client connection // open pg client connection
const client = new Client(pg_credentials); const client = new Client(pg_credentials);
client.connect().catch(() => {
client.end();
});
// query & terminate client.connect().catch(() => {
client.query(query, (err, res) => { client.end();
if (err) { });
if (retryCount--)
return setTimeout(() => _pgExecTest(query, retryCount).then(resolve).catch(reject), 2000);
else
reject(err);
}
console.log('==== success ===', res); // query & terminate
resolve(true); client.query(query, (err, res) => {
client.end(); if (err) {
}); if (retryCount--)
return setTimeout(
() => _pgExecTest(query, retryCount).then(resolve).catch(reject),
2000
);
else reject(err);
}
console.log("==== success ===", res);
resolve(true);
client.end();
}); });
});
} }
/** /**

20
scripts/cypress/plugins/read-xlsx.js

@ -4,10 +4,10 @@ const fs = require("fs");
const XLSX = require("xlsx"); const XLSX = require("xlsx");
const read = ({ file, sheet }) => { const read = ({ file, sheet }) => {
const buf = fs.readFileSync(file); const buf = fs.readFileSync(file);
const workbook = XLSX.read(buf, { type: "buffer" }); const workbook = XLSX.read(buf, { type: "buffer" });
const rows = XLSX.utils.sheet_to_json(workbook.Sheets[sheet]); const rows = XLSX.utils.sheet_to_json(workbook.Sheets[sheet]);
return rows; return rows;
}; };
// const read = ({file, sheet}) => { // const read = ({file, sheet}) => {
@ -21,13 +21,13 @@ const read = ({ file, sheet }) => {
// } // }
const sheetList = ({ file }) => { const sheetList = ({ file }) => {
const buf = fs.readFileSync(file); const buf = fs.readFileSync(file);
const workbook = XLSX.read(buf, { type: "buffer" }); const workbook = XLSX.read(buf, { type: "buffer" });
const rows = workbook.SheetNames; const rows = workbook.SheetNames;
return rows; return rows;
}; };
module.exports = { module.exports = {
read, read,
sheetList, sheetList,
}; };

61
scripts/cypress/plugins/server.js

@ -1,65 +1,64 @@
// https://glebbahmutov.com/blog/restart-server/ // https://glebbahmutov.com/blog/restart-server/
const express = require('express') const express = require("express");
const bodyParser = require("body-parser") const bodyParser = require("body-parser");
let request = [] let request = [];
function makeServer() { function makeServer() {
const app = express() const app = express();
app.use(bodyParser.json()) app.use(bodyParser.json());
app.get("/hook/all", (req, res) => { app.get("/hook/all", (req, res) => {
// console.log(request) // console.log(request)
res.json(request) res.json(request);
}) });
app.get("/hook/last", (req, res) => { app.get("/hook/last", (req, res) => {
if(request.length) { if (request.length) {
// console.log(request[request.length - 1]) // console.log(request[request.length - 1])
res.json(request[request.length - 1]) res.json(request[request.length - 1]);
} }
}) });
app.get("/hook/count", (req, res) => { app.get("/hook/count", (req, res) => {
// console.log(request.length) // console.log(request.length)
res.json(request.length) res.json(request.length);
}) });
app.get("/hook/clear", (req, res) => { app.get("/hook/clear", (req, res) => {
request = [] request = [];
res.status(200).end() res.status(200).end();
}) });
app.post("/hook", (req, res) => { app.post("/hook", (req, res) => {
request.push(req.body) request.push(req.body);
// console.log("/hook :: ", req.body) // Call your action on the request here // console.log("/hook :: ", req.body) // Call your action on the request here
res.status(200).end() // Responding is important res.status(200).end(); // Responding is important
}) });
app.post("/stop", (req, res) => { app.post("/stop", (req, res) => {
process.exit(); process.exit();
}) });
const port = 9090 const port = 9090;
return new Promise((resolve) => { return new Promise((resolve) => {
const server = app.listen(port, function () { const server = app.listen(port, function () {
const port = server.address().port const port = server.address().port;
console.log('Example app listening at port %d', port) console.log("Example app listening at port %d", port);
// close the server // close the server
const close = () => { const close = () => {
return new Promise((resolve) => { return new Promise((resolve) => {
console.log('closing server') console.log("closing server");
server.close(resolve) server.close(resolve);
}) });
} };
resolve({ server, port, close }) resolve({ server, port, close });
}) });
}) });
} }
module.exports = makeServer module.exports = makeServer;
/** /**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd * @copyright Copyright (c) 2021, Xgene Cloud Ltd

12
scripts/cypress/support/index.js

@ -23,10 +23,10 @@ import "cypress-iframe";
// require('./commands') // require('./commands')
Cypress.on("uncaught:exception", (err, runnable) => { Cypress.on("uncaught:exception", (err, runnable) => {
// returning false here prevents Cypress from // returning false here prevents Cypress from
// failing the test // failing the test
console.log("uncaught:exception"); console.log("uncaught:exception");
console.log(err); console.log(err);
console.log(runnable); console.log(runnable);
return false; return false;
}); });

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

@ -7,288 +7,293 @@ import { roles, staticProjects, defaultDbParams } from "./projectConstants";
// suffix to baseUrl needs to be defined here // suffix to baseUrl needs to be defined here
// //
const urlPool = { const urlPool = {
ncUrlBase: "/", ncUrlBase: "/",
ncUrlSignUp: "#/signup", ncUrlSignUp: "#/signup",
ncUrlSignIn: "#/signin", ncUrlSignIn: "#/signin",
}; };
export class _loginPage { export class _loginPage {
// prefix: baseUrl // prefix: baseUrl
go(urlKey) { go(urlKey) {
cy.visit(urlKey); cy.visit(urlKey);
} }
// visit SignIn URL, enter credentials passed as parameters // visit SignIn URL, enter credentials passed as parameters
// //
signIn(userCredentials) { signIn(userCredentials) {
this.go(urlPool.ncUrlBase); this.go(urlPool.ncUrlBase);
cy.get('input[type="text"]', { timeout: 20000 }).type( cy.get('input[type="text"]', { timeout: 20000 }).type(
userCredentials.username userCredentials.username
); );
cy.get('input[type="password"]').type(userCredentials.password); cy.get('input[type="password"]').type(userCredentials.password);
cy.get('button:contains("SIGN IN")').click(); cy.get('button:contains("SIGN IN")').click();
this.waitProjectPageLoad(); this.waitProjectPageLoad();
} }
// visit SignUp URL, enter credentials passed as parameters // visit SignUp URL, enter credentials passed as parameters
// //
signUp(userCredentials) { signUp(userCredentials) {
this.go(urlPool.ncUrlSignUp); this.go(urlPool.ncUrlSignUp);
cy.get('input[type="text"]', { timeout: 20000 }).type( cy.get('input[type="text"]', { timeout: 20000 }).type(
userCredentials.username userCredentials.username
); );
cy.get('input[type="password"]').type(userCredentials.password); cy.get('input[type="password"]').type(userCredentials.password);
cy.get('button:contains("SIGN UP")').click(); cy.get('button:contains("SIGN UP")').click();
this.waitProjectPageLoad(); this.waitProjectPageLoad();
} }
// logout signed up user // logout signed up user
// //
signOut() { signOut() {
cy.get(".nc-user-menu").click(); cy.get(".nc-user-menu").click();
cy.get(".nc-user-menu-signout").click(); cy.get(".nc-user-menu-signout").click();
this.waitLoginPageLoad(); this.waitLoginPageLoad();
} }
// delay/ wait utility routines // delay/ wait utility routines
// //
waitProjectPageLoad() { waitProjectPageLoad() {
cy.get(".nc-new-project-menu").should("exist"); cy.get(".nc-new-project-menu").should("exist");
} }
waitLoginPageLoad() { waitLoginPageLoad() {
cy.get(".nc-form-signin").should("exist"); cy.get(".nc-form-signin").should("exist");
} }
// standard pre-project activity // standard pre-project activity
//
loginAndOpenProject(apiType, dbType) {
loginPage.signIn(roles.owner.credentials);
projectsPage.openConfiguredProject(apiType, dbType);
// if (dbType === "mysql") {
// projectsPage.openProject(staticProjects.externalREST.basic.name);
// } else if (dbType === "xcdb") {
// projectsPage.openProject(staticProjects.sampleREST.basic.name);
// } else if (dbType === "postgres") {
// projectsPage.openProject(staticProjects.pgExternalREST.basic.name);
// }
// //
loginAndOpenProject(apiType, dbType) { // // kludge: wait for page load to finish
loginPage.signIn(roles.owner.credentials); // cy.wait(2000);
projectsPage.openConfiguredProject(apiType, dbType); // // close team & auth tab
// if (dbType === "mysql") { // cy.get('button.ant-tabs-tab-remove').should('exist').click();
// projectsPage.openProject(staticProjects.externalREST.basic.name); // cy.wait(1000);
// } else if (dbType === "xcdb") { }
// projectsPage.openProject(staticProjects.sampleREST.basic.name);
// } else if (dbType === "postgres") {
// projectsPage.openProject(staticProjects.pgExternalREST.basic.name);
// }
//
// // kludge: wait for page load to finish
// cy.wait(2000);
// // close team & auth tab
// cy.get('button.ant-tabs-tab-remove').should('exist').click();
// cy.wait(1000);
}
} }
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// Projects page // Projects page
export class _projectsPage { export class _projectsPage {
// Project creation options // Project creation options
// //
// {dbType, apiType, name} // {dbType, apiType, name}
// for external database, {databaseType, hostAddress, portNumber, username, password, databaseName} // for external database, {databaseType, hostAddress, portNumber, username, password, databaseName}
openConfiguredProject(apiType, dbType) { openConfiguredProject(apiType, dbType) {
if (dbType === "mysql") {
if (dbType === "mysql") { projectsPage.openProject(staticProjects.externalREST.basic.name);
projectsPage.openProject(staticProjects.externalREST.basic.name); } else if (dbType === "xcdb") {
} else if (dbType === "xcdb") { projectsPage.openProject(staticProjects.sampleREST.basic.name);
projectsPage.openProject(staticProjects.sampleREST.basic.name); } else if (dbType === "postgres") {
} else if (dbType === "postgres") { projectsPage.openProject(staticProjects.pgExternalREST.basic.name);
projectsPage.openProject(staticProjects.pgExternalREST.basic.name);
}
// kludge: wait for page load to finish
cy.wait(4000);
// close team & auth tab
cy.get('button.ant-tabs-tab-remove').should('exist').click();
cy.wait(1000);
} }
// kludge: wait for page load to finish
// Open existing project cy.wait(4000);
// // close team & auth tab
openProject(projectName) { cy.get("button.ant-tabs-tab-remove").should("exist").click();
cy.get(".ant-table-row").contains(`${projectName}`).should("exist").click(); cy.wait(1000);
}
// takes a while to load project
this.waitHomePageLoad(); // Open existing project
//
openProject(projectName) {
cy.get(".ant-table-row").contains(`${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(".nc-new-project-menu").should("exist").click();
if ("none" == projectData.dbType) {
// Subsequent form, select (+ Create) option
cy.get(".nc-create-xc-db-project", { timeout: 20000 }).last().click({
force: true,
});
// wait for page load by verifying required elements
cy.get(".nc-metadb-project-name").should("exist");
cy.contains("button", "Create").should("exist");
cy.wait(1000);
// feed project name
cy.get(".nc-metadb-project-name", { timeout: 20000 })
.clear()
.type(projectName);
// Submit
cy.contains("button", "Create", { timeout: 20000 }).click();
// takes a while to load project
this.waitHomePageLoad();
return projectName;
} }
// Create new project // dbType == 'external'
// Input: else {
// projectData {dbType, apiType, name} // Subsequent form, select (+ Create by connection to external database) option
// dbCredentials {databaseType, hostAddress, portNumber, username, password, databaseName} cy.get(".nc-create-external-db-project", { timeout: 20000 })
// Returns: projectName .last()
// .click({
// To configure force: true,
// 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(".nc-new-project-menu").should("exist").click();
if ("none" == projectData.dbType) {
// Subsequent form, select (+ Create) option
cy.get(".nc-create-xc-db-project", { timeout: 20000 }).last().click({
force: true,
});
// wait for page load by verifying required elements
cy.get(".nc-metadb-project-name").should("exist");
cy.contains("button", "Create").should("exist");
cy.wait(1000)
// feed project name
cy.get(".nc-metadb-project-name", { timeout: 20000 }).clear().type(
projectName
);
// Submit
cy.contains("button", "Create", { timeout: 20000 }).click();
// takes a while to load project // wait for page load by verifying required elements
this.waitHomePageLoad(); cy.get(".nc-extdb-host-database").should("exist");
cy.get(".nc-extdb-proj-name").should("exist");
cy.get(".nc-extdb-btn-test-connection").should("exist");
return projectName; // CY goes too fast at times, so wait for the page to load
} cy.wait(1000);
// dbType == 'external' cy.get(".nc-extdb-proj-name").clear().type(projectName);
else {
// Subsequent form, select (+ Create by connection to external database) option
cy.get(".nc-create-external-db-project", { timeout: 20000 }).last().click({
force: true,
});
// wait for page load by verifying required elements if (cred.databaseType === 1) {
cy.get('.nc-extdb-host-database').should('exist'); cy.get(".nc-extdb-db-type").should("exist").click();
cy.get('.nc-extdb-proj-name').should('exist'); cy.getActiveSelection(".nc-dropdown-ext-db-type")
cy.get('.nc-extdb-btn-test-connection').should('exist'); .find(".ant-select-item-option")
.contains("PostgreSQL")
.click();
}
// CY goes too fast at times, so wait for the page to load if (cred.databaseName !== "") {
cy.wait(1000); cy.get(".nc-extdb-host-database").clear().type(cred.databaseName);
}
cy.get('.nc-extdb-proj-name').clear().type(projectName); // Test database connection
cy.contains("Test Database Connection", { timeout: 20000 }).click();
if (cred.databaseType === 1) { // Create project
cy.get('.nc-extdb-db-type').should('exist').click(); cy.contains("Ok & Save Project", { timeout: 20000 }).click();
cy.getActiveSelection('.nc-dropdown-ext-db-type').find('.ant-select-item-option').contains("PostgreSQL").click();
}
if (cred.databaseName !== "") {
cy.get('.nc-extdb-host-database').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();
cy.wait(5000)
// 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
// );
// }
// // search project with given key cy.wait(5000);
// // return project-name array // takes a while to load project
// // this.waitHomePageLoad();
// 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
//
deleteProject(projectName) {
cy.log("Delete project: " + projectName);
cy.get(".nc-noco-brand-icon").should('exist').click();
cy.get(".ant-table-row").contains(`${projectName}`).should("exist")
.then(($obj) => {
cy.log($obj)
cy.wrap($obj).parent().parent().find('.ant-table-cell').last().click()
})
// pop-up, submit
cy.getActiveModal().find('button:contains("Yes")').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() { return projectName;
cy.url({ timeout: 50000 }).should("contain", "/#/nc/p_");
} }
}
// // create REST default project (sakila DB)
// //
// createDefaulRestProject() {
// return this.createProject(
// { dbType: 1, apiType: 0, name: "" },
// defaultDbParams
// );
// }
// // 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
//
deleteProject(projectName) {
cy.log("Delete project: " + projectName);
cy.get(".nc-noco-brand-icon").should("exist").click();
cy.get(".ant-table-row")
.contains(`${projectName}`)
.should("exist")
.then(($obj) => {
cy.log($obj);
cy.wrap($obj).parent().parent().find(".ant-table-cell").last().click();
});
// pop-up, submit
cy.getActiveModal().find('button:contains("Yes")').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", "/#/nc/p_");
}
} }
export const loginPage = new _loginPage(); export const loginPage = new _loginPage();

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

@ -1,19 +1,19 @@
export const defaultDbParams = { export const defaultDbParams = {
databaseType: 0, // MySQL databaseType: 0, // MySQL
hostAddress: "localhost", hostAddress: "localhost",
portNumber: "3306", portNumber: "3306",
username: "root", username: "root",
password: "password", password: "password",
databaseName: "sakila", databaseName: "sakila",
}; };
export const defaultPgDbParams = { export const defaultPgDbParams = {
databaseType: 1, // Postgres databaseType: 1, // Postgres
hostAddress: "localhost", hostAddress: "localhost",
portNumber: "5432", portNumber: "5432",
username: "postgres", username: "postgres",
password: "password", password: "password",
databaseName: "postgres", databaseName: "postgres",
}; };
// database // database
@ -24,145 +24,162 @@ export const defaultPgDbParams = {
// editComment: add comment // editComment: add comment
// shareView: right navigation bar (share options) // shareView: right navigation bar (share options)
export const roles = { export const roles = {
owner: { owner: {
name: "owner", name: "owner",
credentials: { username: "user@nocodb.com", password: "Password123." }, credentials: { username: "user@nocodb.com", password: "Password123." },
validations: { validations: {
advSettings: true, advSettings: true,
editSchema: true, editSchema: true,
editData: true, editData: true,
editComment: true, editComment: true,
shareView: true, shareView: true,
},
}, },
creator: { },
name: "creator", creator: {
credentials: { name: "creator",
username: "creator@nocodb.com", credentials: {
password: "Password123.", username: "creator@nocodb.com",
}, password: "Password123.",
validations: {
advSettings: true,
editSchema: true,
editData: true,
editComment: true,
shareView: true,
},
}, },
editor: { validations: {
name: "editor", advSettings: true,
credentials: { editSchema: true,
username: "editor@nocodb.com", editData: true,
password: "Password123.", editComment: true,
}, shareView: true,
validations: {
advSettings: false,
editSchema: false,
editData: true,
editComment: true,
shareView: false,
},
}, },
commenter: { },
name: "commenter", editor: {
credentials: { name: "editor",
username: "commenter@nocodb.com", credentials: {
password: "Password123.", username: "editor@nocodb.com",
}, password: "Password123.",
validations: {
advSettings: false,
editSchema: false,
editData: false,
editComment: true,
shareView: false,
},
}, },
viewer: { validations: {
name: "viewer", advSettings: false,
credentials: { editSchema: false,
username: "viewer@nocodb.com", editData: true,
password: "Password123.", editComment: true,
}, shareView: false,
validations: {
advSettings: false,
editSchema: false,
editData: false,
editComment: false,
shareView: false,
},
}, },
},
commenter: {
name: "commenter",
credentials: {
username: "commenter@nocodb.com",
password: "Password123.",
},
validations: {
advSettings: false,
editSchema: false,
editData: false,
editComment: true,
shareView: false,
},
},
viewer: {
name: "viewer",
credentials: {
username: "viewer@nocodb.com",
password: "Password123.",
},
validations: {
advSettings: false,
editSchema: false,
editData: false,
editComment: false,
shareView: false,
},
},
}; };
// default projects // default projects
// //
export const staticProjects = { export const staticProjects = {
sampleREST: { sampleREST: {
basic: { dbType: "none", apiType: "REST", name: "sampleREST" }, basic: { dbType: "none", apiType: "REST", name: "sampleREST" },
config: {}, config: {},
}, },
sampleGQL: { sampleGQL: {
basic: { dbType: "none", apiType: "GQL", name: "sampleGQL" }, basic: { dbType: "none", apiType: "GQL", name: "sampleGQL" },
config: {}, config: {},
}, },
externalREST: { externalREST: {
basic: { dbType: "external", apiType: "REST", name: "externalREST" }, basic: { dbType: "external", apiType: "REST", name: "externalREST" },
config: defaultDbParams, config: defaultDbParams,
}, },
externalGQL: { externalGQL: {
basic: { dbType: "external", apiType: "GQL", name: "externalGQL" }, basic: { dbType: "external", apiType: "GQL", name: "externalGQL" },
config: defaultDbParams, config: defaultDbParams,
}, },
pgExternalREST: { pgExternalREST: {
basic: { dbType: "external", apiType: "REST", name: "pgExtREST" }, basic: { dbType: "external", apiType: "REST", name: "pgExtREST" },
config: defaultPgDbParams, config: defaultPgDbParams,
}, },
pgExternalGQL: { pgExternalGQL: {
basic: { dbType: "external", apiType: "GQL", name: "pgExternalGQL" }, basic: { dbType: "external", apiType: "GQL", name: "pgExternalGQL" },
config: defaultPgDbParams, config: defaultPgDbParams,
}, },
}; };
// return TRUE if test suite specified is activated from env-variables // return TRUE if test suite specified is activated from env-variables
// //
export const isTestSuiteActive = (apiType, dbType) => { export const isTestSuiteActive = (apiType, dbType) => {
const env = Cypress.env("testMode"); const env = Cypress.env("testMode");
return env.some( return env.some(
(element) => element.apiType === apiType && element.dbType === dbType (element) => element.apiType === apiType && element.dbType === dbType
); );
}; };
let currentTestMode = { apiType: null, dbType: null }; let currentTestMode = { apiType: null, dbType: null };
let xcdbProjectString = ``; let xcdbProjectString = ``;
export function setCurrentMode(apiType, dbType) { export function setCurrentMode(apiType, dbType) {
currentTestMode = { apiType: apiType, dbType: dbType }; currentTestMode = { apiType: apiType, dbType: dbType };
} }
export function getCurrentMode() { export function getCurrentMode() {
return currentTestMode; return currentTestMode;
} }
export function isXcdb() { export function isXcdb() {
return currentTestMode.dbType === "xcdb"; return currentTestMode.dbType === "xcdb";
} }
export function isPostgres() { export function isPostgres() {
return currentTestMode.dbType === "postgres"; return currentTestMode.dbType === "postgres";
} }
export function setProjectString(projStr) { export function setProjectString(projStr) {
xcdbProjectString = projStr; xcdbProjectString = projStr;
} }
export function getProjectString() { export function getProjectString() {
return xcdbProjectString; return xcdbProjectString;
} }
const sakilaTables = [ const sakilaTables = [
'actor', 'address', 'category', 'city', 'country', 'customer', 'film', 'film_text', 'language', 'payment', 'rental', 'staff' "actor",
] "address",
"category",
"city",
"country",
"customer",
"film",
"film_text",
"language",
"payment",
"rental",
"staff",
];
const sakilaSqlViews = [ const sakilaSqlViews = [
'actor_info', 'customer_list', 'film_list', 'nicer_but_slower_film_list', 'sales_by_film_category', 'sales_by_store', 'staff_list' "actor_info",
] "customer_list",
"film_list",
"nicer_but_slower_film_list",
"sales_by_film_category",
"sales_by_store",
"staff_list",
];
export { sakilaTables, sakilaSqlViews } export { sakilaTables, sakilaSqlViews };

Loading…
Cancel
Save