Skip to content

Commit 9d9d7a7

Browse files
fix: resolve incorrect or missing 'await' usages (#2592)
* chore: fix incorrect or missing 'await' usages * test: fix broken test * chore: ignore lines causing patch coverage to fail
1 parent 7e53e11 commit 9d9d7a7

54 files changed

Lines changed: 136 additions & 62 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

plugins/course-apps/live/Settings.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ const LiveSettings = ({
7272
};
7373

7474
const handleSettingsSave = async (values) => {
75+
// oxlint-disable-next-line @typescript-eslint/await-thenable - this dispatch() IS returning a promise.
7576
await dispatch(saveLiveConfiguration(courseId, values, navigate));
7677
};
7778

plugins/course-apps/ora_settings/Settings.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ const ORASettings = ({ onClose }) => {
4848
event.preventDefault();
4949

5050
success = success && await handleSettingsSave(formValues);
51-
await setSaveError(!success);
51+
setSaveError(!success);
5252
if ((initialFormValues.enableFlexiblePeerGrade !== formValues.enableFlexiblePeerGrade) && success) {
53+
// oxlint-disable-next-line @typescript-eslint/await-thenable - this dispatch() IS returning a promise.
5354
success = await dispatch(updateModel({
5455
modelType: 'courseApps',
5556
model: {

plugins/course-apps/ora_settings/Settings.test.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ describe('ORASettings', () => {
128128
await mockStore({ apiStatus: 200, enabled: true });
129129
renderComponent();
130130

131-
const checkbox = await screen.getByRole('checkbox', { name: /Flex Peer Grading/ });
131+
const checkbox = screen.getByRole('checkbox', { name: /Flex Peer Grading/ });
132132
expect(checkbox).toBeChecked();
133133

134134
await waitFor(() => {

plugins/course-apps/xpert_unit_summary/settings-modal/SettingsModal.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,10 @@ const SettingsModal = ({
239239
const values = { ...rest, enabled: enabled ? checked === 'true' : undefined };
240240

241241
if (enabled) {
242+
// oxlint-disable-next-line @typescript-eslint/await-thenable - this dispatch() IS returning a promise.
242243
success = await dispatch(updateXpertSettings(courseId, values));
243244
} else {
245+
// oxlint-disable-next-line @typescript-eslint/await-thenable - this dispatch() IS returning a promise.
244246
success = await dispatch(removeXpertSettings(courseId));
245247
}
246248

src/certificates/certificates-list/hooks/useCertificatesList.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const useCertificatesList = (courseId) => {
2525
}));
2626

2727
const handleSubmit = async (values) => {
28+
// oxlint-disable-next-line @typescript-eslint/await-thenable - this dispatch() IS returning a promise.
2829
await dispatch(updateCourseCertificate(courseId, values));
2930
setEditModes({});
3031
dispatch(setMode(MODE_STATES.view));

src/content-tags-drawer/data/apiHooks.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ export const useContentTaxonomyTagsUpdater = (contentId: string) => {
172172
// feature to support the legacy Django template courseware page.
173173

174174
// Sends content tags.
175+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
175176
getContentTaxonomyTagsData(contentId).then((data) => {
176177
const contentData = { contentId, ...data };
177178

@@ -187,6 +188,7 @@ export const useContentTaxonomyTagsUpdater = (contentId: string) => {
187188
});
188189

189190
// Sends tags count.
191+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
190192
getContentTaxonomyTagsCount(contentId).then((count) => {
191193
const contentData = { contentId, count };
192194

src/course-checklist/CourseChecklist.test.jsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ describe('CourseChecklistPage', () => {
4646
});
4747
describe('renders', () => {
4848
describe('if enable_quality prop is true', () => {
49-
it('two checklist components ', () => {
49+
it('two checklist components ', async () => {
5050
renderComponent();
51-
mockStore(200);
51+
await mockStore(200);
5252

5353
expect(screen.getByText(messages.launchChecklistLabel.defaultMessage)).toBeVisible();
5454

@@ -67,7 +67,7 @@ describe('CourseChecklistPage', () => {
6767

6868
it('correct content when the launch checklist has loaded', async () => {
6969
renderComponent();
70-
mockStore(404);
70+
await mockStore(404);
7171
await waitFor(() => {
7272
const { launchChecklistStatus } = store.getState().courseChecklist.loadingStatus;
7373

@@ -79,7 +79,7 @@ describe('CourseChecklistPage', () => {
7979

8080
it('correct content when the best practices checklist is loading', async () => {
8181
renderComponent();
82-
mockStore(404);
82+
await mockStore(404);
8383
await waitFor(() => {
8484
const { bestPracticeChecklistStatus } = store.getState().courseChecklist.loadingStatus;
8585

@@ -100,9 +100,9 @@ describe('CourseChecklistPage', () => {
100100
});
101101
});
102102

103-
it('one checklist components ', () => {
103+
it('one checklist components ', async () => {
104104
renderComponent();
105-
mockStore(200);
105+
await mockStore(200);
106106

107107
expect(screen.getByText(messages.launchChecklistLabel.defaultMessage)).toBeVisible();
108108

@@ -112,7 +112,7 @@ describe('CourseChecklistPage', () => {
112112
describe('an aria-live region with', () => {
113113
it('correct content when the launch checklist has loaded', async () => {
114114
renderComponent();
115-
mockStore(404);
115+
await mockStore(404);
116116
await waitFor(() => {
117117
const { launchChecklistStatus } = store.getState().courseChecklist.loadingStatus;
118118

@@ -124,7 +124,7 @@ describe('CourseChecklistPage', () => {
124124

125125
it('correct content when the best practices checklist is loading', async () => {
126126
renderComponent();
127-
mockStore(404);
127+
await mockStore(404);
128128
await waitFor(() => {
129129
const { bestPracticeChecklistStatus } = store.getState().courseChecklist.loadingStatus;
130130

src/course-libraries/LegacyLibContentBlockAlert.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@ const LegacyLibContentBlockAlert = ({ courseId }: Props) => {
3131
if (taskStatus.data?.state === UserTaskStatus.Succeeded) {
3232
showToast(intl.formatMessage(messages.legacyLibReadyToMigrateTaskCompleted));
3333
setTaskId(undefined);
34+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
3435
refetch();
3536
} else if (taskStatus.data?.state === UserTaskStatus.Failed
3637
|| taskStatus.data?.state === UserTaskStatus.Cancelled) {
3738
showToast(intl.formatMessage(messages.legacyLibReadyToMigrateTaskFailed));
3839
setTaskId(undefined);
40+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
3941
refetch();
4042
} else if (taskId) {
4143
showToast(intl.formatMessage(messages.legacyLibReadyToMigrateTaskInProgress));

src/course-outline/CourseOutline.test.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -471,11 +471,11 @@ describe('<CourseOutline />', () => {
471471
const dummyBtn = await screen.findByRole('button', { name: 'Dummy button' });
472472
fireEvent.click(dummyBtn);
473473

474-
waitFor(() => expect(axiosMock.history.post.length).toBe(3));
474+
await waitFor(() => expect(axiosMock.history.post.length).toBe(3));
475475

476476
const [section] = courseOutlineIndexMock.courseStructure.childInfo.children;
477477
const [subsection] = section.childInfo.children;
478-
waitFor(() => {
478+
await waitFor(() => {
479479
expect(axiosMock.history.post[2].data).toBe(JSON.stringify({
480480
type: COMPONENT_TYPES.libraryV2,
481481
category: 'vertical',
@@ -509,10 +509,10 @@ describe('<CourseOutline />', () => {
509509
const dummyBtn = await screen.findByRole('button', { name: 'Dummy button' });
510510
fireEvent.click(dummyBtn);
511511

512-
waitFor(() => expect(axiosMock.history.post.length).toBe(3));
512+
await waitFor(() => expect(axiosMock.history.post.length).toBe(3));
513513

514514
const [section] = courseOutlineIndexMock.courseStructure.childInfo.children;
515-
waitFor(() => {
515+
await waitFor(() => {
516516
expect(axiosMock.history.post[2].data).toBe(JSON.stringify({
517517
type: COMPONENT_TYPES.libraryV2,
518518
category: 'sequential',
@@ -545,10 +545,10 @@ describe('<CourseOutline />', () => {
545545
const dummyBtn = await screen.findByRole('button', { name: 'Dummy button' });
546546
fireEvent.click(dummyBtn);
547547

548-
waitFor(() => expect(axiosMock.history.post.length).toBe(3));
548+
await waitFor(() => expect(axiosMock.history.post.length).toBe(3));
549549

550550
const courseUsageKey = courseOutlineIndexMock.courseStructure.id;
551-
waitFor(() => {
551+
await waitFor(() => {
552552
expect(axiosMock.history.post[2].data).toBe(JSON.stringify({
553553
type: COMPONENT_TYPES.libraryV2,
554554
category: 'chapter',

src/course-outline/OutlineAddChildButtons.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ const LegacyOutlineAddChildButtons = ({
321321
}
322322

323323
const handleOnComponentSelected = (selected: SelectedComponent) => {
324+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
324325
onUseLibraryContent(selected);
325326
closeAddLibrarySectionModal();
326327
};

0 commit comments

Comments
 (0)