Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
2 changes: 0 additions & 2 deletions src/course-outline/__mocks__/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export interface TestCourseOutline {
deprecatedBlocksInfo: Record<string, unknown>;
discussionsIncontextLearnmoreUrl: string;
initialState: Record<string, unknown>;
initialUserClipboard: Record<string, unknown>;
languageCode: string;
lmsLink: string;
mfeProctoredExamSettingsUrl: string;
Expand Down Expand Up @@ -208,7 +207,6 @@ export function buildTestOutline(
deprecatedBlocksInfo: { deprecatedEnabledBlockTypes: [], blocks: [] },
discussionsIncontextLearnmoreUrl: '',
initialState: { expandedLocators: [], locatorToShow: '' },
initialUserClipboard: {},
languageCode: 'en',
lmsLink: '',
mfeProctoredExamSettingsUrl: '',
Expand Down
5 changes: 3 additions & 2 deletions src/course-outline/data/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const getApiBaseUrl = () => getConfig().STUDIO_BASE_URL;

export const getCourseOutlineIndexApiUrl = (
courseId: string,
) => `${getApiBaseUrl()}/api/contentstore/v1/course_index/${courseId}`;
) => `${getApiBaseUrl()}/api/authoring/v2/courses/${courseId}/outline/`;

export const getCourseDetailsApiUrl = (courseId) =>
`${getApiBaseUrl()}/api/contentstore/v3/course_details/${courseId}/`;
Expand Down Expand Up @@ -69,8 +69,9 @@ export const courseLegacyLibraryContentTaskStatus = (courseId: string, taskId: s
* @returns {Promise<CourseOutline>}
*/
export async function getCourseOutlineIndex(courseId: string): Promise<CourseOutline> {
// The default view is a thin tree of names; the outline page needs every block's settings and the page data.
const { data } = await getAuthenticatedHttpClient()
.get(getCourseOutlineIndexApiUrl(courseId));
.get(getCourseOutlineIndexApiUrl(courseId), { params: { view: 'full' } });

return camelCaseObject(data);
}
Expand Down
60 changes: 59 additions & 1 deletion src/course-outline/data/outlineIndexQuery.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from '@src/testUtils';
import { buildTestOutline } from '@src/course-outline/__mocks__';

import { getCourseOutlineIndexApiUrl } from './api';
import { getCourseOutlineIndex, getCourseOutlineIndexApiUrl } from './api';
import {
getCourseOutlineStatusBarData,
useCourseOutlineIndex,
Expand Down Expand Up @@ -58,6 +58,64 @@ describe('outlineIndexQuery', () => {
);
});

it('requests the full view of the course outline and camel-cases it', async () => {
const sectionId = 'block-v1:edX+DemoX+Demo_Course+type@chapter+block@intro';
axiosMock.onGet(getCourseOutlineIndexApiUrl(courseId)).reply(200, {
course_release_date: 'Jan 15, 2026 at 00:00 UTC',
course_structure: {
id: 'block-v1:edX+DemoX+Demo_Course+type@course+block@course',
display_name: 'Demonstration Course',
category: 'course',
has_changes: false,
child_info: {
category: 'chapter',
display_name: 'Section',
children: [{ id: sectionId, display_name: 'Introduction', category: 'chapter' }],
},
},
deprecated_blocks_info: {
deprecated_enabled_block_types: [],
blocks: [],
advance_settings_url: `/settings/advanced/${courseId}`,
},
discussions_incontext_feedback_url: '',
discussions_incontext_learnmore_url: '',
discussions_settings: {
enable_in_context: true,
enable_graded_units: false,
unit_level_visibility: true,
discussion_configuration_url: 'http://apps.example.com/discussion/settings',
},
initial_state: null,
language_code: 'en',
lms_link: null,
mfe_proctored_exam_settings_url: '',
notification_dismiss_url: null,
proctoring_errors: [],
reindex_link: `/course/${courseId}/search_reindex`,
rerun_notification_id: null,
advance_settings_url: `/settings/advanced/${courseId}`,
is_custom_relative_dates_active: true,
created_on: '2025-11-02T09:30:00Z',
});

const outline = await getCourseOutlineIndex(courseId);

expect(axiosMock.history.get).toHaveLength(1);
expect(axiosMock.history.get[0].url).toBe(
`http://localhost:18010/api/authoring/v2/courses/${courseId}/outline/`,
);
expect(axiosMock.history.get[0].params).toEqual({ view: 'full' });
expect(outline.courseStructure.childInfo?.children[0]).toEqual(
{ id: sectionId, displayName: 'Introduction', category: 'chapter' },
);
expect(outline.discussionsSettings).toMatchObject({ enableGradedUnits: false });
expect(outline.reindexLink).toBe(`/course/${courseId}/search_reindex`);
expect(outline.isCustomRelativeDatesActive).toBe(true);
expect(outline.createdOn).toBe('2025-11-02T09:30:00Z');
expect(outline.lmsLink).toBeNull();
});

it('builds status bar payload from outline index response', () => {
const outlineIndex = outlineFixture;

Expand Down
1 change: 0 additions & 1 deletion src/course-outline/data/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export interface CourseOutline {
discussionsSettings?: { providerType: string; enableGradedUnits: boolean; };
advanceSettingsUrl?: string;
initialState: Record<string, any>; // TODO: Create interface for this type
initialUserClipboard: Record<string, any>; // TODO: Create interface for this type
languageCode: string;
lmsLink: string;
mfeProctoredExamSettingsUrl: string;
Expand Down
1 change: 0 additions & 1 deletion src/course-outline/utils/helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ describe('buildOutlineIndex', () => {
expect(outline.deprecatedBlocksInfo).toBeDefined();
expect(outline.discussionsIncontextLearnmoreUrl).toBe('');
expect(outline.initialState).toBeDefined();
expect(outline.initialUserClipboard).toBeDefined();
expect(outline.languageCode).toBe('en');
expect(outline.lmsLink).toBe('');
expect(outline.mfeProctoredExamSettingsUrl).toBe('');
Expand Down
Loading