Skip to content

Commit

Permalink
feat: make level type and primary subjects field optional for masters…
Browse files Browse the repository at this point in the history
… courses
  • Loading branch information
Ali-D-Akbar committed Feb 24, 2025
1 parent 5c19a5c commit 1e66a94
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/EditCoursePage/EditCourseForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,7 @@ export class BaseEditCourseForm extends React.Component {
extraInput={{ onInvalid: this.openCollapsible }}
options={levelTypeOptions}
disabled={disabled}
required={isSubmittingForReview}
required={showMarketingFields && isSubmittingForReview}
/>
<Field
name="subjectPrimary"
Expand Down Expand Up @@ -1040,7 +1040,7 @@ export class BaseEditCourseForm extends React.Component {
extraInput={{ onInvalid: this.openCollapsible }}
options={subjectOptions}
disabled={disabled}
required={isSubmittingForReview}
required={showMarketingFields && isSubmittingForReview}
/>
<Field
name="subjectSecondary"
Expand Down
31 changes: 31 additions & 0 deletions src/components/EditCoursePage/EditCourseForm.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -494,4 +494,35 @@ describe('BaseEditCourseForm', () => {
/>);
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(
<BaseEditCourseForm
handleSubmit={() => 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"
/>

Check failure on line 519 in src/components/EditCoursePage/EditCourseForm.test.jsx

View workflow job for this annotation

GitHub Actions / tests

Missing trailing comma
);

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);
});
});

0 comments on commit 1e66a94

Please sign in to comment.