From 0156e14a1cef32edd35f7eab87ba10cced82ebfe Mon Sep 17 00:00:00 2001
From: Mubbshar Anwar <78487564+mubbsharanwar@users.noreply.github.com>
Date: Wed, 29 Sep 2021 12:02:26 +0500
Subject: [PATCH] fix: add upgrade deadline field (#588)
add upgrade deadline date field in course run form.
DISCO-1622
---
.../CreateCoursePage/CreateCourseForm.jsx | 1 +
.../EditCoursePage/CollapsibleCourseRun.jsx | 18 ++
.../EditCoursePage/EditCoursePage.test.jsx | 17 +-
.../CollapsibleCourseRun.test.jsx.snap | 196 ++++++++++++++++++
.../EditCoursePage.test.jsx.snap | 42 ++--
src/components/EditCoursePage/index.jsx | 24 ++-
6 files changed, 280 insertions(+), 18 deletions(-)
diff --git a/src/components/CreateCoursePage/CreateCourseForm.jsx b/src/components/CreateCoursePage/CreateCourseForm.jsx
index 3e3403a5a..7fce8e564 100644
--- a/src/components/CreateCoursePage/CreateCourseForm.jsx
+++ b/src/components/CreateCoursePage/CreateCourseForm.jsx
@@ -326,6 +326,7 @@ BaseCreateCourseForm.propTypes = {
prices: PropTypes.shape(),
start: PropTypes.string,
end: PropTypes.string,
+ upgrade_deadline_override: PropTypes.string,
}).isRequired,
currentFormValues: PropTypes.shape({
org: PropTypes.string,
diff --git a/src/components/EditCoursePage/CollapsibleCourseRun.jsx b/src/components/EditCoursePage/CollapsibleCourseRun.jsx
index 1187fe950..f6b6ccf0f 100644
--- a/src/components/EditCoursePage/CollapsibleCourseRun.jsx
+++ b/src/components/EditCoursePage/CollapsibleCourseRun.jsx
@@ -288,6 +288,15 @@ class CollapsibleCourseRun extends React.Component {
helpText={courseDateEditHelp}
disabled
/>
+
)
// date inputs for all browsers besides safari
@@ -333,6 +342,15 @@ class CollapsibleCourseRun extends React.Component {
helpText={courseDateEditHelp}
disabled
/>
+
)}
diff --git a/src/components/EditCoursePage/EditCoursePage.test.jsx b/src/components/EditCoursePage/EditCoursePage.test.jsx
index 7e0667a65..0867b484e 100644
--- a/src/components/EditCoursePage/EditCoursePage.test.jsx
+++ b/src/components/EditCoursePage/EditCoursePage.test.jsx
@@ -23,6 +23,7 @@ const mockStore = configureStore();
describe('EditCoursePage', () => {
const defaultPrice = '77';
const defaultEnd = '2019-08-14T00:00:00Z';
+ const defaultUpgradeDeadlineOverride = '2019-09-14T00:00:00Z';
const courseInfo = {
data: {
@@ -32,6 +33,7 @@ describe('EditCoursePage', () => {
key: 'edX101+DemoX+T2',
start: '2019-05-14T00:00:00Z',
end: defaultEnd,
+ upgrade_deadline_override: '2019-05-10T00:00:00Z',
expected_program_type: 'micromasters',
expected_program_name: 'Test Program Name',
go_live_date: '2019-05-06T00:00:00Z',
@@ -55,6 +57,7 @@ describe('EditCoursePage', () => {
key: 'edX101+DemoX+T1',
start: '2019-05-14T00:00:00Z',
end: defaultEnd,
+ upgrade_deadline_override: '2019-05-10T00:00:00Z',
expected_program_type: null,
expected_program_name: '',
go_live_date: '2019-05-06T00:00:00Z',
@@ -278,6 +281,7 @@ describe('EditCoursePage', () => {
key: 'edX101+DemoX+T1',
start: '2019-05-14T00:00:00Z',
end: defaultEnd,
+ upgrade_deadline_override: defaultUpgradeDeadlineOverride,
expected_program_type: null,
expected_program_name: '',
go_live_date: '2019-05-06T00:00:00Z',
@@ -376,6 +380,7 @@ describe('EditCoursePage', () => {
status: UNPUBLISHED,
transcript_languages: ['en-us'],
weeks_to_complete: '100',
+ upgrade_deadline_override: defaultUpgradeDeadlineOverride,
},
{
content_language: 'en-us',
@@ -396,6 +401,7 @@ describe('EditCoursePage', () => {
status: PUBLISHED,
transcript_languages: ['en-us'],
weeks_to_complete: '100',
+ upgrade_deadline_override: defaultUpgradeDeadlineOverride,
},
];
@@ -406,11 +412,13 @@ describe('EditCoursePage', () => {
courseData.course_runs[0].end = defaultEnd;
courseData.course_runs[0].status = UNPUBLISHED;
+ courseData.course_runs[0].upgrade_deadline_override = defaultUpgradeDeadlineOverride;
courseData.prices = {
verified: defaultPrice,
};
expectedSendCourseRuns[0].draft = true;
+ expectedSendCourseRuns[0].upgrade_deadline_override = defaultUpgradeDeadlineOverride;
expectedSendCourseRuns[0].prices = {
verified: defaultPrice,
};
@@ -575,7 +583,7 @@ describe('EditCoursePage', () => {
component.instance().handleCourseSubmit(courseData);
expect(mockEditCourse).toHaveBeenCalledWith(
expectedSendCourse,
- [],
+ expectedSendCourseRuns,
false,
false,
component.instance().getData,
@@ -635,12 +643,13 @@ describe('EditCoursePage', () => {
courseData.prices.verified = '500.00';
expectedSendCourse.prices.verified = '500';
+ expectedSendCourseRuns[0].prices = expectedSendCourse.prices;
expectedSendCourseRuns[1].prices = expectedSendCourse.prices;
component.instance().handleCourseSubmit(courseData);
expect(mockEditCourse).toHaveBeenCalledWith(
expectedSendCourse,
- [expectedSendCourseRuns[1]],
+ expectedSendCourseRuns,
false,
false,
component.instance().getData,
@@ -720,7 +729,7 @@ describe('EditCoursePage', () => {
component.instance().handleCourseSubmit(courseData);
expect(mockEditCourse).toHaveBeenCalledWith(
expectedSendCourse,
- [expectedSendCourseRuns[1]],
+ expectedSendCourseRuns,
true,
false,
component.instance().getData,
@@ -752,7 +761,7 @@ describe('EditCoursePage', () => {
component.instance().handleCourseSubmit(courseData);
expect(mockEditCourse).toHaveBeenCalledWith(
expectedSendCourse,
- [expectedSendCourseRuns[0]],
+ expectedSendCourseRuns,
true,
false,
component.instance().getData,
diff --git a/src/components/EditCoursePage/__snapshots__/CollapsibleCourseRun.test.jsx.snap b/src/components/EditCoursePage/__snapshots__/CollapsibleCourseRun.test.jsx.snap
index 2d1305516..af59c25fa 100644
--- a/src/components/EditCoursePage/__snapshots__/CollapsibleCourseRun.test.jsx.snap
+++ b/src/components/EditCoursePage/__snapshots__/CollapsibleCourseRun.test.jsx.snap
@@ -149,6 +149,34 @@ exports[`Collapsible Course Run renders correctly when given a published course
timeLabel="End time (GMT)"
type="text"
/>
+
+
+ Course run dates are editable in Studio.
+
+
+ Please note that changes in Studio may take up to a business day to be reflected here. For questions, contact your project coordinator.
+
+
+
+ Edit dates.
+
+ .
+
+
+ }
+ name="test-course.upgrade_deadline_override"
+ timeLabel="Upgrade deadline override time (GMT)"
+ type="date"
+ />
+
+
+ Course run dates are editable in Studio.
+
+
+ Please note that changes in Studio may take up to a business day to be reflected here. For questions, contact your project coordinator.
+
+
+
+ Edit dates.
+
+ .
+
+
+ }
+ name="test-course.upgrade_deadline_override"
+ timeLabel="Upgrade deadline override time (GMT)"
+ type="date"
+ />
+
+
+ Course run dates are editable in Studio.
+
+
+ Please note that changes in Studio may take up to a business day to be reflected here. For questions, contact your project coordinator.
+
+
+
+ Edit dates.
+
+ .
+
+
+ }
+ name="test-course.upgrade_deadline_override"
+ timeLabel="Upgrade deadline override time (GMT)"
+ type="date"
+ />
+
+
+ Course run dates are editable in Studio.
+
+
+ Please note that changes in Studio may take up to a business day to be reflected here. For questions, contact your project coordinator.
+
+
+
+ Edit dates.
+
+ .
+
+
+ }
+ name="test-course.upgrade_deadline_override"
+ timeLabel="Upgrade deadline override time (GMT)"
+ type="date"
+ />
+
+
+ Course run dates are editable in Studio.
+
+
+ Please note that changes in Studio may take up to a business day to be reflected here. For questions, contact your project coordinator.
+
+
+
+ Edit dates.
+
+ .
+
+
+ }
+ name="test-course.upgrade_deadline_override"
+ timeLabel="Upgrade deadline override time (GMT)"
+ type="date"
+ />
+
+
+ Course run dates are editable in Studio.
+
+
+ Please note that changes in Studio may take up to a business day to be reflected here. For questions, contact your project coordinator.
+
+
+
+ Edit dates.
+
+ .
+
+
+ }
+ name="test-course.upgrade_deadline_override"
+ timeLabel="Upgrade deadline override time (GMT)"
+ type="date"
+ />
+
+
+ Course run dates are editable in Studio.
+
+
+ Please note that changes in Studio may take up to a business day to be reflected here. For questions, contact your project coordinator.
+
+
+
+ Edit dates.
+
+ .
+
+
+ }
+ name="test-course.upgrade_deadline_override"
+ timeLabel="Upgrade deadline override time (GMT)"
+ type="date"
+ />
{
+ const nonAuditSeat = seats.filter(seat => seat.type !== AUDIT_TRACK.key)[0];
+ return nonAuditSeat.upgrade_deadline_override;
+ };
+
+ const buildSeats = (seats) => (
+ seats.length > 0 && seats.map(seat => ({
+ bulk_sku: seat.bulk_sku,
+ credit_hours: seat.credit_hours,
+ credit_provider: seat.credit_provider,
+ currency: seat.currency,
+ price: seat.price,
+ sku: seat.sku,
+ type: seat.type,
+ }))
+ );
+
return course_runs && course_runs.map(courseRun => ({
key: courseRun.key,
start: courseRun.start,
end: courseRun.end,
+ upgrade_deadline_override: courseRun.seats.length > 0 ? getUpgradeDeadlineOverride(courseRun.seats) : null,
expected_program_type: courseRun.expected_program_type,
expected_program_name: courseRun.expected_program_name,
external_key: courseRun.external_key,
@@ -333,7 +353,7 @@ class EditCoursePage extends React.Component {
has_ofac_restrictions: courseRun.has_ofac_restrictions,
ofac_comment: courseRun.ofac_comment,
run_type: courseRun.run_type,
- seats: courseRun.seats,
+ seats: buildSeats(courseRun.seats),
}));
}