Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add default value when destructuring collaborator options #966

Merged
merged 5 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/EditCoursePage/EditCourseForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ export class BaseEditCourseForm extends React.Component {

const {
data: {
results: allResults,
results: allResults = [],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the collaborators are not fetched, how will the retry occur if data is set to empty list here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its just setting a default. Once the collaborators have been fetched, the state will update which will update the collaborator options with a "non-undefined" value for allResults and then that will be used by the code.

[PS] Note that the collaborator info is in collaboratorOptions, and this is just pulling information out of that object.

},
} = collaboratorOptions;

Expand Down
20 changes: 20 additions & 0 deletions src/components/EditCoursePage/EditCourseForm.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(<BaseEditCourseForm
handleSubmit={() => 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();
});
});
Loading
Loading