refactor(client): remove hasNoTests by challenge type (#54494)

Co-authored-by: Naomi <nhcarrigan@gmail.com>
This commit is contained in:
Shaun Hamilton
2024-04-26 09:30:10 +02:00
committed by GitHub
parent 918e1a473d
commit b334ef64ff
4 changed files with 31 additions and 38 deletions

View File

@@ -17,7 +17,6 @@ import {
} from '../../../utils/error-messages';
import {
challengeTypes,
hasNoTests,
submitTypes
} from '../../../../../shared/config/challenge-types';
import { actionTypes as submitActionTypes } from '../../../redux/action-types';
@@ -100,10 +99,7 @@ function postChallenge(update, username) {
function submitModern(type, state) {
const challengeType = state.challenge.challengeMeta.challengeType;
const tests = challengeTestsSelector(state);
if (
hasNoTests(challengeType) ||
(tests.length > 0 && tests.every(test => test.pass && !test.err))
) {
if (tests.length === 0 || tests.every(test => test.pass && !test.err)) {
if (type === actionTypes.checkChallenge) {
return of({ type: 'this was a check challenge' });
}

View File

@@ -202,19 +202,21 @@ const schema = Joi.object()
superBlock: Joi.string().regex(slugWithSlashRE),
superOrder: Joi.number(),
suborder: Joi.number(),
tests: Joi.array().items(
// public challenges
Joi.object().keys({
id: Joi.string().allow(''),
text: Joi.string().required(),
testString: Joi.string().allow('').required()
}),
// our tests used in certification verification
Joi.object().keys({
id: Joi.string().required(),
title: Joi.string().required()
})
),
tests: Joi.array()
.items(
// public challenges
Joi.object().keys({
id: Joi.string().allow(''),
text: Joi.string().required(),
testString: Joi.string().allow('').required()
}),
// our tests used in certification verification
Joi.object().keys({
id: Joi.string().required(),
title: Joi.string().required()
})
)
.required(),
template: Joi.string().allow(''),
time: Joi.string().allow(''),
title: Joi.string().required(),

View File

@@ -199,19 +199,21 @@ const schema = Joi.object()
superBlock: Joi.string().regex(slugWithSlashRE),
superOrder: Joi.number(),
suborder: Joi.number(),
tests: Joi.array().items(
// public challenges
Joi.object().keys({
id: Joi.string().allow(''),
text: Joi.string().required(),
testString: Joi.string().allow('').required()
}),
// our tests used in certification verification
Joi.object().keys({
id: Joi.string().required(),
title: Joi.string().required()
})
),
tests: Joi.array()
.items(
// public challenges
Joi.object().keys({
id: Joi.string().allow(''),
text: Joi.string().required(),
testString: Joi.string().allow('').required()
}),
// our tests used in certification verification
Joi.object().keys({
id: Joi.string().required(),
title: Joi.string().required()
})
)
.required(),
template: Joi.string().allow(''),
time: Joi.string().allow(''),
title: Joi.string().required(),

View File

@@ -52,13 +52,6 @@ export const challengeTypes = {
multifilePythonCertProject
};
export const hasNoTests = (challengeType: number): boolean =>
challengeType === multipleChoice ||
challengeType === theOdinProject ||
challengeType === video ||
challengeType === dialogue ||
challengeType === fillInTheBlank;
export const hasNoSolution = (challengeType: number): boolean => {
const noSolutions = [
backend,