Skip to content

Commit

Permalink
feat: skip staff checks on publisher for Bootcamps
Browse files Browse the repository at this point in the history
  • Loading branch information
ansabgillani committed Jun 1, 2022
1 parent da2c3f2 commit 20b4ada
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/utils/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,12 @@ const editCourseValidate = (values, props) => {
&& registeredFields['prices.paid-executive-education']
&& registeredFields['prices.paid-executive-education'].count;

const runRequiredFields = isExecutiveEducation ? ['transcript_languages'] : ['transcript_languages', 'staff'];
// 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 runErrors = {};
runRequiredFields.forEach((fieldName) => {
const value = run[fieldName];
Expand Down
30 changes: 30 additions & 0 deletions src/utils/validation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,4 +248,34 @@ describe('editCourseValidate', () => {
},
})).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({});
});
});

0 comments on commit 20b4ada

Please sign in to comment.