diff --git a/common/app/routes/challenges/utils.js b/common/app/routes/challenges/utils.js index 9b2355e133..bad207fe6f 100644 --- a/common/app/routes/challenges/utils.js +++ b/common/app/routes/challenges/utils.js @@ -78,7 +78,11 @@ export function getNextChallenge( // skip is used to skip isComingSoon challenges block.challenges[ index + 1 + skip ] ]; - if (!isDev && nextChallenge && nextChallenge.isComingSoon) { + if ( + !isDev && + nextChallenge && + (nextChallenge.isComingSoon || nextChallenge.isBeta) + ) { // if we find a next challenge and it is a coming soon // recur with plus one to skip this challenge return getNextChallenge(current, entities, { isDev, skip: skip + 1 }); diff --git a/common/app/routes/challenges/utils.test.js b/common/app/routes/challenges/utils.test.js index d802692b45..d4680597b9 100644 --- a/common/app/routes/challenges/utils.test.js +++ b/common/app/routes/challenges/utils.test.js @@ -18,7 +18,7 @@ import { test('common/app/routes/challenges/utils', function(t) { t.test('getNextChallenge', t => { - t.plan(5); + t.plan(7); t.test('should return falsey when current challenge is not found', t => { t.plan(1); const entities = { @@ -166,6 +166,80 @@ test('common/app/routes/challenges/utils', function(t) { comingSoon ); }); + t.test('should skip isBeta challenge', t => { + t.plan(1); + const currentChallenge = { + dashedName: 'current-challenge', + block: 'current-block' + }; + const beta = { + dashedName: 'beta-challenge', + isBeta: true, + block: 'current-block' + }; + const nextChallenge = { + dashedName: 'next-challenge', + block: 'current-block' + }; + const shouldBeNext = getNextChallenge( + 'current-challenge', + { + challenge: { + 'current-challenge': currentChallenge, + 'next-challenge': nextChallenge, + 'beta-challenge': beta, + 'beta-challenge2': beta + }, + block: { + 'current-block': { + challenges: [ + 'current-challenge', + 'beta-challenge', + 'beta-challenge2', + 'next-challenge' + ] + } + } + } + ); + t.isEqual(shouldBeNext, nextChallenge); + }); + t.test('should not skip isBeta challenge if in dev', t => { + t.plan(1); + const currentChallenge = { + dashedName: 'current-challenge', + block: 'current-block' + }; + const beta = { + dashedName: 'beta-challenge', + isBeta: true, + block: 'current-block' + }; + const nextChallenge = { + dashedName: 'next-challenge', + block: 'current-block' + }; + const entities = { + challenge: { + 'current-challenge': currentChallenge, + 'next-challenge': nextChallenge, + 'beta-challenge': beta + }, + block: { + 'current-block': { + challenges: [ + 'current-challenge', + 'beta-challenge', + 'next-challenge' + ] + } + } + }; + t.isEqual( + getNextChallenge('current-challenge', entities, { isDev: true }), + beta + ); + }); }); t.test('getFirstChallengeOfNextBlock', t => {