From b334ef64ff8f874b9a8a00993fe25867a66e7826 Mon Sep 17 00:00:00 2001 From: Shaun Hamilton Date: Fri, 26 Apr 2024 09:30:10 +0200 Subject: [PATCH] refactor(client): remove hasNoTests by challenge type (#54494) Co-authored-by: Naomi --- .../Challenges/redux/completion-epic.js | 6 +--- .../challenge-schema.test.js.snap | 28 ++++++++++--------- curriculum/schema/challenge-schema.js | 28 ++++++++++--------- shared/config/challenge-types.ts | 7 ----- 4 files changed, 31 insertions(+), 38 deletions(-) diff --git a/client/src/templates/Challenges/redux/completion-epic.js b/client/src/templates/Challenges/redux/completion-epic.js index 1a6de6bdc07..9b6767f11bc 100644 --- a/client/src/templates/Challenges/redux/completion-epic.js +++ b/client/src/templates/Challenges/redux/completion-epic.js @@ -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' }); } diff --git a/curriculum/schema/__snapshots__/challenge-schema.test.js.snap b/curriculum/schema/__snapshots__/challenge-schema.test.js.snap index 267c56deba8..3b460fffdb1 100644 --- a/curriculum/schema/__snapshots__/challenge-schema.test.js.snap +++ b/curriculum/schema/__snapshots__/challenge-schema.test.js.snap @@ -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(), diff --git a/curriculum/schema/challenge-schema.js b/curriculum/schema/challenge-schema.js index f873cfa1efb..1d64e028a0c 100644 --- a/curriculum/schema/challenge-schema.js +++ b/curriculum/schema/challenge-schema.js @@ -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(), diff --git a/shared/config/challenge-types.ts b/shared/config/challenge-types.ts index 8d2c7977d99..267034c6189 100644 --- a/shared/config/challenge-types.ts +++ b/shared/config/challenge-types.ts @@ -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,