Skip to content

Commit

Permalink
feat: update save button state for certificate info
Browse files Browse the repository at this point in the history
PROD-3419
  • Loading branch information
uzairr committed Apr 1, 2024
1 parent b3f2bb8 commit 31b34c1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/data/actions/courseInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,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 +137,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 31b34c1

Please sign in to comment.