fix: make help button use subforum topics (#37741)
* fix: make help button use subforum topics * fix: add test to check that block exists Co-authored-by: ojeytonwilliams <ojeytonwilliams@gmail.com> * fix: improve error message * Update curriculum/test/test-challenges.js Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
@ -36,7 +36,12 @@ const { getChallengesForLang } = require('../getChallenges');
|
||||
const MongoIds = require('./utils/mongoIds');
|
||||
const ChallengeTitles = require('./utils/challengeTitles');
|
||||
const { challengeSchemaValidator } = require('../schema/challengeSchema');
|
||||
const { challengeTypes } = require('../../client/utils/challengeTypes');
|
||||
const {
|
||||
challengeTypes,
|
||||
helpCategory
|
||||
} = require('../../client/utils/challengeTypes');
|
||||
|
||||
const { dasherize } = require('../../utils/slugs');
|
||||
|
||||
const { testedLangs } = require('../utils');
|
||||
|
||||
@ -150,6 +155,15 @@ async function getChallenges(lang) {
|
||||
return { lang, challenges };
|
||||
}
|
||||
|
||||
function validateBlock(challenge) {
|
||||
const dashedBlock = dasherize(challenge.block);
|
||||
if (!helpCategory.hasOwnProperty(dashedBlock)) {
|
||||
return `'${dashedBlock}' block not found as a helpCategory in client/utils/challengeTypes.js file for the '${challenge.title}' challenge`;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function populateTestsForLang({ lang, challenges }) {
|
||||
const mongoIds = new MongoIds();
|
||||
const challengeTitles = new ChallengeTitles();
|
||||
@ -162,9 +176,14 @@ function populateTestsForLang({ lang, challenges }) {
|
||||
describe(challenge.title || 'No title', function() {
|
||||
it('Common checks', function() {
|
||||
const result = validateChallenge(challenge);
|
||||
const invalidBlock = validateBlock(challenge);
|
||||
|
||||
if (result.error) {
|
||||
throw new AssertionError(result.error);
|
||||
}
|
||||
if (challenge.challengeType !== 7 && invalidBlock) {
|
||||
throw new Error(invalidBlock);
|
||||
}
|
||||
const { id, title } = challenge;
|
||||
mongoIds.check(id, title);
|
||||
challengeTitles.check(title);
|
||||
|
Reference in New Issue
Block a user