Skip to content

Commit

Permalink
Merge branch 'master' into bilalqamar95/frontend-platform-upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
BilalQamar95 authored Apr 9, 2024
2 parents 6625a14 + ad9b6a3 commit 0ede69b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/data/actions/courseInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ function updateFormValuesAfterSave(change, currentFormValues, initialValues) {
4. url_slug: Auto-generated on backend if not provided
5. tags: To maintain ordering returned by the backend
6. in_year_value: each dict key has default backend value which is not read by form unless changed.
7. additional_metadata.certificate_info: exec-ed courses needs it and is not read by form unless changed.
*/
return (dispatch) => {
const {
Expand All @@ -118,6 +119,12 @@ function updateFormValuesAfterSave(change, currentFormValues, initialValues) {
per_click_usa: perClickUSA,
per_click_international: perClicknternational,
},
additional_metadata: {
certificate_info: {
heading,
blurb,
},
},
} = initialValues;

// This emits a redux action called CHANGE that will update:
Expand All @@ -131,6 +138,8 @@ function updateFormValuesAfterSave(change, currentFormValues, initialValues) {
change('in_year_value.per_lead_international', perLeadInternational);
change('in_year_value.per_click_usa', perClickUSA);
change('in_year_value.per_click_international', perClicknternational);
change('additional_metadata.certificate_info.heading', heading);
change('additional_metadata.certificate_info.blurb', blurb);
for (let i = 0; i < initialCourseRuns.length; i += 1) {
change(`course_runs[${i}].status`, initialCourseRuns[i].status);
change(`course_runs[${i}].transcript_languages`, initialCourseRuns[i].transcript_languages);
Expand Down
12 changes: 10 additions & 2 deletions src/data/actions/courseInfo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ describe('courseInfo edit course actions', () => {
per_click_usa: 25,
per_click_international: 30,
},
additional_metadata: {
certificate_info: {
heading: 'Test Certificate',
blurb: 'test blurb',
},
},
imageSrc: 'http://updated.image.src/woo.small',
course_runs: [
{
Expand All @@ -224,8 +230,10 @@ describe('courseInfo edit course actions', () => {
expect(changeMock).toHaveBeenNthCalledWith(8, 'in_year_value.per_lead_international', 20);
expect(changeMock).toHaveBeenNthCalledWith(9, 'in_year_value.per_click_usa', 25);
expect(changeMock).toHaveBeenNthCalledWith(10, 'in_year_value.per_click_international', 30);
expect(changeMock).toHaveBeenNthCalledWith(11, 'course_runs[0].status', 'published');
expect(changeMock).toHaveBeenNthCalledWith(12, 'course_runs[0].transcript_languages', ['en-us']);
expect(changeMock).toHaveBeenNthCalledWith(11, 'additional_metadata.certificate_info.heading', 'Test Certificate');
expect(changeMock).toHaveBeenNthCalledWith(12, 'additional_metadata.certificate_info.blurb', 'test blurb');
expect(changeMock).toHaveBeenNthCalledWith(13, 'course_runs[0].status', 'published');
expect(changeMock).toHaveBeenNthCalledWith(14, 'course_runs[0].transcript_languages', ['en-us']);
});
});

Expand Down

0 comments on commit 0ede69b

Please sign in to comment.