refactor: drop superorder from metas (#44422)

* refactor: create superOrder from superblock

* chore: drop superOrders from meta

* fix: return null for 'certifications'

* fix: only set superOrder if it is needed

* fix(tests): remove filter from order tests

* test: use getSuperOrder, since superOrder has gone

* test: ignore certificates

* fix: getSuperOrder throw for 'certifications'

* test: remove certificate special case

It wasn't necessary, anyway (it had never been working because I put
certificate not certification)

Co-authored-by: Nicholas Carrigan <nhcarrigan@gmail.com>
This commit is contained in:
Oliver Eyton-Williams
2021-12-14 17:16:23 +01:00
committed by GitHub
parent d4f490419f
commit 1642c631de
74 changed files with 81 additions and 84 deletions

View File

@ -50,7 +50,7 @@ const {
getTranslatableComments
} = require('../getChallenges');
const { challengeSchemaValidator } = require('../schema/challengeSchema');
const { testedLang } = require('../utils');
const { testedLang, getSuperOrder } = require('../utils');
const ChallengeTitles = require('./utils/challengeTitles');
const MongoIds = require('./utils/mongoIds');
const createPseudoWorker = require('./utils/pseudo-worker');
@ -268,22 +268,16 @@ function populateTestsForLang({ lang, challenges, meta }) {
]);
superBlocks.forEach(superBlock => {
const filteredMeta = Object.values(meta)
/**
* Exclude any meta which doesn't have a superOrder, as these shouldn't
* appear on the learn map and thus don't need to be validated.
*/
.filter(
el =>
el.superBlock === superBlock && typeof el.superOrder !== 'undefined'
)
.filter(el => el.superBlock === superBlock)
.sort((a, b) => a.order - b.order);
if (!filteredMeta.length) {
return;
}
it(`${superBlock} should have the same order in every meta`, function () {
const firstOrder = filteredMeta[0].superOrder;
const firstOrder = getSuperOrder(filteredMeta[0].superBlock);
assert.isNumber(firstOrder);
assert.isTrue(
filteredMeta.every(el => el.superOrder === firstOrder),
filteredMeta.every(el => getSuperOrder(el.superBlock) === firstOrder),
'The superOrder properties are mismatched.'
);
});