Skip to content

Commit

Permalink
fix: add upgrade deadline field (#588)
Browse files Browse the repository at this point in the history
add upgrade deadline date field in course run form.

DISCO-1622
  • Loading branch information
mubbsharanwar authored Sep 29, 2021
1 parent f2a4c85 commit 0156e14
Show file tree
Hide file tree
Showing 6 changed files with 280 additions and 18 deletions.
1 change: 1 addition & 0 deletions src/components/CreateCoursePage/CreateCourseForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 18 additions & 0 deletions src/components/EditCoursePage/CollapsibleCourseRun.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,15 @@ class CollapsibleCourseRun extends React.Component {
helpText={courseDateEditHelp}
disabled
/>
<Field
name={`${courseId}.upgrade_deadline_override`}
type="date"
component={DateTimeField}
dateLabel="Upgrade deadline override date"
timeLabel={`Upgrade deadline override time (${localTimeZone})`}
helpText={courseDateEditHelp}
disabled={!administrator || disabled}
/>
</div>
)
// date inputs for all browsers besides safari
Expand Down Expand Up @@ -333,6 +342,15 @@ class CollapsibleCourseRun extends React.Component {
helpText={courseDateEditHelp}
disabled
/>
<Field
name={`${courseId}.upgrade_deadline_override`}
type="date"
component={DateTimeField}
dateLabel="Upgrade deadline override date"
timeLabel={`Upgrade deadline override time (${localTimeZone})`}
helpText={courseDateEditHelp}
disabled={!administrator || disabled}
/>
</div>
)}
<hr />
Expand Down
17 changes: 13 additions & 4 deletions src/components/EditCoursePage/EditCoursePage.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -376,6 +380,7 @@ describe('EditCoursePage', () => {
status: UNPUBLISHED,
transcript_languages: ['en-us'],
weeks_to_complete: '100',
upgrade_deadline_override: defaultUpgradeDeadlineOverride,
},
{
content_language: 'en-us',
Expand All @@ -396,6 +401,7 @@ describe('EditCoursePage', () => {
status: PUBLISHED,
transcript_languages: ['en-us'],
weeks_to_complete: '100',
upgrade_deadline_override: defaultUpgradeDeadlineOverride,
},
];

Expand All @@ -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,
};
Expand Down Expand Up @@ -575,7 +583,7 @@ describe('EditCoursePage', () => {
component.instance().handleCourseSubmit(courseData);
expect(mockEditCourse).toHaveBeenCalledWith(
expectedSendCourse,
[],
expectedSendCourseRuns,
false,
false,
component.instance().getData,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -720,7 +729,7 @@ describe('EditCoursePage', () => {
component.instance().handleCourseSubmit(courseData);
expect(mockEditCourse).toHaveBeenCalledWith(
expectedSendCourse,
[expectedSendCourseRuns[1]],
expectedSendCourseRuns,
true,
false,
component.instance().getData,
Expand Down Expand Up @@ -752,7 +761,7 @@ describe('EditCoursePage', () => {
component.instance().handleCourseSubmit(courseData);
expect(mockEditCourse).toHaveBeenCalledWith(
expectedSendCourse,
[expectedSendCourseRuns[0]],
expectedSendCourseRuns,
true,
false,
component.instance().getData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,34 @@ exports[`Collapsible Course Run renders correctly when given a published course
timeLabel="End time (GMT)"
type="text"
/>
<Field
component={[Function]}
dateLabel="Upgrade deadline override date"
disabled={true}
helpText={
<div>
<p>
Course run dates are editable in Studio.
</p>
<p>
Please note that changes in Studio may take up to a business day to be reflected here. For questions, contact your project coordinator.
</p>
<p>
<a
href="http://localhost:18010/settings/details/edX101+DemoX#schedule"
rel="noopener noreferrer"
target="_blank"
>
Edit dates.
</a>
.
</p>
</div>
}
name="test-course.upgrade_deadline_override"
timeLabel="Upgrade deadline override time (GMT)"
type="date"
/>
</div>
<hr />
<Field
Expand Down Expand Up @@ -669,6 +697,34 @@ exports[`Collapsible Course Run renders correctly when given an unpublished cour
timeLabel="End time (GMT)"
type="text"
/>
<Field
component={[Function]}
dateLabel="Upgrade deadline override date"
disabled={true}
helpText={
<div>
<p>
Course run dates are editable in Studio.
</p>
<p>
Please note that changes in Studio may take up to a business day to be reflected here. For questions, contact your project coordinator.
</p>
<p>
<a
href="http://localhost:18010/settings/details/edX101+DemoX#schedule"
rel="noopener noreferrer"
target="_blank"
>
Edit dates.
</a>
.
</p>
</div>
}
name="test-course.upgrade_deadline_override"
timeLabel="Upgrade deadline override time (GMT)"
type="date"
/>
</div>
<hr />
<Field
Expand Down Expand Up @@ -1189,6 +1245,34 @@ exports[`Collapsible Course Run renders correctly when submitting for review 1`]
timeLabel="End time (GMT)"
type="text"
/>
<Field
component={[Function]}
dateLabel="Upgrade deadline override date"
disabled={true}
helpText={
<div>
<p>
Course run dates are editable in Studio.
</p>
<p>
Please note that changes in Studio may take up to a business day to be reflected here. For questions, contact your project coordinator.
</p>
<p>
<a
href="http://localhost:18010/settings/details/edX101+DemoX#schedule"
rel="noopener noreferrer"
target="_blank"
>
Edit dates.
</a>
.
</p>
</div>
}
name="test-course.upgrade_deadline_override"
timeLabel="Upgrade deadline override time (GMT)"
type="date"
/>
</div>
<hr />
<Field
Expand Down Expand Up @@ -1709,6 +1793,34 @@ exports[`Collapsible Course Run renders correctly when submitting for review and
timeLabel="End time (GMT)"
type="text"
/>
<Field
component={[Function]}
dateLabel="Upgrade deadline override date"
disabled={true}
helpText={
<div>
<p>
Course run dates are editable in Studio.
</p>
<p>
Please note that changes in Studio may take up to a business day to be reflected here. For questions, contact your project coordinator.
</p>
<p>
<a
href="http://localhost:18010/settings/details/edX101+DemoX#schedule"
rel="noopener noreferrer"
target="_blank"
>
Edit dates.
</a>
.
</p>
</div>
}
name="test-course.upgrade_deadline_override"
timeLabel="Upgrade deadline override time (GMT)"
type="date"
/>
</div>
<hr />
<Field
Expand Down Expand Up @@ -2229,6 +2341,34 @@ exports[`Collapsible Course Run renders correctly with a course run type 1`] = `
timeLabel="End time (GMT)"
type="text"
/>
<Field
component={[Function]}
dateLabel="Upgrade deadline override date"
disabled={true}
helpText={
<div>
<p>
Course run dates are editable in Studio.
</p>
<p>
Please note that changes in Studio may take up to a business day to be reflected here. For questions, contact your project coordinator.
</p>
<p>
<a
href="http://localhost:18010/settings/details/edX101+DemoX#schedule"
rel="noopener noreferrer"
target="_blank"
>
Edit dates.
</a>
.
</p>
</div>
}
name="test-course.upgrade_deadline_override"
timeLabel="Upgrade deadline override time (GMT)"
type="date"
/>
</div>
<hr />
<Field
Expand Down Expand Up @@ -2761,6 +2901,34 @@ exports[`Collapsible Course Run renders correctly with external key field enable
timeLabel="End time (GMT)"
type="text"
/>
<Field
component={[Function]}
dateLabel="Upgrade deadline override date"
disabled={true}
helpText={
<div>
<p>
Course run dates are editable in Studio.
</p>
<p>
Please note that changes in Studio may take up to a business day to be reflected here. For questions, contact your project coordinator.
</p>
<p>
<a
href="http://localhost:18010/settings/details/edX101+DemoX#schedule"
rel="noopener noreferrer"
target="_blank"
>
Edit dates.
</a>
.
</p>
</div>
}
name="test-course.upgrade_deadline_override"
timeLabel="Upgrade deadline override time (GMT)"
type="date"
/>
</div>
<hr />
<Field
Expand Down Expand Up @@ -3318,6 +3486,34 @@ exports[`Collapsible Course Run renders correctly with no fields 1`] = `
timeLabel="End time (GMT)"
type="text"
/>
<Field
component={[Function]}
dateLabel="Upgrade deadline override date"
disabled={true}
helpText={
<div>
<p>
Course run dates are editable in Studio.
</p>
<p>
Please note that changes in Studio may take up to a business day to be reflected here. For questions, contact your project coordinator.
</p>
<p>
<a
href="http://localhost:18010/settings/details/undefined#schedule"
rel="noopener noreferrer"
target="_blank"
>
Edit dates.
</a>
.
</p>
</div>
}
name="test-course.upgrade_deadline_override"
timeLabel="Upgrade deadline override time (GMT)"
type="date"
/>
</div>
<hr />
<Field
Expand Down
Loading

0 comments on commit 0156e14

Please sign in to comment.