From f4dc57bc505f4876384e8d342c43f41e003358d0 Mon Sep 17 00:00:00 2001 From: Tom <20648924+moT01@users.noreply.github.com> Date: Wed, 4 Jun 2025 05:13:21 -0500 Subject: [PATCH] fix(curriculum): hide upcoming blocks (#60684) Co-authored-by: Huyen Nguyen <25715018+huyenltnguyen@users.noreply.github.com> --- .../_meta/lab-color-picker/meta.json | 2 +- .../_meta/lab-currency-converter/meta.json | 2 +- .../challenges/_meta/lab-event-rsvp/meta.json | 4 ++-- .../_meta/lab-tic-tac-toe/meta.json | 2 +- .../workshop-shopping-list-app/meta.json | 2 +- curriculum/get-challenges.js | 21 +++++++++++++++++-- curriculum/utils.js | 4 ++-- curriculum/utils.test.ts | 11 +++++++--- 8 files changed, 35 insertions(+), 13 deletions(-) diff --git a/curriculum/challenges/_meta/lab-color-picker/meta.json b/curriculum/challenges/_meta/lab-color-picker/meta.json index 9e5e60fdf2f..bba132ca621 100644 --- a/curriculum/challenges/_meta/lab-color-picker/meta.json +++ b/curriculum/challenges/_meta/lab-color-picker/meta.json @@ -1,6 +1,6 @@ { "name": "Build a Color Picker App", - "isUpcomingChange": false, + "isUpcomingChange": true, "usesMultifileEditor": true, "dashedName": "lab-color-picker", "superBlock": "full-stack-developer", diff --git a/curriculum/challenges/_meta/lab-currency-converter/meta.json b/curriculum/challenges/_meta/lab-currency-converter/meta.json index b6fb8428721..096bb2b5d4a 100644 --- a/curriculum/challenges/_meta/lab-currency-converter/meta.json +++ b/curriculum/challenges/_meta/lab-currency-converter/meta.json @@ -10,7 +10,7 @@ } ], "helpCategory": "JavaScript", - "isUpcomingChange": false, + "isUpcomingChange": true, "blockLayout": "link", "blockType": "lab" } diff --git a/curriculum/challenges/_meta/lab-event-rsvp/meta.json b/curriculum/challenges/_meta/lab-event-rsvp/meta.json index 90c7dc4fcfd..e1936ef257c 100644 --- a/curriculum/challenges/_meta/lab-event-rsvp/meta.json +++ b/curriculum/challenges/_meta/lab-event-rsvp/meta.json @@ -10,7 +10,7 @@ } ], "helpCategory": "JavaScript", - "isUpcomingChange": false, + "isUpcomingChange": true, "blockLayout": "link", "blockType": "lab" -} \ No newline at end of file +} diff --git a/curriculum/challenges/_meta/lab-tic-tac-toe/meta.json b/curriculum/challenges/_meta/lab-tic-tac-toe/meta.json index 1cd2952a19d..3e27ca7f1d7 100644 --- a/curriculum/challenges/_meta/lab-tic-tac-toe/meta.json +++ b/curriculum/challenges/_meta/lab-tic-tac-toe/meta.json @@ -10,7 +10,7 @@ } ], "helpCategory": "JavaScript", - "isUpcomingChange": false, + "isUpcomingChange": true, "blockLayout": "link", "blockType": "lab" } diff --git a/curriculum/challenges/_meta/workshop-shopping-list-app/meta.json b/curriculum/challenges/_meta/workshop-shopping-list-app/meta.json index 13a97b7040e..e5789f3a711 100644 --- a/curriculum/challenges/_meta/workshop-shopping-list-app/meta.json +++ b/curriculum/challenges/_meta/workshop-shopping-list-app/meta.json @@ -2,7 +2,7 @@ "name": "Build a Shopping List App", "blockType": "workshop", "blockLayout": "challenge-grid", - "isUpcomingChange": false, + "isUpcomingChange": true, "usesMultifileEditor": true, "hasEditableBoundaries": true, "dashedName": "workshop-shopping-list-app", diff --git a/curriculum/get-challenges.js b/curriculum/get-challenges.js index 755ec3e0838..6c98a34d249 100644 --- a/curriculum/get-challenges.js +++ b/curriculum/get-challenges.js @@ -383,14 +383,31 @@ function generateChallengeCreator(lang, englishPath, i18nPath) { function addMetaToChallenge(challenge, meta) { function addChapterAndModuleToChallenge(challenge) { if (chapterBasedSuperBlocks.includes(challenge.superBlock)) { - challenge.chapter = getChapterFromBlock( + const chapter = getChapterFromBlock( challenge.block, fullStackSuperBlockStructure ); - challenge.module = getModuleFromBlock( + + if (!meta.isUpcomingChange && chapter.comingSoon) { + throw Error( + `The '${chapter.dashedName}' chapter is 'comingSoon', but its '${meta.dashedName}' block is not hidden. Set 'isUpcomingChange' to 'true' in the 'meta.json' for the block to hide it.` + ); + } + + challenge.chapter = chapter.dashedName; + + const module = getModuleFromBlock( challenge.block, fullStackSuperBlockStructure ); + + if (!meta.isUpcomingChange && module.comingSoon) { + throw Error( + `The '${chapter.dashedName}' module is 'comingSoon', but its '${meta.dashedName}' block is not hidden. Set 'isUpcomingChange' to 'true' in the 'meta.json' for the block to hide it.` + ); + } + + challenge.module = module.dashedName; } } const challengeOrder = findIndex( diff --git a/curriculum/utils.js b/curriculum/utils.js index b3360aaa469..e67c2fff511 100644 --- a/curriculum/utils.js +++ b/curriculum/utils.js @@ -110,7 +110,7 @@ function getChapterFromBlock(blockName, superBlockStructure) { `There is no chapter corresponding to block "${blockName}". It's possible that the block is missing in the superblock structure.` ); } - return chapter.dashedName; + return { dashedName: chapter.dashedName, comingSoon: chapter.comingSoon }; } function getModuleFromBlock(blockName, superBlockStructure) { @@ -125,7 +125,7 @@ function getModuleFromBlock(blockName, superBlockStructure) { `There is no module corresponding to block "${blockName}". It's possible that the block is missing in the superblock structure.` ); } - return module.dashedName; + return { dashedName: module.dashedName, comingSoon: module.comingSoon }; } function getBlockOrder(blockName, superBlockStructure) { diff --git a/curriculum/utils.test.ts b/curriculum/utils.test.ts index babca8c3bec..c71567d3bf5 100644 --- a/curriculum/utils.test.ts +++ b/curriculum/utils.test.ts @@ -74,6 +74,7 @@ const mockSuperBlockStructure = { }, { dashedName: 'css', + comingSoon: true, modules: [ { dashedName: 'module-one', @@ -88,6 +89,7 @@ const mockSuperBlockStructure = { }, { dashedName: 'module-two', + comingSoon: true, blocks: [ { dashedName: 'block-one-m2' @@ -218,8 +220,8 @@ describe('getSuperBlockFromPath', () => { describe('getChapterFromBlock', () => { it('returns a chapter if it exists', () => { expect( - getChapterFromBlock('welcome-to-freecodecamp', mockSuperBlockStructure) - ).toEqual('html'); + getChapterFromBlock('block-one-m1', mockSuperBlockStructure) + ).toStrictEqual({ dashedName: 'css', comingSoon: true }); }); it('throws if a chapter does not exist', () => { @@ -235,7 +237,10 @@ describe('getModuleFromBlock', () => { it('returns a module if it exists', () => { expect( getModuleFromBlock('welcome-to-freecodecamp', mockSuperBlockStructure) - ).toEqual('getting-started-with-freecodecamp'); + ).toStrictEqual({ + dashedName: 'getting-started-with-freecodecamp', + comingSoon: undefined + }); }); it('throws if a module does not exist', () => {