Browse Source

(test) cypress: detailed tests for attachment column-type

Signed-off-by: Raju Udava <sivadstala@gmail.com>
pull/760/head
Raju Udava 3 years ago
parent
commit
5f8fe8f27b
  1. 47
      scripts/cypress/integration/common/4f_grid_view_share.js
  2. 26
      scripts/cypress/integration/common/5a_user_role.js
  3. 28
      scripts/cypress/integration/common/6b_downloadCsv.js
  4. 84
      scripts/cypress/integration/common/6f_attachments.js
  5. 2
      scripts/cypress/integration/test/gqlMisc.js
  6. 2
      scripts/cypress/integration/test/restMisc.js
  7. 20
      scripts/cypress/support/page_objects/mainPage.js

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

@ -151,17 +151,25 @@ export const genTest = (type, xcdb) => {
})
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,`
]
mainPage.hideUnhideField('LastUpdate')
const verifyCsv = (retrievedRecords) => {
// expected output, statically configured
let storedRecords = [
`Address,District,PostalCode,Phone,Location,Address => Customer,Address => Staff,City <= Address,Address <=> Staff`,
`1013 Tabuk Boulevard,West Bengali,96203,158399646978,[object Object],2,,Kanchrapara,`,
`1892 Nabereznyje Telny Lane,Tutuila,28396,478229987054,[object Object],2,,Tafuna,`,
`1993 Tabuk Lane,Tamil Nadu,64221,648482415405,[object Object],2,,Tambaram,`,
`1661 Abha Drive,Tamil Nadu,14400,270456873752,[object Object],1,,Pudukkottai,`
]
for (let i = 0; i < storedRecords.length; i++) {
expect(retrievedRecords[i]).to.be.equal(storedRecords[i])
}
}
// download & verify
mainPage.downloadAndVerifyCsv(`Address_exported_1.csv`, storedRecords)
mainPage.downloadAndVerifyCsv(`Address_exported_1.csv`, verifyCsv)
mainPage.hideUnhideField('LastUpdate')
})
// it(`Share ${viewType} view generate URL with all fields enabled`, () => {
@ -289,12 +297,21 @@ export const genTest = (type, xcdb) => {
})
it(`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`,
`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)
mainPage.hideUnhideField('LastUpdate')
const verifyCsv = (retrievedRecords) => {
// expected output, statically configured
let storedRecords = [
`Address,District,PostalCode,Phone,Location,Address => Customer,Address => Staff,City <= Address,Address <=> Staff`,
`1993 Tabuk Lane,Tamil Nadu,64221,648482415405,[object Object],2,,Tambaram,`,
`1661 Abha Drive,Tamil Nadu,14400,270456873752,[object Object],1,,Pudukkottai,`
]
for (let i = 0; i < storedRecords.length; i++) {
expect(retrievedRecords[i]).to.be.equal(storedRecords[i])
}
}
mainPage.downloadAndVerifyCsv(`Address_exported_1.csv`, verifyCsv)
mainPage.hideUnhideField('LastUpdate')
})
it(`Share ${viewType.toUpperCase()} view : Delete Filter`, () => {

26
scripts/cypress/integration/common/5a_user_role.js

@ -147,14 +147,24 @@ export const genTest = (type, xcdb) => {
it(`[${roles[roleType].name}] Download files`, () => {
mainPage.hideUnhideField('LastUpdate')
let storedRecords = [
`City,City => Address,Country <= City`,
`A Corua (La Corua),939 Probolinggo Loop,Spain`,
`Abha,733 Mandaluyong Place,Saudi Arabia`,
`Abu Dhabi,535 Ahmadnagar Manor,United Arab Emirates`,
`Acua,1789 Saint-Denis Parkway,Mexico`
]
mainPage.downloadAndVerifyCsv(`City_exported_1.csv`, storedRecords)
const verifyCsv = (retrievedRecords) => {
// expected output, statically configured
let storedRecords = [
`City,City => Address,Country <= City`,
`A Corua (La Corua),939 Probolinggo Loop,Spain`,
`Abha,733 Mandaluyong Place,Saudi Arabia`,
`Abu Dhabi,535 Ahmadnagar Manor,United Arab Emirates`,
`Acua,1789 Saint-Denis Parkway,Mexico`
]
for (let i = 0; i < storedRecords.length; i++) {
// cy.log(retrievedRecords[i])
expect(retrievedRecords[i]).to.be.equal(storedRecords[i])
}
}
// download & verify
mainPage.downloadAndVerifyCsv(`City_exported_1.csv`, verifyCsv)
mainPage.hideUnhideField('LastUpdate')
})

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

@ -17,14 +17,26 @@ export const genTest = (type, xcdb) => {
})
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)
mainPage.hideUnhideField('LastUpdate')
const verifyCsv = (retrievedRecords) => {
// expected output, statically configured
let storedRecords = [
`Country,Country => City`,
`Afghanistan,Kabul`,
`Algeria,"Batna,Bchar,Skikda"`,
`American Samoa,Tafuna`,
`Angola,"Benguela,Namibe"`
]
for (let i = 0; i < storedRecords.length; i++) {
cy.log(retrievedRecords[i])
expect(retrievedRecords[i]).to.be.equal(storedRecords[i])
}
}
// download & verify
mainPage.downloadAndVerifyCsv(`Country_exported_1.csv`, verifyCsv)
mainPage.hideUnhideField('LastUpdate')
})
})
}

84
scripts/cypress/integration/common/6f_attachments.js

@ -14,18 +14,98 @@ export const genTest = (type, xcdb) => {
after(() => {
mainPage.deleteColumn('testAttach')
cy.get('[href="#table||db||Country"]').find('button.mdi-close').click()
// clean up newly added rows into Country table operations
// this auto verifies successfull addition of rows to table as well
mainPage.getPagination(5).click()
cy.wait(3000)
mainPage.getRow(10).find('.mdi-checkbox-blank-outline').click({ force: true })
mainPage.getCell("Country", 10).rightclick()
cy.getActiveMenu().contains('Delete Selected Row').click()
cy.get('[href="#table||db||Country"]').find('button.mdi-close').click()
})
it(`Add column of type attachments`, () => {
mainPage.addColumnWithType('testAttach', 'Attachment')
cy.wait(4000)
for (let i = 1; i <= 6; i++) {
for (let i = 1; i <= 2; i++) {
let filepath = `sampleFiles/${i}.json`
mainPage.getCell('testAttach', i).click().find('input[type="file"]').attachFile(filepath)
cy.wait(4000)
}
})
it(`Form view with Attachment field- Submit & verify`, () => {
// create form-view
cy.get(`.nc-create-form-view`).click();
cy.getActiveModal().find('button:contains(Submit)').click()
cy.get(`.nc-view-item.nc-form-view-item`).contains('Country1').click()
cy.get('.v-navigation-drawer__content > .container')
.find('.v-list > .v-list-item')
.contains('Share View')
.click()
// copy link text, visit URL
cy.getActiveModal().find('.share-link-box')
.contains('/nc/form/', { timeout: 10000 })
.then(($obj) => {
let linkText = $obj.text()
cy.log(linkText)
cy.visit(linkText)
// wait for share view page to load!
cy.wait(5000)
cy.get('#data-table-form-Country').type('_abc')
cy.get('#data-table-form-LastUpdate').click()
cy.getActiveModal().find('button').contains('19').click()
cy.getActiveModal().find('button').contains('OK').click()
cy.get('.nc-field-editables')
.last()
.find('input[type="file"]')
.attachFile(`sampleFiles/1.json`)
// submit button & validate
cy.get('.nc-form').find('button').contains('Submit').click()
cy.wait(3000)
})
})
it(`Filter column which contain only attachments, download CSV`, () => {
// come back to main window
loginPage.loginAndOpenProject(type)
cy.openTableTab('Country');
mainPage.filterField('testAttach', 'is not null', null)
cy.wait(1000)
mainPage.hideUnhideField('LastUpdate')
const verifyCsv = (retrievedRecords) => {
let storedRecords = [
`Country,Country => City,testAttach`,
`Afghanistan,Kabul,1.json(http://localhost:8080/dl/externalrest_5agd/db/country/testAttach_VWk3fz_1.json)`
]
expect(retrievedRecords[0]).to.be.equal(storedRecords[0])
for (let i = 1; i < storedRecords.length; i++) {
const columns = retrievedRecords[i].split(',')
expect(columns[2]).to.contain('.json(http://localhost:8080/dl/external')
}
cy.log(retrievedRecords[109])
cy.log(retrievedRecords[110])
cy.log(retrievedRecords[111])
}
mainPage.downloadAndVerifyCsv(`Country_exported_1.csv`, verifyCsv)
mainPage.hideUnhideField('LastUpdate')
mainPage.filterReset()
})
})
}

2
scripts/cypress/integration/test/gqlMisc.js

@ -5,6 +5,7 @@ let t6b = require('../common/6b_downloadCsv')
let t6c = require('../common/6c_swagger_api')
let t6d = require('../common/6d_language_validation')
let t6e = require('../common/6e_project_operations')
let t6f = require('../common/6f_attachments')
// 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)
@ -21,6 +22,7 @@ const nocoTestSuite = (type, xcdb) => {
t6b.genTest(type, xcdb)
t6c.genTest(type, xcdb)
t6d.genTest(type, xcdb)
t6f.genTest(type, xcdb)
// **deletes created project, hence place it @ end
t6e.genTest(type, xcdb)
}

2
scripts/cypress/integration/test/restMisc.js

@ -5,6 +5,7 @@ let t6b = require('../common/6b_downloadCsv')
let t6c = require('../common/6c_swagger_api')
let t6d = require('../common/6d_language_validation')
let t6e = require('../common/6e_project_operations')
let t6f = require('../common/6f_attachments')
// 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)
@ -21,6 +22,7 @@ const nocoTestSuite = (type, xcdb) => {
t6b.genTest(type, xcdb)
t6d.genTest(type, xcdb)
t6c.genTest(type, xcdb)
t6f.genTest(type, xcdb)
// **deletes created project, hence place it @ end
t6e.genTest(type, xcdb)
}

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

@ -159,7 +159,7 @@ export class _mainPage {
.trigger('mouseover')
.click()
cy.get('.nc-column-delete').click()
cy.get('.nc-column-delete', {timeout: 5000}).click()
cy.get('button:contains(Confirm)').click()
}
@ -222,7 +222,9 @@ export class _mainPage {
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()
cy.get('.nc-filter-value-select input:text').last().type(`${value}`);
if ((operation != 'is null') && (operation != 'is not null')) {
cy.get('.nc-filter-value-select input:text').last().type(`${value}`);
}
cy.get('.nc-filter-menu-btn').click()
}
@ -267,7 +269,7 @@ export class _mainPage {
// 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) => {
downloadAndVerifyCsv = (filename, verifyCsv) => {
cy.get('.nc-actions-menu-btn').click()
cy.get(`.menuable__content__active .v-list-item span:contains("Download as CSV")`).click()
@ -289,17 +291,7 @@ export class _mainPage {
// 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++) {
const firstCol = rows[i].split(',')
const expectedFirstCol = expectedRecords[i].split(',')
expect(firstCol[0]).to.be.equal(expectedFirstCol[0])
// expect(rows[i]).to.be.equal(expectedRecords[i])
//cy.log(rows[i])
}
verifyCsv(rows)
deleteDownloadsFolder()
})
})

Loading…
Cancel
Save