From 959fde53e8ffbfb30b7be0d2ad8bb2a4cae46bad Mon Sep 17 00:00:00 2001 From: Muhammad Afaq Shuaib Date: Wed, 30 Oct 2024 19:51:17 +0500 Subject: [PATCH 1/7] fix: tinyMCELanguageSelectorPlugin error related to Button ID --- .../EditCoursePage/CollapsibleCourseRun.jsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/EditCoursePage/CollapsibleCourseRun.jsx b/src/components/EditCoursePage/CollapsibleCourseRun.jsx index cf1c7541c..310bfb80f 100644 --- a/src/components/EditCoursePage/CollapsibleCourseRun.jsx +++ b/src/components/EditCoursePage/CollapsibleCourseRun.jsx @@ -4,6 +4,7 @@ import React from 'react'; import { CopyToClipboard } from 'react-copy-to-clipboard'; import moment from 'moment'; import PropTypes from 'prop-types'; +import { debounce } from 'lodash'; import { Field, FieldArray } from 'redux-form'; import { getAuthenticatedUser } from '@edx/frontend-platform/auth'; @@ -118,6 +119,7 @@ class CollapsibleCourseRun extends React.Component { copied: false, returnFromStaffPage: false, hasExternalKey: undefined, + isCourseRunInReview: false, }; this.openCollapsible = this.openCollapsible.bind(this); @@ -251,7 +253,7 @@ class CollapsibleCourseRun extends React.Component { courseRunTypeOptions, courseInfo, } = this.props; - const { copied, hasExternalKey } = this.state; + const { copied, hasExternalKey, isCourseRunInReview } = this.state; const { administrator } = getAuthenticatedUser(); const courseRunInReview = IN_REVIEW_STATUS.includes(courseRun.status); @@ -278,6 +280,12 @@ class CollapsibleCourseRun extends React.Component { const productSource = courseInfo?.data?.product_source?.slug; const courseType = courseInfo?.data?.course_type; + if (courseInReview !== isCourseRunInReview) { + setTimeout(() => { + this.setState({ isCourseRunInReview: courseInReview }); + }, 500); + } + return ( )} - {administrator && IN_REVIEW_STATUS.includes(courseRun.status) + {administrator && isCourseRunInReview && (
Status: {courseRun.status === REVIEW_BY_LEGAL ? 'Legal Review' : 'PC Review'} From 4414de595532ac96b6a720defcd66218b5ebe2e3 Mon Sep 17 00:00:00 2001 From: Muhammad Afaq Shuaib Date: Wed, 30 Oct 2024 19:55:01 +0500 Subject: [PATCH 2/7] chore: one more change --- src/components/EditCoursePage/CollapsibleCourseRun.jsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/EditCoursePage/CollapsibleCourseRun.jsx b/src/components/EditCoursePage/CollapsibleCourseRun.jsx index 310bfb80f..8aa62be81 100644 --- a/src/components/EditCoursePage/CollapsibleCourseRun.jsx +++ b/src/components/EditCoursePage/CollapsibleCourseRun.jsx @@ -4,7 +4,6 @@ import React from 'react'; import { CopyToClipboard } from 'react-copy-to-clipboard'; import moment from 'moment'; import PropTypes from 'prop-types'; -import { debounce } from 'lodash'; import { Field, FieldArray } from 'redux-form'; import { getAuthenticatedUser } from '@edx/frontend-platform/auth'; From f12592c3b997af29f14b0c0fb5bd00c57c35612f Mon Sep 17 00:00:00 2001 From: Muhammad Afaq Shuaib Date: Thu, 31 Oct 2024 00:12:02 +0500 Subject: [PATCH 3/7] chore: updated filtering condition --- src/components/EditCoursePage/CollapsibleCourseRun.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/EditCoursePage/CollapsibleCourseRun.jsx b/src/components/EditCoursePage/CollapsibleCourseRun.jsx index 8aa62be81..b89c036d2 100644 --- a/src/components/EditCoursePage/CollapsibleCourseRun.jsx +++ b/src/components/EditCoursePage/CollapsibleCourseRun.jsx @@ -281,7 +281,7 @@ class CollapsibleCourseRun extends React.Component { if (courseInReview !== isCourseRunInReview) { setTimeout(() => { - this.setState({ isCourseRunInReview: courseInReview }); + this.setState({ isCourseRunInReview: IN_REVIEW_STATUS.includes(courseRun.status) }); }, 500); } From aeb3c854653943cf90d6cdac23bba4d06d64f57e Mon Sep 17 00:00:00 2001 From: Muhammad Afaq Shuaib Date: Thu, 31 Oct 2024 00:36:33 +0500 Subject: [PATCH 4/7] chore: one more change --- src/components/EditCoursePage/CollapsibleCourseRun.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/EditCoursePage/CollapsibleCourseRun.jsx b/src/components/EditCoursePage/CollapsibleCourseRun.jsx index b89c036d2..7ef0c216c 100644 --- a/src/components/EditCoursePage/CollapsibleCourseRun.jsx +++ b/src/components/EditCoursePage/CollapsibleCourseRun.jsx @@ -279,10 +279,10 @@ class CollapsibleCourseRun extends React.Component { const productSource = courseInfo?.data?.product_source?.slug; const courseType = courseInfo?.data?.course_type; - if (courseInReview !== isCourseRunInReview) { + if (IN_REVIEW_STATUS.includes(courseRun.status) !== isCourseRunInReview) { setTimeout(() => { this.setState({ isCourseRunInReview: IN_REVIEW_STATUS.includes(courseRun.status) }); - }, 500); + }, 100); } return ( From 62697fc809f3617a7f5819f3506ae1b0db777d3f Mon Sep 17 00:00:00 2001 From: Muhammad Afaq Shuaib Date: Thu, 31 Oct 2024 00:42:49 +0500 Subject: [PATCH 5/7] fix: eslint quality --- src/components/EditCoursePage/CollapsibleCourseRun.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/EditCoursePage/CollapsibleCourseRun.jsx b/src/components/EditCoursePage/CollapsibleCourseRun.jsx index 7ef0c216c..f10a46a22 100644 --- a/src/components/EditCoursePage/CollapsibleCourseRun.jsx +++ b/src/components/EditCoursePage/CollapsibleCourseRun.jsx @@ -280,9 +280,9 @@ class CollapsibleCourseRun extends React.Component { const courseType = courseInfo?.data?.course_type; if (IN_REVIEW_STATUS.includes(courseRun.status) !== isCourseRunInReview) { - setTimeout(() => { - this.setState({ isCourseRunInReview: IN_REVIEW_STATUS.includes(courseRun.status) }); - }, 100); + setTimeout(() => { + this.setState({ isCourseRunInReview: IN_REVIEW_STATUS.includes(courseRun.status) }); + }, 100); } return ( From 9868cdad2191c7fedb48b8ada56ca74e909e89ee Mon Sep 17 00:00:00 2001 From: Muhammad Afaq Shuaib Date: Thu, 31 Oct 2024 00:46:10 +0500 Subject: [PATCH 6/7] fix: quality --- src/components/EditCoursePage/CollapsibleCourseRun.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/EditCoursePage/CollapsibleCourseRun.jsx b/src/components/EditCoursePage/CollapsibleCourseRun.jsx index f10a46a22..082cee9ea 100644 --- a/src/components/EditCoursePage/CollapsibleCourseRun.jsx +++ b/src/components/EditCoursePage/CollapsibleCourseRun.jsx @@ -281,7 +281,7 @@ class CollapsibleCourseRun extends React.Component { if (IN_REVIEW_STATUS.includes(courseRun.status) !== isCourseRunInReview) { setTimeout(() => { - this.setState({ isCourseRunInReview: IN_REVIEW_STATUS.includes(courseRun.status) }); + this.setState({ isCourseRunInReview: IN_REVIEW_STATUS.includes(courseRun.status) }); }, 100); } From 4cca1001eefb7e5dfafd59b1dc798502c8be6b42 Mon Sep 17 00:00:00 2001 From: Muhammad Afaq Shuaib Date: Thu, 31 Oct 2024 01:24:36 +0500 Subject: [PATCH 7/7] test: added a unittest --- .../CollapsibleCourseRun.test.jsx | 13 + .../CollapsibleCourseRun.test.jsx.snap | 592 ++++++++++++++++++ 2 files changed, 605 insertions(+) diff --git a/src/components/EditCoursePage/CollapsibleCourseRun.test.jsx b/src/components/EditCoursePage/CollapsibleCourseRun.test.jsx index 5eb2945fd..c6ab4efbb 100644 --- a/src/components/EditCoursePage/CollapsibleCourseRun.test.jsx +++ b/src/components/EditCoursePage/CollapsibleCourseRun.test.jsx @@ -52,6 +52,7 @@ const publishedCourseRun = { }; const unpublishedCourseRun = { ...publishedCourseRun, status: 'unpublished' }; +const inReviewCourseRun = { ...publishedCourseRun, status: 'review_by_internal' }; const currentFormValues = { course_runs: [publishedCourseRun, unpublishedCourseRun], @@ -96,6 +97,18 @@ describe('Collapsible Course Run', () => { expect(shallowToJson(component)).toMatchSnapshot(); }); + it('renders correctly when given a course run in review', () => { + const component = shallow(); + expect(shallowToJson(component)).toMatchSnapshot(); + }); + it('renders correctly with a course run type', () => { const component = shallow( `; +exports[`Collapsible Course Run renders correctly when given a course run in review 1`] = ` + + + Course run starting on Jan 01, 2000 - Self Paced + + +
+ + Publish date is Dec 31, 1999 + +
+
+ + Studio URL -  + + edX101+DemoX + + + Copy course key + + } + placement="top" + popperConfig={{}} + trigger={ + [ + "hover", + "focus", + ] + } + > + + + + + +
+
+ } +> +
+ + All fields are required for publication unless otherwise specified. + +
+
+ +

+ Required Format: yyyy/mm/dd +

+

+ The scheduled date for when the course run will be live and published. +

+

+ To publish as soon as possible, set the publish date to today. Please note that changes may take 48 hours to go live. +

+

+ If you don’t have a publish date yet, set to 1 year in the future. +

+
+ } + id="test-course.go_live_date.label" + optional={false} + text="Publish date" + /> + } + maxLength="10" + name="test-course.go_live_date" + normalize={[Function]} + pattern="20[1-9][0-9]/(0[1-9]|1[012])/(0[1-9]|[12][0-9]|3[01])" + placeholder="yyyy/mm/dd" + required={false} + 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.start" + timeLabel="Start 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.end" + 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 (UTC)" + type="date" + utcTimeZone={true} + /> + +
+ +

+ The enrollment track determines whether a course run offers a paid certificate and what sort of verification is required. +

+

+ + Learn more. + +

+ + } + id="test-course.run_type.label" + optional={false} + text="Course run enrollment track" + /> + } + name="test-course.run_type" + options={ + [ + { + "label": "Select Course enrollment track first", + "value": "", + }, + ] + } + required={true} + /> + +

+ Course pacing is 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 course pacing. + + . +

+ + } + id="test-course.pacing_type.label" + optional={false} + text="Course pacing" + /> + } + name="test-course.pacing_type" + options={ + [ + { + "label": "Self-paced", + "value": "self_paced", + }, + ] + } + type="text" + /> + +

+ The primary instructor or instructors for the course. +

+

+ The order that instructors are listed here is the same order they will be displayed on course pages. You can drag and drop to reorder instructors. +

+ + } + id="test-course.staff.label" + optional={true} + text="Staff" + /> + +
+
+ +

+ The minimum number of hours per week the learner should expect to spend on the course. +

+
+ } + id="test-course.min_effort.label" + optional={false} + text="Minimum effort" + /> + } + name="test-course.min_effort" + required={false} + type="number" + /> +
+
+ +

+ The maximum number of hours per week the learner should expect to spend on the course. +

+
+ } + id="test-course.max_effort.label" + optional={false} + text="Maximum effort" + /> + } + name="test-course.max_effort" + required={false} + type="number" + /> + + + +

+ The estimated number of weeks the learner should expect to spend on the course, rounded to the nearest whole number. +

+ + } + id="test-course.weeks_to_complete.label" + optional={false} + text="Length" + /> + } + name="test-course.weeks_to_complete" + required={false} + type="number" + /> + + } + name="test-course.content_language" + options={ + [ + { + "label": "Arabic - United Arab Emirates", + "value": "ar-ae", + }, + ] + } + required={false} + type="text" + /> + + + +

+ If this Course Run will potentially be part of a Program, please set the expected program type here. +

+ + } + id="test-course.expected_program_type.label" + optional={true} + text="Expected Program Type" + /> + } + name="test-course.expected_program_type" + type="text" + /> + +

+ If this Course Run will potentially be part of a Program, please set the expected program name here. +

+ + } + id="test-course.expected_program_name.label" + optional={true} + text="Expected Program Name" + /> + } + name="test-course.expected_program_name" + type="text" + /> +
+ +

+ Course embargo status for OFAC is managed internally, please contact support with questions. +

+
+ } + id="ofac-notice-label" + optional={false} + text="Course Embargo (OFAC) Restriction text added to the FAQ section" + /> +
+ No +
+ + + +`; + exports[`Collapsible Course Run renders correctly when given a published course run 1`] = `