diff --git a/cypress/e2e/attribute_validations/reporting.cy.js b/cypress/e2e/attribute_validations/reporting.cy.js new file mode 100644 index 0000000000..181d872377 --- /dev/null +++ b/cypress/e2e/attribute_validations/reporting.cy.js @@ -0,0 +1,68 @@ +/// + +Cypress.on('uncaught:exception', (err, runnable) => { + // returning false here prevents Cypress from failing the test + return false +}) + +describe('Add multiple clusters and search', () => { + // This will hold the fixture data and the flag for skipping the tests + let skipTest = false + + before(function () { + // Load the fixture data before running any tests + cy.fixture('data').then((data) => { + this.data = data + // If mode is "matter", set skipTest flag to true + if (this.data.mode !== 'zigbee') { + skipTest = true + } + }) + }) + + it('create two endpoints and validate basic information', function () { + // Skip the test if the flag is true (mode is "matter") + if (skipTest) { + cy.log('Skipping test because mode is not "zigbee"') + return // Skip the test if mode is 'matter' + } + + // Continue with the test if the mode is not "matter" + cy.fixture('baseurl').then((data) => { + cy.visit(data.baseurl) + }) + cy.setZclProperties() + + // Create and validate the first endpoint + cy.fixture('data').then((data) => { + cy.addEndpoint(data.endpoint4, data.cluster1) + }) + cy.get('.flex > strong').should('contain', '#1') + + // Select the "Power Configuration" cluster for the second endpoint + cy.fixture('data').then((data) => { + cy.gotoAttributePage(data.endpoint1, data.cluster1) + cy.contains('.q-item__section .q-item__label', 'General', { + timeout: 10000 + }) + .should('be.visible') + .click() + }) + + // Check the "Attribute Reporting" tab for the second endpoint + cy.fixture('data').then((data) => { + cy.contains('.q-tab__content .q-tab__label', 'Attribute Reporting', { + timeout: 10000 + }) + .should('be.visible') + .click() + }) + cy.get( + '.q-virtual-scroll__content > :nth-child(1) > :nth-child(2) > .q-toggle > .q-toggle__inner > .q-toggle__thumb' + ).click() + // Check to make sure the button is still visible after clicking + cy.get( + '.q-virtual-scroll__content > :nth-child(1) > :nth-child(2) > .q-toggle > .q-toggle__inner > .q-toggle__thumb' + ).should('be.visible') + }) +}) diff --git a/src-electron/rest/user-data.js b/src-electron/rest/user-data.js index 6e5978a9ae..cb23702431 100644 --- a/src-electron/rest/user-data.js +++ b/src-electron/rest/user-data.js @@ -389,6 +389,7 @@ function httpPostAttributeUpdate(db) { let { action, endpointTypeIdList, + selectedEndpoint, id, value, listType, @@ -398,7 +399,6 @@ function httpPostAttributeUpdate(db) { reportMaxInterval, reportableChange } = request.body - if (!Array.isArray(endpointTypeIdList) || !endpointTypeIdList.length) { return response.status(StatusCodes.BAD_REQUEST).json() } @@ -434,11 +434,10 @@ function httpPostAttributeUpdate(db) { ) ) ) - // send latest value to frontend to update UI let eptAttr = await queryZcl.selectEndpointTypeAttribute( db, - endpointTypeIdList[0], + selectedEndpoint, id, clusterRef ) @@ -448,7 +447,7 @@ function httpPostAttributeUpdate(db) { // endpointTypeId doesn't matter since all attributes are the seame. let validationData = await validation.validateAttribute( db, - endpointTypeIdList[0], + selectedEndpoint, id, clusterRef, request.zapSessionId diff --git a/src/util/editable-attributes-mixin.js b/src/util/editable-attributes-mixin.js index 5cfbb62501..3cc7b16343 100644 --- a/src/util/editable-attributes-mixin.js +++ b/src/util/editable-attributes-mixin.js @@ -132,6 +132,7 @@ export default { let editContext = { action: 'boolean', endpointTypeIdList: this.endpointTypeIdList, + selectedEndpoint: this.selectedEndpointTypeId, id: attributeData.id, value: enable, listType: listType, @@ -181,6 +182,7 @@ export default { let editContext = { action: 'text', endpointTypeIdList: this.endpointTypeIdList, + selectedEndpoint: this.selectedEndpointTypeId, id: attributeData.id, value: newValue, listType: listType, @@ -191,7 +193,7 @@ export default { } this.$store.dispatch('zap/updateSelectedAttribute', editContext) }, - async toggleAttributeSelection(list, listType, attributeData, clusterId) { + toggleAttributeSelection(list, listType, attributeData, clusterId) { // We determine the ID that we need to toggle within the list. // This ID comes from hashing the base ZCL attribute and cluster data. let indexOfValue = list.indexOf( @@ -213,6 +215,7 @@ export default { let editContext = { action: 'boolean', endpointTypeIdList: this.endpointTypeIdList, + selectedEndpoint: this.selectedEndpointTypeId, id: attributeData.id, value: addedValue, listType: listType, @@ -222,7 +225,7 @@ export default { reportMaxInterval: attributeData.reportMaxInterval } // Wait for the first dispatch to complete - await this.$store.dispatch('zap/updateSelectedAttribute', editContext) + this.$store.dispatch('zap/updateSelectedAttribute', editContext) if ( addedValue && @@ -230,7 +233,7 @@ export default { attributeData.isReportable ) { editContext.listType = 'selectedReporting' - await this.$store.dispatch('zap/updateSelectedAttribute', editContext) + this.$store.dispatch('zap/updateSelectedAttribute', editContext) } },