From ccd91ce5758313e1d6004a63cb3c821cc4385f0e Mon Sep 17 00:00:00 2001 From: Syed Muhammad Dawoud Sheraz Ali <40599381+DawoudSheraz@users.noreply.github.com> Date: Fri, 25 Aug 2023 11:44:29 +0500 Subject: [PATCH] feat: do not require staff when submitting runs (#908) * feat: do not require staff when submitting runs * chore: Ensure optional tag appears for staff field --- .../EditCoursePage/CollapsibleCourseRun.jsx | 1 + .../CollapsibleCourseRun.test.jsx.snap | 14 ++-- src/utils/validation.js | 14 +--- src/utils/validation.test.js | 72 +------------------ 4 files changed, 12 insertions(+), 89 deletions(-) diff --git a/src/components/EditCoursePage/CollapsibleCourseRun.jsx b/src/components/EditCoursePage/CollapsibleCourseRun.jsx index 2e5a8317f..507287308 100644 --- a/src/components/EditCoursePage/CollapsibleCourseRun.jsx +++ b/src/components/EditCoursePage/CollapsibleCourseRun.jsx @@ -440,6 +440,7 @@ class CollapsibleCourseRun extends React.Component {

)} + optional /> } id="test-course.staff.label" - optional={false} + optional={true} text="Staff" /> } id="test-course.staff.label" - optional={false} + optional={true} text="Staff" /> } id="test-course.staff.label" - optional={false} + optional={true} text="Staff" /> } id="test-course.staff.label" - optional={false} + optional={true} text="Staff" /> } id="test-course.staff.label" - optional={false} + optional={true} text="Staff" /> } id="test-course.staff.label" - optional={false} + optional={true} text="Staff" /> } id="test-course.staff.label" - optional={false} + optional={true} text="Staff" /> { }; const editCourseValidate = (values, props) => { - const { targetRun, registeredFields } = props; + const { targetRun } = props; if (!targetRun || targetRun.status === PUBLISHED) { return {}; @@ -156,17 +156,7 @@ const editCourseValidate = (values, props) => { const { key: targetKey } = targetRun; const isSubmittingRun = run.key === targetKey; if (isSubmittingRun) { - // naive check to deteremine if track is executive education or not - const isExecutiveEducation = registeredFields - && registeredFields['prices.paid-executive-education'] - && registeredFields['prices.paid-executive-education'].count; - - // naive check to deteremine if track is bootcamp or not - const isBootcamp = registeredFields - && registeredFields['prices.paid-bootcamp'] - && registeredFields['prices.paid-bootcamp'].count; - - const runRequiredFields = (isExecutiveEducation || isBootcamp) ? ['transcript_languages'] : ['transcript_languages', 'staff']; + const runRequiredFields = ['transcript_languages']; const runErrors = {}; runRequiredFields.forEach((fieldName) => { const value = run[fieldName]; diff --git a/src/utils/validation.test.js b/src/utils/validation.test.js index 7c61649b0..cdfb86cfa 100644 --- a/src/utils/validation.test.js +++ b/src/utils/validation.test.js @@ -187,7 +187,7 @@ describe('editCourseValidate', () => { expect(editCourseValidate(values, { targetRun: unpublishedTargetRun })).toEqual(expectedErrors); }); - it('returns errors on submitting course runs with missing staff', () => { + it('does not return error when submitting course runs with missing staff', () => { const values = { short_description: 'Short', full_description: 'Full', @@ -209,75 +209,7 @@ describe('editCourseValidate', () => { ], }; - const expectedErrors = { - course_runs: [ - null, - { - staff: requiredMessage, - }, - ], - }; - expect(editCourseValidate(values, { targetRun: unpublishedTargetRun })).toEqual(expectedErrors); - }); - it('returns no error on submitting 2U executive education course runs with missing staff', () => { - const values = { - short_description: 'Short', - full_description: 'Full', - outcome: 'Outcome', - imageSrc: 'base64;encodedimage', - course_runs: [ - { - key: 'NonSubmittingTestRun', - }, - { - key: 'TestRun', - transcript_languages: [ - { - dummy_field: 'Transcript languages dummy field', - }, - ], - staff: [], - }, - ], - }; - expect(editCourseValidate(values, { - targetRun: unpublishedTargetRun, - registeredFields: { - 'prices.paid-executive-education': { - count: 1, - }, - }, - })).toEqual({}); - }); - it('returns no error on submitting 2U bootcamp runs with missing staff', () => { - const values = { - short_description: 'Short', - full_description: 'Full', - outcome: 'Outcome', - imageSrc: 'base64;encodedimage', - course_runs: [ - { - key: 'NonSubmittingTestRun', - }, - { - key: 'TestRun', - transcript_languages: [ - { - dummy_field: 'Transcript languages dummy field', - }, - ], - staff: [], - }, - ], - }; - expect(editCourseValidate(values, { - targetRun: unpublishedTargetRun, - registeredFields: { - 'prices.paid-bootcamp': { - count: 1, - }, - }, - })).toEqual({}); + expect(editCourseValidate(values, { targetRun: unpublishedTargetRun })).toEqual({}); }); test.each([