test(external curricula): run test on all chapters and modules (#60913)

This commit is contained in:
Huyen Nguyen
2025-06-18 22:40:27 +07:00
committed by GitHub
parent e2b9a5e606
commit 92e9ae9e78

View File

@@ -224,38 +224,26 @@ ${result.error.message}`);
superBlock
] as ChapterBasedCurriculumIntros[SuperBlocks];
// Randomly pick a chapter.
const chapters = superBlockData.chapters.filter(
({ comingSoon }) => !comingSoon
);
const randomChapterIndex = Math.floor(Math.random() * chapters.length);
const randomChapter = chapters[randomChapterIndex];
// Randomly pick a module.
const modules = randomChapter.modules.filter(
({ comingSoon }) => !comingSoon
);
const randomModuleIndex = Math.floor(Math.random() * modules.length);
const randomModule = modules[randomModuleIndex];
// Randomly pick a block.
// const blocks = randomModule.blocks;
// const randomBlockIndex = Math.floor(Math.random() * blocks.length);
// const randomBlock = blocks[randomBlockIndex];
// Check super block data
expect(superBlockData.intro).toEqual(superBlockIntros.intro);
// Check chapter data
expect(superBlockData.chapters[randomChapterIndex].name).toEqual(
superBlockIntros.chapters[randomChapter.dashedName]
);
// Loop through all chapters
superBlockData.chapters
.filter(({ comingSoon }) => !comingSoon)
.forEach(chapter => {
expect(chapter.name).toEqual(
superBlockIntros.chapters[chapter.dashedName]
);
// Check module data
expect(
superBlockData.chapters[randomChapterIndex].modules[randomModuleIndex]
.name
).toEqual(superBlockIntros.modules[randomModule.dashedName]);
// Loop through all modules in the chapter
chapter.modules
.filter(({ comingSoon }) => !comingSoon)
.forEach(module => {
expect(module.name).toEqual(
superBlockIntros.modules[module.dashedName]
);
});
});
// Temporary skip these checks to keep CI stable.
// TODO: uncomment these once https://github.com/freeCodeCamp/freeCodeCamp/issues/60660 is completed.