From 56925246a05c87109e7c852ef15b6772be83ab83 Mon Sep 17 00:00:00 2001 From: Raju Udava Date: Thu, 18 Nov 2021 19:37:14 +0530 Subject: [PATCH] test(cypress): import from excel validation Signed-off-by: Raju Udava --- .../cypress/fixtures/sampleFiles/sample.xlsx | Bin 0 -> 7936 bytes .../common/7a_create_project_from_excel.js | 215 ++++++++++++------ scripts/cypress/integration/test/restMisc.js | 7 +- scripts/cypress/plugins/index.js | 15 +- scripts/cypress/plugins/read-xlsx.js | 10 + 5 files changed, 162 insertions(+), 85 deletions(-) create mode 100644 scripts/cypress/fixtures/sampleFiles/sample.xlsx diff --git a/scripts/cypress/fixtures/sampleFiles/sample.xlsx b/scripts/cypress/fixtures/sampleFiles/sample.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..2d0e3143a89c1e7c518acede0d8ae0c64b4d5f45 GIT binary patch literal 7936 zcmbVxbzGF+5;rZ~ASePW-Q5xbB1?nPCCySxOT#MN4I|g z)$4oj?~ix(^UUtEpJ(PdXU?3NIp0x{M@At=Ku1SM5H)vrh42Sq-TgLnG_!HyV87?3 zu^mcXoY;W}o}tVad|xHdv+|o1WSaoIlRLE z?Uz%?@hT8(Cd4rd#B^UY^KKYgI*7+5$L5q(BuD~m?DvySevSm(#1CyJClfU`Y&hB* zpQ4R46Z&&nID0D6c*`p6XOKMMF_a6_NxvT2AX1TkfF6*-o3ejrgi#~}1eO13CcL{R z+-x}Bf*q}m!C-54H(Q&CSMzrBoY>w=nq(fzUIS)8{DS^eG`5PzDP`V?w!%|S|{eKb!4 zznVwOwc1TU+^Sl>cF{e)+-6v=+hgO3pCxOxuH0H>jj5(cFcwtTT8eYHkcglK6vup5 zY3Pup6~@W)^Lu-zjoAkJIs=uX8(c9_ek!l z_(&}setwpcZK7chf;?h7JCgtLggZB~K7M#eNKz0dP`{rF{}EH{Ak^gKkapS9_v-N^ zU=c)PP$S7M@L^o77klJZEh0F(|8`@R_r1qj5u8$aOmh7P8IR8R<&KZ@v_*^w5Q_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0rKDP{eOVmzqR~X7X7D| zUflnx<<}weZ!Lf3{reK?H&Nf+-cRH2g6eM#f9A#e`rtPOko?l{KdObl_52yQ@3ZJ{ zDj@wYIrVSxKcm!rbpK6Cch>p8Df!>A{%`3&W5InS`%RhTe@Oq1Ykw>F(?S1Jf!m!? a{!0K+kw?ArWdsDQyHD?3uA-&5zxzLhWcm02 literal 0 HcmV?d00001 diff --git a/scripts/cypress/integration/common/7a_create_project_from_excel.js b/scripts/cypress/integration/common/7a_create_project_from_excel.js index 4b4879fe13..335d1dbd3e 100644 --- a/scripts/cypress/integration/common/7a_create_project_from_excel.js +++ b/scripts/cypress/integration/common/7a_create_project_from_excel.js @@ -4,82 +4,52 @@ import { projectsPage } from "../../support/page_objects/navigation" import { mainPage } from "../../support/page_objects/mainPage" -import { staticProjects, roles, isTestSuiteActive } from "../../support/page_objects/projectConstants" -// import fs from "fs" +import { isTestSuiteActive } from "../../support/page_objects/projectConstants" -// if (typeof require !== 'undefined') XLSX = require('xlsx'); -// let filepath = `sampleFiles/simple.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 -// }); +// stores sheet names (table name) +let sheetList -// return sheetData[rowIdx] -// } +// stores table data (read from excel) +let sheetData -// // 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 -// } +let filepath = `sampleFiles/simple.xlsx` +let expectedData = { + 0: ['number', 'Number'], + 1: ['float', 'Decimal'], + 2: ['text', 'SingleLineText'] +} -// 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 +// let filepath = `sampleFiles/sample.xlsx` +// let expectedData = { +// 0: ['number', 'Number'], +// 1: ['float', 'Decimal'], +// 2: ['text', 'SingleLineText'] // } - export const genTest = (type, xcdb) => { if (!isTestSuiteActive(type, xcdb)) return; describe(`Import from excel`, () => { - it('Admin SignUp', () => { - cy.waitForSpinners(); - cy.signinOrSignup(roles.owner.credentials) - cy.wait(2000) - }) + before(() => { + // cy.waitForSpinners() + // cy.signinOrSignup(roles.owner.credentials) + // cy.wait(2000) - it(``, () => { - // cy.readFile('simple.xlsx').then((content) => { - // workbook = XLSX.read(content) - - // cy.log(workbook) - - // cy.log(getSheetList(workbook)) - // cy.log(getRow('Sheet2', 1)) - // cy.log(getColumn('Sheet2', 'A')) - // }) - // cy.task('readXlsx', { file: 'simple.xlsx', sheet: "Sheet2" }).then((rows) => { - // cy.log(rows) - // // expect(rows.length).to.equal(543) - // // expect(rows[0]["column name"]).to.equal(11060) - // }) - - cy.task('readSheetList', { file: 'simple.xlsx' }).then((rows) => { - cy.log(rows) - // expect(rows.length).to.equal(543) - // expect(rows[0]["column name"]).to.equal(11060) + cy.task('readSheetList', { file: `./scripts/cypress/fixtures/${filepath}` }) + .then((rows) => { + cy.log(rows) + sheetList = rows }) + + cy.task('readXlsx', { file: `./scripts/cypress/fixtures/${filepath}`, sheet: "Sheet2" }) + .then((rows) => { + cy.log(rows) + sheetData = rows + }) }) - it.skip('Upload excel as template', () => { + it('Upload excel as template', () => { mainPage.toolBarTopLeft(mainPage.HOME).click() @@ -91,35 +61,132 @@ export const genTest = (type, xcdb) => { cy.get('.nc-excel-import-input').attachFile(filepath) cy.get('.nc-btn-use-template', { timeout: 120000 }).should('exist') - - // validate pre-load template page - cy.getActiveContentModal().find('.v-expansion-panel').then((panel) => { - // cy.log(panel.length) - for (let i = 0; i < panel.length; i++) { - // cy.log(panel[i]) - cy.wrap(panel[i]).find('.title').then((blk) => { + }) + + it('Verify pre-load template page', () => { + + cy.getActiveContentModal().find('.v-expansion-panel').then((sheets) => { + + for (let i = 0; i < sheets.length; i++) { + + // verify if all sheet names are correct + cy.wrap(sheets[i]).find('.title').then((blk) => { cy.log(blk.text().trim()) + expect(blk.text().trim()).to.equal(sheetList[i]) }) - cy.wrap(panel[i]).find('.mdi-chevron-down').click() - cy.wait(1000) + + // for each sheet, expand to verify table names & their data types + cy.wrap(sheets[i]).find('.mdi-chevron-down').click() + cy.wait(500) cy.get('.v-data-table').find('tr:visible').then((row) => { - // cy.log(row) - for (let j = 2; j < row.length; j++) { + + for (let j = 1; j < row.length; j++) { + + // column name to match input in excel cy.wrap(row[j]).find('[placeholder="Column name"]').then((obj) => { cy.log(obj[0].value) - }) + expect(obj[0].value).to.equal(expectedData[j-1][0]) + }) + + // datatype to match expected output cy.wrap(row[j]).find('span.caption').then((obj) => { cy.log(obj[0].innerText) + expect(obj[0].innerText).to.equal(expectedData[j-1][1]) }) } }) - cy.wrap(panel[i]).find('.mdi-chevron-down').click() + + // unwind + cy.wrap(sheets[i]).find('.mdi-chevron-down').click() } }) }) + + it('Verify loaded data', () => { + + // create rest/ gql project + cy.get('.nc-btn-use-template', { timeout: 120000 }).click() + // if (type == 'rest') { + // cy.getActiveMenu().find('[role="menuitem"]').contains('REST').click() + // } else { + // cy.getActiveMenu().find('[role="menuitem"]').contains('GQL').click() + // } + + // wait for loading to be completed + projectsPage.waitHomePageLoad() + + // open sheet & validate contents + // sheetData contains data read from excel in format + // 0: { float: 1.1, number: 1, text: "abc" } + // 1: { float: 1.2, number: 0, text: "def" } + + cy.openTableTab('Sheet2') + for (const [key, value] of Object.entries(expectedData)) { + mainPage.getCell(value[0], 1).contains(sheetData[0][value[0]]).should('exist') + mainPage.getCell(value[0], 2).contains(sheetData[1][value[0]]).should('exist') + } + cy.closeTableTab('Sheet2') + + cy.openTableTab('Sheet3') + for (const [key, value] of Object.entries(expectedData)) { + mainPage.getCell(value[0], 1).contains(sheetData[0][value[0]]).should('exist') + mainPage.getCell(value[0], 2).contains(sheetData[1][value[0]]).should('exist') + } + cy.closeTableTab('Sheet3') + }) + + after(() => { + // delete project once all operations are completed + mainPage.toolBarTopLeft(mainPage.HOME).click() + cy.wait(1000) + cy.get(`.nc-${type}-project-row .mdi-delete-circle-outline`, { timeout: 10000 }) + .last() + .invoke('show') + .click(); + cy.contains('Submit') + .closest('button') + .click(); + }) }) } + +// 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 * diff --git a/scripts/cypress/integration/test/restMisc.js b/scripts/cypress/integration/test/restMisc.js index 8ada514d8c..eb07893353 100644 --- a/scripts/cypress/integration/test/restMisc.js +++ b/scripts/cypress/integration/test/restMisc.js @@ -7,6 +7,7 @@ let t6d = require('../common/6d_language_validation') let t6e = require('../common/6e_project_operations') let t6f = require('../common/6f_attachments') let t6g = require('../common/6g_base_share') +let t7a = require('../common/7a_create_project_from_excel') // use 0 as mode to execute individual files (debug mode, skip pre-configs) // use 1 mode if noco.db doesnt contain user credentials (full run over GIT) @@ -26,7 +27,11 @@ const nocoTestSuite = (type, xcdb) => { t6f.genTest(type, xcdb) t6g.genTest(type, xcdb) // **deletes created project, hence place it @ end - t6e.genTest(type, xcdb) + t6e.genTest(type, xcdb) + + // intended to keep this after earlier project deletion + // creates project using excel & deletes it + t7a.genTest(type, xcdb) } nocoTestSuite('rest', false) diff --git a/scripts/cypress/plugins/index.js b/scripts/cypress/plugins/index.js index 76d8b3b10a..3f2089c4c5 100644 --- a/scripts/cypress/plugins/index.js +++ b/scripts/cypress/plugins/index.js @@ -12,6 +12,10 @@ // This function is called when a project is opened or re-opened (e.g. due to // the project's config changing) const { rmdir } = require('fs') + +// https://stackoverflow.com/questions/61934443/read-excel-files-in-cypress +const readXlsx = require('./read-xlsx') + /** * @type {Cypress.PluginConfig} */ @@ -37,17 +41,8 @@ module.exports = (on, config) => { }) }) }, - }) -} - - -// https://stackoverflow.com/questions/61934443/read-excel-files-in-cypress -const readXlsx = require('./read-xlsx') - -module.exports = (on, config) => { - on('task', { 'readXlsx': readXlsx.read, - 'readSheetList': readXlsx.sheetList + 'readSheetList': readXlsx.sheetList, }) } diff --git a/scripts/cypress/plugins/read-xlsx.js b/scripts/cypress/plugins/read-xlsx.js index ee08fef3f8..7ed5aa4648 100644 --- a/scripts/cypress/plugins/read-xlsx.js +++ b/scripts/cypress/plugins/read-xlsx.js @@ -10,6 +10,16 @@ const read = ({file, sheet}) => { return rows } +// const read = ({file, sheet}) => { +// const buf = fs.readFileSync(file); +// const workbook = XLSX.read(buf, { type: 'buffer' }); +// const rows = XLSX.utils.sheet_to_json(workbook.Sheets[sheet], { +// header: 1, +// blankrows: false +// }); +// return rows +// } + const sheetList = ({file}) => { const buf = fs.readFileSync(file); const workbook = XLSX.read(buf, { type: 'buffer' });