0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00

Added integrity test for flags (#20094)

ref
https://ghost.slack.com/archives/C02G9E68C/p1714047709694639?thread_ts=1713956576.497899&cid=C02G9E68C
    
    - Ensures unique feature flags, avoiding configuration conflicts.
    - Enhances code reliability and simplifies feature tracking.
    - Prevents bad rebases was the reason for the initial duplication.
This commit is contained in:
Ronald Langeveld 2024-04-29 10:39:15 +08:00 committed by GitHub
parent 305029bc38
commit b2970cb4e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 1 deletions

View file

@ -51,7 +51,6 @@ const ALPHA_FEATURES = [
'tipsAndDonations',
'importMemberTier',
'lexicalIndicators',
// 'adminXOffers',
'adminXDemo',
'membersSpamPrevention'
];
@ -82,6 +81,10 @@ module.exports.getAll = () => {
return labs;
};
module.exports.getAllFlags = function () {
return [...GA_FEATURES, ...BETA_FEATURES, ...ALPHA_FEATURES];
};
/**
* @param {string} flag
* @returns {boolean}

View file

@ -143,3 +143,13 @@ describe('Labs Service', function () {
assert.equal(labs.isSet('publicAPI'), false);
});
});
describe('Labs Service - Flag Integrity', function () {
it('should have no duplicate flags across categories', function () {
const allFlags = labs.getAllFlags();
const duplicates = allFlags.filter((flag, index) => allFlags.indexOf(flag) !== index);
assert.equal(duplicates.length, 0, `There are duplicate flags in the labs configuration: ${duplicates.join(', ')}`);
});
});