fix: allow submissions to complete if signed out (#51260)

This commit is contained in:
Oliver Eyton-Williams
2023-08-14 14:18:35 +02:00
committed by GitHub
parent b89f91cb11
commit fd58cffd2d
2 changed files with 34 additions and 1 deletions

View File

@@ -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)

View File

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