diff --git a/src-electron/validation/conformance-checker.js b/src-electron/validation/conformance-checker.js index d2108233f4..d60f7b0ef9 100644 --- a/src-electron/validation/conformance-checker.js +++ b/src-electron/validation/conformance-checker.js @@ -90,19 +90,7 @@ function generateWarningMessage( } } - // Check 2: if the feature conformance contains the operand 'desc' - let featureContainsDesc = conformEvaluator.checkIfExpressionHasOperand( - featureData.conformance, - dbEnum.conformanceTag.described - ) - if (featureContainsDesc) { - result.warningMessage.push( - warningPrefix + - ` ${updateDisabledString} its conformance is too complex for ZAP to process, or it includes 'desc'.` - ) - } - - // Check 3: if the feature update will change the conformance of other dependent features + // Check 2: if the feature update will change the conformance of other dependent features if (featuresToUpdate && Object.keys(featuresToUpdate).length > 0) { let featuresToUpdateString = Object.entries(featuresToUpdate) .map(([feature, isEnabled]) => @@ -115,7 +103,7 @@ function generateWarningMessage( ) } - // Check 4: if any elements that conform to the updated feature contain 'desc' in their conformance + // Check 3: if any elements that conform to the updated feature contain 'desc' in their conformance if ( (descElements.attributes && descElements.attributes.length > 0) || (descElements.commands && descElements.commands.length > 0) || @@ -142,7 +130,6 @@ function generateWarningMessage( if ( missingOperands.length == 0 && - !featureContainsDesc && (Object.keys(descElements).length == 0 || (descElements.attributes.length == 0 && descElements.commands.length == 0 && @@ -203,6 +190,17 @@ function generateWarningMessage( : buildNonElementConformMessage('enabled', 'mandatory')) result.displayWarning = !added } + // if the feature conformance contains the operand 'desc', do not disable toggling, but show warning message + let featureContainsDesc = conformEvaluator.checkIfExpressionHasOperand( + featureData.conformance, + dbEnum.conformanceTag.described + ) + if (featureContainsDesc) { + result.warningMessage = + warningPrefix + + ` 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.` + result.displayWarning = true + } // generate patterns for outdated feature warnings to be deleted let updatedFeatures = [featureData, ...(changedConformFeatures || [])] diff --git a/test/feature.test.js b/test/feature.test.js index 179294c6b4..7cd946998e 100644 --- a/test/feature.test.js +++ b/test/feature.test.js @@ -767,6 +767,56 @@ test( testUtil.timeout.short() ) +test( + 'Check feature with desc conformance allows toggling but shows warning', + () => { + // Test enabling a feature with 'desc' conformance + let elements = { + attributes: [], + commands: [], + events: [] + } + let featureMap = { + DESCFEATURE: false + } + let featureWithDesc = { + cluster: 'Test Cluster', + name: 'Feature With Desc', + code: 'DESCFEATURE', + conformance: 'desc', + deviceTypes: ['Test Device Type'], + bit: 0 + } + let clusterFeatures = [featureWithDesc] + let endpointId = 1 + + // Enable the feature with 'desc' conformance + featureMap['DESCFEATURE'] = true + let result = conformChecker.checkElementConformance( + elements, + featureMap, + featureWithDesc, + endpointId, + clusterFeatures + ) + + // Should allow toggling (disableChange is false) but show warning + let warningPrefix = env.formatEmojiMessage( + '⚠️', + `Check Feature Compliance on endpoint: ${endpointId}, cluster: ${featureWithDesc.cluster}, ` + + `feature: ${featureWithDesc.name} (${featureWithDesc.code}) (bit ${featureWithDesc.bit} in featureMap attribute)` + ) + let expectedWarning = + warningPrefix + + ` is being enabled, but it has descriptive conformance and requires manual validation from the feature specification to enable/disable the right dependencies in ZAP.` + + expect(result.displayWarning).toBeTruthy() + expect(result.disableChange).toBeFalsy() + expect(result.warningMessage).toBe(expectedWarning) + }, + testUtil.timeout.short() +) + test( 'Test API for getting FeatureMap attribute value', async () => {