fix: store completed js projects in redux (#44496)

* fix: store completed js projects in redux

These were missed when we migrated from files to challengeFiles

* test: put the data-cy on the correct button

Rather than the fallback. The tests were only passing because the
fallback was kicking in and, since that was fixed, the tests started to
fail!
This commit is contained in:
Oliver Eyton-Williams
2021-12-15 00:59:53 +01:00
committed by GitHub
parent 5bf5b36c9c
commit b57cf4ffa7
3 changed files with 20 additions and 11 deletions

View File

@ -65,6 +65,7 @@ const ShowProjectLinks = (props: ShowProjectLinksProps): JSX.Element => {
return (
<button
className='project-link-button-override'
data-cy={`${projectTitle} solution`}
onClick={onClickHandler}
>
{t('certification.project.solution')}
@ -97,11 +98,7 @@ const ShowProjectLinks = (props: ShowProjectLinksProps): JSX.Element => {
);
}
return (
<button
className='project-link-button-override'
data-cy={`${projectTitle} solution`}
onClick={onClickHandler}
>
<button className='project-link-button-override' onClick={onClickHandler}>
{t('certification.project.solution')}
</button>
);

View File

@ -1,3 +1,4 @@
import { omit } from 'lodash-es';
import { call, delay, put, takeLatest, takeEvery } from 'redux-saga/effects';
import { createFlashMessage } from '../../components/Flash/redux';
@ -85,7 +86,13 @@ function* verifyCertificationSaga({ payload }) {
yield put(
verifyCertComplete({
...response,
payload: { ...isCertMap, completedChallenges }
payload: {
...isCertMap,
completedChallenges: completedChallenges.map(x => ({
...omit(x, 'files'),
challengeFiles: x.files ?? null
}))
}
})
);
yield put(createFlashMessage(response));

View File

@ -1,4 +1,5 @@
import { navigate } from 'gatsby';
import { omit } from 'lodash-es';
import { ofType } from 'redux-observable';
import { of, empty } from 'rxjs';
import {
@ -35,16 +36,20 @@ import {
function postChallenge(update, username) {
const saveChallenge = postUpdate$(update).pipe(
retry(3),
switchMap(({ points }) =>
of(
switchMap(({ points }) => {
const payloadWithClientProperties = {
...omit(update.payload, ['files']),
challengeFiles: update.payload.files ?? null
};
return of(
submitComplete({
username,
points,
...update.payload
...payloadWithClientProperties
}),
updateComplete()
)
),
);
}),
catchError(() => of(updateFailed(update)))
);
return saveChallenge;