Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions src-electron/validation/conformance-checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]) =>
Expand All @@ -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) ||
Expand All @@ -142,7 +130,6 @@ function generateWarningMessage(

if (
missingOperands.length == 0 &&
!featureContainsDesc &&
(Object.keys(descElements).length == 0 ||
(descElements.attributes.length == 0 &&
descElements.commands.length == 0 &&
Expand Down Expand Up @@ -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 || [])]
Expand Down
50 changes: 50 additions & 0 deletions test/feature.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
Loading