Browse Source

(test) cypress: basic test for column type attachment

Signed-off-by: Raju Udava <sivadstala@gmail.com>
pull/743/head
Raju Udava 3 years ago
parent
commit
56fe783c25
  1. 6
      package-lock.json
  2. 1
      package.json
  3. BIN
      scripts/cypress/fixtures/images/avatar-1.JPG
  4. BIN
      scripts/cypress/fixtures/images/avatar-2.JPG
  5. BIN
      scripts/cypress/fixtures/images/avatar-3.JPG
  6. BIN
      scripts/cypress/fixtures/images/avatar-4.JPG
  7. BIN
      scripts/cypress/fixtures/images/avatar-5.JPG
  8. BIN
      scripts/cypress/fixtures/images/avatar-6.JPG
  9. 5
      scripts/cypress/fixtures/sampleFiles/1.json
  10. 4
      scripts/cypress/fixtures/sampleFiles/2.json
  11. 4
      scripts/cypress/fixtures/sampleFiles/3.json
  12. 4
      scripts/cypress/fixtures/sampleFiles/4.json
  13. 4
      scripts/cypress/fixtures/sampleFiles/5.json
  14. 4
      scripts/cypress/fixtures/sampleFiles/6.json
  15. 52
      scripts/cypress/integration/common/6f_attachments.js
  16. 2
      scripts/cypress/support/commands.js
  17. 21
      scripts/cypress/support/page_objects/mainPage.js

6
package-lock.json generated

@ -3643,6 +3643,12 @@
"yauzl": "^2.10.0"
}
},
"cypress-file-upload": {
"version": "5.0.8",
"resolved": "https://registry.npmjs.org/cypress-file-upload/-/cypress-file-upload-5.0.8.tgz",
"integrity": "sha512-+8VzNabRk3zG6x8f8BWArF/xA/W0VK4IZNx3MV0jFWrJS/qKn8eHfa5nU73P9fOQAgwHFJx7zjg4lwOnljMO8g==",
"dev": true
},
"dargs": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/dargs/-/dargs-4.1.0.tgz",

1
package.json

@ -3,6 +3,7 @@
"devDependencies": {
"@4tw/cypress-drag-drop": "^2.0.0",
"cypress": "^7.3.0",
"cypress-file-upload": "^5.0.8",
"jsdoc-to-markdown": "^5.0.3",
"lerna": "^3.20.1"
},

BIN
scripts/cypress/fixtures/images/avatar-1.JPG

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
scripts/cypress/fixtures/images/avatar-2.JPG

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
scripts/cypress/fixtures/images/avatar-3.JPG

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
scripts/cypress/fixtures/images/avatar-4.JPG

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
scripts/cypress/fixtures/images/avatar-5.JPG

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
scripts/cypress/fixtures/images/avatar-6.JPG

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

5
scripts/cypress/fixtures/sampleFiles/1.json

@ -0,0 +1,5 @@
{
"country": "Afghanistan",
"city": ["Kabul"]
}

4
scripts/cypress/fixtures/sampleFiles/2.json

@ -0,0 +1,4 @@
{
"country": "Algeria",
"city": ["Batna", "Bchar", "Skikda"]
}

4
scripts/cypress/fixtures/sampleFiles/3.json

@ -0,0 +1,4 @@
{
"country": "Americal Samoa",
"city": ["Tafuna"]
}

4
scripts/cypress/fixtures/sampleFiles/4.json

@ -0,0 +1,4 @@
{
"country": "Angola",
"city": ["Benguela", "Namibe"]
}

4
scripts/cypress/fixtures/sampleFiles/5.json

@ -0,0 +1,4 @@
{
"country": "Anguilla",
"city": ["South Hill"]
}

4
scripts/cypress/fixtures/sampleFiles/6.json

@ -0,0 +1,4 @@
{
"country": "Argentina",
"city": ["Almirante Brown", "Avellaneda", "Beha Blanca", "Crdoba"]
}

52
scripts/cypress/integration/common/6f_attachments.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()} Columns of type attachment`, () => {
before(() => {
loginPage.loginAndOpenProject(type)
cy.openTableTab('Country');
})
after(() => {
mainPage.deleteColumn('testAttach')
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++) {
let filepath = `sampleFiles/${i}.json`
mainPage.getCell('testAttach', i).click().find('input[type="file"]').attachFile(filepath)
cy.wait(4000)
}
})
})
}
/**
* @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/>.
*
*/

2
scripts/cypress/support/commands.js

@ -24,6 +24,8 @@
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
import 'cypress-file-upload';
require('@4tw/cypress-drag-drop')
// for waiting until page load

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

@ -142,6 +142,27 @@ export class _mainPage {
cy.get('.nc-col-create-or-edit-card').contains('Save').click()
}
addColumnWithType = (colName, colType) => {
cy.get('.v-window-item--active .nc-grid tr > th:last button').click({ force: true });
cy.get('.nc-column-name-input input', { timeout: 3000 }).clear().type(colName)
// Column data type: to be set to lookup in this context
cy.get('.nc-ui-dt-dropdown').click()
cy.getActiveMenu().contains(colType).click()
cy.get('.nc-col-create-or-edit-card').contains('Save').click()
cy.wait(500)
}
deleteColumn = (colName) => {
cy.get(`th:contains(${colName}) .mdi-menu-down`)
.trigger('mouseover')
.click()
cy.get('.nc-column-delete').click()
cy.get('button:contains(Confirm)').click()
}
getAuthToken = () => {
let obj = JSON.parse(localStorage['vuex'])
return obj["users"]["token"]

Loading…
Cancel
Save