From d848ebeea6050d84ce1d819e6399aacd1f102ff5 Mon Sep 17 00:00:00 2001
From: Ali Nawaz
Date: Fri, 2 Aug 2024 11:15:24 +0500
Subject: [PATCH 1/5] fix: add default value when destructuring collaborator
options
---
src/components/EditCoursePage/EditCourseForm.jsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/components/EditCoursePage/EditCourseForm.jsx b/src/components/EditCoursePage/EditCourseForm.jsx
index 85e3c944d..12b94d2d8 100644
--- a/src/components/EditCoursePage/EditCourseForm.jsx
+++ b/src/components/EditCoursePage/EditCourseForm.jsx
@@ -268,7 +268,7 @@ export class BaseEditCourseForm extends React.Component {
const {
data: {
- results: allResults,
+ results: allResults = [],
},
} = collaboratorOptions;
From 6963be297d0890cbdf953a84eea93f1ea301712c Mon Sep 17 00:00:00 2001
From: Ali Nawaz
Date: Fri, 2 Aug 2024 12:32:45 +0500
Subject: [PATCH 2/5] fix: coverage
---
.../EditCoursePage/EditCourseForm.test.jsx | 20 +
.../EditCourseForm.test.jsx.snap | 1385 +++++++++++++++++
2 files changed, 1405 insertions(+)
diff --git a/src/components/EditCoursePage/EditCourseForm.test.jsx b/src/components/EditCoursePage/EditCourseForm.test.jsx
index 9077b5b97..83a2a5923 100644
--- a/src/components/EditCoursePage/EditCourseForm.test.jsx
+++ b/src/components/EditCoursePage/EditCourseForm.test.jsx
@@ -474,4 +474,24 @@ describe('BaseEditCourseForm', () => {
const fields = component.find({ name: 'imageSrc' });
expect(fields).toHaveLength(1);
});
+
+ it('renders html correctly while fetching collaborator options', () => {
+ const component = shallow( null}
+ initialValues={{
+ title: initialValuesFull.title,
+ }}
+ title={initialValuesFull.title}
+ number="Test101x"
+ courseStatuses={[UNPUBLISHED]}
+ courseInfo={courseInfo}
+ courseOptions={courseOptions}
+ courseRunOptions={courseRunOptions}
+ uuid={initialValuesFull.uuid}
+ type={initialValuesFull.type}
+ id="edit-course-form"
+ collaboratorOptions={{data: {}}}
+ />);
+ expect(shallowToJson(component)).toMatchSnapshot();
+ });
});
diff --git a/src/components/EditCoursePage/__snapshots__/EditCourseForm.test.jsx.snap b/src/components/EditCoursePage/__snapshots__/EditCourseForm.test.jsx.snap
index ea72d10b9..cd1942f3e 100644
--- a/src/components/EditCoursePage/__snapshots__/EditCourseForm.test.jsx.snap
+++ b/src/components/EditCoursePage/__snapshots__/EditCourseForm.test.jsx.snap
@@ -3700,6 +3700,1391 @@ exports[`BaseEditCourseForm renders correctly when submitting for review 1`] = `
`;
+exports[`BaseEditCourseForm renders html correctly while fetching collaborator options 1`] = `
+
+ }
+ id="title.label"
+ optional={false}
+ text="Title"
+ />
+ }
+ name="title"
+ required={true}
+ type="text"
+ />
+
+
+
+ Note: Course editors cannot edit the URL slug. Please reach out to your project coordinator or edX support to edit this field.
+
+
+
+ This field is optional. If left blank, edX will automatically create a URL slug based on the course title.
+
+
+ If you find that a given URL slug is already in use, we recommend adding your school or institution name to the slug to ensure uniqueness.
+
+
+ This URL slug can be changed, and learners who visit an older URL will be redirected to the current URL.
+
+
+
+ What is a URL slug?
+
+
+
+ In the following example URLs:
+
+
+
+ www.edx.org/course/math-101, the URL slug is “math-101”
+
+
+
+ Using URL slugs that are short and easily understandable helps learners find and remember course pages, and also drives higher rankings in search engine results.
+
+
+ }
+ id="slug.label"
+ optional={true}
+ text="URL slug"
+ />
+ }
+ name="url_slug"
+ optional={true}
+ pattern="^[a-z0-9_]+(?:-[a-z0-9_]+)*$"
+ type="text"
+ />
+
+ A list of email addresses that will receive notifications when the course run of the course is published or reviewed.
+
+ }
+ id="watchers.label"
+ optional={true}
+ text="Watchers"
+ />
+ }
+ name="watchers_list"
+ optional={true}
+ />
+
+
+
+ The Product source is a key that identifies where the course originates.
+
+
+
+ Example:
+
+
+
+ If the course originates from the edX platform, the Product source is edX.
+
+
+ }
+ id="productSource"
+ optional={false}
+ text="Product Source"
+ />
+
+ N/A
+
+
+
+
+
+
+
+
+
+ Date:
+
+
+ N/A
+
+
+
+
+ Time (UTC):
+
+
+ N/A
+
+
+
+
+
+ The Course enrollment track determines what enrollment tracks are eligible for the course runs.
+
+
+
+ Example:
+
+
+
+ The Verified and Audit selection will allow course runs to either be Verified and Audit or Audit only.
+
+
+ }
+ id="type.label"
+ optional={false}
+ text="Course enrollment track"
+ />
+ }
+ name="type"
+ options={
+ Array [
+ Object {
+ "label": "Select enrollment track",
+ "value": "",
+ },
+ Object {
+ "label": "Credit",
+ "value": "9521aa7d-801b-4a67-92c3-716ea30f5086",
+ },
+ Object {
+ "label": "Masters Only",
+ "value": "7b41992e-f268-4331-8ba9-72acb0880454",
+ },
+ Object {
+ "label": "Verified and Audit",
+ "value": "8a8f30e1-23ce-4ed3-a361-1325c656b67b",
+ },
+ Object {
+ "label": "Professional Only",
+ "value": "fdde7d04-7ce0-4ff7-ac90-7f518e90ac1e",
+ },
+ Object {
+ "label": "Audit Only",
+ "value": "03e09c15-4127-4031-bc02-e20fcbdf09f0",
+ },
+ ]
+ }
+ />
+
+
+
+ Course teams are responsible for securing any necessary permissions for use of third-party logos.
+
+
+ To elaborate on the support, please include additional information in the “About this course” section. Please avoid including statements that the course is jointly offered or that the 3rd party is collaborating or partnering with edX.
+
+
+ }
+ id="collaborators.label"
+ optional={true}
+ text="Collaborators"
+ />
+
+
+
+ An eye-catching, colorful image that captures the essence of your course.
+
+
+
+ New course images must be 1134×675 pixels in size.
+
+
+ The image must be a JPEG or PNG file.
+
+
+ Each course must have a unique image.
+
+
+ The image cannot include text or headlines.
+
+
+ You must have permission to use the image. Possible image sources include Flickr creative commons, Stock Vault, Stock XCHNG, and iStock Photo.
+
+
+
+
+ Learn more.
+
+
+
+ }
+ id="image.label"
+ optional={false}
+ text="Image"
+ />
+ }
+ maxImageSizeKilo={1000}
+ name="imageSrc"
+ requiredHeight={675}
+ requiredWidth={1134}
+ />
+
+ You can add tags in the format mba-no-gmat,mba,mba_4_modules,mba_NY
+
+ }
+ id="tags.label"
+ optional={true}
+ text="Topics"
+ />
+ }
+ loadOptions={[Function]}
+ name="tags"
+ optional={true}
+ />
+
+
+
+
+ Introductory
+
+
+ No prerequisites
+
+
+ Intermediate
+
+
+ Basic prerequisites
+
+
+ Advanced
+
+
+ Significant prerequisites
+
+
+
+ }
+ id="level.label"
+ optional={false}
+ text="Course level"
+ />
+ }
+ name="level_type"
+ options={
+ Array [
+ Object {
+ "label": "--",
+ "value": "",
+ },
+ Object {
+ "label": "Beginner",
+ "value": "beginner",
+ },
+ Object {
+ "label": "Intermediate",
+ "value": "intermediate",
+ },
+ Object {
+ "label": "Advanced",
+ "value": "advanced",
+ },
+ ]
+ }
+ required={false}
+ />
+
+
+ The subject of the course.
+
+
+ You can select up to two subjects in addition to the primary subject. Only the primary subject appears on the About page.
+
+
+
+ Learn more.
+
+
+
+ }
+ id="subject1.label"
+ optional={false}
+ text="Primary subject"
+ />
+ }
+ name="subjectPrimary"
+ options={
+ Array [
+ Object {
+ "label": "--",
+ "value": "",
+ },
+ Object {
+ "label": "Business",
+ "value": "business",
+ },
+ Object {
+ "label": "Chemistry",
+ "value": "chemistry",
+ },
+ Object {
+ "label": "English",
+ "value": "english",
+ },
+ Object {
+ "label": "Security",
+ "value": "security",
+ },
+ ]
+ }
+ required={false}
+ />
+
+ }
+ name="subjectSecondary"
+ optional={true}
+ options={
+ Array [
+ Object {
+ "label": "--",
+ "value": "",
+ },
+ Object {
+ "label": "Business",
+ "value": "business",
+ },
+ Object {
+ "label": "Chemistry",
+ "value": "chemistry",
+ },
+ Object {
+ "label": "English",
+ "value": "english",
+ },
+ Object {
+ "label": "Security",
+ "value": "security",
+ },
+ ]
+ }
+ />
+
+ }
+ name="subjectTertiary"
+ optional={true}
+ options={
+ Array [
+ Object {
+ "label": "--",
+ "value": "",
+ },
+ Object {
+ "label": "Business",
+ "value": "business",
+ },
+ Object {
+ "label": "Chemistry",
+ "value": "chemistry",
+ },
+ Object {
+ "label": "English",
+ "value": "english",
+ },
+ Object {
+ "label": "Security",
+ "value": "security",
+ },
+ ]
+ }
+ />
+
+ }
+ name="organization_short_code_override"
+ optional={true}
+ />
+
+ }
+ maxImageSizeKilo={256}
+ name="organization_logo_override_url"
+ optional={true}
+ requiredHeight={110}
+ requiredWidth={110}
+ />
+
+
+
+
+
+ Add Course Run
+
+
+
+
+`;
+
exports[`BaseEditCourseForm renders html correctly while submitting 1`] = `
Date: Fri, 2 Aug 2024 12:43:50 +0500
Subject: [PATCH 3/5] fix: update snapshot after rebase
---
.../EditCourseForm.test.jsx.snap | 446 +++++++++---------
1 file changed, 223 insertions(+), 223 deletions(-)
diff --git a/src/components/EditCoursePage/__snapshots__/EditCourseForm.test.jsx.snap b/src/components/EditCoursePage/__snapshots__/EditCourseForm.test.jsx.snap
index cd1942f3e..b9e73a2e9 100644
--- a/src/components/EditCoursePage/__snapshots__/EditCourseForm.test.jsx.snap
+++ b/src/components/EditCoursePage/__snapshots__/EditCourseForm.test.jsx.snap
@@ -3725,7 +3725,7 @@ exports[`BaseEditCourseForm renders html correctly while fetching collaborator o
Course: Test Title
Date: Fri, 2 Aug 2024 12:47:03 +0500
Subject: [PATCH 4/5] fix: lint
---
src/components/EditCoursePage/EditCourseForm.test.jsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/components/EditCoursePage/EditCourseForm.test.jsx b/src/components/EditCoursePage/EditCourseForm.test.jsx
index 83a2a5923..fc0ebc624 100644
--- a/src/components/EditCoursePage/EditCourseForm.test.jsx
+++ b/src/components/EditCoursePage/EditCourseForm.test.jsx
@@ -490,7 +490,7 @@ describe('BaseEditCourseForm', () => {
uuid={initialValuesFull.uuid}
type={initialValuesFull.type}
id="edit-course-form"
- collaboratorOptions={{data: {}}}
+ collaboratorOptions={ {data: {}} }
/>);
expect(shallowToJson(component)).toMatchSnapshot();
});
From 0e9d1497220f714790c89496c5363fe68d6fa3f3 Mon Sep 17 00:00:00 2001
From: Ali Nawaz
Date: Fri, 2 Aug 2024 12:51:03 +0500
Subject: [PATCH 5/5] fix: more lint fixes
---
src/components/EditCoursePage/EditCourseForm.test.jsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/components/EditCoursePage/EditCourseForm.test.jsx b/src/components/EditCoursePage/EditCourseForm.test.jsx
index fc0ebc624..840da6048 100644
--- a/src/components/EditCoursePage/EditCourseForm.test.jsx
+++ b/src/components/EditCoursePage/EditCourseForm.test.jsx
@@ -490,7 +490,7 @@ describe('BaseEditCourseForm', () => {
uuid={initialValuesFull.uuid}
type={initialValuesFull.type}
id="edit-course-form"
- collaboratorOptions={ {data: {}} }
+ collaboratorOptions={{ data: {} }}
/>);
expect(shallowToJson(component)).toMatchSnapshot();
});