Browse Source

test: use class names for menu & selection in filter & sort test

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
pull/3712/head
Raju Udava 2 years ago
parent
commit
ba4808da1d
  1. 315
      scripts/cypress/support/page_objects/mainPage.js

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

@ -32,28 +32,30 @@ export class _settingsPage {
// open settings tab
// cy.get('.nc-team-settings').should('exist').click()
// cy.get(`[data-menu-id=${menuId}]`).should('exist').click()
cy.get('.nc-project-menu').should('exist').click()
cy.getActiveMenu(".nc-dropdown-project-menu").find(`[data-menu-id="teamAndSettings"]`).should('exist').click()
cy.get(`[data-menu-id=${menuId}]`).should('exist').click()
cy.get(".nc-project-menu").should("exist").click();
cy.getActiveMenu(".nc-dropdown-project-menu")
.find(`[data-menu-id="teamAndSettings"]`)
.should("exist")
.click();
cy.get(`[data-menu-id=${menuId}]`).should("exist").click();
}
openTab(tabId) {
cy.get(`[data-menu-id=${tabId}]`).should('exist').last().click()
cy.get(`[data-menu-id=${tabId}]`).should("exist").last().click();
}
closeMenu() {
cy.getActiveModal().find('.nc-modal-close').click({ force: true });
cy.getActiveModal().find(".nc-modal-close").click({ force: true });
}
openProjectMenu() {
cy.get('.nc-project-menu').should('exist').click()
cy.get(".nc-project-menu").should("exist").click();
}
}
// main page
export class _mainPage {
constructor() {
// Top Left items
this.HOME = 0;
@ -88,8 +90,11 @@ export class _mainPage {
navigationDraw(item) {
// open settings tab
cy.get('.nc-project-menu').should('exist').click()
cy.getActiveMenu(".nc-dropdown-project-menu").find(`[data-menu-id="teamAndSettings"]`).should('exist').click()
cy.get(".nc-project-menu").should("exist").click();
cy.getActiveMenu(".nc-dropdown-project-menu")
.find(`[data-menu-id="teamAndSettings"]`)
.should("exist")
.click();
switch (item) {
case this.AUDIT:
@ -107,20 +112,27 @@ export class _mainPage {
//
addNewUserToProject = (userCred, roleType) => {
let linkText;
let roleIndex = ["creator", "editor", "commenter", "viewer"].indexOf(roleType)
let roleIndex = ["creator", "editor", "commenter", "viewer"].indexOf(
roleType
);
// click on New User button, feed details
cy.get('button.nc-invite-team').click();
cy.get("button.nc-invite-team").click();
cy.get('input[placeholder="E-mail"]')
.type(userCred.username)
cy.get('input[placeholder="E-mail"]').type(userCred.username);
cy.get('.ant-select.nc-user-roles').click();
cy.get(".ant-select.nc-user-roles").click();
// opt-in requested role & submit
// cy.getActiveSelection().contains(roleType).click({force: true});
cy.getActiveSelection('.nc-dropdown-user-role').find('.nc-role-option').eq(roleIndex).should('exist').click()
cy.getActiveModal(".nc-modal-invite-user-and-share-base").find("button.ant-btn-primary").click();
cy.getActiveSelection(".nc-dropdown-user-role")
.find(".nc-role-option")
.eq(roleIndex)
.should("exist")
.click();
cy.getActiveModal(".nc-modal-invite-user-and-share-base")
.find("button.ant-btn-primary")
.click();
cy.toastWait("Successfully updated the user details");
@ -158,9 +170,9 @@ export class _mainPage {
// };
getCell = (columnHeader, cellNumber) => {
return cy.get(
`:nth-child(${cellNumber}) > [data-title="${columnHeader}"]`
).last();
return cy
.get(`:nth-child(${cellNumber}) > [data-title="${columnHeader}"]`)
.last();
};
getPagination = (pageNumber) => {
@ -184,12 +196,15 @@ export class _mainPage {
});
cy.getActiveMenu(".nc-dropdown-grid-add-column")
.find('input.nc-column-name-input')
.should('exist')
.find("input.nc-column-name-input")
.should("exist")
.clear()
.type(colName);
cy.getActiveMenu(".nc-dropdown-grid-add-column")
.find(".ant-btn-primary").contains("Save").should('exist').click();
.find(".ant-btn-primary")
.contains("Save")
.should("exist")
.click();
cy.toastWait(`Column created`);
cy.get(`th[data-title="${colName}"]`).should("exist");
};
@ -200,20 +215,23 @@ export class _mainPage {
});
cy.getActiveMenu(".nc-dropdown-grid-add-column")
.find('input.nc-column-name-input')
.should('exist')
.find("input.nc-column-name-input")
.should("exist")
.clear()
.type(colName);
// change column type and verify
// cy.get(".nc-column-type-input").last().click();
cy.getActiveMenu('.nc-dropdown-grid-add-column')
cy.getActiveMenu(".nc-dropdown-grid-add-column")
.find(".nc-column-type-input")
.last()
.click()
cy.getActiveSelection('.nc-dropdown-column-type').find('.ant-select-item-option').contains(colType).click();
.click();
cy.getActiveSelection(".nc-dropdown-column-type")
.find(".ant-select-item-option")
.contains(colType)
.click();
// cy.get(".ant-btn-primary:visible").contains("Save").click();
cy.getActiveMenu('.nc-dropdown-grid-add-column')
cy.getActiveMenu(".nc-dropdown-grid-add-column")
.find(".ant-btn-primary:visible")
.contains("Save")
.click();
@ -229,13 +247,13 @@ export class _mainPage {
.trigger("mouseover", { force: true })
.click({ force: true });
cy.wait(500)
cy.wait(500);
cy.get(".nc-column-delete").click();
cy.wait(500)
cy.wait(500);
cy.get(".nc-column-delete").should("not.be.visible");
cy.get(".ant-btn-dangerous:visible").contains("Delete").click();
cy.wait(500)
cy.wait(500);
cy.get(`th:contains(${colName})`).should("not.exist");
};
@ -246,28 +264,48 @@ export class _mainPage {
};
configureSMTP = (from, host, port, secure) => {
cy.getActiveModal().find('.nc-app-store-card-SMTP').click().then((obj) => {
cy.wrap(obj).find('.nc-app-store-card-install').click({ force: true });
})
cy.getActiveModal()
.find(".nc-app-store-card-SMTP")
.click()
.then((obj) => {
cy.wrap(obj).find(".nc-app-store-card-install").click({ force: true });
});
cy.getActiveModal().find('#form_item_from').should('exist').clear().type(from)
cy.getActiveModal().find('#form_item_host').should('exist').clear().type(host)
cy.getActiveModal().find('#form_item_port').should('exist').clear().type(port)
cy.getActiveModal()
.find("#form_item_from")
.should("exist")
.clear()
.type(from);
cy.getActiveModal()
.find("#form_item_host")
.should("exist")
.clear()
.type(host);
cy.getActiveModal()
.find("#form_item_port")
.should("exist")
.clear()
.type(port);
// cy.getActiveModal().find('#form_item_secure').should('exist').clear().type(secure)
cy.getActiveModal().find("button").contains("Save").click();
cy.toastWait('Successfully installed and email notification will use SMTP configuration');
settingsPage.closeMenu()
cy.toastWait(
"Successfully installed and email notification will use SMTP configuration"
);
settingsPage.closeMenu();
};
resetSMTP = () => {
cy.getActiveModal().find('.nc-app-store-card-SMTP').click().then((obj) => {
cy.wrap(obj).find('.nc-app-store-card-reset').click({ force: true });
})
cy.getActiveModal()
.find(".nc-app-store-card-SMTP")
.click()
.then((obj) => {
cy.wrap(obj).find(".nc-app-store-card-reset").click({ force: true });
});
cy.getActiveModal().find("button").contains("Confirm").click();
cy.toastWait("Plugin uninstalled successfully");
settingsPage.closeMenu()
settingsPage.closeMenu();
};
shareView = () => {
@ -275,115 +313,144 @@ export class _mainPage {
};
shareViewList = () => {
cy.get(".nc-actions-menu-btn").should('exist').click();
return cy.getActiveMenu(".nc-dropdown-actions-menu").find('.ant-dropdown-menu-item').contains('Shared View List');
cy.get(".nc-actions-menu-btn").should("exist").click();
return cy
.getActiveMenu(".nc-dropdown-actions-menu")
.find(".ant-dropdown-menu-item")
.contains("Shared View List");
};
downloadCsv = () => {
cy.get(".nc-actions-menu-btn").should('exist').click();
return cy.getActiveMenu(".nc-dropdown-actions-menu").find('.ant-dropdown-menu-item').contains('Download as CSV');
cy.get(".nc-actions-menu-btn").should("exist").click();
return cy
.getActiveMenu(".nc-dropdown-actions-menu")
.find(".ant-dropdown-menu-item")
.contains("Download as CSV");
};
downloadExcel = () => {
cy.get(".nc-actions-menu-btn").should('exist').click();
return cy.getActiveMenu(".nc-dropdown-actions-menu").find('.ant-dropdown-menu-item').contains('Download as XLSX');
cy.get(".nc-actions-menu-btn").should("exist").click();
return cy
.getActiveMenu(".nc-dropdown-actions-menu")
.find(".ant-dropdown-menu-item")
.contains("Download as XLSX");
};
uploadCsv = () => {
cy.get(".nc-actions-menu-btn").should('exist').click();
return cy.getActiveMenu(".nc-dropdown-actions-menu").find('.ant-dropdown-menu-item').contains('Upload CSV');
cy.get(".nc-actions-menu-btn").should("exist").click();
return cy
.getActiveMenu(".nc-dropdown-actions-menu")
.find(".ant-dropdown-menu-item")
.contains("Upload CSV");
};
automations = () => {
cy.get(".nc-actions-menu-btn").should('exist').click();
return cy.getActiveMenu(".nc-dropdown-actions-menu").find('.ant-dropdown-menu-item').contains('Webhooks');
cy.get(".nc-actions-menu-btn").should("exist").click();
return cy
.getActiveMenu(".nc-dropdown-actions-menu")
.find(".ant-dropdown-menu-item")
.contains("Webhooks");
};
hideField = (field) => {
cy.get(`th[data-title="${field}"]`).should("be.visible");
cy.get(".nc-fields-menu-btn").click();
cy.wait(500)
cy.getActiveMenu(".nc-dropdown-fields-menu").find(`.nc-fields-list label:contains(${field}):visible`).click();
cy.wait(500)
cy.getActiveMenu(".nc-dropdown-fields-menu")
.find(`.nc-fields-list label:contains(${field}):visible`)
.click();
cy.get(".nc-fields-menu-btn").click();
cy.wait(500)
cy.get(`th[data-title="${field}"]`).should("not.exist");
};
unhideField = (field) => {
cy.get(`th[data-title="${field}"]`).should("not.exist");
cy.get(".nc-fields-menu-btn").click();
cy.wait(500)
cy.getActiveMenu(".nc-dropdown-fields-menu").find(`.nc-fields-list label:contains(${field}):visible`).click();
cy.wait(500)
cy.getActiveMenu(".nc-dropdown-fields-menu")
.find(`.nc-fields-list label:contains(${field}):visible`)
.click();
cy.get(".nc-fields-menu-btn").click();
cy.wait(500)
cy.get(`th[data-title="${field}"]`).should("be.visible");
};
sortField = (field, criteria) => {
cy.get(".nc-sort-menu-btn").click();
cy.wait(500)
cy.getActiveMenu('.nc-dropdown-sort-menu').contains("Add Sort Option").click();
cy.wait(500)
// cy.get(".nc-sort-field-select div").first().click().type(field);
cy.get(".nc-sort-field-select div").first().click();
cy.wait(500)
cy.get('.ant-select-dropdown:visible').find(`.ant-select-item`).contains(new RegExp("^" + field + "$", "g")).should('exist').click();
cy.wait(500)
cy.get(".nc-sort-dir-select div").first().click();
cy.wait(500)
cy.get('.sort-dir-dropdown.ant-select-dropdown:visible').find(`.ant-select-item`).contains(criteria).should('exist').click();
cy.wait(500)
cy.getActiveMenu(".nc-dropdown-sort-menu")
.find(".ant-btn-primary")
.contains("Add Sort Option")
.click();
cy.getActiveMenu(".nc-dropdown-sort-menu")
.find(".nc-sort-field-select div")
.first()
.click();
cy.getActiveSelection(".nc-dropdown-toolbar-field-list")
.find(`.ant-select-item`)
.contains(new RegExp("^" + field + "$", "g"))
.should("exist")
.click();
cy.getActiveMenu(".nc-dropdown-sort-menu")
.find(".nc-sort-dir-select div")
.first()
.click();
cy.getActiveSelection(".nc-dropdown-sort-dir")
.find(`.ant-select-item`)
.contains(criteria)
.should("exist")
.click();
cy.get(".nc-sort-menu-btn").click();
cy.wait(500)
};
clearSort = () => {
cy.get(".nc-sort-menu-btn").click();
cy.wait(500)
cy.get(".nc-sort-item-remove-btn").click();
cy.wait(500)
cy.get(".nc-sort-item-remove-btn:visible").should("not.exist");
cy.getActiveMenu(".nc-dropdown-sort-menu")
.find(".nc-sort-item-remove-btn")
.click();
cy.getActiveMenu(".nc-dropdown-sort-menu")
.find(".nc-sort-item-remove-btn:visible")
.should("not.exist");
cy.get(".nc-sort-menu-btn").click();
cy.wait(500)
};
filterField = (field, operation, value) => {
cy.get(".nc-filter-menu-btn").click();
cy.wait(500)
cy.contains("Add Filter").click();
cy.wait(500)
// cy.get(".nc-filter-field-select").should("exist").last().click().type(field);
cy.get(".nc-filter-field-select").should("exist").last().click();
cy.wait(500)
cy.get('.ant-select-dropdown:visible').should('exist').find(`.ant-select-item`).contains(new RegExp("^" + field + "$", "g")).should('exist').click();
cy.wait(500)
cy.get(".nc-filter-operation-select").should("exist").last().click();
cy.wait(500)
cy.get('.ant-select-dropdown:visible').should('exist').find(`.ant-select-item`).contains(operation).should('exist').click();
cy.wait(500)
if (operation != "is null" && operation != "is not null") {
cy.get(".nc-filter-value-select")
cy.getActiveMenu(".nc-dropdown-filter-menu")
.find(".ant-btn-primary")
.contains("Add Filter")
.click();
cy.getActiveMenu(".nc-dropdown-filter-menu")
.find(".nc-filter-field-select")
.should("exist")
.last()
.type(value);
cy.get(".nc-filter-operation-select").last().click();
cy.wait(500)
.click();
cy.getActiveSelection(".nc-dropdown-toolbar-field-list")
.find(`.ant-select-item`)
.contains(new RegExp("^" + field + "$", "g"))
.should("exist")
.click();
cy.getActiveMenu(".nc-dropdown-filter-menu")
.find(".nc-filter-operation-select")
.should("exist")
.last()
.click();
cy.getActiveSelection(".nc-dropdown-filter-comp-op")
.find(`.ant-select-item`)
.contains(operation)
.should("exist")
.click();
if (operation != "is null" && operation != "is not null") {
cy.get(".nc-filter-value-select").should("exist").last().type(value);
}
cy.get(".nc-filter-menu-btn").click();
cy.wait(500)
};
filterReset = () => {
cy.get(".nc-filter-menu-btn").click();
cy.wait(500)
cy.get(".nc-filter-item-remove-btn").click();
cy.wait(500)
cy.get(".nc-filter-item-remove-btn").should("not.exist");
cy.getActiveMenu(".nc-dropdown-filter-menu")
.find(".nc-filter-item-remove-btn")
.click();
cy.getActiveMenu(".nc-dropdown-filter-menu")
.find(".nc-filter-item-remove-btn")
.should("not.exist");
cy.get(".nc-filter-menu-btn").click();
cy.wait(500)
};
// delete created views
@ -408,7 +475,10 @@ export class _mainPage {
})
.then(() => {
cy.toastWait("Deleted shared view successfully");
cy.getActiveModal().find("button.ant-modal-close").should('exist').click();
cy.getActiveModal()
.find("button.ant-modal-close")
.should("exist")
.click();
});
};
@ -419,15 +489,23 @@ export class _mainPage {
// if it exists, verify it against 'expectedRecords' passed in as parameter
//
downloadAndVerifyCsv = (filename, verifyCsv, role) => {
if(role === 'commenter' || role === 'viewer') {
if (role === "commenter" || role === "viewer") {
cy.get(".nc-actions-menu-btn").click();
cy.getActiveMenu(".nc-dropdown-actions-menu").find('.nc-project-menu-item').contains('Download as CSV').click();
cy.getActiveMenu(".nc-dropdown-actions-menu")
.find(".nc-project-menu-item")
.contains("Download as CSV")
.click();
} else {
cy.get(".nc-actions-menu-btn").click();
cy.getActiveMenu(".nc-dropdown-actions-menu").find('.nc-project-menu-item').contains('Download').click();
cy.getActiveMenu(".nc-dropdown-actions-menu")
.find(".nc-project-menu-item")
.contains("Download")
.click();
cy.wait(1000);
cy.get('.nc-project-menu-item').contains('Download as CSV').should('exist').click();
cy.get(".nc-project-menu-item")
.contains("Download as CSV")
.should("exist")
.click();
}
cy.toastWait("Successfully exported all table data").then(() => {
@ -447,7 +525,10 @@ export class _mainPage {
downloadAndVerifyCsvFromSharedView = (filename, verifyCsv) => {
cy.get(".nc-actions-menu-btn").click();
cy.get('.nc-project-menu-item').contains('Download as CSV').should('exist').click();
cy.get(".nc-project-menu-item")
.contains("Download as CSV")
.should("exist")
.click();
cy.toastWait("Successfully exported all table data").then(() => {
// download folder path, read from config file
@ -467,9 +548,7 @@ export class _mainPage {
getIFrameCell = (columnHeader, cellNumber) => {
return cy
.iframe()
.find(
`tbody > :nth-child(${cellNumber}) > [data-col="${columnHeader}"]`
);
.find(`tbody > :nth-child(${cellNumber}) > [data-col="${columnHeader}"]`);
};
// https://docs.cypress.io/guides/core-concepts/variables-and-aliases#Sharing-Context
@ -487,19 +566,17 @@ export class _mainPage {
openMetaTab() {
// open Project metadata tab
//
settingsPage.openMenu(settingsPage.PROJ_METADATA)
settingsPage.openTab(settingsPage.METADATA)
settingsPage.openMenu(settingsPage.PROJ_METADATA);
settingsPage.openTab(settingsPage.METADATA);
}
closeMetaTab() {
// close Project metadata tab
settingsPage.closeMenu()
settingsPage.closeMenu();
}
metaSyncValidate(tbl, msg) {
cy.get(".nc-btn-metasync-reload")
.should("exist")
.click();
cy.get(".nc-btn-metasync-reload").should("exist").click();
cy.wait(2000);
cy.get(`.nc-metasync-row-${tbl}`).contains(msg).should("exist");
cy.get(".nc-btn-metasync-sync-now")

Loading…
Cancel
Save