Skip to content

Commit 60eed85

Browse files
committed
fix: hardcoded course name
1 parent 8531fea commit 60eed85

2 files changed

Lines changed: 35 additions & 7 deletions

File tree

src/course-outline/outline-sidebar/OutlineInfoSidebar.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ import { ComponentCountSnippet } from '@src/generic/block-type-utils';
66
import { useGetBlockTypes } from '@src/search-manager';
77

88
import { SidebarContent, SidebarSection, SidebarTitle } from '@src/generic/sidebar';
9+
import { useCourseOutline } from '../hooks';
910

1011
import messages from './messages';
1112

1213
export const OutlineInfoSidebar = ({ courseId }: { courseId: string }) => {
1314
const intl = useIntl();
15+
const { courseName } = useCourseOutline({ courseId });
1416

1517
const { data: componentData } = useGetBlockTypes(
1618
[`context_key = "${courseId}"`],
@@ -19,7 +21,7 @@ export const OutlineInfoSidebar = ({ courseId }: { courseId: string }) => {
1921
return (
2022
<div>
2123
<SidebarTitle
22-
title="Course 1"
24+
title={courseName}
2325
icon={SchoolOutline}
2426
/>
2527
<SidebarContent>

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

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,46 @@ import { userEvent } from '@testing-library/user-event';
44
import {
55
initializeMocks, render, screen, waitFor, within,
66
} from '@src/testUtils';
7+
import { CourseAuthoringProvider } from '@src/CourseAuthoringContext';
8+
import { executeThunk } from '@src/utils';
9+
10+
import {
11+
fetchCourseOutlineIndexQuery,
12+
} from '../data/thunk';
13+
import {
14+
getCourseOutlineIndexApiUrl,
15+
} from '../data/api';
16+
import {
17+
courseOutlineIndexMock,
18+
} from '../__mocks__';
719

820
import { OutlineSidebarProvider } from './OutlineSidebarContext';
921
import OutlineSidebar from './OutlineSidebar';
1022

1123
const courseId = 'course-v1:TestOrg+TestCourse+2023_1';
1224

25+
const extraWrapper = ({ children }) => (
26+
<CourseAuthoringProvider courseId={courseId}>
27+
<OutlineSidebarProvider>
28+
{children}
29+
</OutlineSidebarProvider>
30+
</CourseAuthoringProvider>
31+
);
1332
const renderComponent = () => render(
1433
<OutlineSidebar courseId={courseId} />,
15-
{ extraWrapper: OutlineSidebarProvider },
34+
{ extraWrapper },
1635
);
1736

1837
describe('<OutlineSidebar>', () => {
19-
beforeEach(() => {
20-
initializeMocks();
38+
beforeEach(async () => {
39+
const mocks = initializeMocks();
40+
41+
const { axiosMock, reduxStore: store } = mocks;
42+
axiosMock
43+
.onGet(getCourseOutlineIndexApiUrl(courseId))
44+
.reply(200, courseOutlineIndexMock);
45+
46+
await executeThunk(fetchCourseOutlineIndexQuery(courseId), store.dispatch);
2147
});
2248

2349
it('should render the help sidebar by default', async () => {
@@ -36,7 +62,7 @@ describe('<OutlineSidebar>', () => {
3662

3763
// Check that the new sidebar is rendered, with the Info page
3864
await waitFor(() => {
39-
expect(screen.getByText('Course 1')).toBeInTheDocument();
65+
expect(screen.getByText('Demonstration Course')).toBeInTheDocument();
4066
});
4167

4268
const sidebarToggle = screen.getByTestId('sidebar-toggle');
@@ -48,14 +74,14 @@ describe('<OutlineSidebar>', () => {
4874
await userEvent.click(toggleButton);
4975

5076
// Check that there are no more Info sidebar elements
51-
expect(screen.queryByText('Course 1')).not.toBeInTheDocument();
77+
expect(screen.queryByText('Demonstration Course')).not.toBeInTheDocument();
5278

5379
// Show the sidebar
5480
await userEvent.click(toggleButton);
5581

5682
// Check that the new sidebar is rendered, with the Info page
5783
await waitFor(() => {
58-
expect(screen.getByText('Course 1')).toBeInTheDocument();
84+
expect(screen.getByText('Demonstration Course')).toBeInTheDocument();
5985
});
6086

6187
// Change page

0 commit comments

Comments
 (0)