Browse Source

test: cy explicit delete local storage before restoring

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
pull/3422/head
Raju Udava 2 years ago
parent
commit
94dc3c44c3
  1. 62
      scripts/cypress-v2/integration/common/7a_create_project_from_excel.js
  2. 4
      scripts/cypress-v2/integration/spec/roleValidation.spec.js
  3. 14
      scripts/cypress-v2/support/commands.js

62
scripts/cypress-v2/integration/common/7a_create_project_from_excel.js

@ -69,6 +69,8 @@ export const genTest = (apiType, dbType) => {
describe(`Import from excel`, () => {
before(() => {
// loginPage.signIn(roles.owner.credentials);
cy.restoreLocalStorage();
cy.wait(1000);
@ -106,15 +108,9 @@ export const genTest = (apiType, dbType) => {
cy.get('.nc-import-menu').should('exist').click()
cy.getActiveMenu().find('.ant-dropdown-menu-item').contains('Microsoft Excel').click()
// trigger import
// cy.get(`[data-menu-id="addORImport"]`).click();
// cy.getActivePopUp().contains("Microsoft Excel").should('exist').click();
cy.get(".nc-input-import").should('exist').find('input').attachFile(filepath);
cy.toastWait("Uploaded file simple.xlsx successfully");
cy.get(".nc-btn-import").should('exist').click();
// cy.toastWait("Uploaded file simple.xlsx successfully")
});
it("File Upload: Verify pre-load template page", () => {
@ -161,11 +157,12 @@ export const genTest = (apiType, dbType) => {
}
});
cy.getActiveModal().find(".ant-btn-primary").click();
// wait for page to get loaded (issue observed in CI-CD)
cy.wait(5000);
});
it("File Upload: Verify loaded data", () => {
// wait for page to get loaded (issue observed in CICD)
cy.wait(5000);
cy.openTableTab("Sheet2", 2);
for (const [key, value] of Object.entries(expectedData)) {
@ -192,19 +189,6 @@ export const genTest = (apiType, dbType) => {
.should("exist");
}
cy.closeTableTab("Sheet3");
// // delete project once all operations are completed
// cy.get('.nc-noco-brand-icon').click();
//
// cy.get(`.nc-action-btn`)
// .should("exist")
// .last()
// .click();
//
// cy.getActiveModal()
// .find(".ant-btn-dangerous")
// .should("exist")
// .click();
});
it.skip("URL: Upload excel as template", () => {
@ -302,42 +286,6 @@ export const genTest = (apiType, dbType) => {
});
};
// if (typeof require !== 'undefined') XLSX = require('xlsx');
// let workbook
// const getSheetList = (wb) => {
// return wb.SheetNames
// }
// const getRow = (sheet, rowIdx) => {
// let sheetData = XLSX.utils.sheet_to_json(workbook.Sheets[sheet], {
// header: 1,
// blankrows: false
// });
// return sheetData[rowIdx]
// }
// // https://stackoverflow.com/questions/40630606/how-to-read-only-column-a-value-from-excel-using-nodejs
// const getColumn = (sheet, colIdx) => {
// let columnA = []
// const worksheet = workbook.Sheets[sheet];
// for (let z in worksheet) {
// if (z.toString()[0] === colIdx) {
// columnA.push(worksheet[z].v);
// }
// }
// return columnA
// }
// const getCell = (sheet, cellIdx) => {
// const worksheet = workbook.Sheets[sheet];
// var desired_cell = worksheet[cellIdx];
// desired_value = (desired_cell ? desired_cell.v : undefined);
// return desired_value
// }
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*

4
scripts/cypress-v2/integration/spec/roleValidation.spec.js

@ -10,7 +10,8 @@ export function _advSettings(roleType, mode) {
cy.log(roleType, mode);
if(mode === 'baseShare') {
cy.get('.nc-project-menu').should('not.exist')
cy.get('.nc-project-menu').should('exist').click()
cy.getActiveMenu().find(`[data-menu-id="language"]`).should('exist')
return;
}
@ -230,6 +231,7 @@ export function _viewMenu(roleType, mode) {
menuWithSubmenuCount = 2;
// Get API Snippet
menuWithoutSubmenuCount = 1
if(mode === 'baseShare') menuWithoutSubmenuCount = 0
} else if (roleType === "commenter" || roleType === "viewer") {
// Download CSV & Download excel
menuWithSubmenuCount = 0;

14
scripts/cypress-v2/support/commands.js

@ -243,9 +243,12 @@ Cypress.Commands.add("saveLocalStorage", (name) => {
return;
}
LOCAL_STORAGE_MEMORY = {};
Object.keys(localStorage).forEach((key) => {
LOCAL_STORAGE_MEMORY[key] = localStorage[key];
});
cy.printLocalStorage();
});
Cypress.Commands.add("restoreLocalStorage", (name) => {
@ -257,11 +260,13 @@ Cypress.Commands.add("restoreLocalStorage", (name) => {
return;
}
Object.keys(LOCAL_STORAGE_MEMORY).forEach((key) => {
localStorage.setItem(key, LOCAL_STORAGE_MEMORY[key]);
});
cy.deleteLocalStorage().then(() => {
Object.keys(LOCAL_STORAGE_MEMORY).forEach((key) => {
localStorage.setItem(key, LOCAL_STORAGE_MEMORY[key]);
});
cy.printLocalStorage();
cy.printLocalStorage();
});
});
Cypress.Commands.add("deleteLocalStorage", () => {
@ -273,6 +278,7 @@ Cypress.Commands.add("deleteLocalStorage", () => {
Cypress.Commands.add('printLocalStorage', () => {
cy.task('log', `[printLocalStorage]`);
cy.task('log', JSON.stringify(localStorage, null, 2));
cy.task('log', JSON.stringify(LOCAL_STORAGE_MEMORY, null, 2));
})
Cypress.Commands.add("getActiveModal", () => {

Loading…
Cancel
Save