diff --git a/scripts/cypress/integration/common/00_pre_configurations.js b/scripts/cypress/integration/common/00_pre_configurations.js index a44270d816..1e4ba0ac15 100644 --- a/scripts/cypress/integration/common/00_pre_configurations.js +++ b/scripts/cypress/integration/common/00_pre_configurations.js @@ -164,7 +164,7 @@ export const genTest = (apiType, dbType) => { it("Admin SignUp", () => { cy.task("log", "This will be output to the terminal"); - loginPage.signUp(roles.owner.credentials); + loginPage.signIn(roles.owner.credentials); }); function cy_createProjectBlock(proj, apiType, dbType) { @@ -240,6 +240,7 @@ export const genTest = (apiType, dbType) => { } // close team & auth tab + cy.wait(2000); cy.get("button.ant-tabs-tab-remove").should("exist").click(); cy.get("button.ant-tabs-tab-remove").should("not.exist"); diff --git a/scripts/cypress/support/commands.js b/scripts/cypress/support/commands.js index 646286f6c3..19c2e08fcd 100644 --- a/scripts/cypress/support/commands.js +++ b/scripts/cypress/support/commands.js @@ -480,6 +480,78 @@ Cypress.Commands.add("gotoProjectsPage", () => { cy.get(`.nc-project-page-title:contains("My Projects")`).should("exist"); }); +// View basic routines +// +function capitalizeFirstLetter(string) { + return string.charAt(0).toUpperCase() + string.slice(1); +} + +// viewCreate +// : viewType: grid, gallery, kanban, form +// : creates view with default name +// +Cypress.Commands.add("viewCreate", (viewType) => { + // click on 'Grid/Gallery/Form/Kanban' button on Views bar + cy.get(`.nc-create-${viewType}-view`).click(); + + // Pop up window, click Submit (accepting default name for view) + cy.getActiveModal(".nc-modal-view-create").find(".ant-btn-primary").click(); + cy.toastWait("View created successfully"); + + // validate if view was created && contains default name 'Country1' + cy.get(`.nc-${viewType}-view-item`) + .contains(`${capitalizeFirstLetter(viewType)}-1`) + .should("exist"); +}); + +// viewDelete +// : delete view by index (0-based, exclude default view) +// +Cypress.Commands.add("viewDelete", (viewIndex) => { + // click on delete icon (becomes visible on hovering mouse) + cy.get(".nc-view-delete-icon").eq(viewIndex).click({ force: true }); + cy.wait(300); + + // click on 'Delete' button on confirmation modal + cy.getActiveModal(".nc-modal-view-delete").find(".ant-btn-dangerous").click(); + cy.toastWait("View deleted successfully"); +}); + +// viewDuplicate +// : duplicate view by index (0-based, *include* default view) +// +Cypress.Commands.add("viewCopy", (viewIndex) => { + // click on delete icon (becomes visible on hovering mouse) + cy.get(".nc-view-copy-icon").eq(viewIndex).click({ force: true }); + cy.wait(300); + + // click on 'Delete' button on confirmation modal + cy.getActiveModal(".nc-modal-view-create").find(".ant-btn-primary").click(); + cy.toastWait("View created successfully"); +}); + +// viewRename +// : rename view by index (0-based, exclude default view) +// +Cypress.Commands.add("viewRename", (viewType, viewIndex, newName) => { + // click on edit-icon (becomes visible on hovering mouse) + cy.get(`.nc-${viewType}-view-item`).eq(viewIndex).dblclick(); + + // feed new name + cy.get(`.nc-${viewType}-view-item input`).clear().type(`${newName}{enter}`); + cy.toastWait("View renamed successfully"); + + // validate + cy.get(`.nc-${viewType}-view-item`).contains(`${newName}`).should("exist"); +}); + +// openTableView +// : open view by type & name +// +Cypress.Commands.add("openTableView", (viewType, viewName) => { + cy.get(`.nc-${viewType}-view-item`).contains(`${viewName}`).click(); +}); + // Drag n Drop // refer: https://stackoverflow.com/a/55409853 /* @@ -589,4 +661,4 @@ Cypress.Commands.addAll( dragTo, } ) -*/ \ No newline at end of file +*/