From e1e2292b698484d2bc1f8fe67e0cba89625f0f9d Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Thu, 9 Oct 2025 12:42:09 +0200 Subject: [PATCH] fix(curriculum): filter by challengeId when building blocks (#62622) --- curriculum/test/test-challenges.js | 8 +++++--- curriculum/test/utils/generate-block-tests.mjs | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/curriculum/test/test-challenges.js b/curriculum/test/test-challenges.js index 0eb3cb23d43..0bd630c467a 100644 --- a/curriculum/test/test-challenges.js +++ b/curriculum/test/test-challenges.js @@ -60,14 +60,16 @@ async function newPageContext() { return globalThis.__fccPuppeteerPages[poolId]; } -export async function defineTestsForBlock({ block }) { +export async function defineTestsForBlock(testFilter) { const lang = testedLang(); - const challenges = await getChallenges(lang, { block }); + const challenges = await getChallenges(lang, testFilter); const nonCertificationChallenges = challenges.filter( ({ challengeType }) => challengeType !== 7 ); if (isEmpty(nonCertificationChallenges)) { - console.warn(`No non-certification challenges to test for block ${block}.`); + console.warn( + `No non-certification challenges to test for block ${testFilter.block}.` + ); describe('Check challenges', () => { it('No non-certification challenges to test', () => {}); }); diff --git a/curriculum/test/utils/generate-block-tests.mjs b/curriculum/test/utils/generate-block-tests.mjs index c92bfd451ab..60bb794cd15 100644 --- a/curriculum/test/utils/generate-block-tests.mjs +++ b/curriculum/test/utils/generate-block-tests.mjs @@ -32,17 +32,17 @@ async function main() { for (const block of blocks) { const filePath = path.join(GENERATED_DIR, `${block}.test.js`); - const contents = generateSingleBlockFile({ block }); + const contents = generateSingleBlockFile({ ...testFilter, block }); await fs.promises.writeFile(filePath, contents, 'utf8'); } console.log(`Generated ${blocks.length} block test file(s).`); } -function generateSingleBlockFile({ block }) { +function generateSingleBlockFile(testFilter) { return `import { defineTestsForBlock } from '../test-challenges.js'; -await defineTestsForBlock({ block: ${JSON.stringify(block)} }); +await defineTestsForBlock(${JSON.stringify(testFilter)}); `; }