Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions plugins/course-apps/live/Settings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const LiveSettings = ({
};

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

Expand Down
3 changes: 2 additions & 1 deletion plugins/course-apps/ora_settings/Settings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ const ORASettings = ({ onClose }) => {
event.preventDefault();

success = success && await handleSettingsSave(formValues);
await setSaveError(!success);
setSaveError(!success);
if ((initialFormValues.enableFlexiblePeerGrade !== formValues.enableFlexiblePeerGrade) && success) {
// oxlint-disable-next-line @typescript-eslint/await-thenable - this dispatch() IS returning a promise.
success = await dispatch(updateModel({
modelType: 'courseApps',
model: {
Expand Down
2 changes: 1 addition & 1 deletion plugins/course-apps/ora_settings/Settings.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ describe('ORASettings', () => {
await mockStore({ apiStatus: 200, enabled: true });
renderComponent();

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

await waitFor(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,10 @@ const SettingsModal = ({
const values = { ...rest, enabled: enabled ? checked === 'true' : undefined };

if (enabled) {
// oxlint-disable-next-line @typescript-eslint/await-thenable - this dispatch() IS returning a promise.
success = await dispatch(updateXpertSettings(courseId, values));
} else {
// oxlint-disable-next-line @typescript-eslint/await-thenable - this dispatch() IS returning a promise.
success = await dispatch(removeXpertSettings(courseId));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const useCertificatesList = (courseId) => {
}));

const handleSubmit = async (values) => {
// oxlint-disable-next-line @typescript-eslint/await-thenable - this dispatch() IS returning a promise.
await dispatch(updateCourseCertificate(courseId, values));
setEditModes({});
dispatch(setMode(MODE_STATES.view));
Expand Down
2 changes: 2 additions & 0 deletions src/content-tags-drawer/data/apiHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ export const useContentTaxonomyTagsUpdater = (contentId: string) => {
// feature to support the legacy Django template courseware page.

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

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

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

Expand Down
16 changes: 8 additions & 8 deletions src/course-checklist/CourseChecklist.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ describe('CourseChecklistPage', () => {
});
describe('renders', () => {
describe('if enable_quality prop is true', () => {
it('two checklist components ', () => {
it('two checklist components ', async () => {
renderComponent();
mockStore(200);
await mockStore(200);

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

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

it('correct content when the launch checklist has loaded', async () => {
renderComponent();
mockStore(404);
await mockStore(404);
await waitFor(() => {
const { launchChecklistStatus } = store.getState().courseChecklist.loadingStatus;

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

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

Expand All @@ -100,9 +100,9 @@ describe('CourseChecklistPage', () => {
});
});

it('one checklist components ', () => {
it('one checklist components ', async () => {
renderComponent();
mockStore(200);
await mockStore(200);

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

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

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

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

Expand Down
2 changes: 2 additions & 0 deletions src/course-libraries/LegacyLibContentBlockAlert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ const LegacyLibContentBlockAlert = ({ courseId }: Props) => {
if (taskStatus.data?.state === UserTaskStatus.Succeeded) {
showToast(intl.formatMessage(messages.legacyLibReadyToMigrateTaskCompleted));
setTaskId(undefined);
// eslint-disable-next-line @typescript-eslint/no-floating-promises
refetch();
} else if (taskStatus.data?.state === UserTaskStatus.Failed
|| taskStatus.data?.state === UserTaskStatus.Cancelled) {
showToast(intl.formatMessage(messages.legacyLibReadyToMigrateTaskFailed));
setTaskId(undefined);
// eslint-disable-next-line @typescript-eslint/no-floating-promises
refetch();
} else if (taskId) {
showToast(intl.formatMessage(messages.legacyLibReadyToMigrateTaskInProgress));
Expand Down
12 changes: 6 additions & 6 deletions src/course-outline/CourseOutline.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -471,11 +471,11 @@ describe('<CourseOutline />', () => {
const dummyBtn = await screen.findByRole('button', { name: 'Dummy button' });
fireEvent.click(dummyBtn);

waitFor(() => expect(axiosMock.history.post.length).toBe(3));
await waitFor(() => expect(axiosMock.history.post.length).toBe(3));

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

waitFor(() => expect(axiosMock.history.post.length).toBe(3));
await waitFor(() => expect(axiosMock.history.post.length).toBe(3));

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

waitFor(() => expect(axiosMock.history.post.length).toBe(3));
await waitFor(() => expect(axiosMock.history.post.length).toBe(3));

const courseUsageKey = courseOutlineIndexMock.courseStructure.id;
waitFor(() => {
await waitFor(() => {
expect(axiosMock.history.post[2].data).toBe(JSON.stringify({
type: COMPONENT_TYPES.libraryV2,
category: 'chapter',
Expand Down
1 change: 1 addition & 0 deletions src/course-outline/OutlineAddChildButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ const LegacyOutlineAddChildButtons = ({
}

const handleOnComponentSelected = (selected: SelectedComponent) => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
onUseLibraryContent(selected);
closeAddLibrarySectionModal();
};
Expand Down
2 changes: 1 addition & 1 deletion src/course-outline/card-header/CardHeader.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ describe('<CardHeader />', () => {
});

expect(await screen.findByTestId('subsection-edit-field')).toBeInTheDocument();
waitFor(() => {
await waitFor(() => {
expect(screen.queryByTestId('subsection-card-header__expanded-btn')).not.toBeInTheDocument();
expect(screen.queryByTestId('edit-button')).not.toBeInTheDocument();
});
Expand Down
1 change: 1 addition & 0 deletions src/course-outline/hooks.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ const useCourseOutline = ({ courseId }) => {

const headerNavigationsActions = {
handleNewSection: () => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
handleAddSection.mutateAsync({
type: ContainerType.Chapter,
parentLocator: courseStructure?.id,
Expand Down
8 changes: 4 additions & 4 deletions src/course-outline/section-card/SectionCard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,12 @@ describe('<SectionCard />', () => {
renderComponent();
const element = await screen.findByTestId('section-card');
const menu = await within(element).findByTestId('section-card-header__menu-button');
await fireEvent.click(menu);
fireEvent.click(menu);

const manageTagsBtn = await within(element).findByTestId('section-card-header__menu-manage-tags-button');
expect(manageTagsBtn).toBeInTheDocument();

await fireEvent.click(manageTagsBtn);
fireEvent.click(manageTagsBtn);

const drawer = await screen.findByRole('alert');
expect(within(drawer).getByText(/manage tags/i));
Expand Down Expand Up @@ -364,12 +364,12 @@ describe('<SectionCard />', () => {
renderComponent();
const element = await screen.findByTestId('section-card');
const menu = await within(element).findByTestId('section-card-header__menu-button');
await fireEvent.click(menu);
fireEvent.click(menu);

const manageTagsBtn = await within(element).findByTestId('section-card-header__menu-manage-tags-button');
expect(manageTagsBtn).toBeInTheDocument();

await fireEvent.click(manageTagsBtn);
fireEvent.click(manageTagsBtn);

await waitFor(() => {
expect(mockSetCurrentPageKey).toHaveBeenCalledWith('align', section.id);
Expand Down
1 change: 1 addition & 0 deletions src/course-outline/status-bar/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export function useDynamicHookShim() {
}
}

// eslint-disable-next-line @typescript-eslint/no-floating-promises
load();

return () => {
Expand Down
8 changes: 4 additions & 4 deletions src/course-outline/subsection-card/SubsectionCard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -428,12 +428,12 @@ describe('<SubsectionCard />', () => {
renderComponent();
const element = await screen.findByTestId('subsection-card');
const menu = await within(element).findByTestId('subsection-card-header__menu-button');
await fireEvent.click(menu);
fireEvent.click(menu);

const manageTagsBtn = await within(element).findByTestId('subsection-card-header__menu-manage-tags-button');
expect(manageTagsBtn).toBeInTheDocument();

await fireEvent.click(manageTagsBtn);
fireEvent.click(manageTagsBtn);

const drawer = await screen.findByRole('alert');
expect(within(drawer).getByText(/manage tags/i));
Expand Down Expand Up @@ -474,12 +474,12 @@ describe('<SubsectionCard />', () => {
renderComponent();
const element = await screen.findByTestId('subsection-card');
const menu = await within(element).findByTestId('subsection-card-header__menu-button');
await fireEvent.click(menu);
fireEvent.click(menu);

const manageTagsBtn = await within(element).findByTestId('subsection-card-header__menu-manage-tags-button');
expect(manageTagsBtn).toBeInTheDocument();

await fireEvent.click(manageTagsBtn);
fireEvent.click(manageTagsBtn);

await waitFor(() => {
expect(mockSetCurrentPageKey).toHaveBeenCalledWith('align', subsection.id);
Expand Down
8 changes: 4 additions & 4 deletions src/course-outline/unit-card/UnitCard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -286,12 +286,12 @@ describe('<UnitCard />', () => {
renderComponent();
const element = await screen.findByTestId('unit-card');
const menu = await within(element).findByTestId('unit-card-header__menu-button');
await fireEvent.click(menu);
fireEvent.click(menu);

const manageTagsBtn = await within(element).findByTestId('unit-card-header__menu-manage-tags-button');
expect(manageTagsBtn).toBeInTheDocument();

await fireEvent.click(manageTagsBtn);
fireEvent.click(manageTagsBtn);

const drawer = await screen.findByRole('alert');
expect(within(drawer).getByText(/manage tags/i));
Expand Down Expand Up @@ -332,12 +332,12 @@ describe('<UnitCard />', () => {
renderComponent();
const element = await screen.findByTestId('unit-card');
const menu = await within(element).findByTestId('unit-card-header__menu-button');
await fireEvent.click(menu);
fireEvent.click(menu);

const manageTagsBtn = await within(element).findByTestId('unit-card-header__menu-manage-tags-button');
expect(manageTagsBtn).toBeInTheDocument();

await fireEvent.click(manageTagsBtn);
fireEvent.click(manageTagsBtn);

await waitFor(() => {
expect(mockSetCurrentPageKey).toHaveBeenCalledWith('align', unit.id);
Expand Down
1 change: 1 addition & 0 deletions src/course-outline/unit-card/UnitCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ const UnitCard = ({
};

const handleCopyClick = () => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
copyToClipboard(id);
};

Expand Down
13 changes: 10 additions & 3 deletions src/course-rerun/CourseRerun.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ jest.mock('react-redux', () => ({
useSelector: jest.fn(),
}));

const mockNavigate = jest.fn();

jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'), // use actual for all non-hook parts
useNavigate: () => mockNavigate,
}));

describe('<CourseRerun />', () => {
beforeEach(() => {
const { axiosMock } = initializeMocks();
Expand All @@ -30,13 +37,13 @@ describe('<CourseRerun />', () => {
expect(getAllByRole('button', { name: messages.cancelButton.defaultMessage }).length).toBe(2);
});

it('should navigate to /home on cancel button click', () => {
it('should navigate to /home on cancel button click', async () => {
const { getAllByRole } = render(<CourseRerun />);
const cancelButton = getAllByRole('button', { name: messages.cancelButton.defaultMessage })[0];

fireEvent.click(cancelButton);
waitFor(() => {
expect(window.location.pathname).toBe('/home');
await waitFor(() => {
expect(mockNavigate).toHaveBeenCalledWith('/home');
});
});

Expand Down
12 changes: 10 additions & 2 deletions src/course-unit/CourseUnit.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ import {
import { cloneDeep, set } from 'lodash';

import {
act, fireEvent, render, waitFor, within, screen, initializeMocks,
act,
cleanup,
fireEvent,
initializeMocks,
render,
waitFor,
within,
screen,
} from '@src/testUtils';
import { IFRAME_FEATURE_POLICY } from '@src/constants';
import { mockWaffleFlags } from '@src/data/apiHooks.mock';
Expand Down Expand Up @@ -790,9 +797,10 @@ describe('<CourseUnit />', () => {
.reply(200, {
...updatedCourseSectionVerticalData,
});
cleanup(); // clear the first render before we create the second.
render(<RootWrapper />);
// to wait for loading
screen.findByTestId('unit-header-title');
await screen.findByTestId('unit-header-title');
// The new unit button should not be visible when childAddable is false
expect(
screen.queryByRole('button', { name: courseSequenceMessages.newUnitBtnText.defaultMessage }),
Expand Down
1 change: 1 addition & 0 deletions src/course-unit/unit-sidebar/unit-info/UnitInfoSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ const UnitInfoSettings = () => {
groupAccess: Object | null,
isDiscussionEnabled: boolean,
) => {
// oxlint-disable-next-line @typescript-eslint/await-thenable - this dispatch() IS returning a promise.
await dispatch(editCourseUnitVisibilityAndData(
id,
PUBLISH_TYPES.republish,
Expand Down
5 changes: 3 additions & 2 deletions src/course-updates/update-form/UpdateForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ const UpdateForm = ({
if (!isValidDate(value)) {
return;
}
// eslint-disable-next-line @typescript-eslint/no-floating-promises
setFieldValue('date', convertToStringFromDate(value));
}}
/>
Expand All @@ -103,8 +104,8 @@ const UpdateForm = ({
data-testid="course-updates-wisiwyg-editor"
name={contentFieldName}
minHeight={300}
onChange={(value) => {
setFieldValue(contentFieldName, value || DEFAULT_EMPTY_WYSIWYG_VALUE);
onChange={async (value) => {
await setFieldValue(contentFieldName, value || DEFAULT_EMPTY_WYSIWYG_VALUE);
}}
/>
</Form.Group>
Expand Down
Loading