Browse Source

Merge pull request #1027 from nocodb/test/cypress-stability

Test/cypress stability - [kludge] delay induced between successive sqlite triggers during xcdb project meta-sync
pull/1044/head
Raju Udava 3 years ago committed by GitHub
parent
commit
96e756c56b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 327
      scripts/cypress/integration/common/00_pre_configurations.js
  2. 877
      scripts/cypress/support/page_objects/mainPage.js

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

@ -4,35 +4,35 @@
import { loginPage, projectsPage } from "../../support/page_objects/navigation";
import { mainPage } from "../../support/page_objects/mainPage";
import {
staticProjects,
roles,
isTestSuiteActive,
getPrimarySuite,
isSecondarySuite,
getCurrentMode,
isXcdb,
setProjectString,
staticProjects,
roles,
isTestSuiteActive,
getPrimarySuite,
isSecondarySuite,
getCurrentMode,
isXcdb,
setProjectString,
} from "../../support/page_objects/projectConstants";
function prepareSqliteQuery(projId) {
let sqliteQuery = [
`ALTER TABLE "actor" RENAME TO "nc_${projId}__actor"`,
`ALTER TABLE "address" RENAME TO "nc_${projId}__address"`,
`ALTER TABLE "category" RENAME TO "nc_${projId}__category"`,
`ALTER TABLE "city" RENAME TO "nc_${projId}__city"`,
`ALTER TABLE "country" RENAME TO "nc_${projId}__country"`,
`ALTER TABLE "customer" RENAME TO "nc_${projId}__customer"`,
`ALTER TABLE "film" RENAME TO "nc_${projId}__film"`,
`ALTER TABLE "film_actor" RENAME TO "nc_${projId}__film_actor"`,
`ALTER TABLE "film_category" RENAME TO "nc_${projId}__film_category"`,
`ALTER TABLE "film_text" RENAME TO "nc_${projId}__film_text"`,
`ALTER TABLE "inventory" RENAME TO "nc_${projId}__inventory"`,
`ALTER TABLE "language" RENAME TO "nc_${projId}__language"`,
`ALTER TABLE "payment" RENAME TO "nc_${projId}__payment"`,
`ALTER TABLE "rental" RENAME TO "nc_${projId}__rental"`,
`ALTER TABLE "staff" RENAME TO "nc_${projId}__staff"`,
`ALTER TABLE "store" RENAME TO "nc_${projId}__store"`,
`CREATE VIEW nc_${projId}__customer_list
let sqliteQuery = [
`ALTER TABLE "actor" RENAME TO "nc_${projId}__actor"`,
`ALTER TABLE "address" RENAME TO "nc_${projId}__address"`,
`ALTER TABLE "category" RENAME TO "nc_${projId}__category"`,
`ALTER TABLE "city" RENAME TO "nc_${projId}__city"`,
`ALTER TABLE "country" RENAME TO "nc_${projId}__country"`,
`ALTER TABLE "customer" RENAME TO "nc_${projId}__customer"`,
`ALTER TABLE "film" RENAME TO "nc_${projId}__film"`,
`ALTER TABLE "film_actor" RENAME TO "nc_${projId}__film_actor"`,
`ALTER TABLE "film_category" RENAME TO "nc_${projId}__film_category"`,
`ALTER TABLE "film_text" RENAME TO "nc_${projId}__film_text"`,
`ALTER TABLE "inventory" RENAME TO "nc_${projId}__inventory"`,
`ALTER TABLE "language" RENAME TO "nc_${projId}__language"`,
`ALTER TABLE "payment" RENAME TO "nc_${projId}__payment"`,
`ALTER TABLE "rental" RENAME TO "nc_${projId}__rental"`,
`ALTER TABLE "staff" RENAME TO "nc_${projId}__staff"`,
`ALTER TABLE "store" RENAME TO "nc_${projId}__store"`,
`CREATE VIEW nc_${projId}__customer_list
AS
SELECT cu.customer_id AS ID,
cu.first_name||' '||cu.last_name AS name,
@ -45,7 +45,7 @@ function prepareSqliteQuery(projId) {
cu.store_id AS SID
FROM "nc_${projId}__customer" AS cu JOIN "nc_${projId}__address" AS a ON cu.address_id = a.address_id JOIN "nc_${projId}__city" ON a.city_id = "nc_${projId}__city".city_id
JOIN "nc_${projId}__country" ON "nc_${projId}__city".country_id = "nc_${projId}__country".country_id`,
`CREATE VIEW nc_${projId}__film_list
`CREATE VIEW nc_${projId}__film_list
AS
SELECT "nc_${projId}__film".film_id AS FID,
"nc_${projId}__film".title AS title,
@ -58,7 +58,7 @@ function prepareSqliteQuery(projId) {
FROM "nc_${projId}__category" LEFT JOIN "nc_${projId}__film_category" ON "nc_${projId}__category".category_id = "nc_${projId}__film_category".category_id LEFT JOIN "nc_${projId}__film" ON "nc_${projId}__Film_category".film_id = "nc_${projId}__film".film_id
JOIN "nc_${projId}__film_actor" ON "nc_${projId}__film".film_id = "nc_${projId}__film_actor".film_id
JOIN "nc_${projId}__actor" ON "nc_${projId}__film_actor".actor_id = "nc_${projId}__actor".actor_id`,
`CREATE VIEW nc_${projId}__sales_by_film_category
`CREATE VIEW nc_${projId}__sales_by_film_category
AS
SELECT
c.name AS category
@ -70,7 +70,7 @@ function prepareSqliteQuery(projId) {
INNER JOIN "nc_${projId}__film_category" AS fc ON f.film_id = fc.film_id
INNER JOIN "nc_${projId}__category" AS c ON fc.category_id = c.category_id
GROUP BY c.name`,
`CREATE VIEW nc_${projId}__sales_by_store
`CREATE VIEW nc_${projId}__sales_by_store
AS
SELECT
s.store_id
@ -89,7 +89,7 @@ function prepareSqliteQuery(projId) {
s.store_id
, c.city||','||cy.country
, m.first_name||' '||m.last_name`,
`CREATE VIEW nc_${projId}__staff_list
`CREATE VIEW nc_${projId}__staff_list
AS
SELECT s.staff_id AS ID,
s.first_name||' '||s.last_name AS name,
@ -101,8 +101,8 @@ function prepareSqliteQuery(projId) {
s.store_id AS SID
FROM "nc_${projId}__staff" AS s JOIN "nc_${projId}__address" AS a ON s.address_id = a.address_id JOIN "nc_${projId}__city" ON a.city_id = "nc_${projId}__city".city_id
JOIN "nc_${projId}__country" ON "nc_${projId}__city".country_id = "nc_${projId}__country".country_id`,
// below two are dummy entries to ensure view record exists
`CREATE VIEW nc_${projId}__actor_info
// below two are dummy entries to ensure view record exists
`CREATE VIEW nc_${projId}__actor_info
AS
SELECT s.staff_id AS ID,
s.first_name||' '||s.last_name AS name,
@ -114,7 +114,7 @@ function prepareSqliteQuery(projId) {
s.store_id AS SID
FROM "nc_${projId}__staff" AS s JOIN "nc_${projId}__address" AS a ON s.address_id = a.address_id JOIN "nc_${projId}__city" ON a.city_id = "nc_${projId}__city".city_id
JOIN "nc_${projId}__country" ON "nc_${projId}__city".country_id = "nc_${projId}__country".country_id`,
`CREATE VIEW nc_${projId}__nice_but_slower_film_list
`CREATE VIEW nc_${projId}__nice_but_slower_film_list
AS
SELECT s.staff_id AS ID,
s.first_name||' '||s.last_name AS name,
@ -126,155 +126,156 @@ function prepareSqliteQuery(projId) {
s.store_id AS SID
FROM "nc_${projId}__staff" AS s JOIN "nc_${projId}__address" AS a ON s.address_id = a.address_id JOIN "nc_${projId}__city" ON a.city_id = "nc_${projId}__city".city_id
JOIN "nc_${projId}__country" ON "nc_${projId}__city".country_id = "nc_${projId}__country".country_id`,
// `CREATE VIEW nc_${projId}__actor_info
// AS
// SELECT
// a.actor_id AS actor_id,
// a.first_name AS first_name,
// a.last_name AS last_name,
// GROUP_CONCAT(DISTINCT CONCAT(c.name,
// ': ',
// (SELECT
// GROUP_CONCAT(f.title
// ORDER BY f.title ASC
// SEPARATOR ', ')
// FROM
// ((nc_${projId}__film f
// JOIN nc_${projId}__film_category fc ON ((f.film_id = fc.film_id)))
// JOIN nc_${projId}__film_actor fa ON ((f.film_id = fa.film_id)))
// WHERE
// ((fc.category_id = c.category_id)
// AND (fa.actor_id = a.actor_id))))
// ORDER BY c.name ASC
// SEPARATOR '; ') AS nc_${projId}__film_info
// FROM
// (((actor a
// LEFT JOIN nc_${projId}__film_actor fa ON ((a.actor_id = fa.actor_id)))
// LEFT JOIN nc_${projId}__film_category fc ON ((fa.film_id = fc.film_id)))
// LEFT JOIN nc_${projId}__category c ON ((fc.category_id = c.category_id)))
// GROUP BY a.actor_id , a.first_name , a.last_name`,
];
return sqliteQuery;
// `CREATE VIEW nc_${projId}__actor_info
// AS
// SELECT
// a.actor_id AS actor_id,
// a.first_name AS first_name,
// a.last_name AS last_name,
// GROUP_CONCAT(DISTINCT CONCAT(c.name,
// ': ',
// (SELECT
// GROUP_CONCAT(f.title
// ORDER BY f.title ASC
// SEPARATOR ', ')
// FROM
// ((nc_${projId}__film f
// JOIN nc_${projId}__film_category fc ON ((f.film_id = fc.film_id)))
// JOIN nc_${projId}__film_actor fa ON ((f.film_id = fa.film_id)))
// WHERE
// ((fc.category_id = c.category_id)
// AND (fa.actor_id = a.actor_id))))
// ORDER BY c.name ASC
// SEPARATOR '; ') AS nc_${projId}__film_info
// FROM
// (((actor a
// LEFT JOIN nc_${projId}__film_actor fa ON ((a.actor_id = fa.actor_id)))
// LEFT JOIN nc_${projId}__film_category fc ON ((fa.film_id = fc.film_id)))
// LEFT JOIN nc_${projId}__category c ON ((fc.category_id = c.category_id)))
// GROUP BY a.actor_id , a.first_name , a.last_name`,
];
return sqliteQuery;
}
export const genTest = (type, xcdb) => {
if (!isTestSuiteActive(type, xcdb)) return;
describe(`Project pre-configurations`, () => {
it("Admin SignUp", () => {
cy.task("log", "This will be output to the terminal");
cy.waitForSpinners();
cy.signinOrSignup(roles.owner.credentials);
});
if (!isTestSuiteActive(type, xcdb)) return;
describe(`Project pre-configurations`, () => {
it("Admin SignUp", () => {
cy.task("log", "This will be output to the terminal");
cy.waitForSpinners();
cy.signinOrSignup(roles.owner.credentials);
});
const createProject = (proj) => {
it(`Create ${proj.basic.name} project`, () => {
// click home button
cy.get(".nc-noco-brand-icon").click();
const createProject = (proj) => {
it(`Create ${proj.basic.name} project`, () => {
// click home button
cy.get(".nc-noco-brand-icon").click();
cy.get(".nc-container").then((obj) => {
cy.log(obj);
cy.get(".nc-container").then((obj) => {
cy.log(obj);
// if project already created, open
// else, create a new one
if (true == obj[0].innerHTML.includes(proj.basic.name)) {
projectsPage.openProject(proj.basic.name);
} else {
projectsPage.createProject(proj.basic, proj.config);
}
// if project already created, open
// else, create a new one
if (true == obj[0].innerHTML.includes(proj.basic.name)) {
projectsPage.openProject(proj.basic.name);
} else {
projectsPage.createProject(proj.basic, proj.config);
}
if (xcdb) {
// store base URL- to re-visit and delete form view later
let projId;
cy.url()
.then((url) => {
// project prefix code can include "_"
// projId = url.split("_")[1].split("?")[0];
let startIdx = url.indexOf("_");
let endIdx = url.indexOf("?");
projId = url.slice(startIdx + 1, endIdx);
cy.log(url, projId);
setProjectString(projId);
if (xcdb) {
// store base URL- to re-visit and delete form view later
let projId;
cy.url()
.then((url) => {
// project prefix code can include "_"
// projId = url.split("_")[1].split("?")[0];
let startIdx = url.indexOf("_");
let endIdx = url.indexOf("?");
projId = url.slice(startIdx + 1, endIdx);
cy.log(url, projId);
setProjectString(projId);
let query = prepareSqliteQuery(projId);
for (let i = 0; i < query.length; i++) {
cy.task("sqliteExec", query[i]);
}
})
.then(() => {
cy.log(projId);
mainPage.openMetaTab();
mainPage.metaSyncValidate(
`nc_${projId}__actor`,
`New table, New relation added`
);
mainPage.closeMetaTab();
});
}
let query = prepareSqliteQuery(projId);
for (let i = 0; i < query.length; i++) {
cy.task("sqliteExec", query[i]);
cy.wait(1000);
}
})
.then(() => {
cy.log(projId);
mainPage.openMetaTab();
mainPage.metaSyncValidate(
`nc_${projId}__actor`,
`New table, New relation added`
);
mainPage.closeMetaTab();
});
}
// create requested project
// projectsPage.createProject(proj.basic, proj.config)
});
});
};
// create requested project
// projectsPage.createProject(proj.basic, proj.config)
});
});
};
// if (isTestSuiteActive('rest', true)) createProject(staticProjects.sampleREST)
// if (isTestSuiteActive('graphql', true)) createProject(staticProjects.sampleGQL)
// if (isTestSuiteActive('rest', false)) createProject(staticProjects.externalREST)
// if (isTestSuiteActive('graphql', false)) createProject(staticProjects.externalGQL)
// if (isTestSuiteActive('rest', true)) createProject(staticProjects.sampleREST)
// if (isTestSuiteActive('graphql', true)) createProject(staticProjects.sampleGQL)
// if (isTestSuiteActive('rest', false)) createProject(staticProjects.externalREST)
// if (isTestSuiteActive('graphql', false)) createProject(staticProjects.externalGQL)
if ("rest" == type) {
if (true == xcdb) {
createProject(staticProjects.sampleREST);
} else {
createProject(staticProjects.externalREST);
}
} else if ("graphql" == type) {
if (true == xcdb) {
createProject(staticProjects.sampleGQL);
} else {
createProject(staticProjects.externalGQL);
}
}
});
if ("rest" == type) {
if (true == xcdb) {
createProject(staticProjects.sampleREST);
} else {
createProject(staticProjects.externalREST);
}
} else if ("graphql" == type) {
if (true == xcdb) {
createProject(staticProjects.sampleGQL);
} else {
createProject(staticProjects.externalGQL);
}
}
});
// describe('Static user creations (different roles)', () => {
// describe('Static user creations (different roles)', () => {
// beforeEach(() => {
// loginPage.signIn(roles.owner.credentials)
// projectsPage.openProject(getPrimarySuite().basic.name)
// })
// beforeEach(() => {
// loginPage.signIn(roles.owner.credentials)
// projectsPage.openProject(getPrimarySuite().basic.name)
// })
// const addUser = (user) => {
// it(`RoleType: ${user.name}`, () => {
// mainPage.addNewUserToProject(user.credentials, user.name)
// })
// }
// const addUser = (user) => {
// it(`RoleType: ${user.name}`, () => {
// mainPage.addNewUserToProject(user.credentials, user.name)
// })
// }
// addUser(roles.creator)
// addUser(roles.editor)
// addUser(roles.commenter)
// addUser(roles.viewer)
// })
// addUser(roles.creator)
// addUser(roles.editor)
// addUser(roles.commenter)
// addUser(roles.viewer)
// })
// describe('Static users- add to other static projects', () => {
// describe('Static users- add to other static projects', () => {
// const addUserToProject = (proj) => {
// it(`Add users to ${proj.basic.name}`, () => {
// loginPage.signIn(roles.owner.credentials)
// projectsPage.openProject(proj.basic.name)
// const addUserToProject = (proj) => {
// it(`Add users to ${proj.basic.name}`, () => {
// loginPage.signIn(roles.owner.credentials)
// projectsPage.openProject(proj.basic.name)
// mainPage.addExistingUserToProject(roles.creator.credentials.username, roles.creator.name)
// mainPage.addExistingUserToProject(roles.editor.credentials.username, roles.editor.name)
// mainPage.addExistingUserToProject(roles.commenter.credentials.username, roles.commenter.name)
// mainPage.addExistingUserToProject(roles.viewer.credentials.username, roles.viewer.name)
// })
// }
// mainPage.addExistingUserToProject(roles.creator.credentials.username, roles.creator.name)
// mainPage.addExistingUserToProject(roles.editor.credentials.username, roles.editor.name)
// mainPage.addExistingUserToProject(roles.commenter.credentials.username, roles.commenter.name)
// mainPage.addExistingUserToProject(roles.viewer.credentials.username, roles.viewer.name)
// })
// }
// if (isSecondarySuite('rest', true)) addUserToProject(staticProjects.sampleREST)
// if (isSecondarySuite('graphql', true)) addUserToProject(staticProjects.sampleGQL)
// if (isSecondarySuite('rest', false)) addUserToProject(staticProjects.externalREST)
// if (isSecondarySuite('graphql', false)) addUserToProject(staticProjects.externalGQL)
// })
// if (isSecondarySuite('rest', true)) addUserToProject(staticProjects.sampleREST)
// if (isSecondarySuite('graphql', true)) addUserToProject(staticProjects.sampleGQL)
// if (isSecondarySuite('rest', false)) addUserToProject(staticProjects.externalREST)
// if (isSecondarySuite('graphql', false)) addUserToProject(staticProjects.externalGQL)
// })
};
/**

877
scripts/cypress/support/page_objects/mainPage.js

@ -5,445 +5,464 @@ const path = require("path");
* slate before starting.
*/
export const deleteDownloadsFolder = () => {
const downloadsFolder = Cypress.config("downloadsFolder");
const downloadsFolder = Cypress.config("downloadsFolder");
cy.task("deleteFolder", downloadsFolder);
cy.task("deleteFolder", downloadsFolder);
};
// main page
export class _mainPage {
constructor() {
// Top Right items
this.SHARE = 0;
this.THEME_BODY = 1;
this.THEME_HEADER = 2;
this.ALERT = 3;
this.LANGUAGE = 4;
this.USER = 5;
// Top Left items
this.HOME = 0;
this.GIT_HOME = 1;
this.GIT_STAR = 2;
this.GIT_DOCS = 3;
this.AUDIT = 0;
this.APPSTORE = 2;
this.TEAM_N_AUTH = 3;
this.PROJ_METADATA = 4;
this.ROLE_VIEW = 5;
this.ROLE_VIEW_EDITOR = 6;
this.ROLE_VIEW_COMMENTER = 7;
this.ROLE_VIEW_VIEWER = 8;
this.ROLE_VIEW_RESET = 9;
this.roleURL = {};
}
toolBarTopLeft(toolBarItem) {
return cy
.get("header.v-toolbar", { timeout: 20000 })
.eq(0)
.find("a")
.eq(toolBarItem);
}
toolBarTopRight(toolBarItem) {
return cy
.get("header.v-toolbar", { timeout: 20000 })
.eq(0)
.find("button")
.eq(toolBarItem);
}
navigationDraw(item) {
// if (item == this.ROLE_VIEW)
// return cy.get('.nc-nav-drawer').find('.v-list').last()
// else
// return cy.get('.nc-nav-drawer').find('.v-list > .v-list-item').eq(item)
switch (item) {
case this.AUDIT:
return cy.get(".nc-settings-audit");
case this.APPSTORE:
return cy.get(".nc-settings-appstore");
case this.TEAM_N_AUTH:
return cy.get(".nc-settings-teamauth");
case this.PROJ_METADATA:
return cy.get(".nc-settings-projmeta");
case this.ROLE_VIEW_EDITOR:
return cy.get(".nc-preview-editor");
case this.ROLE_VIEW_COMMENTER:
return cy.get(".nc-preview-commenter");
case this.ROLE_VIEW_VIEWER:
return cy.get(".nc-preview-viewer");
case this.ROLE_VIEW_RESET:
return cy.get(".nc-preview-reset");
constructor() {
// Top Right items
this.SHARE = 0;
this.THEME_BODY = 1;
this.THEME_HEADER = 2;
this.ALERT = 3;
this.LANGUAGE = 4;
this.USER = 5;
// Top Left items
this.HOME = 0;
this.GIT_HOME = 1;
this.GIT_STAR = 2;
this.GIT_DOCS = 3;
this.AUDIT = 0;
this.APPSTORE = 2;
this.TEAM_N_AUTH = 3;
this.PROJ_METADATA = 4;
this.ROLE_VIEW = 5;
this.ROLE_VIEW_EDITOR = 6;
this.ROLE_VIEW_COMMENTER = 7;
this.ROLE_VIEW_VIEWER = 8;
this.ROLE_VIEW_RESET = 9;
this.roleURL = {};
}
}
// add new user to specified role
//
addNewUserToProject = (userCred, roleType) => {
let linkText;
// click on New User button, feed details
cy.get('button:contains("New User")').first().click();
cy.get('label:contains("Email")')
.next("input")
.type(userCred.username)
.trigger("input");
cy.get('label:contains("Select User roles")').click();
// opt-in requested role & submit
cy.getActiveMenu().contains(roleType).click();
cy.get(".nc-invite-or-save-btn").click();
cy.toastWait("Successfully updated the user details");
// get URL, invoke
cy.getActiveModal()
.find(".v-alert")
.then(($obj) => {
linkText = $obj.text().trim();
cy.log(linkText);
this.roleURL[roleType] = linkText;
cy.get("body").click("right");
});
};
addExistingUserToProject = (emailId, role) => {
cy.get('.v-list-item:contains("Team & Auth")').click();
cy.get(`tr:contains(${emailId})`)
.find(".mdi-plus", { timeout: 2000 })
.click();
cy.get(`tr:contains(${emailId})`)
.find(".mdi-pencil-outline", { timeout: 2000 })
.click();
cy.get("label:contains(Select User roles)").click();
// opt-in requested role & submit
//
cy.getActiveMenu().contains(role).click();
cy.get(".nc-invite-or-save-btn").click();
cy.toastWait("Successfully updated the user details");
this.roleURL[role] = "http://localhost:3000/#/user/authentication/signin";
};
getCell = (columnHeader, cellNumber) => {
return cy.get(
`tbody > :nth-child(${cellNumber}) > [data-col="${columnHeader}"]`
);
};
getPagination = (pageNumber) => {
if (pageNumber == "<")
return cy.get(".nc-pagination .v-pagination > li:first-child");
if (pageNumber == ">")
return cy.get(".nc-pagination .v-pagination > li:last-child");
return cy.get(
`.nc-pagination .v-pagination > li:contains(${pageNumber}) button`
);
};
getRow = (rowIndex) => {
return cy.get(".xc-row-table").find("tr").eq(rowIndex);
};
addColumn = (colName, tableName) => {
cy.get(".v-window-item--active .nc-grid tr > th:last button").click({
force: true,
});
cy.get(".nc-column-name-input input", { timeout: 3000 })
.clear()
.type(colName);
cy.get(".nc-col-create-or-edit-card").contains("Save").click();
cy.toastWait(`Update table successful`);
};
addColumnWithType = (colName, colType, tableName) => {
cy.get(".v-window-item--active .nc-grid tr > th:last button").click({
force: true,
});
cy.get(".nc-column-name-input input", { timeout: 3000 })
.clear()
.type(colName);
// Column data type: to be set to lookup in this context
cy.get(".nc-ui-dt-dropdown").click();
cy.getActiveMenu().contains(colType).click();
cy.get(".nc-col-create-or-edit-card").contains("Save").click();
cy.toastWait(`Update table successful`);
};
deleteColumn = (colName) => {
cy.get(`th:contains(${colName}) .mdi-menu-down`)
.trigger("mouseover")
.click();
cy.get(".nc-column-delete", { timeout: 5000 }).click();
cy.get("button:contains(Confirm)").click();
};
getAuthToken = () => {
let obj = JSON.parse(localStorage["vuex"]);
return obj["users"]["token"];
};
configureSMTP = (from, host, port, secure) => {
cy.get(".v-card__title.title")
.contains("SMTP")
.parents(".elevatio")
.find("button")
.contains(" Install ")
.click({ force: true });
cy.getActiveModal()
.find('[placeholder="eg: admin@example.com"]')
.click()
.type(from);
cy.getActiveModal()
.find('[placeholder="eg: smtp.example.com"]')
.click()
.type(host);
cy.getActiveModal().find('[placeholder="Port"]').click().type(port);
cy.getActiveModal().find('[placeholder="Secure"]').click().type(secure);
cy.getActiveModal().find("button").contains("Save").click();
cy.toastWait(
"Successfully installed and email notification will use SMTP configuration"
);
};
resetSMTP = () => {
cy.get(".v-card__title.title")
.contains("SMTP")
.parents(".elevatio")
.find("button")
.contains(" Reset ")
.click({ force: true });
cy.getActiveModal().find("button").contains("Submit").click();
cy.toastWait("Plugin uninstalled successfully");
};
shareView = () => {
return cy.get('.nc-btn-share-view');
}
shareViewList = () => {
cy.get('.nc-actions-menu-btn').click();
return cy.getActiveMenu().find('[role="menuitem"]').eq(2);
}
downloadCsv = () => {
cy.get('.nc-actions-menu-btn').click();
return cy.getActiveMenu().find('[role="menuitem"]').eq(0);
}
uploadCsv = () => {
cy.get('.nc-actions-menu-btn').click();
return cy.getActiveMenu().find('[role="menuitem"]').eq(1);
}
automations = () => {
cy.get('.nc-actions-menu-btn').click();
return cy.getActiveMenu().find('[role="menuitem"]').eq(3);
}
hideField = (field) => {
cy.get(".nc-grid-header-cell").contains(field).should("be.visible");
cy.get(".nc-fields-menu-btn").click();
cy.get(
`.menuable__content__active .v-list-item label:contains(${field})`
).click();
cy.get(".nc-fields-menu-btn").click();
cy.get(".nc-grid-header-cell").contains(field).should("not.be.visible");
};
unhideField = (field) => {
cy.get(".nc-grid-header-cell").contains(field).should("not.be.visible");
cy.get(".nc-fields-menu-btn").click();
cy.get(
`.menuable__content__active .v-list-item label:contains(${field})`
).click();
cy.get(".nc-fields-menu-btn").click();
cy.get(".nc-grid-header-cell").contains(field).should("be.visible");
};
sortField = (field, criteria) => {
cy.get(".nc-sort-menu-btn").click();
cy.contains("Add Sort Option").click();
cy.get(".nc-sort-field-select div").first().click();
cy.get(
`.menuable__content__active .v-list-item:contains(${field})`
).click();
cy.get(".nc-sort-dir-select div").first().click();
cy.get(
`.menuable__content__active .v-list-item:contains(${criteria})`
).click();
cy.get(".nc-sort-menu-btn").click();
};
clearSort = () => {
cy.get(".nc-sort-menu-btn").click();
cy.get(".nc-sort-item-remove-btn").click();
cy.get(".nc-sort-menu-btn").click();
};
filterField = (field, operation, value) => {
cy.get(".nc-filter-menu-btn").click();
cy.contains("Add Filter").click();
cy.get(".nc-filter-field-select").last().click();
cy.getActiveMenu().find(`.v-list-item:contains(${field})`).first().click();
cy.get(".nc-filter-operation-select").last().click();
cy.getActiveMenu().find(`.v-list-item:contains(${operation})`).click();
if (operation != "is null" && operation != "is not null") {
cy.get(".nc-filter-value-select input:text").last().type(`${value}`);
cy.get(".nc-filter-operation-select").last().click();
toolBarTopLeft(toolBarItem) {
return cy
.get("header.v-toolbar", { timeout: 20000 })
.eq(0)
.find("a")
.eq(toolBarItem);
}
toolBarTopRight(toolBarItem) {
return cy
.get("header.v-toolbar", { timeout: 20000 })
.eq(0)
.find("button")
.eq(toolBarItem);
}
cy.get(".nc-filter-field-select")
.find(".v-select__slot")
.contains(field)
.should("exist");
cy.get(".nc-filter-operation-select")
.find(".v-select__slot")
.contains(operation)
.should("exist");
cy.get(".nc-filter-menu-btn").click();
};
filterReset = () => {
cy.get(".nc-filter-menu-btn").click();
cy.get(".nc-filter-item-remove-btn").click();
cy.get(".nc-filter-menu-btn").click();
};
// delete created views
//
deleteCreatedViews = () => {
// cy.get(".v-navigation-drawer__content > .container")
// .find(".v-list > .v-list-item")
// .contains("Share View")
// .parent()
// .find("button.mdi-dots-vertical")
// .click();
// cy.getActiveMenu().find(".v-list-item").contains("Views List").click();
this.shareViewList().click();
cy.wait(1000);
// cy.get('.container').find('button.mdi-delete-outline')
cy.get('th:contains("View Link")')
.should("exist")
.parent()
.parent()
.next()
.find("tr")
.each(($tableRow) => {
cy.log($tableRow[0].childElementCount);
// one of the row would contain seggregation header ('other views)
if (4 == $tableRow[0].childElementCount) {
cy.wrap($tableRow).find("button").last().click();
cy.wait(1000);
navigationDraw(item) {
// if (item == this.ROLE_VIEW)
// return cy.get('.nc-nav-drawer').find('.v-list').last()
// else
// return cy.get('.nc-nav-drawer').find('.v-list > .v-list-item').eq(item)
switch (item) {
case this.AUDIT:
return cy.get(".nc-settings-audit");
case this.APPSTORE:
return cy.get(".nc-settings-appstore");
case this.TEAM_N_AUTH:
return cy.get(".nc-settings-teamauth");
case this.PROJ_METADATA:
return cy.get(".nc-settings-projmeta");
case this.ROLE_VIEW_EDITOR:
return cy.get(".nc-preview-editor");
case this.ROLE_VIEW_COMMENTER:
return cy.get(".nc-preview-commenter");
case this.ROLE_VIEW_VIEWER:
return cy.get(".nc-preview-viewer");
case this.ROLE_VIEW_RESET:
return cy.get(".nc-preview-reset");
}
})
.then(() => {
cy.toastWait("Deleted shared view successfully");
// close modal
cy.get('.v-overlay--active > .v-overlay__scrim').click({force: true});
});
};
// download CSV & verify
// download folder is configurable in cypress.
// trigger download
// wait for a while & check in configured download folder for the intended file
// if it exists, verify it against 'expectedRecords' passed in as parameter
//
downloadAndVerifyCsv = (filename, verifyCsv) => {
cy.get(".nc-actions-menu-btn").click();
cy.get(
`.menuable__content__active .v-list-item span:contains("Download as CSV")`
).click();
cy.toastWait("Successfully exported all table data").then(() => {
// download folder path, read from config file
const downloadsFolder = Cypress.config("downloadsFolder");
let filePath = path.join(downloadsFolder, filename);
// append download folder path with filename to generate full file path, retrieve file
cy.readFile(filePath).then((fileData) => {
// from CSV, split into records (rows)
const rows = fileData.replace(/\r\n/g, "\n").split("\n");
verifyCsv(rows);
deleteDownloadsFolder();
});
});
};
getIFrameCell = (columnHeader, cellNumber) => {
return cy
.iframe()
.find(`tbody > :nth-child(${cellNumber}) > [data-col="${columnHeader}"]`);
};
// https://docs.cypress.io/guides/core-concepts/variables-and-aliases#Sharing-Context
getDatatype = (tableName, columnName) => {
cy.window().then((win) => {
const col = win.$nuxt.$store.state.meta.metas[tableName].columns;
let dataType = "";
col.forEach((element) => {
if (element.cn == columnName) dataType = element.uidt;
});
cy.wrap(dataType).as("ncDatatype");
});
};
openMetaTab() {
// open Project metadata tab
}
// add new user to specified role
//
this.navigationDraw(this.PROJ_METADATA).click();
cy.get(".nc-meta-mgmt-metadata-tab").should("exist").click({ force: true });
// kludge, at times test failed to open tab on click
cy.get(".nc-meta-mgmt-metadata-tab").should("exist").click({ force: true });
}
closeMetaTab() {
// user href link to find meta mgmt tab
cy.get('[href="#disableOrEnableModel||||Meta Management"]')
.find("button.mdi-close")
.click({ force: true });
// refresh
cy.refreshTableTab();
}
metaSyncValidate(tbl, msg) {
cy.get(".nc-btn-metasync-reload").should("exist").click({ force: true });
cy.get(`.nc-metasync-row-${tbl}`).contains(msg).should("exist");
cy.get(".nc-btn-metasync-sync-now").should("exist").click({ force: true });
cy.get(".nc-metasync-row").then((row) => {
for (let i = 0; i < row.length; i++) {
cy.wrap(row).contains("No change identified").should("exist");
}
});
// cy.get(`.nc-metasync-row-${tbl}`).contains(msg).should("not.exist");
// cy.get(`.nc-metasync-row-${tbl}`)
// .contains("No change identified")
// .should("exist");
cy.toastWait(`Table metadata recreated successfully`);
// cy.get(`.nc-metasync-row-${tbl}`).should("exist");
}
addNewUserToProject = (userCred, roleType) => {
let linkText;
// click on New User button, feed details
cy.get('button:contains("New User")').first().click();
cy.get('label:contains("Email")')
.next("input")
.type(userCred.username)
.trigger("input");
cy.get('label:contains("Select User roles")').click();
// opt-in requested role & submit
cy.getActiveMenu().contains(roleType).click();
cy.get(".nc-invite-or-save-btn").click();
cy.toastWait("Successfully updated the user details");
// get URL, invoke
cy.getActiveModal()
.find(".v-alert")
.then(($obj) => {
linkText = $obj.text().trim();
cy.log(linkText);
this.roleURL[roleType] = linkText;
cy.get("body").click("right");
});
};
addExistingUserToProject = (emailId, role) => {
cy.get('.v-list-item:contains("Team & Auth")').click();
cy.get(`tr:contains(${emailId})`)
.find(".mdi-plus", { timeout: 2000 })
.click();
cy.get(`tr:contains(${emailId})`)
.find(".mdi-pencil-outline", { timeout: 2000 })
.click();
cy.get("label:contains(Select User roles)").click();
// opt-in requested role & submit
//
cy.getActiveMenu().contains(role).click();
cy.get(".nc-invite-or-save-btn").click();
cy.toastWait("Successfully updated the user details");
this.roleURL[role] =
"http://localhost:3000/#/user/authentication/signin";
};
getCell = (columnHeader, cellNumber) => {
return cy.get(
`tbody > :nth-child(${cellNumber}) > [data-col="${columnHeader}"]`
);
};
getPagination = (pageNumber) => {
if (pageNumber == "<")
return cy.get(".nc-pagination .v-pagination > li:first-child");
if (pageNumber == ">")
return cy.get(".nc-pagination .v-pagination > li:last-child");
return cy.get(
`.nc-pagination .v-pagination > li:contains(${pageNumber}) button`
);
};
getRow = (rowIndex) => {
return cy.get(".xc-row-table").find("tr").eq(rowIndex);
};
addColumn = (colName, tableName) => {
cy.get(".v-window-item--active .nc-grid tr > th:last button").click({
force: true,
});
cy.get(".nc-column-name-input input", { timeout: 3000 })
.clear()
.type(colName);
cy.get(".nc-col-create-or-edit-card").contains("Save").click();
cy.toastWait(`Update table successful`);
};
addColumnWithType = (colName, colType, tableName) => {
cy.get(".v-window-item--active .nc-grid tr > th:last button").click({
force: true,
});
cy.get(".nc-column-name-input input", { timeout: 3000 })
.clear()
.type(colName);
// Column data type: to be set to lookup in this context
cy.get(".nc-ui-dt-dropdown").click();
cy.getActiveMenu().contains(colType).click();
cy.get(".nc-col-create-or-edit-card").contains("Save").click();
cy.toastWait(`Update table successful`);
};
deleteColumn = (colName) => {
cy.get(`th:contains(${colName}) .mdi-menu-down`)
.trigger("mouseover")
.click();
cy.get(".nc-column-delete", { timeout: 5000 }).click();
cy.get("button:contains(Confirm)").click();
};
getAuthToken = () => {
let obj = JSON.parse(localStorage["vuex"]);
return obj["users"]["token"];
};
configureSMTP = (from, host, port, secure) => {
cy.get(".v-card__title.title")
.contains("SMTP")
.parents(".elevatio")
.find("button")
.contains(" Install ")
.click({ force: true });
cy.getActiveModal()
.find('[placeholder="eg: admin@example.com"]')
.click()
.type(from);
cy.getActiveModal()
.find('[placeholder="eg: smtp.example.com"]')
.click()
.type(host);
cy.getActiveModal().find('[placeholder="Port"]').click().type(port);
cy.getActiveModal().find('[placeholder="Secure"]').click().type(secure);
cy.getActiveModal().find("button").contains("Save").click();
cy.toastWait(
"Successfully installed and email notification will use SMTP configuration"
);
};
resetSMTP = () => {
cy.get(".v-card__title.title")
.contains("SMTP")
.parents(".elevatio")
.find("button")
.contains(" Reset ")
.click({ force: true });
cy.getActiveModal().find("button").contains("Submit").click();
cy.toastWait("Plugin uninstalled successfully");
};
shareView = () => {
return cy.get(".nc-btn-share-view");
};
shareViewList = () => {
cy.get(".nc-actions-menu-btn").click();
return cy.getActiveMenu().find('[role="menuitem"]').eq(2);
};
downloadCsv = () => {
cy.get(".nc-actions-menu-btn").click();
return cy.getActiveMenu().find('[role="menuitem"]').eq(0);
};
uploadCsv = () => {
cy.get(".nc-actions-menu-btn").click();
return cy.getActiveMenu().find('[role="menuitem"]').eq(1);
};
automations = () => {
cy.get(".nc-actions-menu-btn").click();
return cy.getActiveMenu().find('[role="menuitem"]').eq(3);
};
hideField = (field) => {
cy.get(".nc-grid-header-cell").contains(field).should("be.visible");
cy.get(".nc-fields-menu-btn").click();
cy.get(
`.menuable__content__active .v-list-item label:contains(${field})`
).click();
cy.get(".nc-fields-menu-btn").click();
cy.get(".nc-grid-header-cell").contains(field).should("not.be.visible");
};
unhideField = (field) => {
cy.get(".nc-grid-header-cell").contains(field).should("not.be.visible");
cy.get(".nc-fields-menu-btn").click();
cy.get(
`.menuable__content__active .v-list-item label:contains(${field})`
).click();
cy.get(".nc-fields-menu-btn").click();
cy.get(".nc-grid-header-cell").contains(field).should("be.visible");
};
sortField = (field, criteria) => {
cy.get(".nc-sort-menu-btn").click();
cy.contains("Add Sort Option").click();
cy.get(".nc-sort-field-select div").first().click();
cy.get(
`.menuable__content__active .v-list-item:contains(${field})`
).click();
cy.get(".nc-sort-dir-select div").first().click();
cy.get(
`.menuable__content__active .v-list-item:contains(${criteria})`
).click();
cy.get(".nc-sort-menu-btn").click();
};
clearSort = () => {
cy.get(".nc-sort-menu-btn").click();
cy.get(".nc-sort-item-remove-btn").click();
cy.get(".nc-sort-menu-btn").click();
};
filterField = (field, operation, value) => {
cy.get(".nc-filter-menu-btn").click();
cy.contains("Add Filter").click();
cy.get(".nc-filter-field-select").last().click();
cy.getActiveMenu()
.find(`.v-list-item:contains(${field})`)
.first()
.click();
cy.get(".nc-filter-operation-select").last().click();
cy.getActiveMenu().find(`.v-list-item:contains(${operation})`).click();
if (operation != "is null" && operation != "is not null") {
cy.get(".nc-filter-value-select input:text")
.last()
.type(`${value}`);
cy.get(".nc-filter-operation-select").last().click();
}
cy.get(".nc-filter-field-select")
.find(".v-select__slot")
.contains(field)
.should("exist");
cy.get(".nc-filter-operation-select")
.find(".v-select__slot")
.contains(operation)
.should("exist");
cy.get(".nc-filter-menu-btn").click();
};
filterReset = () => {
cy.get(".nc-filter-menu-btn").click();
cy.get(".nc-filter-item-remove-btn").click();
cy.get(".nc-filter-menu-btn").click();
};
// delete created views
//
deleteCreatedViews = () => {
// cy.get(".v-navigation-drawer__content > .container")
// .find(".v-list > .v-list-item")
// .contains("Share View")
// .parent()
// .find("button.mdi-dots-vertical")
// .click();
// cy.getActiveMenu().find(".v-list-item").contains("Views List").click();
this.shareViewList().click();
cy.wait(1000);
// cy.get('.container').find('button.mdi-delete-outline')
cy.get('th:contains("View Link")')
.should("exist")
.parent()
.parent()
.next()
.find("tr")
.each(($tableRow) => {
cy.log($tableRow[0].childElementCount);
// one of the row would contain seggregation header ('other views)
if (4 == $tableRow[0].childElementCount) {
cy.wrap($tableRow).find("button").last().click();
cy.wait(1000);
}
})
.then(() => {
cy.toastWait("Deleted shared view successfully");
// close modal
cy.get(".v-overlay--active > .v-overlay__scrim").click({
force: true,
});
});
};
// download CSV & verify
// download folder is configurable in cypress.
// trigger download
// wait for a while & check in configured download folder for the intended file
// if it exists, verify it against 'expectedRecords' passed in as parameter
//
downloadAndVerifyCsv = (filename, verifyCsv) => {
cy.get(".nc-actions-menu-btn").click();
cy.get(
`.menuable__content__active .v-list-item span:contains("Download as CSV")`
).click();
cy.toastWait("Successfully exported all table data").then(() => {
// download folder path, read from config file
const downloadsFolder = Cypress.config("downloadsFolder");
let filePath = path.join(downloadsFolder, filename);
// append download folder path with filename to generate full file path, retrieve file
cy.readFile(filePath).then((fileData) => {
// from CSV, split into records (rows)
const rows = fileData.replace(/\r\n/g, "\n").split("\n");
verifyCsv(rows);
deleteDownloadsFolder();
});
});
};
getIFrameCell = (columnHeader, cellNumber) => {
return cy
.iframe()
.find(
`tbody > :nth-child(${cellNumber}) > [data-col="${columnHeader}"]`
);
};
// https://docs.cypress.io/guides/core-concepts/variables-and-aliases#Sharing-Context
getDatatype = (tableName, columnName) => {
cy.window().then((win) => {
const col = win.$nuxt.$store.state.meta.metas[tableName].columns;
let dataType = "";
col.forEach((element) => {
if (element.cn == columnName) dataType = element.uidt;
});
cy.wrap(dataType).as("ncDatatype");
});
};
openMetaTab() {
// open Project metadata tab
//
this.navigationDraw(this.PROJ_METADATA).click();
cy.get(".nc-meta-mgmt-metadata-tab")
.should("exist")
.click({ force: true });
// kludge, at times test failed to open tab on click
cy.get(".nc-meta-mgmt-metadata-tab")
.should("exist")
.click({ force: true });
}
closeMetaTab() {
// user href link to find meta mgmt tab
cy.get('[href="#disableOrEnableModel||||Meta Management"]')
.find("button.mdi-close")
.click({ force: true });
// refresh
cy.refreshTableTab();
}
metaSyncValidate(tbl, msg) {
cy.get(".nc-btn-metasync-reload")
.should("exist")
.click({ force: true });
cy.get(`.nc-metasync-row-${tbl}`).contains(msg).should("exist");
cy.get(".nc-btn-metasync-sync-now")
.should("exist")
.click({ force: true })
.then(() => {
cy.toastWait(`Table metadata recreated successfully`);
});
cy.get(".nc-metasync-row").then((row) => {
for (let i = 0; i < row.length; i++) {
cy.wrap(row).contains("No change identified").should("exist");
}
});
// cy.get(`.nc-metasync-row-${tbl}`).contains(msg).should("not.exist");
// cy.get(`.nc-metasync-row-${tbl}`)
// .contains("No change identified")
// .should("exist");
// cy.toastWait(`Table metadata recreated successfully`);
// cy.get(`.nc-metasync-row-${tbl}`).should("exist");
}
}
export const mainPage = new _mainPage();

Loading…
Cancel
Save