Skip to content

Commit 7d97e99

Browse files
chore: fix incorrect or missing 'await' usages
1 parent 5d97a98 commit 7d97e99

11 files changed

Lines changed: 34 additions & 17 deletions

File tree

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 IS a promise; it just has wrong type info.
7576
await dispatch(saveLiveConfiguration(courseId, values, navigate));
7677
};
7778

plugins/course-apps/ora_settings/Settings.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ 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) {
5353
success = await dispatch(updateModel({
5454
modelType: 'courseApps',

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 IS a promise; it just has wrong type info.
242243
success = await dispatch(updateXpertSettings(courseId, values));
243244
} else {
245+
// oxlint-disable-next-line @typescript-eslint/await-thenable - this IS a promise; it just has wrong type info.
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 IS a promise; it just has wrong type info.
2829
await dispatch(updateCourseCertificate(courseId, values));
2930
setEditModes({});
3031
dispatch(setMode(MODE_STATES.view));

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-unit/CourseUnit.test.jsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@ import {
77
import { cloneDeep, set } from 'lodash';
88

99
import {
10-
act, fireEvent, render, waitFor, within, screen, initializeMocks,
10+
act,
11+
cleanup,
12+
fireEvent,
13+
initializeMocks,
14+
render,
15+
waitFor,
16+
within,
17+
screen,
1118
} from '@src/testUtils';
1219
import { IFRAME_FEATURE_POLICY } from '@src/constants';
1320
import { mockWaffleFlags } from '@src/data/apiHooks.mock';
@@ -790,9 +797,10 @@ describe('<CourseUnit />', () => {
790797
.reply(200, {
791798
...updatedCourseSectionVerticalData,
792799
});
800+
cleanup(); // clear the first render before we create the second.
793801
render(<RootWrapper />);
794802
// to wait for loading
795-
screen.findByTestId('unit-header-title');
803+
await screen.findByTestId('unit-header-title');
796804
// The new unit button should not be visible when childAddable is false
797805
expect(
798806
screen.queryByRole('button', { name: courseSequenceMessages.newUnitBtnText.defaultMessage }),

src/library-authoring/hierarchy/ItemHierarchyPublisher.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ export const ItemHierarchyPublisher = ({
123123
{intl.formatMessage(messages.publishCancel)}
124124
</Button>
125125
<LoadingButton
126-
onClick={async (e) => {
126+
onClick={(e) => {
127127
e.preventDefault();
128128
e.stopPropagation();
129-
await handlePublish();
129+
handlePublish();
130130
}}
131131
variant="primary rounded-0"
132132
label={intl.formatMessage(messages.publishConfirm)}

src/optimizer-page/scan-results/ScanResults.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ const ScanResults: FC<Props> = ({
460460
const handleUpdateCompletion = async () => {
461461
if (rerunLinkUpdateInProgress === false && isUpdateAllInProgress) {
462462
try {
463+
// oxlint-disable-next-line @typescript-eslint/await-thenable - this IS a promise; it just has wrong type info
463464
const updateStatusResponse = await dispatch(fetchRerunLinkUpdateStatus(courseId)) as any;
464465

465466
if (!updateStatusResponse) {
@@ -590,13 +591,15 @@ const ScanResults: FC<Props> = ({
590591
try {
591592
setUpdatingLinkIds(prev => ({ ...prev, [uniqueId]: true }));
592593
const contentType = getContentType(sectionId || '');
594+
// oxlint-disable-next-line @typescript-eslint/await-thenable - this IS a promise; it just has wrong type info.
593595
await dispatch(updateSinglePreviousRunLink(courseId, link, blockId, contentType));
594596

595597
const pollForSingleLinkResult = async (attempts = 0): Promise<boolean> => {
596598
if (attempts > 30) { // Max 30 attempts (60 seconds)
597599
throw new Error('Timeout waiting for link update result');
598600
}
599601

602+
// oxlint-disable-next-line @typescript-eslint/await-thenable - this IS a promise; it just has wrong type info.
600603
const updateStatusResponse = await dispatch(fetchRerunLinkUpdateStatus(courseId)) as any;
601604
const pollStatus = updateStatusResponse?.status || updateStatusResponse?.updateStatus;
602605

@@ -755,6 +758,7 @@ const ScanResults: FC<Props> = ({
755758
try {
756759
setProcessedResponseIds(new Set());
757760
setIsUpdateAllInProgress(true);
761+
// oxlint-disable-next-line @typescript-eslint/await-thenable - this IS a promise; it just has wrong type info.
758762
await dispatch(updateAllPreviousRunLinks(courseId));
759763

760764
return true;

src/pages-and-resources/app-settings-modal/AppSettingsModal.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,22 @@ const AppSettingsModal = ({
7272
const handleFormSubmit = async (values) => {
7373
let success = true;
7474
if (appInfo.enabled !== values.enabled) {
75+
// oxlint-disable-next-line @typescript-eslint/await-thenable - this IS a promise; it just has wrong type info.
7576
success = await dispatch(updateAppStatus(courseId, appInfo.id, values.enabled));
7677
}
7778
// Call the submit handler for the settings component to save its settings
7879
if (onSettingsSave) {
7980
success = success && await onSettingsSave(values);
8081
}
81-
await setSaveError(!success);
82+
setSaveError(!success);
8283
!success && alertRef?.current.scrollIntoView(); // eslint-disable-line @typescript-eslint/no-unused-expressions
8384
};
8485

8586
const handleFormikSubmit = ({ handleSubmit, errors }) => async (event) => {
8687
// If submitting the form with errors, show the alert and scroll to it.
8788
await handleSubmit(event);
8889
if (Object.keys(errors).length > 0) {
89-
await setSaveError(true);
90+
setSaveError(true);
9091
alertRef?.current.scrollIntoView?.(); // eslint-disable-line no-unused-expressions
9192
}
9293
};

0 commit comments

Comments
 (0)