Skip to content

Commit d5ca93b

Browse files
authored
ZAPP-1695: Enable toggling desc features to fix the TagList feature issue (#1685)
* do not disable toggling on desc features, display warning instead * add unit test
1 parent e33856a commit d5ca93b

2 files changed

Lines changed: 63 additions & 15 deletions

File tree

src-electron/validation/conformance-checker.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,7 @@ function generateWarningMessage(
9090
}
9191
}
9292

93-
// Check 2: if the feature conformance contains the operand 'desc'
94-
let featureContainsDesc = conformEvaluator.checkIfExpressionHasOperand(
95-
featureData.conformance,
96-
dbEnum.conformanceTag.described
97-
)
98-
if (featureContainsDesc) {
99-
result.warningMessage.push(
100-
warningPrefix +
101-
` ${updateDisabledString} its conformance is too complex for ZAP to process, or it includes 'desc'.`
102-
)
103-
}
104-
105-
// Check 3: if the feature update will change the conformance of other dependent features
93+
// Check 2: if the feature update will change the conformance of other dependent features
10694
if (featuresToUpdate && Object.keys(featuresToUpdate).length > 0) {
10795
let featuresToUpdateString = Object.entries(featuresToUpdate)
10896
.map(([feature, isEnabled]) =>
@@ -115,7 +103,7 @@ function generateWarningMessage(
115103
)
116104
}
117105

118-
// Check 4: if any elements that conform to the updated feature contain 'desc' in their conformance
106+
// Check 3: if any elements that conform to the updated feature contain 'desc' in their conformance
119107
if (
120108
(descElements.attributes && descElements.attributes.length > 0) ||
121109
(descElements.commands && descElements.commands.length > 0) ||
@@ -142,7 +130,6 @@ function generateWarningMessage(
142130

143131
if (
144132
missingOperands.length == 0 &&
145-
!featureContainsDesc &&
146133
(Object.keys(descElements).length == 0 ||
147134
(descElements.attributes.length == 0 &&
148135
descElements.commands.length == 0 &&
@@ -203,6 +190,17 @@ function generateWarningMessage(
203190
: buildNonElementConformMessage('enabled', 'mandatory'))
204191
result.displayWarning = !added
205192
}
193+
// if the feature conformance contains the operand 'desc', do not disable toggling, but show warning message
194+
let featureContainsDesc = conformEvaluator.checkIfExpressionHasOperand(
195+
featureData.conformance,
196+
dbEnum.conformanceTag.described
197+
)
198+
if (featureContainsDesc) {
199+
result.warningMessage =
200+
warningPrefix +
201+
` is being ${added ? 'enabled' : 'disabled'}, but it has descriptive conformance and requires manual validation from the feature specification to enable/disable the right dependencies in ZAP.`
202+
result.displayWarning = true
203+
}
206204

207205
// generate patterns for outdated feature warnings to be deleted
208206
let updatedFeatures = [featureData, ...(changedConformFeatures || [])]

test/feature.test.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,56 @@ test(
767767
testUtil.timeout.short()
768768
)
769769

770+
test(
771+
'Check feature with desc conformance allows toggling but shows warning',
772+
() => {
773+
// Test enabling a feature with 'desc' conformance
774+
let elements = {
775+
attributes: [],
776+
commands: [],
777+
events: []
778+
}
779+
let featureMap = {
780+
DESCFEATURE: false
781+
}
782+
let featureWithDesc = {
783+
cluster: 'Test Cluster',
784+
name: 'Feature With Desc',
785+
code: 'DESCFEATURE',
786+
conformance: 'desc',
787+
deviceTypes: ['Test Device Type'],
788+
bit: 0
789+
}
790+
let clusterFeatures = [featureWithDesc]
791+
let endpointId = 1
792+
793+
// Enable the feature with 'desc' conformance
794+
featureMap['DESCFEATURE'] = true
795+
let result = conformChecker.checkElementConformance(
796+
elements,
797+
featureMap,
798+
featureWithDesc,
799+
endpointId,
800+
clusterFeatures
801+
)
802+
803+
// Should allow toggling (disableChange is false) but show warning
804+
let warningPrefix = env.formatEmojiMessage(
805+
'⚠️',
806+
`Check Feature Compliance on endpoint: ${endpointId}, cluster: ${featureWithDesc.cluster}, ` +
807+
`feature: ${featureWithDesc.name} (${featureWithDesc.code}) (bit ${featureWithDesc.bit} in featureMap attribute)`
808+
)
809+
let expectedWarning =
810+
warningPrefix +
811+
` is being enabled, but it has descriptive conformance and requires manual validation from the feature specification to enable/disable the right dependencies in ZAP.`
812+
813+
expect(result.displayWarning).toBeTruthy()
814+
expect(result.disableChange).toBeFalsy()
815+
expect(result.warningMessage).toBe(expectedWarning)
816+
},
817+
testUtil.timeout.short()
818+
)
819+
770820
test(
771821
'Test API for getting FeatureMap attribute value',
772822
async () => {

0 commit comments

Comments
 (0)