Skip to content

Commit

Permalink
feat: support multiple features for a single ac
Browse files Browse the repository at this point in the history
  • Loading branch information
edd committed May 16, 2024
1 parent 74380f9 commit 5e35910
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vegaprotocol/approbation",
"version": "4.7.2",
"version": "4.7.3",
"description": "Match Acceptance Criteria Codes with the tests that test them",
"engine": ">= 18",
"bin": "./bin/approbation.js",
Expand Down
40 changes: 25 additions & 15 deletions src/lib/feature.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ function setFeatures(fileFeatures) {
const isValid = isValidFeature(featureName, feature)

feature.acs.forEach((ac) => {
acToFeatureLookup.set(ac, featureName);
const existingMap = acToFeatureLookup.get(ac);
if (!existingMap) {
acToFeatureLookup.set(ac, [featureName]);
} else {
acToFeatureLookup.set(ac, [...existingMap, featureName]);
}
})
})

Expand All @@ -69,35 +74,40 @@ function setFeatures(fileFeatures) {

function getFeatureForAc(ac) {
const f = acToFeatureLookup.get(ac);

return f
}

function setOrIncreaseProperty(feature, property, value) {
let f = (feature.match(validAcceptanceCriteriaCode) ? getFeatureForAc(feature) : feature);

if (isFeatureEmpty() || !specFeatures[f]) {
f = 'Unknown';
if (isFeatureEmpty() || !f) {
f = ['Unknown'];
}

if (specFeatures[f][property]) {
specFeatures[f][property] += value;
} else {
specFeatures[f][property] = value;
}
f.forEach((feature) => {
if (specFeatures[feature][property]) {
specFeatures[feature][property] += value;
} else {
specFeatures[feature][property] = value;
}
})
}

function logUncoveredForFeature(feature) {
let f = (feature.match(validAcceptanceCriteriaCode) ? getFeatureForAc(feature) : feature);

if (isFeatureEmpty() || !specFeatures[f]) {
f = 'Unknown';
if (isFeatureEmpty() || !f) {
f = ['Unknown'];
}

if (specFeatures[f]['uncoveredAcs']) {
specFeatures[f]['uncoveredAcs'].add(feature);
} else {
specFeatures[f]['uncoveredAcs'] = new Set([feature]);
}
f.forEach((feat) => {
if (specFeatures[feat]['uncoveredAcs']) {
specFeatures[feat]['uncoveredAcs'].add(feature);
} else {
specFeatures[feat]['uncoveredAcs'] = new Set([feature]);
}
});
}

function increaseCodesForFeature(feature, count) {
Expand Down

0 comments on commit 5e35910

Please sign in to comment.