mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2025-12-30 03:03:06 -05:00
fix: allow submissions to complete if signed out (#51260)
This commit is contained in:
committed by
GitHub
parent
b89f91cb11
commit
fd58cffd2d
@@ -211,7 +211,9 @@ export default function completionEpic(action$, state$) {
|
||||
block,
|
||||
blockHashSlug
|
||||
} = challengeMetaSelector(state);
|
||||
let submitter = () => of({ type: 'no-user-signed-in' });
|
||||
// Default to submitChallengeComplete since we do not want the user to
|
||||
// be stuck in the 'isSubmitting' state.
|
||||
let submitter = () => of(submitChallengeComplete());
|
||||
if (
|
||||
!(challengeType in submitTypes) ||
|
||||
!(submitTypes[challengeType] in submitters)
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
import { TestScheduler } from 'rxjs/testing';
|
||||
import completionEpic from './completion-epic';
|
||||
import { submitChallenge, submitChallengeComplete } from './actions';
|
||||
|
||||
describe('completionEpic', () => {
|
||||
describe('signed out user', () => {
|
||||
const testScheduler = new TestScheduler((actual, expected) => {
|
||||
it('should dispatch submitChallengeComplete', () => {
|
||||
expect(actual).toEqual(expect.arrayContaining(expected));
|
||||
});
|
||||
});
|
||||
|
||||
testScheduler.run(({ hot, expectObservable }) => {
|
||||
const action$ = hot('a', {
|
||||
a: submitChallenge()
|
||||
});
|
||||
const state$ = {
|
||||
value: {
|
||||
challenge: { challengeMeta: { challengeType: 0 } },
|
||||
app: { user: { username: 'test' } }
|
||||
}
|
||||
};
|
||||
|
||||
const output$ = completionEpic(action$, state$);
|
||||
|
||||
expectObservable(output$).toBe('a', {
|
||||
a: submitChallengeComplete()
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user