fix: make sure ext curriculum tests fail if missing meta (#61904)

This commit is contained in:
Oliver Eyton-Williams
2025-08-21 19:57:45 +02:00
committed by GitHub
parent b246d99b30
commit efe3d22b06
3 changed files with 134 additions and 116 deletions
@@ -72,14 +72,18 @@ ${result.error.message}`
await readdirp.promise(`${clientStaticPath}/curriculum-data/${VERSION}`, {
directoryFilter: ['!challenges'],
fileFilter: entry => {
// path without extension:
const filePath = entry.path.replace(/\.json$/, '');
// The directory contains super block files and other curriculum-related files.
// We're only interested in super block ones.
const superBlocks = Object.values(SuperBlocks);
return superBlocks.includes(entry.basename);
return superBlocks.includes(filePath);
}
})
).map(file => file.path);
expect(fileArray.length).toBeGreaterThan(0);
fileArray.forEach(fileInArray => {
const fileContent = fs.readFileSync(
`${clientStaticPath}/curriculum-data/${VERSION}/${fileInArray}`,
@@ -100,14 +104,18 @@ ${result.error.message}`);
await readdirp.promise(`${clientStaticPath}/curriculum-data/${VERSION}`, {
directoryFilter: ['!challenges'],
fileFilter: entry => {
// path without extension:
const filePath = entry.path.replace(/\.json$/, '');
// The directory contains super block files and other curriculum-related files.
// We're only interested in super block ones.
const superBlocks = Object.values(SuperBlocks);
return superBlocks.includes(entry.basename);
return superBlocks.includes(filePath);
}
})
).map(file => file.path);
expect(superBlockFiles.length).toBeGreaterThan(0);
superBlockFiles.forEach(file => {
const fileContentJson = fs.readFileSync(
`${clientStaticPath}/curriculum-data/${VERSION}/${file}`,
@@ -2,7 +2,8 @@ const Joi = require('joi');
const blockSchema = Joi.object({}).keys({
desc: Joi.array().min(1),
challenges: Joi.object({}).keys({
challenges: Joi.object({})
.keys({
name: Joi.string().required(),
isUpcomingChange: Joi.bool().required(),
usesMultifileEditor: Joi.bool().optional(),
@@ -49,16 +50,20 @@ const blockSchema = Joi.object({}).keys({
then: Joi.required(),
otherwise: Joi.optional()
}),
challengeOrder: Joi.array().items(
challengeOrder: Joi.array()
.items(
Joi.object({}).keys({
id: Joi.string(),
title: Joi.string()
})
),
)
.min(1)
.required(),
disableLoopProtectTests: Joi.boolean(),
disableLoopProtectPreview: Joi.boolean(),
superOrder: Joi.number()
})
.required()
});
const subSchema = Joi.object({}).keys({
@@ -7,7 +7,8 @@ const slugRE = new RegExp('^[a-z0-9-]+$');
const blockSchema = Joi.object().keys({
intro: Joi.array().min(1),
meta: Joi.object({}).keys({
meta: Joi.object({})
.keys({
name: Joi.string().required(),
isUpcomingChange: Joi.bool().required(),
usesMultifileEditor: Joi.bool().optional(),
@@ -55,15 +56,19 @@ const blockSchema = Joi.object().keys({
otherwise: Joi.optional()
}),
challengeOrder: Joi.array().items(
Joi.object({}).keys({
Joi.object({})
.keys({
id: Joi.string(),
title: Joi.string()
})
.min(1)
.required()
),
disableLoopProtectTests: Joi.boolean(),
disableLoopProtectPreview: Joi.boolean(),
superOrder: Joi.number()
})
.required()
});
const blockBasedCurriculumSchema = Joi.object().pattern(