Skip to content

Commit

Permalink
Add test to validate that cohort names do not contain special charact…
Browse files Browse the repository at this point in the history
…ers. (#2688)
  • Loading branch information
sammacbeth authored Jan 29, 2025
1 parent 5c086ee commit 75d790f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/config-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,22 @@ describe('Config schema tests', () => {
}
}
});

it('All experiment cohorts should be named correctly', () => {
const cohortNameRegex = /^[a-zA-Z0-9]+$/;
/** @type {Record<string, import('../schema/feature').GenericFeature>} */
const features = config.body.features;
for (const featureName of Object.keys(config.body.features)) {
for (const subfeatureName of Object.keys(features[featureName].features || {})) {
const subFeature = features[featureName].features[subfeatureName];
if (subFeature.cohorts) {
for (const cohort of subFeature.cohorts) {
expect(cohort.name).to.match(cohortNameRegex);
}
}
}
}
});
});
}

Expand Down

0 comments on commit 75d790f

Please sign in to comment.