From 1e66a94fc2bd1b27d4614d2a84dd1edbea0a3aaa Mon Sep 17 00:00:00 2001 From: Ali Akbar Date: Wed, 19 Feb 2025 14:57:45 +0500 Subject: [PATCH] feat: make level type and primary subjects field optional for masters courses --- .../EditCoursePage/EditCourseForm.jsx | 4 +-- .../EditCoursePage/EditCourseForm.test.jsx | 31 +++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/components/EditCoursePage/EditCourseForm.jsx b/src/components/EditCoursePage/EditCourseForm.jsx index 12b94d2d8..2270ce46e 100644 --- a/src/components/EditCoursePage/EditCourseForm.jsx +++ b/src/components/EditCoursePage/EditCourseForm.jsx @@ -1007,7 +1007,7 @@ export class BaseEditCourseForm extends React.Component { extraInput={{ onInvalid: this.openCollapsible }} options={levelTypeOptions} disabled={disabled} - required={isSubmittingForReview} + required={showMarketingFields && isSubmittingForReview} /> { />); expect(shallowToJson(component)).toMatchSnapshot(); }); + + it('does not add required prop for level_type and subjectPrimary fields when not submitting for review', () => { + const initialValuesWithMasters = { + ...initialValuesFull, + type: '7b41992e-f268-4331-8ba9-72acb0880454', + }; + + const component = shallow( + null} + title="Test Course" + initialValues={{ title: initialValuesFull.title }} + currentFormValues={initialValuesWithMasters} + number="Test101x" + courseStatuses={[UNPUBLISHED]} + courseInfo={courseInfo} + courseOptions={courseOptions} + courseRunOptions={courseRunOptions} + uuid={initialValuesWithMasters.uuid} + type={initialValuesWithMasters.type} + isSubmittingForReview={false} + id="edit-course-form" + /> + ); + + const levelTypeField = component.find(Field).filterWhere(n => n.prop('name') === 'level_type'); + const subjectPrimaryField = component.find(Field).filterWhere(n => n.prop('name') === 'subjectPrimary'); + + expect(levelTypeField.prop('required')).toBe(false); + expect(subjectPrimaryField.prop('required')).toBe(false); + }); });