Skip to content

Commit

Permalink
Merge pull request #399 from Mehradml/master
Browse files Browse the repository at this point in the history
Resolving issues and adding cypress to ci and writing new tests
  • Loading branch information
tecimovic authored Feb 3, 2022
2 parents ebacff8 + 596c4b3 commit d44455f
Show file tree
Hide file tree
Showing 21 changed files with 330 additions and 32 deletions.
1 change: 1 addition & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
- run: npm run gen
- run: npm run genmatter
- run: npm run gendotdot
- run: xvfb-run -a npm run test:e2e-ci
- run: export GH_TOKEN=${{ secrets.GITHUB_TOKEN}} && npm run dist-linux
- run: xvfb-run -a dist/linux-unpacked/zap selfCheck
- name: Archive .rpm file
Expand Down
9 changes: 6 additions & 3 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"viewportWidth": 1080,
"viewportHeight": 920
}
"viewportWidth": 1080,
"viewportHeight": 920,
"video": false,
"testFiles": "**/theme/theme.spec.js",
"ignoreTestFiles": ["**/*.test.js"]
}
27 changes: 27 additions & 0 deletions cypress/integration/attribute validations/bitmap8.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/// <reference types="cypress" />

Cypress.on('uncaught:exception', (err, runnable) => {
// returning false here prevents Cypress from
// failing the test
return false
})

describe('Testing BITMAP8 type validation', () => {
it('create a new endpoint and click on configure to open attributes of endpoint', () => {
cy.visit('http://localhost:8080/?restPort=9070#/')
cy.gotoAttributePage('Billing Unit (0x0203)', 'General')
cy.wait(1000)
})
it('getting an attribute with BITMAP8 type and change defualt amount', () => {
cy.get(
':nth-child(16) > [style="min-width: 180px;"] > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > input'
)
.clear({ force: true })
.type('test', { force: true })
})
it('check if validation works properly', () => {
cy.get(
':nth-child(16) > [style="min-width: 180px;"] > .q-field > .q-field__inner > .q-field__bottom > .q-field__messages > div'
).should('exist')
})
})
27 changes: 27 additions & 0 deletions cypress/integration/attribute validations/boolean.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/// <reference types="cypress" />

Cypress.on('uncaught:exception', (err, runnable) => {
// returning false here prevents Cypress from
// failing the test
return false
})

describe('Testing BOOLEAN type validation', () => {
it('create a new endpoint and click on configure to open attributes of endpoint', () => {
cy.visit('http://localhost:8080/?restPort=9070#/')
cy.gotoAttributePage('Billing Unit (0x0203)', 'General')
cy.wait(1000)
})
it('getting an attribute with BOOLEAN type and change defualt amount', () => {
cy.get(
':nth-child(15) > [style="min-width: 180px;"] > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > input'
)
.clear({ force: true })
.type('test', { force: true })
})
it('check if validation works properly', () => {
cy.get(
':nth-child(15) > [style="min-width: 180px;"] > .q-field > .q-field__inner > .q-field__bottom > .q-field__messages > div'
).should('exist')
})
})
27 changes: 27 additions & 0 deletions cypress/integration/attribute validations/enum8.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/// <reference types="cypress" />

Cypress.on('uncaught:exception', (err, runnable) => {
// returning false here prevents Cypress from
// failing the test
return false
})

describe('Testing ENUM8 type validation', () => {
it('create a new endpoint and click on configure to open attributes of endpoint', () => {
cy.visit('http://localhost:8080/?restPort=9070#/')
cy.gotoAttributePage('Billing Unit (0x0203)', 'General')
cy.wait(1000)
})
it('getting an attribute with ENUM8 type and change defualt amount', () => {
cy.get(
':nth-child(8) > [style="min-width: 180px;"] > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > input'
)
.clear({ force: true })
.type('test', { force: true })
})
it('check if validation works properly', () => {
cy.get(
':nth-child(8) > [style="min-width: 180px;"] > .q-field > .q-field__inner > .q-field__bottom > .q-field__messages > div'
).should('exist')
})
})
27 changes: 27 additions & 0 deletions cypress/integration/attribute validations/int16.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/// <reference types="cypress" />

Cypress.on('uncaught:exception', (err, runnable) => {
// returning false here prevents Cypress from
// failing the test
return false
})

describe('Testing INT16U type validation', () => {
it('create a new endpoint and click on configure to open attributes of endpoint', () => {
cy.visit('http://localhost:8080/?restPort=9070#/')
cy.gotoAttributePage('Billing Unit (0x0203)', 'General')
cy.wait(1000)
})
it('getting an attribute with INT16U type and change defualt amount', () => {
cy.get(
':nth-child(19) > [style="min-width: 180px;"] > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > input'
)
.clear({ force: true })
.type('test', { force: true })
})
it('check if validation works properly', () => {
cy.get(
':nth-child(19) > [style="min-width: 180px;"] > .q-field > .q-field__inner > .q-field__bottom > .q-field__messages > div'
).should('exist')
})
})
27 changes: 27 additions & 0 deletions cypress/integration/attribute validations/int8.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/// <reference types="cypress" />

Cypress.on('uncaught:exception', (err, runnable) => {
// returning false here prevents Cypress from
// failing the test
return false
})

describe('Testing INT8U type validation', () => {
it('create a new endpoint and click on configure to open attributes of endpoint', () => {
cy.visit('http://localhost:8080/?restPort=9070#/')
cy.gotoAttributePage('Billing Unit (0x0203)', 'General')
cy.wait(1000)
})
it('getting an attribute with INT8U type and change defualt amount', () => {
cy.get(
':nth-child(1) > [style="min-width: 180px;"] > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > input'
)
.clear({ force: true })
.type('test', { force: true })
})
it('check if validation works properly', () => {
cy.get(
':nth-child(1) > [style="min-width: 180px;"] > .q-field > .q-field__inner > .q-field__bottom > .q-field__messages > div'
).should('exist')
})
})
32 changes: 32 additions & 0 deletions cypress/integration/attributes/check-search.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/// <reference types="cypress" />

Cypress.on('uncaught:exception', (err, runnable) => {
// returning false here prevents Cypress from
// failing the test
return false
})

describe('Testing attribute search', () => {
it('create a new endpoint and click on configure to open attributes of endpoint', () => {
cy.visit('http://localhost:8080/?restPort=9070#/')
cy.gotoAttributePage('Billing Unit (0x0203)', 'General')
cy.wait(1000)
})
it('check existance of ZCL version and application version', () => {
cy.get('tbody')
.children()
.should('contain', 'ZCL version')
.and('contain', 'application version')
})
it('Search for application', () => {
cy.get(
'.q-py-none > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > input'
)
.clear({ force: true })
.type('application', { force: true })
})
it('check if search result is correct', () => {
cy.get('tbody').children().contains('ZCL version').should('not.exist')
cy.get('tbody').children().should('contain', 'application version')
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('Testing enabled attributes amount', () => {
.then(() => { })
cy.get(':nth-child(7) > .text-right').then(($div2) => {
const num2 = parseFloat($div2.text())
expect(num2).to.eq(num1 + 1)
expect(num2).to.eq(17)
})
})
})
Expand Down
4 changes: 2 additions & 2 deletions cypress/integration/check summary/enabled-clusters.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ describe('Testing enabled attributes amount', () => {
it('create a new endpoint and get amount of enabled attributes', () => {
cy.visit('http://localhost:8080/?restPort=9070#/')
cy.addEndpoint('Billing Unit (0x0203)', 'General')
cy.wait(1000)
cy.wait(2000)
cy.get(':nth-child(6) > .text-right').then(($div) => {
const num1 = parseFloat($div.text())
cy.get('.q-page-container > div').children().should('contain', 'General')
cy.get('div').contains('General').click()
cy.get('div').children().contains('Not Enabled').first().click()
cy.get('#qvs_5 > :nth-child(3)').contains('Server').click()
cy.get('.q-virtual-scroll__content > :nth-child(3)').contains('Server').click()
cy.wait(1000)
cy.get(':nth-child(6) > .text-right').then(($div2) => {
const num2 = parseFloat($div2.text())
Expand Down
42 changes: 42 additions & 0 deletions cypress/integration/clusters/cluster-filter.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/// <reference types="cypress" />

Cypress.on('uncaught:exception', (err, runnable) => {
// returning false here prevents Cypress from
// failing the test
return false
})

describe('Testing cluster filters', () => {
it('create a new endpoint', () => {
cy.visit('http://localhost:8080/?restPort=9070#/')
cy.addEndpoint('Billing Unit (0x0203)', 'General')
})
it('filter enabled clusters and check clusters', () => {
cy.get(
'.bar > :nth-child(1) > :nth-child(2) > .q-field > .q-field__inner > .q-field__control'
).click({ force: true })
cy.get('#qvs_3 > :nth-child(3)').click()
cy.get('tbody')
.children()
.contains('Power Configuration')
.should('not.exist')
})
it('enable power configuration cluster and check if it exists this time', () => {
cy.get(
'.bar > :nth-child(1) > :nth-child(2) > .q-field > .q-field__inner > .q-field__control'
).click({ force: true })
cy.get('#qvs_3 > :nth-child(1)').click()
cy.get('tbody').children().should('contain', 'Power Configuration')
cy.get(
'#General > .q-expansion-item__container > .q-expansion-item__content > :nth-child(1) > .q-table__container > .q-table__middle > .q-table > tbody > :nth-child(2) > :nth-child(6) > .q-field > .q-field__inner > .q-field__control'
).click()
cy.get('.q-virtual-scroll__content > :nth-child(3)')
.contains('Server')
.click()
cy.get(
'.bar > :nth-child(1) > :nth-child(2) > .q-field > .q-field__inner > .q-field__control'
).click({ force: true })
cy.get('#qvs_3 > :nth-child(3)').click()
cy.get('tbody').children().should('contain', 'Power Configuration')
})
})
30 changes: 30 additions & 0 deletions cypress/integration/clusters/cluster-search.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/// <reference types="cypress" />

Cypress.on('uncaught:exception', (err, runnable) => {
// returning false here prevents Cypress from
// failing the test
return false
})

describe('Testing cluster search', () => {
it('create a new endpoint and check existance of Basic and Power Configuration clusters', () => {
cy.visit('http://localhost:8080/?restPort=9070#/')
cy.addEndpoint('Billing Unit (0x0203)', 'General')
cy.get('#General > .q-expansion-item__container > .q-item').click()
cy.get('tbody')
.children()
.should('contain', 'Basic')
.and('contain', 'Power Configuration')
})
it('Search for power', () => {
cy.get(
'.col-4 > .q-field__inner > .q-field__control > .q-field__control-container > input'
)
.clear({ force: true })
.type('power', { force: true })
})
it('check if search result is correct', () => {
cy.get('tbody').children().contains('Basic').should('not.exist')
cy.get('tbody').children().should('contain', 'Power Configuration')
})
})
4 changes: 2 additions & 2 deletions cypress/integration/overview/overview.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ describe('Testing endpoints, clusters and attributes', () => {
cy.get('div').contains('General').click()
//check if configure button works fine
cy.get(
'#General > .q-expansion-item__container > .q-expansion-item__content > :nth-child(1) > .q-table__container > .q-table__middle > .q-table > tbody > :nth-child(1) > :nth-child(7) > .q-btn > .q-btn__wrapper > .q-btn__content > .material-icons'
).click()
'#General > .q-expansion-item__container > .q-expansion-item__content > :nth-child(1) > .q-table__container > .q-table__middle > .q-table > tbody > .text-weight-bolder > :nth-child(7) > .q-btn > .q-btn__wrapper > .q-btn__content > .notranslate'
).click({force:true})
cy.wait(1000)

//check if attributes are loaded
Expand Down
4 changes: 1 addition & 3 deletions cypress/integration/preview button/preview_button.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ Cypress.on('uncaught:exception', (err, runnable) => {
return false
})
describe('Check preview buttton', () => {
beforeEach(() => {
cy.visit('http://localhost:8080/?restPort=9070#/')
})

it('adding a new endpoint', () => {
cy.visit('http://localhost:8080/?restPort=9070#/')
cy.get('button').contains('Add New Endpoint').click()
cy.wait(1000)
cy.get(
Expand Down
4 changes: 1 addition & 3 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,5 @@ Cypress.Commands.add('gotoAttributePage', (endpoint, cluster) => {
if (endpoint) cy.addEndpoint(endpoint)
cy.get('.q-page-container > div').children().should('contain', cluster)
cy.get('div').contains(cluster).click()
cy.get(
`#${cluster} > .q-expansion-item__container > .q-expansion-item__content > :nth-child(1) > .q-table__container > .q-table__middle > .q-table > tbody > :nth-child(1) > :nth-child(7) > .q-btn > .q-btn__wrapper > .q-btn__content > .material-icons`
).click()
cy.get(`#${cluster} > .q-expansion-item__container > .q-expansion-item__content > :nth-child(1) > .q-table__container > .q-table__middle > .q-table > tbody > .text-weight-bolder > :nth-child(7) > .q-btn > .q-btn__wrapper > .q-btn__content > .notranslate`).click({force: true})
})
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"type": "commonjs",
"name": "zap",
"version": "2022.1.29",
"version": "2022.2.2",
"description": "Configuration tool for the Zigbee Cluster Library",
"productName": "zap",
"cordovaId": "",
Expand All @@ -25,8 +25,8 @@
"test:unit:coverage": "jest --coverage",
"test:unit:watch": "jest --watch",
"test:unit:watchAll": "jest --watchAll",
"test:e2e": "npm run zap-devserver | start-test \"quasar dev\" http-get://localhost:8080 \"cypress open\"",
"test:e2e-ci": "npm run zap-devserver | start-test \"quasar dev\" http-get://localhost:8080 \"cypress run\"",
"test:e2e": "node src-script/zap-uitest.js open",
"test:e2e-ci": "node src-script/zap-uitest.js run",
"postinstall": "electron-builder install-app-deps && husky install && npm rebuild canvas --update-binary",
"wpzap": "npm run build-spa && npm run build-backend && npm run dist-mac && npm run apack:mac",
"zap": "node src-script/zap-start.js --logToStdout --gen ./test/gen-template/zigbee/gen-templates.json",
Expand Down
1 change: 1 addition & 0 deletions src-electron/validation/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ function checkBoundsFloat(defaultValue, min, max) {
return defaultValue >= min && defaultValue <= max
}


// exports
exports.validateAttribute = validateAttribute
exports.validateEndpoint = validateEndpoint
Expand Down
16 changes: 8 additions & 8 deletions src-script/zap-start.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ scriptUtil
),
]

if (process.platform == 'linux') {
if (!process.env.DISPLAY) {
console.log(`
⛔ You are on Linux and you are attempting to run zap in UI mode without DISPLAY set.
⛔ Please set your DISPLAY environment variable or run zap-start.js with a command that does not require DISPLAY.`)
process.exit(1)
}
}
// if (process.platform == 'linux') {
// if (!process.env.DISPLAY) {
// console.log(`
// ⛔ You are on Linux and you are attempting to run zap in UI mode without DISPLAY set.
// ⛔ Please set your DISPLAY environment variable or run zap-start.js with a command that does not require DISPLAY.`)
// process.exit(1)
// }
// }
cmdArgs.push(...args)
return scriptUtil.executeCmd(null, 'npx', cmdArgs)
})
Expand Down
Loading

0 comments on commit d44455f

Please sign in to comment.