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. 30
      scripts/cypress/integration/common/00_pre_configurations.js
  2. 6
      scripts/cypress/integration/common/1a_table_operations.js
  3. 59
      scripts/cypress/integration/common/1c_sql_view.js
  4. 4
      scripts/cypress/integration/common/1d_pg_table_view_drag_drop_reorder.js
  5. 13
      scripts/cypress/integration/common/1d_table_view_drag_drop_reorder.js
  6. 21
      scripts/cypress/integration/common/1e_meta_sync.js
  7. 8
      scripts/cypress/integration/common/1e_pg_meta_sync.js
  8. 61
      scripts/cypress/integration/common/2a_table_with_belongs_to_colulmn.js
  9. 47
      scripts/cypress/integration/common/3b_formula_column.js
  10. 10
      scripts/cypress/integration/common/4a_table_view_grid_gallery_form.js
  11. 47
      scripts/cypress/integration/common/4b_table_view_share.js
  12. 129
      scripts/cypress/integration/common/4c_form_view_detailed.js
  13. 45
      scripts/cypress/integration/common/4d_table_view_grid_locked.js
  14. 21
      scripts/cypress/integration/common/4e_form_view_share.js
  15. 33
      scripts/cypress/integration/common/4f_pg_grid_view_share.js
  16. 118
      scripts/cypress/integration/common/4g_table_view_expanded_form.js
  17. 71
      scripts/cypress/integration/common/5a_user_role.js
  18. 35
      scripts/cypress/integration/common/5b_preview_role.js
  19. 14
      scripts/cypress/integration/common/6b_downloadCsv.js
  20. 68
      scripts/cypress/integration/common/6c_swagger_api.js
  21. 27
      scripts/cypress/integration/common/6d_language_validation.js
  22. 10
      scripts/cypress/integration/common/6e_project_operations.js
  23. 31
      scripts/cypress/integration/common/6f_attachments.js
  24. 107
      scripts/cypress/integration/common/7a_create_project_from_excel.js
  25. 47
      scripts/cypress/integration/common/7b_import_from_airtable.js
  26. 313
      scripts/cypress/integration/common/9a_QuickTest.js
  27. 464
      scripts/cypress/integration/common/9b_ERD.js
  28. 2
      scripts/cypress/integration/test/pg-restMisc.js
  29. 2
      scripts/cypress/integration/test/quickTest.js
  30. 2
      scripts/cypress/integration/test/restMisc.js
  31. 4
      scripts/cypress/integration/test/xcdb-restMisc.js
  32. 67
      scripts/cypress/plugins/index.js
  33. 59
      scripts/cypress/plugins/server.js
  34. 47
      scripts/cypress/support/page_objects/navigation.js
  35. 27
      scripts/cypress/support/page_objects/projectConstants.js

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

@ -160,7 +160,7 @@ export const genTest = (apiType, dbType) => {
describe(`Project pre-configurations`, () => { describe(`Project pre-configurations`, () => {
before(() => { before(() => {
cy.fileHook(); cy.fileHook();
}) });
it("Admin SignUp", () => { it("Admin SignUp", () => {
cy.task("log", "This will be output to the terminal"); cy.task("log", "This will be output to the terminal");
@ -171,7 +171,6 @@ export const genTest = (apiType, dbType) => {
// click home button // click home button
cy.get(".nc-noco-brand-icon").click(); cy.get(".nc-noco-brand-icon").click();
cy.get(".ant-table-content").then((obj) => { cy.get(".ant-table-content").then((obj) => {
// if project already created, open // if project already created, open
// else, create a new one // else, create a new one
if (true == obj[0].innerHTML.includes(proj.basic.name)) { if (true == obj[0].innerHTML.includes(proj.basic.name)) {
@ -179,14 +178,12 @@ export const genTest = (apiType, dbType) => {
let projId; let projId;
if (dbType === "xcdb") { if (dbType === "xcdb") {
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).then( cy.task("sqliteExecReturnValue", query).then((resolve) => {
(resolve) => {
cy.log(resolve); cy.log(resolve);
projId = resolve.prefix; projId = resolve.prefix;
setProjectString(projId); setProjectString(projId);
cy.log(projId); cy.log(projId);
} });
);
} }
} else { } else {
projectsPage.createProject(proj.basic, proj.config); projectsPage.createProject(proj.basic, proj.config);
@ -211,13 +208,8 @@ export const genTest = (apiType, dbType) => {
setProjectString(projId); setProjectString(projId);
}) })
.then(() => { .then(() => {
let query = let query = prepareSqliteQuery(projId);
prepareSqliteQuery(projId); for (let i = 0; i < query.length; i++) {
for (
let i = 0;
i < query.length;
i++
) {
cy.task("sqliteExec", query[i]); cy.task("sqliteExec", query[i]);
cy.wait(1000); cy.wait(1000);
} }
@ -241,19 +233,17 @@ export const genTest = (apiType, dbType) => {
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 {
}
else {
cy_createProjectBlock(proj, apiType, dbType); 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

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

@ -22,7 +22,7 @@ export const genTest = (apiType, dbType) => {
afterEach(() => { afterEach(() => {
cy.saveLocalStorage(); cy.saveLocalStorage();
}) });
// after(() => { // after(() => {
// }); // });
@ -50,7 +50,7 @@ export const genTest = (apiType, dbType) => {
// //
cy.get("thead > tr > th.ant-table-cell").should("have.length", 5); cy.get("thead > tr > th.ant-table-cell").should("have.length", 5);
cy.wait(3000) cy.wait(3000);
// Audit table entries // Audit table entries
// [Header] Operation Type, Operation Sub Type, Description, User, Created // [Header] Operation Type, Operation Sub Type, Description, User, Created
@ -65,7 +65,7 @@ export const genTest = (apiType, dbType) => {
getAuditCell(1, 1).contains("CREATED").should("exist"); getAuditCell(1, 1).contains("CREATED").should("exist");
getAuditCell(1, 3).contains("user@nocodb.com").should("exist"); getAuditCell(1, 3).contains("user@nocodb.com").should("exist");
settingsPage.closeMenu() settingsPage.closeMenu();
}); });
it("Table Rename operation", () => { it("Table Rename operation", () => {

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

@ -17,11 +17,11 @@ export const genTest = (apiType, dbType) => {
beforeEach(() => { beforeEach(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
}) });
afterEach(() => { afterEach(() => {
cy.saveLocalStorage(); cy.saveLocalStorage();
}) });
it(`XCDB: SQL View Column operations`, () => { it(`XCDB: SQL View Column operations`, () => {
// Open one of the views & verify validity of first two entries // Open one of the views & verify validity of first two entries
@ -30,18 +30,12 @@ export const genTest = (apiType, dbType) => {
// Record-1 validation // Record-1 validation
mainPage.getCell(`ID`, 1).contains("1").should("exist"); mainPage.getCell(`ID`, 1).contains("1").should("exist");
mainPage mainPage.getCell(`Name`, 1).contains("MARY SMITH").should("exist");
.getCell(`Name`, 1)
.contains("MARY SMITH")
.should("exist");
mainPage mainPage
.getCell(`Address`, 1) .getCell(`Address`, 1)
.contains("1913 Hanoi Way") .contains("1913 Hanoi Way")
.should("exist"); .should("exist");
mainPage mainPage.getCell(`ZipCode`, 1).contains("35200").should("exist");
.getCell(`ZipCode`, 1)
.contains("35200")
.should("exist");
// Record-2 validation // Record-2 validation
mainPage.getCell(`ID`, 2).contains("2").should("exist"); mainPage.getCell(`ID`, 2).contains("2").should("exist");
@ -53,10 +47,7 @@ export const genTest = (apiType, dbType) => {
.getCell(`Address`, 2) .getCell(`Address`, 2)
.contains("1121 Loja Avenue") .contains("1121 Loja Avenue")
.should("exist"); .should("exist");
mainPage mainPage.getCell(`ZipCode`, 2).contains("17886").should("exist");
.getCell(`ZipCode`, 2)
.contains("17886")
.should("exist");
// Column operations: Hide // Column operations: Hide
mainPage.hideField(`ZipCode`); mainPage.hideField(`ZipCode`);
@ -64,18 +55,12 @@ export const genTest = (apiType, dbType) => {
// Column operations: Sort // Column operations: Sort
mainPage.sortField("Name", "Z → A"); mainPage.sortField("Name", "Z → A");
mainPage mainPage.getCell(`Name`, 1).contains("ZACHARY HITE").should("exist");
.getCell(`Name`, 1)
.contains("ZACHARY HITE")
.should("exist");
mainPage.clearSort(); mainPage.clearSort();
// Column operations: Filter // Column operations: Filter
mainPage.filterField("Name", "is like", "MARY"); mainPage.filterField("Name", "is like", "MARY");
mainPage mainPage.getCell(`Name`, 1).contains("MARY SMITH").should("exist");
.getCell(`Name`, 1)
.contains("MARY SMITH")
.should("exist");
mainPage.filterReset(); mainPage.filterReset();
cy.closeViewsTab("CustomerList"); cy.closeViewsTab("CustomerList");
@ -90,14 +75,8 @@ export const genTest = (apiType, dbType) => {
// Record-1 validation // Record-1 validation
mainPage.getCell(`ActorId`, 1).contains("1").should("exist"); mainPage.getCell(`ActorId`, 1).contains("1").should("exist");
mainPage mainPage.getCell(`FirstName`, 1).contains("PENELOPE").should("exist");
.getCell(`FirstName`, 1) mainPage.getCell(`LastName`, 1).contains("GUINESS").should("exist");
.contains("PENELOPE")
.should("exist");
mainPage
.getCell(`LastName`, 1)
.contains("GUINESS")
.should("exist");
mainPage mainPage
.getCell(`FilmInfo`, 1) .getCell(`FilmInfo`, 1)
.contains("Animation: ANACONDA CONFESSIONS") .contains("Animation: ANACONDA CONFESSIONS")
@ -105,14 +84,8 @@ export const genTest = (apiType, dbType) => {
// Record-2 validation // Record-2 validation
mainPage.getCell(`ActorId`, 2).contains("2").should("exist"); mainPage.getCell(`ActorId`, 2).contains("2").should("exist");
mainPage mainPage.getCell(`FirstName`, 2).contains("NICK").should("exist");
.getCell(`FirstName`, 2) mainPage.getCell(`LastName`, 2).contains("WAHLBERG").should("exist");
.contains("NICK")
.should("exist");
mainPage
.getCell(`LastName`, 2)
.contains("WAHLBERG")
.should("exist");
mainPage mainPage
.getCell(`FilmInfo`, 2) .getCell(`FilmInfo`, 2)
.contains("Action: BULL SHAWSHANK") .contains("Action: BULL SHAWSHANK")
@ -124,18 +97,12 @@ export const genTest = (apiType, dbType) => {
// Column operations: Sort // Column operations: Sort
mainPage.sortField("FirstName", "Z → A"); mainPage.sortField("FirstName", "Z → A");
mainPage mainPage.getCell(`FirstName`, 1).contains("ZERO").should("exist");
.getCell(`FirstName`, 1)
.contains("ZERO")
.should("exist");
mainPage.clearSort(); mainPage.clearSort();
// Column operations: Filter // Column operations: Filter
mainPage.filterField("FirstName", "is like", "PENELOPE"); mainPage.filterField("FirstName", "is like", "PENELOPE");
mainPage mainPage.getCell(`FirstName`, 1).contains("PENELOPE").should("exist");
.getCell(`FirstName`, 1)
.contains("PENELOPE")
.should("exist");
mainPage.filterReset(); mainPage.filterReset();
cy.closeViewsTab("ActorInfo"); cy.closeViewsTab("ActorInfo");

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

@ -87,7 +87,9 @@ export const genTest = (apiType, dbType) => {
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)")
.click();
cy.toastWait("View created successfully"); cy.toastWait("View created successfully");
} }

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

@ -10,7 +10,11 @@ export const genTest = (apiType, dbType) => {
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");
} }
/* /*
@ -42,7 +46,8 @@ export const genTest = (apiType, dbType) => {
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");
@ -90,7 +95,9 @@ export const genTest = (apiType, dbType) => {
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)")
.click();
cy.toastWait("View created successfully"); cy.toastWait("View created successfully");
} }

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

@ -26,15 +26,15 @@ export const genTest = (apiType, dbType) => {
tblDisplayPrefix = `${getProjectString()}`; tblDisplayPrefix = `${getProjectString()}`;
} }
mainPage.openMetaTab(); mainPage.openMetaTab();
}) });
beforeEach(() => { beforeEach(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
}) });
afterEach(() => { afterEach(() => {
cy.saveLocalStorage(); cy.saveLocalStorage();
}) });
it(`Create table`, () => { it(`Create table`, () => {
// Create Table // Create Table
@ -74,14 +74,8 @@ export const genTest = (apiType, dbType) => {
// //
if (!isXcdb()) { if (!isXcdb()) {
// Remove relation (FK) // Remove relation (FK)
cy.task( cy.task(dbCmd, `ALTER TABLE ${projPrefix}table1 DROP FOREIGN KEY fk1`);
dbCmd, cy.task(dbCmd, `ALTER TABLE ${projPrefix}table1 DROP INDEX fk1_idx`);
`ALTER TABLE ${projPrefix}table1 DROP FOREIGN KEY fk1`
);
cy.task(
dbCmd,
`ALTER TABLE ${projPrefix}table1 DROP INDEX fk1_idx`
);
mainPage.metaSyncValidate( mainPage.metaSyncValidate(
`${tblDisplayPrefix}table1`, `${tblDisplayPrefix}table1`,
"Relation removed" "Relation removed"
@ -132,10 +126,7 @@ export const genTest = (apiType, dbType) => {
// DROP TABLE // DROP TABLE
cy.task(dbCmd, `DROP TABLE ${projPrefix}table1`); cy.task(dbCmd, `DROP TABLE ${projPrefix}table1`);
cy.task(dbCmd, `DROP TABLE ${projPrefix}table2`); cy.task(dbCmd, `DROP TABLE ${projPrefix}table2`);
mainPage.metaSyncValidate( mainPage.metaSyncValidate(`${tblDisplayPrefix}table1`, "Table removed");
`${tblDisplayPrefix}table1`,
"Table removed"
);
}); });
it(`Hide, Filter, Sort`, () => { it(`Hide, Filter, Sort`, () => {

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

@ -22,8 +22,7 @@ export const genTest = (apiType, dbType) => {
mainPage.openMetaTab(); mainPage.openMetaTab();
}); });
beforeEach(() => { beforeEach(() => {});
});
after(() => { after(() => {
// mainPage.closeMetaTab(); // mainPage.closeMetaTab();
@ -105,10 +104,7 @@ export const genTest = (apiType, dbType) => {
// DROP TABLE // DROP TABLE
cy.task(dbCmd, `DROP TABLE IF EXISTS table1`); cy.task(dbCmd, `DROP TABLE IF EXISTS table1`);
cy.task(dbCmd, `DROP TABLE IF EXISTS table2`); cy.task(dbCmd, `DROP TABLE IF EXISTS table2`);
mainPage.metaSyncValidate( mainPage.metaSyncValidate(`${tblDisplayPrefix}table1`, "Table removed");
`${tblDisplayPrefix}table1`,
"Table removed"
);
}); });
it(`Hide, Filter, Sort`, () => { it(`Hide, Filter, Sort`, () => {

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

@ -16,7 +16,7 @@ export const genTest = (apiType, dbType) => {
afterEach(() => { afterEach(() => {
cy.saveLocalStorage(); cy.saveLocalStorage();
}) });
// after(() => { // after(() => {
// cy.closeTableTab("City"); // cy.closeTableTab("City");
@ -32,27 +32,35 @@ export const genTest = (apiType, dbType) => {
it("Grid cell chip content validation", () => { it("Grid cell chip content validation", () => {
// grid cell content validation // grid cell content validation
mainPage.getCell("City List", 1) mainPage
.find('.nc-virtual-cell > .chips-wrapper > .chips > .group > .name') .getCell("City List", 1)
.find(".nc-virtual-cell > .chips-wrapper > .chips > .group > .name")
.contains("Kabul") .contains("Kabul")
.should('exist'); .should("exist");
mainPage.getCell("City List", 2) mainPage
.find('.nc-virtual-cell > .chips-wrapper > .chips > .group > .name') .getCell("City List", 2)
.find(".nc-virtual-cell > .chips-wrapper > .chips > .group > .name")
.contains("Batna") .contains("Batna")
.should('exist'); .should("exist");
mainPage.getCell("City List", 2) mainPage
.find('.nc-virtual-cell > .chips-wrapper > .chips > .group > .name') .getCell("City List", 2)
.find(".nc-virtual-cell > .chips-wrapper > .chips > .group > .name")
.contains("Bchar") .contains("Bchar")
.should('exist'); .should("exist");
mainPage.getCell("City List", 2) mainPage
.find('.nc-virtual-cell > .chips-wrapper > .chips > .group > .name') .getCell("City List", 2)
.find(".nc-virtual-cell > .chips-wrapper > .chips > .group > .name")
.contains("Skikda") .contains("Skikda")
.should('exist'); .should("exist");
}) });
it("Expand has-many column", () => { it("Expand has-many column", () => {
mainPage.getCell("City List", 1).should("exist").trigger("mouseover").click(); mainPage
cy.get('.nc-action-icon').eq(0).should('exist').click({ force: true }); .getCell("City List", 1)
.should("exist")
.trigger("mouseover")
.click();
cy.get(".nc-action-icon").eq(0).should("exist").click({ force: true });
}); });
it("Expand Link record, validate", () => { it("Expand Link record, validate", () => {
@ -60,9 +68,10 @@ export const genTest = (apiType, dbType) => {
.find("button:contains(Link to 'City')") .find("button:contains(Link to 'City')")
.click() .click()
.then(() => { .then(() => {
// Link record form validation // Link record form validation
cy.getActiveModal(".nc-modal-link-record").contains("Link record").should("exist"); cy.getActiveModal(".nc-modal-link-record")
.contains("Link record")
.should("exist");
cy.getActiveModal(".nc-modal-link-record") cy.getActiveModal(".nc-modal-link-record")
.find(".nc-reload") .find(".nc-reload")
.should("exist"); .should("exist");
@ -92,17 +101,19 @@ export const genTest = (apiType, dbType) => {
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)
.find(".nc-virtual-cell > .chips-wrapper > .chips > .group > .name")
.contains("Spain") .contains("Spain")
.should('exist'); .should("exist");
mainPage.getCell("Country", 2) mainPage
.find('.nc-virtual-cell > .chips-wrapper > .chips > .group > .name') .getCell("Country", 2)
.find(".nc-virtual-cell > .chips-wrapper > .chips > .group > .name")
.contains("Saudi Arabia") .contains("Saudi Arabia")
.should('exist'); .should("exist");
cy.closeTableTab("City"); cy.closeTableTab("City");
}) });
}); });
}; };

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

@ -18,11 +18,11 @@ export const genTest = (apiType, dbType) => {
beforeEach(() => { beforeEach(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
}) });
afterEach(() => { afterEach(() => {
cy.saveLocalStorage(); cy.saveLocalStorage();
}) });
// after(() => { // after(() => {
// cy.closeTableTab("City"); // cy.closeTableTab("City");
@ -40,7 +40,10 @@ export const genTest = (apiType, dbType) => {
// for (let i = 0; i < 10; i++) // for (let i = 0; i < 10; i++)
for (let i = 3; i < 5; i++) for (let i = 3; i < 5; i++)
mainPage.getCell(rowName, i+1).contains(result[i].toString()).should("exist"); mainPage
.getCell(rowName, i + 1)
.contains(result[i].toString())
.should("exist");
// cy.get(`tbody > :nth-child(${i + 1}) > [data-col="${rowName}"]`) // cy.get(`tbody > :nth-child(${i + 1}) > [data-col="${rowName}"]`)
// .contains(result[i].toString()) // .contains(result[i].toString())
// .should("exist"); // .should("exist");
@ -53,26 +56,27 @@ export const genTest = (apiType, dbType) => {
force: true, force: true,
}); });
cy.getActiveMenu(".nc-dropdown-grid-add-column").find('input.nc-column-name-input', { timeout: 3000 }) cy.getActiveMenu(".nc-dropdown-grid-add-column")
.should('exist') .find("input.nc-column-name-input", { timeout: 3000 })
.should("exist")
.clear() .clear()
.type(columnName); .type(columnName);
// cy.get(".nc-column-type-input").last().click().type("Formula"); // cy.get(".nc-column-type-input").last().click().type("Formula");
cy.getActiveMenu('.nc-dropdown-grid-add-column') cy.getActiveMenu(".nc-dropdown-grid-add-column")
.find(".nc-column-type-input") .find(".nc-column-type-input")
.last() .last()
.click() .click()
.type("Formula"); .type("Formula");
cy.getActiveSelection('.nc-dropdown-column-type') cy.getActiveSelection(".nc-dropdown-column-type")
.find('.ant-select-item-option') .find(".ant-select-item-option")
.contains("Formula") .contains("Formula")
.click(); .click();
cy.getActiveMenu('.nc-dropdown-grid-add-column') cy.getActiveMenu(".nc-dropdown-grid-add-column")
.find('textarea.nc-formula-input') .find("textarea.nc-formula-input")
.click() .click()
.type(formula, { parseSpecialCharSequences: false }); .type(formula, { parseSpecialCharSequences: false });
// cy.get(".ant-btn-primary").contains("Save").should('exist').click(); // cy.get(".ant-btn-primary").contains("Save").should('exist').click();
cy.getActiveMenu('.nc-dropdown-grid-add-column') cy.getActiveMenu(".nc-dropdown-grid-add-column")
.find(".ant-btn-primary:visible") .find(".ant-btn-primary:visible")
.contains("Save") .contains("Save")
.click(); .click();
@ -92,7 +96,6 @@ export const genTest = (apiType, dbType) => {
// routine to edit column // routine to edit column
// //
const editColumnByName = (oldName, newName, newFormula) => { const editColumnByName = (oldName, newName, newFormula) => {
cy.get(`th:contains(${oldName}) .nc-icon.ant-dropdown-trigger`) cy.get(`th:contains(${oldName}) .nc-icon.ant-dropdown-trigger`)
.trigger("mouseover", { force: true }) .trigger("mouseover", { force: true })
.click({ force: true }); .click({ force: true });
@ -103,13 +106,17 @@ export const genTest = (apiType, dbType) => {
.find(".nc-column-edit") .find(".nc-column-edit")
.click(); .click();
cy.getActiveMenu(".nc-dropdown-edit-column").find('input.nc-column-name-input', { timeout: 3000 }) cy.getActiveMenu(".nc-dropdown-edit-column")
.should('exist') .find("input.nc-column-name-input", { timeout: 3000 })
.should("exist")
.clear() .clear()
.type(newName); .type(newName);
cy.get('textarea.nc-formula-input').click().clear().type(newFormula, { parseSpecialCharSequences: false }); cy.get("textarea.nc-formula-input")
cy.get(".ant-btn-primary").contains("Save").should('exist').click(); .click()
.clear()
.type(newFormula, { parseSpecialCharSequences: false });
cy.get(".ant-btn-primary").contains("Save").should("exist").click();
// cy.toastWait(`Column created`); // cy.toastWait(`Column created`);
cy.get(`th[data-title="${oldName}"]`).should("not.exist"); cy.get(`th[data-title="${oldName}"]`).should("not.exist");
cy.get(`th[data-title="${newName}"]`).should("exist"); cy.get(`th[data-title="${newName}"]`).should("exist");
@ -190,11 +197,7 @@ export const genTest = (apiType, dbType) => {
}); });
it.skip("Formula: WEEKDAY", () => { it.skip("Formula: WEEKDAY", () => {
editColumnByName( editColumnByName("NC_MATH_0", "NC_WEEKDAY_0", `WEEKDAY("2022-07-19")`);
"NC_MATH_0",
"NC_WEEKDAY_0",
`WEEKDAY("2022-07-19")`
);
rowValidation("NC_WEEKDAY_0", RESULT_WEEKDAY_0); rowValidation("NC_WEEKDAY_0", RESULT_WEEKDAY_0);
editColumnByName( editColumnByName(
@ -239,7 +242,7 @@ export const genTest = (apiType, dbType) => {
it("Formula: NOW, EDIT & Delete column", () => { it("Formula: NOW, EDIT & Delete column", () => {
// if (!isXcdb()) editColumnByName("NC_MATH_2", "NC_NOW", `NOW()`); // if (!isXcdb()) editColumnByName("NC_MATH_2", "NC_NOW", `NOW()`);
if (dbType === 'mysql') 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()`); else editColumnByName("NC_MATH_1", "NC_NOW", `NOW()`);
deleteColumnByName("NC_NOW"); deleteColumnByName("NC_NOW");

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

@ -44,7 +44,9 @@ 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").find(".ant-btn-primary").click(); cy.getActiveModal(".nc-modal-view-create")
.find(".ant-btn-primary")
.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'
@ -75,8 +77,10 @@ export const genTest = (apiType, dbType) => {
// click on delete icon (becomes visible on hovering mouse) // click on delete icon (becomes visible on hovering mouse)
cy.get(".nc-view-delete-icon").click({ force: true }); cy.get(".nc-view-delete-icon").click({ force: true });
cy.wait(300) cy.wait(300);
cy.getActiveModal(".nc-modal-view-delete").find('.ant-btn-dangerous').click(); cy.getActiveModal(".nc-modal-view-delete")
.find(".ant-btn-dangerous")
.click();
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

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

@ -7,15 +7,30 @@ 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")
.contains("This view is shared via a private link")
.should("be.visible");
// enable checkbox & feed pwd, save // enable checkbox & feed pwd, save
cy.getActiveModal(".nc-modal-share-view").find('.ant-collapse').should('exist').click(); cy.getActiveModal(".nc-modal-share-view")
cy.getActiveModal(".nc-modal-share-view").find('.ant-checkbox-input').should('exist').first().then(($el) => { .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"]')
.clear()
.type("1");
cy.getActiveModal(".nc-modal-share-view")
.find('button:contains("Save password")')
.click();
cy.toastWait("Successfully updated"); cy.toastWait("Successfully updated");
} }
}); });
@ -72,22 +87,30 @@ export const genTest = (apiType, dbType) => {
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()
.type("a");
cy.getActiveModal(".nc-modal-shared-view-password-dlg")
.find('button:contains("Unlock")')
.click();
// if pwd is incorrect, active modal requesting to feed in password again will persist // if pwd is incorrect, active modal requesting to feed in password again will persist
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")')
.should("exist");
}); });
// fallover test- use previously opened view & continue verification instead of opening again // fallover test- use previously opened view & continue verification instead of opening again
it("Share view with correct password", () => { it("Share view with correct password", () => {
// feed password // feed password
cy.getActiveModal(".nc-modal-shared-view-password-dlg") cy.getActiveModal(".nc-modal-shared-view-password-dlg")
.find('input[type="password"]') .find('input[type="password"]')
.clear() .clear()
.type("1"); .type("1");
cy.getActiveModal(".nc-modal-shared-view-password-dlg").find('button:contains("Unlock")').click(); cy.getActiveModal(".nc-modal-shared-view-password-dlg")
.find('button:contains("Unlock")')
.click();
// if pwd is incorrect, active modal requesting to feed in password again will persist // if pwd is incorrect, active modal requesting to feed in password again will persist
// cy.getActiveModal().find('button:contains("Unlock")').should('not.exist'); // cy.getActiveModal().find('button:contains("Unlock")').should('not.exist');
@ -97,10 +120,10 @@ export const genTest = (apiType, dbType) => {
// Verify Download as CSV is here // Verify Download as CSV is here
mainPage.downloadCsv().should("exist"); mainPage.downloadCsv().should("exist");
cy.get(".nc-actions-menu-btn").should('exist').click(); cy.get(".nc-actions-menu-btn").should("exist").click();
mainPage.downloadExcel().should("exist"); mainPage.downloadExcel().should("exist");
cy.get(".nc-actions-menu-btn").should('exist').click(); cy.get(".nc-actions-menu-btn").should("exist").click();
}); });
it("Delete view", () => { it("Delete view", () => {

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

@ -5,10 +5,7 @@ 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) {
@ -18,17 +15,17 @@ function verifyFormDrawerHideObjectCount(count) {
.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")
.find(".ant-card")
.should("have.length", cardCount);
} else { } else {
cy.get('.nc-form-left-drawer').find('.ant-card').should('not.exist'); cy.get(".nc-form-left-drawer").find(".ant-card").should("not.exist");
} }
} }
@ -37,16 +34,18 @@ function validateFormHeader() {
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) => {
cy.log($el);
expect($el.val()).to.equal("A B C D"); expect($el.val()).to.equal("A B C D");
}) });
cy.get(".nc-form") cy.get(".nc-form")
.find('[placeholder="Add form description"]') .find('[placeholder="Add form description"]')
.should("exist").then(($el) => { .should("exist")
cy.log($el) .then(($el) => {
cy.log($el);
expect($el.val()).to.equal("Some description about form comes here"); expect($el.val()).to.equal("Some description about form comes here");
}) });
} }
export const genTest = (apiType, dbType) => { export const genTest = (apiType, dbType) => {
@ -86,12 +85,13 @@ export const genTest = (apiType, dbType) => {
// //
const viewTest = (viewType) => { const viewTest = (viewType) => {
it(`Create ${viewType} view`, () => { it(`Create ${viewType} view`, () => {
// 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();
// 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)")
.click();
cy.toastWait("View created successfully"); cy.toastWait("View created successfully");
@ -107,9 +107,7 @@ export const genTest = (apiType, dbType) => {
verifyFormDrawerFieldLocation("LastUpdate", 1); verifyFormDrawerFieldLocation("LastUpdate", 1);
// move Country field down (drag, drop) // move Country field down (drag, drop)
cy.get(".nc-form-drag-LastUpdate").drag( cy.get(".nc-form-drag-LastUpdate").drag(".nc-form-drag-Country");
".nc-form-drag-Country"
);
cy.wait(1000); cy.wait(1000);
// Verify if order is: LastUpdate, Country, Country => City // Verify if order is: LastUpdate, Country, Country => City
@ -119,13 +117,11 @@ export const genTest = (apiType, dbType) => {
it(`Validate ${viewType} view: Drag & drop for add/remove items`, () => { 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 // default, only one item in menu-bar; ensure LastUpdate field was present in form view
verifyFormMenuDrawerCardCount(0) verifyFormMenuDrawerCardCount(0);
verifyFormDrawerFieldLocation("LastUpdate", 0); verifyFormDrawerFieldLocation("LastUpdate", 0);
// drag 'LastUpdate' & drop into menu bar drag-drop box // drag 'LastUpdate' & drop into menu bar drag-drop box
cy.get(".nc-form-drag-LastUpdate").drag( cy.get(".nc-form-drag-LastUpdate").drag(".nc-drag-n-drop-to-hide");
".nc-drag-n-drop-to-hide"
);
// validate- fields count in menu bar to be increased by 1 && // validate- fields count in menu bar to be increased by 1 &&
// first member in 'formView' is Country // first member in 'formView' is Country
@ -134,15 +130,14 @@ export const genTest = (apiType, dbType) => {
}); });
it(`Validate ${viewType} view: Inverted order field member addition from menu`, () => { it(`Validate ${viewType} view: Inverted order field member addition from menu`, () => {
cy.get(".nc-form-remove-all").click(); cy.get(".nc-form-remove-all").click();
verifyFormMenuDrawerCardCount(2) verifyFormMenuDrawerCardCount(2);
// click fields in inverted order: LastUpdate, Country => City // click fields in inverted order: LastUpdate, Country => City
cy.get('.nc-form-left-drawer').find('.ant-card').eq(1).click(); cy.get(".nc-form-left-drawer").find(".ant-card").eq(1).click();
verifyFormMenuDrawerCardCount(1); verifyFormMenuDrawerCardCount(1);
cy.get('.nc-form-left-drawer').find('.ant-card').eq(0).click(); cy.get(".nc-form-left-drawer").find(".ant-card").eq(0).click();
// verify if order of appearance in form is right // verify if order of appearance in form is right
// Country was never removed as its required field. Other two will appear in inverted order // Country was never removed as its required field. Other two will appear in inverted order
@ -154,9 +149,7 @@ export const genTest = (apiType, dbType) => {
it(`Validate ${viewType}: Form header & description validation`, () => { it(`Validate ${viewType}: Form header & description validation`, () => {
// Header & description should exist // Header & description should exist
cy.get(".nc-form") cy.get(".nc-form").find('[placeholder="Form Title"]').should("exist");
.find('[placeholder="Form Title"]')
.should("exist");
cy.get(".nc-form") cy.get(".nc-form")
.find('[placeholder="Add form description"]') .find('[placeholder="Add form description"]')
.should("exist"); .should("exist");
@ -170,17 +163,20 @@ export const genTest = (apiType, dbType) => {
.find('[placeholder="Add form description"]') .find('[placeholder="Add form description"]')
.type("Some description about form comes here"); .type("Some description about form comes here");
cy.get(".nc-form").click() cy.get(".nc-form").click();
// validate new contents // validate new contents
validateFormHeader(); validateFormHeader();
}); });
it(`Validate ${viewType}: Add all, Remove all validation`, () => { it(`Validate ${viewType}: Add all, Remove all validation`, () => {
// ensure buttons exist on left hand menu // 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")
cy.get(".nc-form-left-drawer").find(".nc-form-remove-all").should("be.visible"); .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 // click: remove-all
cy.get(".nc-form-left-drawer").find(".nc-form-remove-all").click(); cy.get(".nc-form-left-drawer").find(".nc-form-remove-all").click();
@ -191,8 +187,13 @@ export const genTest = (apiType, dbType) => {
verifyFormMenuDrawerCardCount(2); verifyFormMenuDrawerCardCount(2);
// click: Add all // click: Add all
cy.get(".nc-form-left-drawer").find(".nc-form-add-all").should('be.visible').click(); cy.get(".nc-form-left-drawer")
cy.get(".nc-form-left-drawer").find(".nc-form-remove-all").should("be.visible"); .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" // form should contain "field remove icons"
verifyFormDrawerHideObjectCount(2); verifyFormDrawerHideObjectCount(2);
@ -227,18 +228,19 @@ export const genTest = (apiType, dbType) => {
.click(); .click();
// fill up mandatory fields // fill up mandatory fields
cy.get(".nc-form-input-Country").should('exist').type("_abc"); cy.get(".nc-form-input-Country").should("exist").type("_abc");
cy.get(".nc-form-input-LastUpdate").click(); cy.get(".nc-form-input-LastUpdate").click();
cy.get(".ant-picker-now-btn:visible").contains("Now").click(); cy.get(".ant-picker-now-btn:visible").contains("Now").click();
cy.get(".ant-btn-primary:visible").contains("Ok").click(); cy.get(".ant-btn-primary:visible").contains("Ok").click();
// add message // add message
cy.get("textarea.nc-form-after-submit-msg") cy.get("textarea.nc-form-after-submit-msg").type("Congratulations!");
.type("Congratulations!");
// submit button & validate // submit button & validate
cy.get(".nc-form").find("button").contains("Submit").click(); cy.get(".nc-form").find("button").contains("Submit").click();
cy.get(".ant-alert-message").contains("Congratulations!").should("exist"); 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. // end of test removes newly added rows from table. that step validates if row was successfully added.
}); });
@ -260,7 +262,9 @@ export const genTest = (apiType, dbType) => {
// submit button & validate // submit button & validate
cy.get(".nc-form").find("button").contains("Submit").click(); cy.get(".nc-form").find("button").contains("Submit").click();
cy.get(".ant-alert-message").contains("Congratulations").should("exist"); cy.get(".ant-alert-message")
.contains("Congratulations")
.should("exist");
cy.get("button") cy.get("button")
.contains("Submit Another Form") .contains("Submit Another Form")
.should("exist") .should("exist")
@ -273,17 +277,14 @@ export const genTest = (apiType, dbType) => {
}); });
it(`Validate ${viewType}: Submit default, Enable checkbox "blank form after 5 seconds"`, () => { 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-Country").type("_abc");
cy.get(".nc-form-input-LastUpdate").click(); cy.get(".nc-form-input-LastUpdate").click();
cy.get(".ant-picker-now-btn:visible").contains("Now").click(); cy.get(".ant-picker-now-btn:visible").contains("Now").click();
cy.get(".ant-btn-primary:visible").contains("Ok").click(); cy.get(".ant-btn-primary:visible").contains("Ok").click();
// enable "New form after 5 seconds" button // enable "New form after 5 seconds" button
cy.get("button.nc-form-checkbox-submit-another-form") cy.get("button.nc-form-checkbox-submit-another-form").click();
.click(); cy.get("button.nc-form-checkbox-show-blank-form").click();
cy.get("button.nc-form-checkbox-show-blank-form")
.click();
// submit button & validate // submit button & validate
cy.get(".nc-form").find("button").contains("Submit").click(); cy.get(".nc-form").find("button").contains("Submit").click();
@ -318,13 +319,8 @@ export const genTest = (apiType, dbType) => {
it(`Validate ${viewType}: Email me verification, with SMTP configuration`, () => { it(`Validate ${viewType}: Email me verification, with SMTP configuration`, () => {
// activate SMTP, dummy profile // activate SMTP, dummy profile
settingsPage.openMenu(settingsPage.APPSTORE) settingsPage.openMenu(settingsPage.APPSTORE);
mainPage.configureSMTP( mainPage.configureSMTP("admin@ex.com", "smtp.ex.com", "8080", "TLS");
"admin@ex.com",
"smtp.ex.com",
"8080",
"TLS"
);
// open form view & enable "email me" option // open form view & enable "email me" option
cy.openTableTab("Country", 25); cy.openTableTab("Country", 25);
@ -337,10 +333,9 @@ export const genTest = (apiType, dbType) => {
// validate if form has appeared again // validate if form has appeared again
validateFormHeader(); validateFormHeader();
cy.get(".nc-form-checkbox-send-email") cy.get(".nc-form-checkbox-send-email").click();
.click();
settingsPage.openMenu(settingsPage.APPSTORE) settingsPage.openMenu(settingsPage.APPSTORE);
mainPage.resetSMTP(); mainPage.resetSMTP();
cy.wait(300); cy.wait(300);
@ -363,7 +358,11 @@ export const genTest = (apiType, dbType) => {
cy.get(".nc-form").find(".nc-field-remove-icon").eq(1).click(); 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-input-LastUpdate").should("not.exist");
cy.get('.nc-form-left-drawer').find('.ant-card').contains('LastUpdate').should('exist').click(); cy.get(".nc-form-left-drawer")
.find(".ant-card")
.contains("LastUpdate")
.should("exist")
.click();
cy.get(".nc-form-input-LastUpdate").should("exist"); cy.get(".nc-form-input-LastUpdate").should("exist");
cy.wait(300); cy.wait(300);
@ -384,8 +383,10 @@ export const genTest = (apiType, dbType) => {
// click on delete icon (becomes visible on hovering mouse) // click on delete icon (becomes visible on hovering mouse)
cy.get(".nc-view-delete-icon").click({ force: true }); cy.get(".nc-view-delete-icon").click({ force: true });
cy.wait(1000) cy.wait(1000);
cy.getActiveModal(".nc-modal-view-delete").find('.ant-btn-dangerous').click(); cy.getActiveModal(".nc-modal-view-delete")
.find(".ant-btn-dangerous")
.click();
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
@ -396,10 +397,10 @@ export const genTest = (apiType, dbType) => {
mainPage.getPagination(5).click(); mainPage.getPagination(5).click();
cy.get(".nc-grid-row").should("have.length", 13); 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(10).click({ force: true });
cy.get(".ant-checkbox").should('exist').eq(11).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(12).click({ force: true });
cy.get(".ant-checkbox").should('exist').eq(13).click({ force: true }); cy.get(".ant-checkbox").should("exist").eq(13).click({ force: true });
mainPage.getCell("Country", 10).rightclick({ force: true }); mainPage.getCell("Country", 10).rightclick({ force: true });
cy.getActiveMenu(".nc-dropdown-grid-context-menu") cy.getActiveMenu(".nc-dropdown-grid-context-menu")

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

@ -29,14 +29,20 @@ export const genTest = (apiType, dbType) => {
const lockViewTest = (enabled) => { const lockViewTest = (enabled) => {
it(`Grid: lock view set to ${enabled}: validation`, () => { it(`Grid: lock view set to ${enabled}: validation`, () => {
let vString = enabled ? "not." : ""; let vString = enabled ? "not." : "";
let menuOption = enabled ? 'Locked View' : 'Collaborative View'; let menuOption = enabled ? "Locked View" : "Collaborative View";
// on menu, collaboration view appears first (at index 0) // on menu, collaboration view appears first (at index 0)
// followed by Locked view (at index 1) // followed by Locked view (at index 1)
cy.get(".nc-actions-menu-btn").click(); cy.get(".nc-actions-menu-btn").click();
cy.getActiveMenu(".nc-dropdown-actions-menu").find('.ant-dropdown-menu-submenu').eq(0).click(); cy.getActiveMenu(".nc-dropdown-actions-menu")
.find(".ant-dropdown-menu-submenu")
.eq(0)
.click();
cy.wait(1000); cy.wait(1000);
cy.get('.nc-locked-menu-item').contains(menuOption).should('exist').click(); cy.get(".nc-locked-menu-item")
.contains(menuOption)
.should("exist")
.click();
// cy.get(".nc-sidebar-lock-menu") // cy.get(".nc-sidebar-lock-menu")
// .click(); // .click();
@ -46,10 +52,10 @@ export const genTest = (apiType, dbType) => {
// .click(); // .click();
if (enabled) { if (enabled) {
cy.toastWait('Successfully Switched to locked view') cy.toastWait("Successfully Switched to locked view");
cy.get(".nc-icon-locked").should("exist"); cy.get(".nc-icon-locked").should("exist");
} else { } else {
cy.toastWait('Successfully Switched to collaborative view') cy.toastWait("Successfully Switched to collaborative view");
cy.get(".nc-icon-collaborative").should("exist"); cy.get(".nc-icon-collaborative").should("exist");
} }
@ -58,26 +64,19 @@ export const genTest = (apiType, dbType) => {
// cy.get(".nc-sidebar-lock-menu:enabled") // cy.get(".nc-sidebar-lock-menu:enabled")
// .should("exist"); // .should("exist");
cy.get(".nc-toolbar-reload-btn") cy.get(".nc-toolbar-reload-btn").should("exist");
.should("exist"); cy.get(".nc-add-new-row-btn > .cursor-pointer").should(
cy.get(".nc-add-new-row-btn > .cursor-pointer") `${vString}exist`
.should(`${vString}exist`); );
cy.get(".nc-fields-menu-btn:enabled") cy.get(".nc-fields-menu-btn:enabled").should(`${vString}exist`);
.should(`${vString}exist`); cy.get(".nc-sort-menu-btn:enabled").should(`${vString}exist`);
cy.get(".nc-sort-menu-btn:enabled") cy.get(".nc-filter-menu-btn:enabled").should(`${vString}exist`);
.should(`${vString}exist`);
cy.get(".nc-filter-menu-btn:enabled")
.should(`${vString}exist`);
// dblClick on a cell & see if we can edit // dblClick on a cell & see if we can edit
mainPage.getCell("Country", 1).dblclick(); mainPage.getCell("Country", 1).dblclick();
mainPage mainPage.getCell("Country", 1).find("input").should(`${vString}exist`);
.getCell("Country", 1)
.find("input")
.should(`${vString}exist`);
cy.get(".nc-row-expand") cy.get(".nc-row-expand").should(`${vString}exist`);
.should(`${vString}exist`);
// check if add/ expand options available for 'has many' column type // check if add/ expand options available for 'has many' column type
// GUI-v2: TBD // GUI-v2: TBD
@ -94,9 +93,7 @@ export const genTest = (apiType, dbType) => {
// update row option (right click) - should not be available for Lock view // update row option (right click) - should not be available for Lock view
mainPage.getCell("City List", 1).rightclick(); mainPage.getCell("City List", 1).rightclick();
cy.get(".ant-dropdown-content").should( cy.get(".ant-dropdown-content").should(`${vString}be.visible`);
`${vString}be.visible`
);
}); });
}; };

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

@ -36,13 +36,16 @@ export const genTest = (apiType, dbType) => {
// Input: viewType - 'grid'/'gallery' // Input: viewType - 'grid'/'gallery'
// //
const viewTest = (viewType) => { const viewTest = (viewType) => {
it(`Create ${viewType} view`, () => {0 it(`Create ${viewType} view`, () => {
0;
// click on create grid view button // click on create grid view button
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").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");
@ -69,12 +72,10 @@ export const genTest = (apiType, dbType) => {
.type("Some description about form comes here"); .type("Some description about form comes here");
// add message // add message
cy.get("textarea.nc-form-after-submit-msg") cy.get("textarea.nc-form-after-submit-msg").type("Congratulations!");
.type("Congratulations!");
// move Country field down (drag, drop) // move Country field down (drag, drop)
cy.get(".nc-form-drag-LastUpdate").drag( cy.get(".nc-form-drag-LastUpdate").drag(".nc-form-drag-City");
".nc-form-drag-City");
cy.get('[title="Address List"]').drag(".nc-drag-n-drop-to-hide"); cy.get('[title="Address List"]').drag(".nc-drag-n-drop-to-hide");
@ -85,7 +86,6 @@ export const genTest = (apiType, dbType) => {
}); });
it(`Share form view`, () => { it(`Share form view`, () => {
cy.get(`.nc-view-item.nc-${viewType}-view-item`) cy.get(`.nc-view-item.nc-${viewType}-view-item`)
.contains("Form-1") .contains("Form-1")
.click(); .click();
@ -95,7 +95,7 @@ export const genTest = (apiType, dbType) => {
// copy link text, visit URL // copy link text, visit URL
cy.getActiveModal(".nc-modal-share-view") cy.getActiveModal(".nc-modal-share-view")
.should('exist') .should("exist")
.find(".share-link-box") .find(".share-link-box")
.contains("/nc/form/", { timeout: 10000 }) .contains("/nc/form/", { timeout: 10000 })
.should("exist") .should("exist")
@ -191,7 +191,10 @@ export const genTest = (apiType, dbType) => {
// click on delete icon (becomes visible on hovering mouse) // click on delete icon (becomes visible on hovering mouse)
cy.get(".nc-view-delete-icon").click({ force: true }); cy.get(".nc-view-delete-icon").click({ force: true });
cy.wait(1000); cy.wait(1000);
cy.getActiveModal(".nc-modal-view-delete").find('.ant-btn-dangerous').should('exist').click(); cy.getActiveModal(".nc-modal-view-delete")
.find(".ant-btn-dangerous")
.should("exist")
.click();
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

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

@ -75,7 +75,9 @@ export const genTest = (apiType, dbType) => {
it(`Create ${viewType.toUpperCase()} view`, () => { it(`Create ${viewType.toUpperCase()} view`, () => {
// create a normal public view // create a normal public view
cy.get(`.nc-create-${viewType}-view`).click(); cy.get(`.nc-create-${viewType}-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");
// store base URL- to re-visit and delete form view later // store base URL- to re-visit and delete form view later
@ -188,10 +190,7 @@ export const genTest = (apiType, dbType) => {
}; };
// download & verify // download & verify
mainPage.downloadAndVerifyCsv( mainPage.downloadAndVerifyCsv(`Address_exported_1.csv`, verifyCsv);
`Address_exported_1.csv`,
verifyCsv
);
mainPage.unhideField("LastUpdate"); mainPage.unhideField("LastUpdate");
}); });
@ -247,10 +246,7 @@ export const genTest = (apiType, dbType) => {
expect(strCol[2]).to.be.equal(retCol[2]); expect(strCol[2]).to.be.equal(retCol[2]);
} }
}; };
mainPage.downloadAndVerifyCsv( mainPage.downloadAndVerifyCsv(`Address_exported_1.csv`, verifyCsv);
`Address_exported_1.csv`,
verifyCsv
);
mainPage.unhideField("LastUpdate"); mainPage.unhideField("LastUpdate");
}); });
@ -287,7 +283,9 @@ export const genTest = (apiType, dbType) => {
.find("button.mdi-arrow-expand") .find("button.mdi-arrow-expand")
.click(); .click();
cy.getActiveModal(".nc-modal-child-list").find("button.mdi-reload").should("exist"); cy.getActiveModal(".nc-modal-child-list")
.find("button.mdi-reload")
.should("exist");
cy.getActiveModal(".nc-modal-child-list") cy.getActiveModal(".nc-modal-child-list")
.find("button") .find("button")
.contains("Link to") .contains("Link to")
@ -340,7 +338,9 @@ export const genTest = (apiType, dbType) => {
.find("button.mdi-arrow-expand") .find("button.mdi-arrow-expand")
.click(); .click();
cy.getActiveModal(".nc-modal-child-list").find("button.mdi-reload").should("exist"); cy.getActiveModal(".nc-modal-child-list")
.find("button.mdi-reload")
.should("exist");
cy.getActiveModal(".nc-modal-child-list") cy.getActiveModal(".nc-modal-child-list")
.find("button") .find("button")
.contains("Link to") .contains("Link to")
@ -395,7 +395,7 @@ export const genTest = (apiType, dbType) => {
// delete row // delete row
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);
@ -404,7 +404,9 @@ export const genTest = (apiType, dbType) => {
.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 Selected Row").click(); cy.getActiveMenu(".nc-dropdown-grid-context-menu")
.contains("Delete Selected Row")
.click();
// delete column // delete column
cy.get(`th:contains('dummy') .mdi-menu-down`) cy.get(`th:contains('dummy') .mdi-menu-down`)
@ -424,10 +426,7 @@ export const genTest = (apiType, dbType) => {
it(`Generate default Shared GRID view URL`, () => { it(`Generate default Shared GRID view URL`, () => {
// add row // add row
cy.get(".nc-add-new-row-btn").click(); cy.get(".nc-add-new-row-btn").click();
cy.get("#data-table-form-Country > input") cy.get("#data-table-form-Country > input").first().click().type("a");
.first()
.click()
.type("a");
cy.contains("Save row").filter("button").click({ force: true }); cy.contains("Save row").filter("button").click({ force: true });
cy.toastWait("updated successfully"); cy.toastWait("updated successfully");

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
}); });
}; };

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

@ -29,7 +29,7 @@ export const genTest = (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(() => {
@ -38,7 +38,7 @@ export const genTest = (apiType, dbType) => {
afterEach(() => { afterEach(() => {
cy.saveLocalStorage(); cy.saveLocalStorage();
}) });
after(() => { after(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
@ -67,11 +67,8 @@ export const genTest = (apiType, dbType) => {
// } // }
// }); // });
cy.get(`.nc-user-row`).should('exist') cy.get(`.nc-user-row`).should("exist");
mainPage.addNewUserToProject( mainPage.addNewUserToProject(user.credentials, user.name);
user.credentials,
user.name
);
}); });
}; };
@ -91,10 +88,8 @@ export const genTest = (apiType, dbType) => {
settingsPage.openTab(settingsPage.UI_ACCESS_CONTROL); settingsPage.openTab(settingsPage.UI_ACCESS_CONTROL);
// validate if it has 19 entries representing tables & views // validate if it has 19 entries representing tables & views
if (isPostgres()) if (isPostgres()) cy.get(".nc-acl-table-row").should("have.length", 24);
cy.get(".nc-acl-table-row").should("have.length", 24); else if (isXcdb()) cy.get(".nc-acl-table-row").should("have.length", 19);
else if (isXcdb())
cy.get(".nc-acl-table-row").should("have.length", 19);
else 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 // disable table & view access
@ -116,62 +111,51 @@ export const genTest = (apiType, dbType) => {
const roleValidation = (roleType) => { const roleValidation = (roleType) => {
describe(`User role validation`, () => { describe(`User role validation`, () => {
before(() => { before(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
cy.visit(mainPage.roleURL[roleType]) cy.visit(mainPage.roleURL[roleType]);
cy.wait(5000); cy.wait(5000);
cy.get('button:contains("SIGN UP")').should('exist') cy.get('button:contains("SIGN UP")').should("exist");
cy.get('input[type="text"]', { timeout: 20000 }).type( cy.get('input[type="text"]', { timeout: 20000 }).type(
roles[roleType].credentials.username roles[roleType].credentials.username
); );
cy.get('input[type="password"]').type(roles[roleType].credentials.password); cy.get('input[type="password"]').type(
roles[roleType].credentials.password
);
cy.get('button:contains("SIGN UP")').click(); cy.get('button:contains("SIGN UP")').click();
cy.wait(3000); cy.wait(3000);
cy.get('.nc-project-page-title').contains("My Projects").should("be.visible"); cy.get(".nc-project-page-title")
.contains("My Projects")
.should("be.visible");
if (dbType === "xcdb") { if (dbType === "xcdb") {
if ("rest" == apiType) if ("rest" == apiType)
projectsPage.openProject( projectsPage.openProject(staticProjects.sampleREST.basic.name);
staticProjects.sampleREST.basic.name else projectsPage.openProject(staticProjects.sampleGQL.basic.name);
);
else
projectsPage.openProject(
staticProjects.sampleGQL.basic.name
);
} else if (dbType === "mysql") { } else if (dbType === "mysql") {
if ("rest" == apiType) if ("rest" == apiType)
projectsPage.openProject( projectsPage.openProject(staticProjects.externalREST.basic.name);
staticProjects.externalREST.basic.name else projectsPage.openProject(staticProjects.externalGQL.basic.name);
);
else
projectsPage.openProject(
staticProjects.externalGQL.basic.name
);
} else if (dbType === "postgres") { } else if (dbType === "postgres") {
if ("rest" == apiType) if ("rest" == apiType)
projectsPage.openProject( projectsPage.openProject(staticProjects.pgExternalREST.basic.name);
staticProjects.pgExternalREST.basic.name
);
else else
projectsPage.openProject( projectsPage.openProject(staticProjects.pgExternalGQL.basic.name);
staticProjects.pgExternalGQL.basic.name
);
} }
if (roleType === "creator") { if (roleType === "creator") {
// kludge: wait for page load to finish // kludge: wait for page load to finish
// close team & auth tab // close team & auth tab
cy.wait(2000); cy.wait(2000);
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);
} }
cy.saveLocalStorage(); cy.saveLocalStorage();
}) });
beforeEach(() => { beforeEach(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
@ -179,7 +163,7 @@ export const genTest = (apiType, dbType) => {
afterEach(() => { afterEach(() => {
cy.saveLocalStorage(); cy.saveLocalStorage();
}) });
after(() => { after(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
@ -233,10 +217,9 @@ export const genTest = (apiType, dbType) => {
}); });
it(`[${roles[roleType].name}] Download files`, () => { it(`[${roles[roleType].name}] Download files`, () => {
// to be fixed // to be fixed
if(roleType === 'commenter' || roleType === 'viewer') {} if (roleType === "commenter" || roleType === "viewer") {
else { } else {
// viewer & commenter doesn't contain hideField option in ncv2 // viewer & commenter doesn't contain hideField option in ncv2
// #ID, City, LastUpdate, City => Address, Country <= City, + // #ID, City, LastUpdate, City => Address, Country <= City, +
mainPage.hideField("LastUpdate"); mainPage.hideField("LastUpdate");
@ -255,9 +238,7 @@ export const genTest = (apiType, dbType) => {
if (!isXcdb()) { if (!isXcdb()) {
for (let i = 0; i < storedRecords.length; i++) { for (let i = 0; i < storedRecords.length; i++) {
// cy.log(retrievedRecords[i]) // cy.log(retrievedRecords[i])
expect(retrievedRecords[i]).to.be.equal( expect(retrievedRecords[i]).to.be.equal(storedRecords[i]);
storedRecords[i]
);
} }
} }
}; };

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

@ -7,7 +7,8 @@ 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,
@ -35,11 +36,18 @@ export const genTest = (apiType, dbType, roleType) => {
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(1000);
cy.get(".ant-dropdown-menu-submenu")
.eq(4)
.find(`[data-menu-id="editor"]`)
.should("exist")
.click();
cy.wait(10000) cy.wait(10000);
cy.saveLocalStorage(); cy.saveLocalStorage();
}); });
@ -54,10 +62,7 @@ export const genTest = (apiType, dbType, roleType) => {
// cy.wait(20000) // cy.wait(20000)
// wait for page rendering to complete // wait for page rendering to complete
cy.get(".nc-grid-row", { timeout: 25000 }).should( cy.get(".nc-grid-row", { timeout: 25000 }).should("have.length", 25);
"have.length",
25
);
// cy.get('.nc-preview-reset:visible').should('not-exist') // cy.get('.nc-preview-reset:visible').should('not-exist')
@ -72,10 +77,8 @@ export const genTest = (apiType, dbType, roleType) => {
cy.get(".nc-ui-acl-tab").click({ force: true }); cy.get(".nc-ui-acl-tab").click({ force: true });
// validate if it has 19 entries representing tables & views // validate if it has 19 entries representing tables & views
if (isPostgres()) if (isPostgres()) cy.get(".nc-acl-table-row").should("have.length", 24);
cy.get(".nc-acl-table-row").should("have.length", 24); else if (isXcdb()) cy.get(".nc-acl-table-row").should("have.length", 19);
else if (isXcdb())
cy.get(".nc-acl-table-row").should("have.length", 19);
else cy.get(".nc-acl-table-row").should("have.length", 19); else cy.get(".nc-acl-table-row").should("have.length", 19);
// restore access // restore access
@ -92,12 +95,12 @@ export const genTest = (apiType, dbType, roleType) => {
const genTestSub = (roleType) => { const genTestSub = (roleType) => {
it(`Role preview: ${roleType}: Enable preview`, () => { it(`Role preview: ${roleType}: Enable preview`, () => {
cy.get(".nc-floating-preview-btn", { timeout: 30000 }).should("exist"); cy.get(".nc-floating-preview-btn", { timeout: 30000 }).should("exist");
cy.get('.nc-floating-preview-btn') cy.get(".nc-floating-preview-btn")
.find(`[type="radio"][value="${roleType}"]`) .find(`[type="radio"][value="${roleType}"]`)
.should('exist') .should("exist")
.click(); .click();
cy.wait(5000) cy.wait(5000);
cy.saveLocalStorage(); cy.saveLocalStorage();
}); });

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

@ -20,7 +20,7 @@ export const genTest = (apiType, dbType) => {
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);
@ -36,11 +36,11 @@ export const genTest = (apiType, dbType) => {
// `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()) {
@ -56,7 +56,7 @@ export const genTest = (apiType, dbType) => {
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

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

@ -42,7 +42,7 @@ export const genTest = (apiType, dbType) => {
describe(`Swagger page, base verification`, () => { describe(`Swagger page, base verification`, () => {
before(() => { before(() => {
cy.fileHook(); cy.fileHook();
}) });
// returns swagger button intended for // returns swagger button intended for
// //
@ -82,51 +82,33 @@ export const genTest = (apiType, dbType) => {
.next() .next()
.find(".opblock") .find(".opblock")
.should("has.length", 9); .should("has.length", 9);
getSwaggerButton( getSwaggerButton("Authentication", 0, "User login").should("exist");
"Authentication", getSwaggerButton("Authentication", 1, "User signup").should(
0, "exist"
"User login" );
).should("exist"); getSwaggerButton("Authentication", 2, "Password Forgot").should(
getSwaggerButton( "exist"
"Authentication", );
1, getSwaggerButton("Authentication", 3, "Email validate link").should(
"User signup" "exist"
).should("exist"); );
getSwaggerButton(
"Authentication",
2,
"Password Forgot"
).should("exist");
getSwaggerButton(
"Authentication",
3,
"Email validate link"
).should("exist");
getSwaggerButton( getSwaggerButton(
"Authentication", "Authentication",
4, 4,
"Validate password reset token" "Validate password reset token"
).should("exist"); ).should("exist");
getSwaggerButton( getSwaggerButton("Authentication", 5, "Password reset").should(
"Authentication", "exist"
5, );
"Password reset" getSwaggerButton("Authentication", 6, "User details").should(
).should("exist"); "exist"
getSwaggerButton( );
"Authentication", getSwaggerButton("Authentication", 7, "Update user details").should(
6, "exist"
"User details" );
).should("exist"); getSwaggerButton("Authentication", 8, "Update user details").should(
getSwaggerButton( "exist"
"Authentication", );
7,
"Update user details"
).should("exist");
getSwaggerButton(
"Authentication",
8,
"Update user details"
).should("exist");
}); });
}); });
}); });
@ -138,9 +120,7 @@ export const genTest = (apiType, dbType) => {
cy.get(".auth-btn-wrapper > .authorize").click(); cy.get(".auth-btn-wrapper > .authorize").click();
// Response: "Authorized" should exist on DOM // Response: "Authorized" should exist on DOM
cy.get(".auth-container") cy.get(".auth-container").contains("Authorized").should("exist");
.contains("Authorized")
.should("exist");
cy.get(".btn-done").click(); cy.get(".btn-done").click();
// Authorize button is LOCKED now // Authorize button is LOCKED now

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

@ -9,27 +9,30 @@ export const genTest = (apiType, dbType) => {
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
@ -38,9 +41,12 @@ export const genTest = (apiType, dbType) => {
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")
.find(".ant-dropdown-menu-item")
.eq(idx)
.click();
cy.wait(200); cy.wait(200);
// basic validations // basic validations
@ -96,8 +102,7 @@ export const genTest = (apiType, dbType) => {
]; ];
// 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]);

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

@ -14,18 +14,14 @@ export const genTest = (apiType, dbType) => {
beforeEach(() => { beforeEach(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
}) });
afterEach(() => { afterEach(() => {
cy.saveLocalStorage(); cy.saveLocalStorage();
}) });
it("Delete Project", () => { it("Delete Project", () => {
cy.get(`.nc-action-btn`).should("exist").last().click();
cy.get(`.nc-action-btn`)
.should("exist")
.last()
.click();
cy.getActiveModal(".nc-modal-project-delete") cy.getActiveModal(".nc-modal-project-delete")
.find(".ant-btn-dangerous") .find(".ant-btn-dangerous")

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

@ -14,11 +14,11 @@ export const genTest = (apiType, dbType) => {
beforeEach(() => { beforeEach(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
}) });
afterEach(() => { afterEach(() => {
cy.saveLocalStorage(); cy.saveLocalStorage();
}) });
after(() => { after(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
@ -30,7 +30,7 @@ export const genTest = (apiType, dbType) => {
// 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);
@ -40,7 +40,9 @@ export const genTest = (apiType, dbType) => {
// .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();
@ -51,10 +53,10 @@ export const genTest = (apiType, dbType) => {
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");
@ -67,7 +69,9 @@ export const genTest = (apiType, dbType) => {
// 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");
@ -79,7 +83,7 @@ export const genTest = (apiType, dbType) => {
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);
@ -99,11 +103,12 @@ export const genTest = (apiType, dbType) => {
// 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();

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

@ -87,8 +87,11 @@ export const genTest = (apiType, dbType) => {
sheetData = rows; sheetData = rows;
}); });
cy.visit("/") cy.visit("/");
projectsPage.createProject({ dbType: "none", apiType: "REST", name: "importSample" }, {}) projectsPage.createProject(
{ dbType: "none", apiType: "REST", name: "importSample" },
{}
);
cy.wait(4000); cy.wait(4000);
cy.saveLocalStorage(); cy.saveLocalStorage();
@ -100,57 +103,66 @@ export const genTest = (apiType, dbType) => {
afterEach(() => { afterEach(() => {
cy.saveLocalStorage(); cy.saveLocalStorage();
}) });
it("File Upload: Upload excel as template", () => { it("File Upload: Upload excel as template", () => {
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")
cy.getActiveMenu(".nc-dropdown-import-menu").find('.ant-dropdown-menu-item').contains('Microsoft Excel').click() .find(".ant-dropdown-menu-item")
.contains("Microsoft Excel")
cy.get(".nc-input-import").should('exist').find('input').attachFile(filepath); .click();
cy.get(".nc-input-import")
.should("exist")
.find("input")
.attachFile(filepath);
cy.toastWait("Uploaded file simple.xlsx successfully"); cy.toastWait("Uploaded file simple.xlsx successfully");
cy.get(".nc-btn-import").should('exist').click(); cy.get(".nc-btn-import").should("exist").click();
}); });
it("File Upload: Verify pre-load template page", () => { it("File Upload: Verify pre-load template page", () => {
cy.getActiveModal() cy.getActiveModal()
.find(".ant-collapse-item") .find(".ant-collapse-item")
.then((sheets) => { .then((sheets) => {
// hardcoded. fix me. // hardcoded. fix me.
let sheetList = ["Sheet2", "Sheet3", "Sheet4"]; let sheetList = ["Sheet2", "Sheet3", "Sheet4"];
for (let i = 0; i < sheets.length; i++) { for (let i = 0; i < sheets.length; i++) {
cy.wrap(sheets[i]) cy.wrap(sheets[i])
.find('.ant-collapse-header') .find(".ant-collapse-header")
.contains(sheetList[i]) .contains(sheetList[i])
.should("exist"); .should("exist");
// for each sheet, expand to verify table names & their data types // for each sheet, expand to verify table names & their data types
if(i!==0) if (i !== 0) cy.wrap(sheets[i]).find(".ant-collapse-arrow").click();
cy.wrap(sheets[i]).find(".ant-collapse-arrow").click();
// sheet > tables > rows > cells > inputs // sheet > tables > rows > cells > inputs
cy.wrap(sheets[i]).find(".ant-table-tbody").then((tables) => { cy.wrap(sheets[i])
cy.wrap(tables).find(".ant-table-row:visible") .find(".ant-table-tbody")
.then((tables) => {
cy.wrap(tables)
.find(".ant-table-row:visible")
.should("have.length", 3) .should("have.length", 3)
.then((rows) => { .then((rows) => {
// cy.log(rows) // cy.log(rows)
for (let j = 0; j < rows.length; j++) { for (let j = 0; j < rows.length; j++) {
cy.wrap(rows[j]).find(".ant-table-cell") cy.wrap(rows[j])
.find(".ant-table-cell")
.then((cells) => { .then((cells) => {
cy.wrap(cells[0]).find("input") cy.wrap(cells[0])
.find("input")
.then((input) => { .then((input) => {
expect(input.val()).to.equal(expectedData[j][0]) expect(input.val()).to.equal(expectedData[j][0]);
}) });
cy.wrap(cells[1]).find(".ant-select-selection-item") cy.wrap(cells[1])
.find(".ant-select-selection-item")
.contains(expectedData[j][1]) .contains(expectedData[j][1])
.should("exist") .should("exist");
}) });
} }
}) });
}) });
// unwind // unwind
cy.wrap(sheets[i]).find(".ant-collapse-arrow").click(); cy.wrap(sheets[i]).find(".ant-collapse-arrow").click();
@ -163,7 +175,6 @@ export const genTest = (apiType, dbType) => {
}); });
it("File Upload: Verify loaded data", () => { it("File Upload: Verify loaded data", () => {
cy.openTableTab("Sheet2", 2); cy.openTableTab("Sheet2", 2);
for (const [key, value] of Object.entries(expectedData)) { for (const [key, value] of Object.entries(expectedData)) {
mainPage mainPage
@ -194,47 +205,52 @@ export const genTest = (apiType, dbType) => {
it.skip("URL: Upload excel as template", () => { it.skip("URL: Upload excel as template", () => {
// trigger import // trigger import
cy.get(`[data-menu-id="addORImport"]`).click(); cy.get(`[data-menu-id="addORImport"]`).click();
cy.getActivePopUp().contains("Microsoft Excel").should('exist').click(); cy.getActivePopUp().contains("Microsoft Excel").should("exist").click();
cy.getActiveModal().find('.ant-tabs-tab').last().click() cy.getActiveModal().find(".ant-tabs-tab").last().click();
cy.get("input[type=\"text\"]") cy.get('input[type="text"]').last().click().type(URL);
.last() cy.get(".nc-btn-primary").should("exist").click();
.click()
.type(URL);
cy.get(".nc-btn-primary").should('exist').click();
}); });
it.skip("URL: Verify pre-load template page", () => { it.skip("URL: Verify pre-load template page", () => {
cy.getActiveModal() cy.getActiveModal()
.find(".ant-collapse-item") .find(".ant-collapse-item")
.then((sheets) => { .then((sheets) => {
let sheetList = ["Sheet1"]; let sheetList = ["Sheet1"];
for (let i = 0; i < sheets.length; i++) { for (let i = 0; i < sheets.length; i++) {
cy.wrap(sheets[i]) cy.wrap(sheets[i])
.find('.ant-collapse-header') .find(".ant-collapse-header")
.contains(sheetList[i]) .contains(sheetList[i])
.should("exist"); .should("exist");
cy.wrap(sheets[i]).find(".ant-table-tbody").then((tables) => { cy.wrap(sheets[i])
cy.wrap(tables).find(".ant-table-row:visible") .find(".ant-table-tbody")
.then((tables) => {
cy.wrap(tables)
.find(".ant-table-row:visible")
.then((rows) => { .then((rows) => {
// cy.log(rows) // cy.log(rows)
for (let j = 0; j < 10; j++) { for (let j = 0; j < 10; j++) {
cy.wrap(rows[j]).find(".ant-table-cell").then((cells) => { cy.wrap(rows[j])
.find(".ant-table-cell")
.then((cells) => {
// cy.log(cells) // cy.log(cells)
for (let k = 0; k < 2; k++) { for (let k = 0; k < 2; k++) {
cy.wrap(cells[k]).find("input").then((input) => { cy.wrap(cells[k])
.find("input")
.then((input) => {
// cy.log(input) // cy.log(input)
expect(input.val()).to.equal(UrlFileExpectedData[j][k]) expect(input.val()).to.equal(
}) UrlFileExpectedData[j][k]
);
});
} }
}) });
} }
}) });
}) });
// unwind // unwind
cy.wrap(sheets[i]).find(".ant-collapse-arrow").click(); cy.wrap(sheets[i]).find(".ant-collapse-arrow").click();
@ -242,10 +258,9 @@ export const genTest = (apiType, dbType) => {
}); });
cy.getActiveModal().find(".ant-btn-primary").click(); cy.getActiveModal().find(".ant-btn-primary").click();
}) });
it.skip("URL: Verify loaded data", () => { it.skip("URL: Verify loaded data", () => {
// wait for loading to be completed // wait for loading to be completed
projectsPage.waitHomePageLoad(); projectsPage.waitHomePageLoad();

47
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
* *

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

@ -29,18 +29,38 @@ let records2 = {
"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();
} }
@ -48,40 +68,38 @@ function openWebhook(index) {
// 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");
@ -89,25 +107,23 @@ export const genTest = (apiType, dbType, testMode) => {
// 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 {
else {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
} }
cy.openTableTab("Film", 3) cy.openTableTab("Film", 3);
cy.saveLocalStorage(); cy.saveLocalStorage();
}); });
beforeEach(() => { beforeEach(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
}) });
afterEach(() => { afterEach(() => {
cy.saveLocalStorage(); cy.saveLocalStorage();
}) });
after(() => { after(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
@ -116,21 +132,18 @@ export const genTest = (apiType, dbType, testMode) => {
}); });
it("Verify Schema", () => { it("Verify Schema", () => {
// verify if all tables exist // verify if all tables exist
for (let i = 0; i < tn.length; i++) { for (let i = 0; i < tn.length; i++) {
cy.get(`.nc-project-tree-tbl-${tn[i]}`).should('exist') cy.get(`.nc-project-tree-tbl-${tn[i]}`).should("exist");
} }
// for Film table, verify columns // for Film table, verify columns
for (let i = 0; i < columnCount; i++) { for (let i = 0; i < columnCount; i++) {
cy.get(`th[data-title="${cn[i]}"]`).should("exist"); cy.get(`th[data-title="${cn[i]}"]`).should("exist");
} }
}); });
it("Verify Data types", () => { it("Verify Data types", () => {
// normal cells // normal cells
for (let [key, value] of Object.entries(records)) { for (let [key, value] of Object.entries(records)) {
mainPage.getCell(key, cellIdx).contains(value).should("exist"); mainPage.getCell(key, cellIdx).contains(value).should("exist");
@ -145,7 +158,10 @@ export const genTest = (apiType, dbType, testMode) => {
// date // date
// duration // duration
mainPage.getCell("Duration", cellIdx).contains(records2.Duration).should("exist"); mainPage
.getCell("Duration", cellIdx)
.contains(records2.Duration)
.should("exist");
// rating // rating
mainPage mainPage
@ -159,7 +175,7 @@ export const genTest = (apiType, dbType, testMode) => {
// LinkToAnotherRecord // LinkToAnotherRecord
mainPage.getCell("Actor", cellIdx).scrollIntoView(); mainPage.getCell("Actor", cellIdx).scrollIntoView();
cy.get(`:nth-child(${cellIdx}) > [data-title="Actor"]`) cy.get(`:nth-child(${cellIdx}) > [data-title="Actor"]`)
.find('.chip') .find(".chip")
.eq(0) .eq(0)
.contains(records2.Actor[0]) .contains(records2.Actor[0])
.should("exist"); .should("exist");
@ -167,34 +183,48 @@ export const genTest = (apiType, dbType, testMode) => {
// lookup // lookup
mainPage.getCell("Status (from Actor)", cellIdx).scrollIntoView(); mainPage.getCell("Status (from Actor)", cellIdx).scrollIntoView();
cy.get(`:nth-child(${cellIdx}) > [data-title="Status (from Actor)"]`) cy.get(`:nth-child(${cellIdx}) > [data-title="Status (from Actor)"]`)
.find('.nc-cell') .find(".nc-cell")
.eq(0) .eq(0)
.contains(records2["Status (from Actor)"][0]) .contains(records2["Status (from Actor)"][0])
.should("exist"); .should("exist");
// rollup // rollup
if( testMode === 'CY_QUICK') { if (testMode === "CY_QUICK") {
mainPage.getCell("RollUp", cellIdx).scrollIntoView(); mainPage.getCell("RollUp", cellIdx).scrollIntoView();
mainPage.getCell("RollUp", cellIdx).contains(records2.RollUp).should("exist"); mainPage
.getCell("RollUp", cellIdx)
.contains(records2.RollUp)
.should("exist");
// formula // formula
mainPage.getCell("Computation", cellIdx).scrollIntoView(); mainPage.getCell("Computation", cellIdx).scrollIntoView();
mainPage.getCell("Computation", cellIdx).contains(records2.Computation).should("exist"); mainPage
.getCell("Computation", cellIdx)
.contains(records2.Computation)
.should("exist");
// ltar hm relation // ltar hm relation
mainPage.getCell("Producer", cellIdx).scrollIntoView(); mainPage.getCell("Producer", cellIdx).scrollIntoView();
mainPage.getCell("Producer", cellIdx).find('.chip').eq(0).contains(records2.Producer[0]).should('exist') mainPage
mainPage.getCell("Producer", cellIdx).find('.chip').eq(1).contains(records2.Producer[1]).should('exist') .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", () => { it("Verify Views & Shared base", () => {
cy.get('.nc-form-view-item:visible') cy.get(".nc-form-view-item:visible")
.should('exist') .should("exist")
.eq(0) .eq(0)
.click({ force: true }) .click({ force: true });
// Header & description should exist // Header & description should exist
// cy.get(".nc-form") // cy.get(".nc-form")
@ -210,44 +240,57 @@ export const genTest = (apiType, dbType, testMode) => {
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) => {
cy.log($el);
expect($el.val()).to.equal("FormTitle"); expect($el.val()).to.equal("FormTitle");
}) });
cy.get(".nc-form") cy.get(".nc-form")
.find('[placeholder="Add form description"]') .find('[placeholder="Add form description"]')
.should("exist").then(($el) => { .should("exist")
cy.log($el) .then(($el) => {
cy.log($el);
expect($el.val()).to.equal("FormDescription"); expect($el.val()).to.equal("FormDescription");
}) });
// modified column name & help text // modified column name & help text
cy.get(".nc-editable").eq(0) cy.get(".nc-editable")
.find('.name') .eq(0)
.find(".name")
.contains("DisplayName") .contains("DisplayName")
.should('exist') .should("exist");
cy.get(".nc-editable").eq(0) cy.get(".nc-editable")
.find('.text-gray-500') .eq(0)
.contains('HelpText') .find(".text-gray-500")
.should('exist') .contains("HelpText")
.should("exist");
cy.get(".nc-editable").eq(1)
.find('.name') cy.get(".nc-editable")
.eq(1)
.find(".name")
.contains("Email") .contains("Email")
.should('exist') .should("exist");
// add message // add message
cy.get("textarea.nc-form-after-submit-msg").then(($element) => { cy.get("textarea.nc-form-after-submit-msg").then(($element) => {
expect($element[0].value).to.have.string("Thank you for submitting the form!") expect($element[0].value).to.have.string(
}) "Thank you for submitting the form!"
);
});
// cy.get(".nc-form > .mx-auto") // cy.get(".nc-form > .mx-auto")
// .find("textarea").then(($element) => { // .find("textarea").then(($element) => {
// expect($element[0].value).to.have.string("Thank you for submitting the form!") // 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(
cy.get("button.nc-form-checkbox-show-blank-form.ant-switch-checked").should('exist') "button.nc-form-checkbox-submit-another-form.ant-switch-checked"
cy.get("button.nc-form-checkbox-send-email.ant-switch-checked").should('not.exist') ).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 // // submit another form button
// cy.get(".nc-form > .mx-auto") // cy.get(".nc-form > .mx-auto")
@ -269,39 +312,39 @@ export const genTest = (apiType, dbType, testMode) => {
}); });
it("Verify Webhooks", () => { it("Verify Webhooks", () => {
if( testMode === 'CY_QUICK') { if (testMode === "CY_QUICK") {
cy.openTableTab("Actor", 25); cy.openTableTab("Actor", 25);
openWebhook(0) openWebhook(0);
verifyWebhook({ verifyWebhook({
title: "Webhook-1", title: "Webhook-1",
event: "After Insert", event: "After Insert",
notification: "URL", notification: "URL",
type: "POST", type: "POST",
url: "http://localhost:9090/hook", url: "http://localhost:9090/hook",
condition: false condition: false,
}) });
cy.get("body").type("{esc}"); cy.get("body").type("{esc}");
openWebhook(1) openWebhook(1);
verifyWebhook({ verifyWebhook({
title: "Webhook-2", title: "Webhook-2",
event: "After Update", event: "After Update",
notification: "URL", notification: "URL",
type: "POST", type: "POST",
url: "http://localhost:9090/hook", url: "http://localhost:9090/hook",
condition: false condition: false,
}) });
cy.get("body").type("{esc}"); cy.get("body").type("{esc}");
openWebhook(2) openWebhook(2);
verifyWebhook({ verifyWebhook({
title: "Webhook-3", title: "Webhook-3",
event: "After Delete", event: "After Delete",
notification: "URL", notification: "URL",
type: "POST", type: "POST",
url: "http://localhost:9090/hook", url: "http://localhost:9090/hook",
condition: false condition: false,
}) });
cy.get("body").type("{esc}"); cy.get("body").type("{esc}");
cy.closeTableTab("Actor"); cy.closeTableTab("Actor");
@ -331,48 +374,67 @@ export const genTest = (apiType, dbType, testMode) => {
it("Verify Fields, Filter & Sort", () => { it("Verify Fields, Filter & Sort", () => {
cy.openTableTab("Actor", 25); cy.openTableTab("Actor", 25);
cy.get(".nc-grid-view-item").eq(1).click() cy.get(".nc-grid-view-item").eq(1).click();
cy.wait(3000) cy.wait(3000);
cy.get(".nc-grid-header").find(`th[data-title="Name"]`).should("be.visible"); cy.get(".nc-grid-header")
cy.get(".nc-grid-header").find(`th[data-title="Notes"]`).should("be.visible"); .find(`th[data-title="Name"]`)
cy.get(".nc-grid-header").find(`th[data-title="Attachments"]`).should("not.exist"); .should("be.visible");
cy.get(".nc-grid-header").find(`th[data-title="Status"]`).should("be.visible"); cy.get(".nc-grid-header")
cy.get(".nc-grid-header").find(`th[data-title="Film"]`).should("be.visible"); .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.wait(2000);
cy.get(".nc-fields-menu-btn").click() 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")
cy.getActiveMenu(".nc-dropdown-fields-menu").find(`[type="checkbox"]`).eq(1).should('be.checked') .find(`[type="checkbox"]`)
cy.getActiveMenu(".nc-dropdown-fields-menu").find(`[type="checkbox"]`).eq(2).should('not.be.checked') .eq(0)
cy.getActiveMenu(".nc-dropdown-fields-menu").find(`[type="checkbox"]`).eq(3).should('be.checked') .should("be.checked");
cy.getActiveMenu(".nc-dropdown-fields-menu").find(`[type="checkbox"]`).eq(4).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-fields-menu-btn").click();
cy.get(".nc-sort-menu-btn").click(); cy.get(".nc-sort-menu-btn").click();
cy.get(".nc-sort-field-select").eq(0) cy.get(".nc-sort-field-select").eq(0).contains("Name").should("exist");
.contains('Name') cy.get(".nc-sort-dir-select").eq(0).contains("A → Z").should("exist");
.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-sort-menu-btn").click();
cy.get(".nc-filter-menu-btn").click(); cy.get(".nc-filter-menu-btn").click();
cy.get(".nc-filter-field-select").eq(0) cy.get(".nc-filter-field-select").eq(0).contains("Name").should("exist");
.contains('Name') cy.get(".nc-filter-operation-select")
.should("exist"); .eq(0)
cy.get(".nc-filter-operation-select").eq(0) .contains("is like")
.contains('is like')
.should("exist"); .should("exist");
cy.get(".nc-filter-field-select").eq(1) cy.get(".nc-filter-field-select").eq(1).contains("Name").should("exist");
.contains('Name') cy.get(".nc-filter-operation-select")
.should("exist"); .eq(1)
cy.get(".nc-filter-operation-select").eq(1) .contains("is like")
.contains('is like')
.should("exist"); .should("exist");
cy.get(".nc-filter-menu-btn").click(); cy.get(".nc-filter-menu-btn").click();
@ -380,30 +442,31 @@ export const genTest = (apiType, dbType, testMode) => {
}); });
it("Views, bt relation", () => { it("Views, bt relation", () => {
if( testMode === 'CY_QUICK') { if (testMode === "CY_QUICK") {
cy.openTableTab("Producer", 3);
cy.openTableTab("Producer", 3)
cy.get('.nc-grid-view-item').should('have.length', 4) cy.get(".nc-grid-view-item").should("have.length", 4);
cy.get('.nc-form-view-item').should('have.length', 4) cy.get(".nc-form-view-item").should("have.length", 4);
cy.get('.nc-gallery-view-item').should('have.length', 3) cy.get(".nc-gallery-view-item").should("have.length", 3);
// LinkToAnotherRecord hm relation // LinkToAnotherRecord hm relation
mainPage.getCell("FilmRead", 1).scrollIntoView(); mainPage.getCell("FilmRead", 1).scrollIntoView();
cy.get('[data-title="FilmRead"] > .h-full > .nc-virtual-cell > .w-full > .chips > .chip > .name') cy.get(
'[data-title="FilmRead"] > .h-full > .nc-virtual-cell > .w-full > .chips > .chip > .name'
)
// cy.get( // cy.get(
// ':nth-child(1) > [data-col="FilmRead"] > .nc-virtual-cell > .v-lazy > .d-100 > .chips > :nth-child(1) > .v-chip__content > .name' // ':nth-child(1) > [data-col="FilmRead"] > .nc-virtual-cell > .v-lazy > .d-100 > .chips > :nth-child(1) > .v-chip__content > .name'
// ) // )
.contains('Movie-1') .contains("Movie-1")
.should("exist"); .should("exist");
cy.closeTableTab("Producer") cy.closeTableTab("Producer");
} }
}) });
it.skip("Delete Project", () => { it.skip("Delete Project", () => {
if( testMode === 'AT_IMPORT') { if (testMode === "AT_IMPORT") {
mainPage.toolBarTopLeft(mainPage.HOME).click({force:true}) mainPage.toolBarTopLeft(mainPage.HOME).click({ force: true });
cy.get(`.mdi-delete-outline`, { cy.get(`.mdi-delete-outline`, {
timeout: 10000, timeout: 10000,
}) })

464
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();
@ -38,312 +42,408 @@ export const genTest = (apiType, dbType) => {
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")
.should("have.length", 14);
cy.get(".nc-erd-vue-flow")
.find(".nc-erd-edge-circle")
.should("have.length", 11);
cy.get(".nc-erd-vue-flow")
.find(".nc-erd-edge-rect")
.should("have.length", 17);
for (const tableName of sakilaTables) { for (const tableName of sakilaTables) {
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");
} }
// 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")
.should("have.length", 14);
cy.get(".nc-erd-vue-flow")
.find(".nc-erd-edge-circle")
.should("have.length", 11);
cy.get(".nc-erd-vue-flow")
.find(".nc-erd-edge-rect")
.should("have.length", 17);
for (const tableName of sakilaTables) { for (const tableName of sakilaTables) {
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");
} }
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");
cy.get(".nc-erd-showPkAndFk-checkbox-unchecked").should("exist");
const countryColumns = [ const countryColumns = ["city_list"];
'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', () => { 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-vue-flow-single-table").within(() => {
cy.get('.nc-erd-context-menu').get('.nc-erd-showPkAndFk-checkbox').click(); cy.get(".nc-erd-context-menu")
.get(".nc-erd-showPkAndFk-checkbox")
.click();
const countryColumns = [ const countryColumns = ["country", "last_update", "city_list"];
'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();
}); });

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

@ -23,7 +23,7 @@ const nocoTestSuite = (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);

2
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");
}; };

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

@ -27,7 +27,7 @@ const nocoTestSuite = (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);

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

@ -7,7 +7,7 @@ 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,
@ -24,7 +24,7 @@ const nocoTestSuite = (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);

67
scripts/cypress/plugins/index.js

@ -15,7 +15,7 @@ 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}
*/ */
@ -27,25 +27,26 @@ module.exports = (on, 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(
"./scripts/cypress/fixtures/quickTest/noco_0_91_7.db",
"./packages/nocodb/noco.db",
(err) => {
if (err) { if (err) {
console.log(err) console.log(err);
return reject(err) return reject(err);
} }
resolve(null); resolve(null);
}) }
}) );
});
}, },
deleteFolder(folderName) { deleteFolder(folderName) {
console.log("deleting folder %s", folderName); console.log("deleting folder %s", folderName);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
rmdir( rmdir(folderName, { maxRetries: 10, recursive: true }, (err) => {
folderName,
{ maxRetries: 10, recursive: true },
(err) => {
if (err) { if (err) {
console.error(err); console.error(err);
@ -53,8 +54,7 @@ module.exports = (on, config) => {
} }
resolve(null); resolve(null);
} });
);
}); });
}, },
readXlsx: readXlsx.read, readXlsx: readXlsx.read,
@ -79,29 +79,29 @@ module.exports = (on, config) => {
}, },
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
@ -205,7 +205,6 @@ function _pgExec(query) {
}); });
} }
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
@ -219,12 +218,14 @@ function _pgExecTest(query, retryCount = 60) {
client.query(query, (err, res) => { client.query(query, (err, res) => {
if (err) { if (err) {
if (retryCount--) if (retryCount--)
return setTimeout(() => _pgExecTest(query, retryCount).then(resolve).catch(reject), 2000); return setTimeout(
else () => _pgExecTest(query, retryCount).then(resolve).catch(reject),
reject(err); 2000
);
else reject(err);
} }
console.log('==== success ===', res); console.log("==== success ===", res);
resolve(true); resolve(true);
client.end(); client.end();
}); });

59
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

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

@ -97,7 +97,6 @@ export class _projectsPage {
// 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") {
@ -109,11 +108,10 @@ export class _projectsPage {
// kludge: wait for page load to finish // kludge: wait for page load to finish
cy.wait(4000); cy.wait(4000);
// 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);
} }
// Open existing project // Open existing project
// //
openProject(projectName) { openProject(projectName) {
@ -152,12 +150,12 @@ export class _projectsPage {
cy.get(".nc-metadb-project-name").should("exist"); cy.get(".nc-metadb-project-name").should("exist");
cy.contains("button", "Create").should("exist"); cy.contains("button", "Create").should("exist");
cy.wait(1000) cy.wait(1000);
// feed project name // feed project name
cy.get(".nc-metadb-project-name", { timeout: 20000 }).clear().type( cy.get(".nc-metadb-project-name", { timeout: 20000 })
projectName .clear()
); .type(projectName);
// Submit // Submit
cy.contains("button", "Create", { timeout: 20000 }).click(); cy.contains("button", "Create", { timeout: 20000 }).click();
@ -171,27 +169,32 @@ export class _projectsPage {
// dbType == 'external' // dbType == 'external'
else { else {
// Subsequent form, select (+ Create by connection to external database) option // Subsequent form, select (+ Create by connection to external database) option
cy.get(".nc-create-external-db-project", { timeout: 20000 }).last().click({ cy.get(".nc-create-external-db-project", { timeout: 20000 })
.last()
.click({
force: true, force: true,
}); });
// wait for page load by verifying required elements // wait for page load by verifying required elements
cy.get('.nc-extdb-host-database').should('exist'); cy.get(".nc-extdb-host-database").should("exist");
cy.get('.nc-extdb-proj-name').should('exist'); cy.get(".nc-extdb-proj-name").should("exist");
cy.get('.nc-extdb-btn-test-connection').should('exist'); cy.get(".nc-extdb-btn-test-connection").should("exist");
// CY goes too fast at times, so wait for the page to load // CY goes too fast at times, so wait for the page to load
cy.wait(1000); cy.wait(1000);
cy.get('.nc-extdb-proj-name').clear().type(projectName); cy.get(".nc-extdb-proj-name").clear().type(projectName);
if (cred.databaseType === 1) { if (cred.databaseType === 1) {
cy.get('.nc-extdb-db-type').should('exist').click(); cy.get(".nc-extdb-db-type").should("exist").click();
cy.getActiveSelection('.nc-dropdown-ext-db-type').find('.ant-select-item-option').contains("PostgreSQL").click(); cy.getActiveSelection(".nc-dropdown-ext-db-type")
.find(".ant-select-item-option")
.contains("PostgreSQL")
.click();
} }
if (cred.databaseName !== "") { if (cred.databaseName !== "") {
cy.get('.nc-extdb-host-database').clear().type(cred.databaseName); cy.get(".nc-extdb-host-database").clear().type(cred.databaseName);
} }
// Test database connection // Test database connection
@ -200,7 +203,7 @@ export class _projectsPage {
// Create project // Create project
cy.contains("Ok & Save Project", { timeout: 20000 }).click(); cy.contains("Ok & Save Project", { timeout: 20000 }).click();
cy.wait(5000) cy.wait(5000);
// takes a while to load project // takes a while to load project
this.waitHomePageLoad(); this.waitHomePageLoad();
@ -246,12 +249,14 @@ export class _projectsPage {
// //
deleteProject(projectName) { deleteProject(projectName) {
cy.log("Delete project: " + projectName); cy.log("Delete project: " + projectName);
cy.get(".nc-noco-brand-icon").should('exist').click(); cy.get(".nc-noco-brand-icon").should("exist").click();
cy.get(".ant-table-row").contains(`${projectName}`).should("exist") cy.get(".ant-table-row")
.contains(`${projectName}`)
.should("exist")
.then(($obj) => { .then(($obj) => {
cy.log($obj) cy.log($obj);
cy.wrap($obj).parent().parent().find('.ant-table-cell').last().click() cy.wrap($obj).parent().parent().find(".ant-table-cell").last().click();
}) });
// pop-up, submit // pop-up, submit
cy.getActiveModal().find('button:contains("Yes")').click({}); cy.getActiveModal().find('button:contains("Yes")').click({});

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

@ -158,11 +158,28 @@ export function getProjectString() {
} }
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