Skip to content

Commit a475f59

Browse files
committed
fix: Broken tests
1 parent 9dd5302 commit a475f59

6 files changed

Lines changed: 24 additions & 8 deletions

File tree

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ describe('ProctoredExamSettings', () => {
7474
provider: null,
7575
});
7676

77+
axiosMock.onGet(/course_index/).reply(200, { sections: [] });
78+
7779
axiosMock.onGet(
7880
StudioApiService.getProctoredExamSettingsUrl(defaultProps.courseId),
7981
).reply(200, {
@@ -466,7 +468,8 @@ describe('ProctoredExamSettings', () => {
466468
// (1) for studio settings
467469
// (2) waffle flags
468470
// (3) for course details
469-
expect(axiosMock.history.get.length).toBe(3);
471+
// (4) for course outline index (from CourseAuthoringProvider)
472+
expect(axiosMock.history.get.length).toBe(4);
470473
expect(axiosMock.history.get[0].url.includes('proctored_exam_settings')).toEqual(true);
471474
});
472475

src/course-outline/outline-sidebar/OutlineSidebar.test.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ jest.mock('@src/course-outline/data/apiHooks', () => ({
1515
useCourseDetails: jest.fn().mockReturnValue({ isPending: false, data: { title: 'Test Course' } }),
1616
useCreateCourseBlock: jest.fn(),
1717
useCourseItemData: jest.fn().mockReturnValue({ data: {} }),
18+
useDuplicateItem: jest.fn().mockReturnValue({ duplicateItem: jest.fn() }),
19+
useDeleteCourseItem: jest.fn().mockReturnValue({ mutateAsync: jest.fn() }),
1820
}));
1921

2022
const courseId = '123';

src/course-outline/outline-sidebar/info-sidebar/InfoSection.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ export const InfoSection = ({ itemId }: Props) => {
5454
}
5555
}, [dispatch, selectedContainerState, queryClient, courseId]);
5656

57+
if (!itemData) {
58+
return null;
59+
}
60+
5761
return (
5862
<>
5963
<LibraryReferenceCard

src/course-outline/outline-sidebar/info-sidebar/InfoSidebar.test.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ describe('InfoSidebar component', () => {
5454
const user = userEvent.setup();
5555
selectedContainerState = {
5656
currentId: 'block-v1:UNIX+UX1+2025_T3+type@chapter+block@123',
57+
sectionId: 'block-v1:UNIX+UX1+2025_T3+type@chapter+block@123',
5758
};
5859
const data = {
5960
id: selectedContainerState.currentId,
@@ -80,6 +81,7 @@ describe('InfoSidebar component', () => {
8081
const user = userEvent.setup();
8182
selectedContainerState = {
8283
currentId: 'block-v1:UNIX+UX1+2025_T3+type@sequential+block@123',
84+
subsectionId: 'block-v1:UNIX+UX1+2025_T3+type@sequential+block@123',
8385
sectionId: 'block-v1:UNIX+UX1+2025_T3+type@chapter+block@123',
8486
};
8587
const data = {

src/course-unit/CourseUnit.test.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ import CourseUnit from './CourseUnit';
6868
import tagsDrawerMessages from '../content-tags-drawer/messages';
6969
import configureModalMessages from '../generic/configure-modal/messages';
7070
import { getContentTaxonomyTagsApiUrl, getContentTaxonomyTagsCountApiUrl } from '../content-tags-drawer/data/api';
71+
import { getXBlockApiUrl } from '../course-outline/data/api';
7172
import addComponentMessages from './add-component/messages';
7273
import { messageTypes, PUBLISH_TYPES, UNIT_VISIBILITY_STATES } from './constants';
7374
import moveModalMessages from './move-modal/messages';
@@ -3250,6 +3251,10 @@ describe('<CourseUnit />', () => {
32503251
ENABLE_UNIT_PAGE_NEW_DESIGN: 'true',
32513252
});
32523253

3254+
axiosMock
3255+
.onGet(getXBlockApiUrl(mockContentData.textXBlock))
3256+
.reply(200, mockContentData.textXBlockData);
3257+
32533258
render(<RootWrapper />);
32543259

32553260
await screen.findByTitle(xblockContainerIframeMessages.xblockIframeTitle.defaultMessage);

src/generic/sidebar/InfoSidebarMenu.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export const InfoSidebarMenu = ({
6262
alt={intl.formatMessage(messages.itemMenuAlt)}
6363
/>
6464
<Dropdown.Menu>
65-
{actions.duplicable && onClickDuplicate && (
65+
{actions?.duplicable && onClickDuplicate && (
6666
<Dropdown.Item
6767
onClick={onClickDuplicate}
6868
>
@@ -96,7 +96,7 @@ export const InfoSidebarMenu = ({
9696
</Stack>
9797
</Dropdown.Item>
9898
)}
99-
{actions.draggable && onClickMoveUp && onClickMoveDown && canMoveItem && (
99+
{actions?.draggable && onClickMoveUp && onClickMoveDown && canMoveItem && (
100100
<>
101101
<Dropdown.Item
102102
onClick={onClickMoveUp}
@@ -128,20 +128,20 @@ export const InfoSidebarMenu = ({
128128
</Stack>
129129
</Dropdown.Item>
130130
)}
131-
{((actions.unlinkable ?? null) !== null || actions.deletable) && <Dropdown.Divider />}
132-
{(actions.unlinkable ?? null) !== null && (
131+
{((actions?.unlinkable ?? null) !== null || actions?.deletable) && <Dropdown.Divider />}
132+
{(actions?.unlinkable ?? null) !== null && (
133133
<Dropdown.Item
134134
onClick={onClickUnlink}
135-
disabled={!actions.unlinkable}
136-
title={!actions.unlinkable ? intl.formatMessage(messages.menuUnlinkDisabledTooltip) : undefined}
135+
disabled={!actions?.unlinkable}
136+
title={!actions?.unlinkable ? intl.formatMessage(messages.menuUnlinkDisabledTooltip) : undefined}
137137
>
138138
<Stack direction="horizontal" gap={2}>
139139
<Icon src={LinkOff} />
140140
{intl.formatMessage(messages.menuUnlink)}
141141
</Stack>
142142
</Dropdown.Item>
143143
)}
144-
{actions.deletable && (
144+
{actions?.deletable && (
145145
<Dropdown.Item
146146
onClick={onClickDelete}
147147
className="text-danger-700"

0 commit comments

Comments
 (0)