fix(challenges): update nextChallenge logic to ignore beta
This commit is contained in:
@ -78,7 +78,11 @@ export function getNextChallenge(
|
|||||||
// skip is used to skip isComingSoon challenges
|
// skip is used to skip isComingSoon challenges
|
||||||
block.challenges[ index + 1 + skip ]
|
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
|
// if we find a next challenge and it is a coming soon
|
||||||
// recur with plus one to skip this challenge
|
// recur with plus one to skip this challenge
|
||||||
return getNextChallenge(current, entities, { isDev, skip: skip + 1 });
|
return getNextChallenge(current, entities, { isDev, skip: skip + 1 });
|
||||||
|
@ -18,7 +18,7 @@ import {
|
|||||||
|
|
||||||
test('common/app/routes/challenges/utils', function(t) {
|
test('common/app/routes/challenges/utils', function(t) {
|
||||||
t.test('getNextChallenge', t => {
|
t.test('getNextChallenge', t => {
|
||||||
t.plan(5);
|
t.plan(7);
|
||||||
t.test('should return falsey when current challenge is not found', t => {
|
t.test('should return falsey when current challenge is not found', t => {
|
||||||
t.plan(1);
|
t.plan(1);
|
||||||
const entities = {
|
const entities = {
|
||||||
@ -166,6 +166,80 @@ test('common/app/routes/challenges/utils', function(t) {
|
|||||||
comingSoon
|
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 => {
|
t.test('getFirstChallengeOfNextBlock', t => {
|
||||||
|
Reference in New Issue
Block a user