diff --git a/src-electron/db/zap-schema.sql b/src-electron/db/zap-schema.sql index 8e8c198dd2..73dbf51080 100644 --- a/src-electron/db/zap-schema.sql +++ b/src-electron/db/zap-schema.sql @@ -860,10 +860,12 @@ WHEN ENDPOINT_TYPE_CLUSTER.SIDE = new.SIDE AND ENDPOINT_TYPE_CLUSTER.ENABLED != 1 + AND + DEVICE_TYPE_CLUSTER.CLUSTER_REF = new.CLUSTER_REF AND ((DEVICE_TYPE_CLUSTER.INCLUDE_CLIENT = 1 AND LOWER(new.SIDE) = 'client') OR (LOWER(new.SIDE) = 'client' AND DEVICE_TYPE_CLUSTER.LOCK_CLIENT=0 ) - OR (DEVICE_TYPE_CLUSTER.INCLUDE_SERVER = 1 AND LOWER(new.SIDE) = 'SERVER') + OR (DEVICE_TYPE_CLUSTER.INCLUDE_SERVER = 1 AND LOWER(new.SIDE) = 'server') OR (LOWER(new.SIDE) = 'server' AND DEVICE_TYPE_CLUSTER.LOCK_SERVER=0 )) ) > 0 BEGIN @@ -959,10 +961,12 @@ WHEN ENDPOINT_TYPE_CLUSTER.SIDE = new.SIDE AND ENDPOINT_TYPE_CLUSTER.ENABLED = 1 + AND + DEVICE_TYPE_CLUSTER.CLUSTER_REF = new.CLUSTER_REF AND ((DEVICE_TYPE_CLUSTER.INCLUDE_CLIENT = 1 AND LOWER(new.SIDE) = 'client') OR (LOWER(new.SIDE) = 'client' AND DEVICE_TYPE_CLUSTER.LOCK_CLIENT=0 ) - OR (DEVICE_TYPE_CLUSTER.INCLUDE_SERVER = 1 AND LOWER(new.SIDE) = 'SERVER') + OR (DEVICE_TYPE_CLUSTER.INCLUDE_SERVER = 1 AND LOWER(new.SIDE) = 'server') OR (LOWER(new.SIDE) = 'server' AND DEVICE_TYPE_CLUSTER.LOCK_SERVER=0 )) ) > 0 BEGIN @@ -1058,10 +1062,12 @@ WHEN ENDPOINT_TYPE_CLUSTER.SIDE = new.SIDE AND ENDPOINT_TYPE_CLUSTER.ENABLED = 1 + AND + DEVICE_TYPE_CLUSTER.CLUSTER_REF = new.CLUSTER_REF AND ((DEVICE_TYPE_CLUSTER.INCLUDE_CLIENT = 1 AND LOWER(new.SIDE) = 'client') OR (LOWER(new.SIDE) = 'client' AND DEVICE_TYPE_CLUSTER.LOCK_CLIENT=0 ) - OR (DEVICE_TYPE_CLUSTER.INCLUDE_SERVER = 1 AND LOWER(new.SIDE) = 'SERVER') + OR (DEVICE_TYPE_CLUSTER.INCLUDE_SERVER = 1 AND LOWER(new.SIDE) = 'server') OR (LOWER(new.SIDE) = 'server' AND DEVICE_TYPE_CLUSTER.LOCK_SERVER=0 )) ) > 0 BEGIN diff --git a/test/spec-check.test.js b/test/spec-check.test.js index 357395a5e7..45fa5aefa3 100644 --- a/test/spec-check.test.js +++ b/test/spec-check.test.js @@ -156,6 +156,40 @@ test( let allClusters = await testQuery.getAllSessionClusters(db, sid) let descriptorCluster = allClusters.find((c) => c.code === 0x001d) // Finding the descriptor cluster by code let identifyCluster = allClusters.find((c) => c.code === 0x0003) // Finding the identify cluster by code + let onOffCluster = allClusters.find((c) => c.code === 0x0006) // Find the on/off cluster by code + + // Negative test: Adding on/off cluster to endpoint 0 and then disabling it. + // Note that on/off cluster is not a required cluster based on the device types + // enabled on endpoint 0 so there should be no additional session warnings when + // enabling or disabling the on/off cluster. + let sessionNotificationCountBeforeOnOffEnabled = sessionNotifications.length + // Enable on off server cluster + await queryConfig.insertOrReplaceClusterState( + db, + endpoint0.endpointTypeId, + onOffCluster.id, + 'SERVER', + true + ) + sessionNotifications = await testQuery.getAllSessionNotifications(db, sid) + let sessionNotificationCountAfterOnOffEnabled = sessionNotifications.length + expect(sessionNotificationCountBeforeOnOffEnabled).toEqual( + sessionNotificationCountAfterOnOffEnabled + ) + + // Disable on off server cluster + await queryConfig.insertOrReplaceClusterState( + db, + endpoint0.endpointTypeId, + onOffCluster.id, + 'SERVER', + false + ) + sessionNotifications = await testQuery.getAllSessionNotifications(db, sid) + let sessionNotificationCountAfterOnOffDisabled = sessionNotifications.length + expect(sessionNotificationCountBeforeOnOffEnabled).toEqual( + sessionNotificationCountAfterOnOffDisabled + ) // Insert the descriptor cluster and check for session notice warnings again await queryConfig.insertOrReplaceClusterState(