fix(curriculum): filter by challengeId when building blocks (#62622)

This commit is contained in:
Oliver Eyton-Williams
2025-10-09 12:42:09 +02:00
committed by GitHub
parent 9c31ffdf8d
commit e1e2292b69
2 changed files with 8 additions and 6 deletions

View File

@@ -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', () => {});
});

View File

@@ -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)});
`;
}