Browse Source

[test] cypress: download csv base view/ shared view verification

Signed-off-by: Raju Udava <sivadstala@gmail.com>
pull/743/head
Raju Udava 3 years ago
parent
commit
e5e9f681ee
  1. 2
      packages/nc-gui/components/project/spreadsheet/components/csvExport.vue
  2. 25
      scripts/cypress/integration/common/4f_grid_view_share.js
  3. 52
      scripts/cypress/integration/common/6b_downloadCsv.js
  4. 39
      scripts/cypress/support/page_objects/mainPage.js

2
packages/nc-gui/components/project/spreadsheet/components/csvExport.vue

@ -7,7 +7,7 @@
<template #activator="{on}">
<v-btn
outlined
class="caption"
class="nc-actions-menu-btn caption"
small
text
v-on="on"

25
scripts/cypress/integration/common/4f_grid_view_share.js

@ -150,6 +150,20 @@ export const genTest = (type, xcdb) => {
mainPage.getCell("District", 3).contains("Tamil Nadu").should('exist')
})
it(`Share ${viewType.toUpperCase()} view : verify download CSV`, () => {
// expected output, statically configured
let storedRecords = [
`Address,District,PostalCode,Phone,Location,LastUpdate,Address => Customer,Address => Staff,City <= Address,Address <=> Staff`,
`1013 Tabuk Boulevard,West Bengali,96203,158399646978,[object Object],2014-09-25T17:01:19.000Z,2,,Kanchrapara,`,
`1892 Nabereznyje Telny Lane,Tutuila,28396,478229987054,[object Object],2014-09-25T17:00:02.000Z,2,,Tafuna,`,
`1993 Tabuk Lane,Tamil Nadu,64221,648482415405,[object Object],2014-09-25T17:01:27.000Z,2,,Tambaram,`,
`1661 Abha Drive,Tamil Nadu,14400,270456873752,[object Object],2014-09-25T17:01:23.000Z,1,,Pudukkottai,`
]
// download & verify
mainPage.downloadAndVerifyCsv(`Address_exported_1.csv`, storedRecords)
})
// it(`Share ${viewType} view generate URL with all fields enabled`, () => {
// cy.get(`.nc-view-item.nc-${viewType}-view-item`).contains('Country1').click()
// generateViewLink('default')
@ -274,6 +288,17 @@ export const genTest = (type, xcdb) => {
mainPage.getCell("District", 1).contains("Tamil").should('exist')
})
it.skip(`Share ${viewType.toUpperCase()} view : verify download CSV after local filter`, () => {
let storedRecords = [
`Address,District,PostalCode,Phone,Location,LastUpdate,Address => Customer,Address => Staff,City <= Address,Address <=> Staff`,
`1013 Tabuk Boulevard,West Bengali,96203,158399646978,[object Object],2014-09-25T17:01:19.000Z,2,,Kanchrapara,`,
`1892 Nabereznyje Telny Lane,Tutuila,28396,478229987054,[object Object],2014-09-25T17:00:02.000Z,2,,Tafuna,`,
`1993 Tabuk Lane,Tamil Nadu,64221,648482415405,[object Object],2014-09-25T17:01:27.000Z,2,,Tambaram,`,
`1661 Abha Drive,Tamil Nadu,14400,270456873752,[object Object],2014-09-25T17:01:23.000Z,1,,Pudukkottai,`
]
mainPage.downloadAndVerifyCsv(`Address_exported_1.csv`, storedRecords)
})
it(`Share ${viewType.toUpperCase()} view : Delete Filter`, () => {
// Remove sort and Validate
mainPage.filterReset()

52
scripts/cypress/integration/common/6b_downloadCsv.js

@ -0,0 +1,52 @@
import { mainPage } from "../../support/page_objects/mainPage"
import { loginPage } from "../../support/page_objects/navigation"
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"
export const genTest = (type, xcdb) => {
if(!isTestSuiteActive(type, xcdb)) return;
describe(`${type.toUpperCase()} Upload/ Download CSV`, () => {
before(() => {
loginPage.loginAndOpenProject(type)
cy.openTableTab('Country');
})
after(() => {
cy.get('[href="#table||db||Country"]').find('button.mdi-close').click()
})
it('Download verification- base view, default columns', () => {
let storedRecords = [
`Country,LastUpdate,Country => City`,
`Afghanistan,2006-02-14T23:14:00.000Z,Kabul`,
`Algeria,2006-02-14T23:14:00.000Z,"Batna,Bchar,Skikda"`,
`American Samoa,2006-02-14T23:14:00.000Z,Tafuna`,
`Angola,2006-02-14T23:14:00.000Z,"Benguela,Namibe"`
]
mainPage.downloadAndVerifyCsv(`Country_exported_1.csv`, storedRecords)
})
})
}
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Raju Udava <sivadstala@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

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

@ -1,4 +1,6 @@
const path = require("path");
// main page
export class _mainPage {
@ -227,6 +229,43 @@ export class _mainPage {
cy.get('.v-overlay__content > .d-flex > .v-icon').click()
})
}
// 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, expectedRecords) => {
cy.get('.nc-actions-menu-btn').click()
cy.get(`.menuable__content__active .v-list-item span:contains("Download as CSV")`).click()
// Toast verification disabled as for larger table, multiple toasts appear before success one
// for each partitioned file
// cy.get('.toasted', { timeout: 5000 })
// .contains('Successfully exported all table data')
// .should('exist')
cy.wait(5000)
.then(() => {
// download folder path, read from config file
const downloadsFolder = Cypress.config("downloadsFolder")
// append download folder path with filename to generate full file path, retrieve file
cy.readFile(path.join(downloadsFolder, filename))
.then((fileData) => {
// from CSV, split into records (rows)
const rows = fileData.replace(/\r\n/g, '\n').split('\n');
// verify records against intended contents
for (let i = 0; i < expectedRecords.length; i++) {
expect(rows[i]).to.be.equal(expectedRecords[i])
//cy.log(rows[i])
}
})
})
}
}

Loading…
Cancel
Save