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
13 changes: 1 addition & 12 deletions src/studio-home/data/api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
handleCourseNotification,
sendRequestForCourseCreator,
getApiBaseUrl,
getStudioHomeCourses,
getStudioHomeCoursesV2,
getStudioHomeLibraries,
} from './api';
Expand Down Expand Up @@ -48,18 +47,8 @@ describe('studio-home api calls', () => {
expect(result).toEqual(expected);
});

it('should get studio courses data', async () => {
const apiLink = `${getApiBaseUrl()}/api/contentstore/v1/home/courses`;
axiosMock.onGet(apiLink).reply(200, generateGetStudioCoursesApiResponseV2());
const result = await getStudioHomeCourses('');
const expected = generateGetStudioCoursesApiResponseV2();

expect(axiosMock.history.get[0].url).toEqual(apiLink);
expect(result).toEqual(expected);
});

it('should get studio courses data v2', async () => {
const apiLink = `${getApiBaseUrl()}/api/contentstore/v2/home/courses`;
const apiLink = `${getApiBaseUrl()}/api/contentstore/v4/home/courses/`;
axiosMock.onGet(apiLink).reply(200, generateGetStudioCoursesApiResponseV2());
const result = await getStudioHomeCoursesV2('');
const expected = generateGetStudioCoursesApiResponseV2();
Expand Down
17 changes: 6 additions & 11 deletions src/studio-home/data/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,18 @@ export async function getStudioHomeData(): Promise<object> {
return camelCaseObject(data);
}

/** Get list of courses from the deprecated non-paginated API */
export async function getStudioHomeCourses(search: string) {
const { data } = await getAuthenticatedHttpClient().get(
`${getApiBaseUrl()}/api/contentstore/v1/home/courses${search}`,
);
return camelCaseObject(data);
}
/**
* Get's studio home courses.
* Note: We are changing /api/contentstore/v1 to /api/contentstore/v2 due to upcoming breaking changes.
* Features such as pagination, filtering, and ordering are better handled in the new version.
* Please refer to this PR for further details: https://github.com/openedx/edx-platform/pull/34173
*
* FC-0118 (ADR 0028/0037): migrated to the standardized v4 `home/courses`
* endpoint. The trailing slash is required by the DRF DefaultRouter that serves
* the v4 ViewSet. The deprecated non-paginated v1 `home/courses` fallback has
* been dropped; pagination, filtering, and ordering are handled natively by v4.
*/
export async function getStudioHomeCoursesV2(search: string, customParams: object): Promise<object> {
const customParamsFormat = snakeCaseObject(customParams);
const { data } = await getAuthenticatedHttpClient().get(
`${getApiBaseUrl()}/api/contentstore/v2/home/courses${search}`,
`${getApiBaseUrl()}/api/contentstore/v4/home/courses/${search}`,
{ params: customParamsFormat },
);
return camelCaseObject(data);
Expand Down
2 changes: 1 addition & 1 deletion src/studio-home/data/thunks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('fetchStudioHomeData thunk', () => {
dispatch = jest.fn();

axiosMock.onGet(getStudioHomeApiUrl()).reply(200, generateGetStudioHomeDataApiResponse());
axiosMock.onGet(new RegExp(`${getApiBaseUrl()}/api/contentstore/v2/home/courses.*`))
axiosMock.onGet(new RegExp(`${getApiBaseUrl()}/api/contentstore/v4/home/courses.*`))
.reply(200, generateGetStudioCoursesApiResponseV2());
});

Expand Down
2 changes: 1 addition & 1 deletion src/studio-home/tabs-section/TabsSection.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const { studioShortName } = studioHomeMock;

let axiosMock;
let store;
const courseApiLinkV2 = `${getApiBaseUrl()}/api/contentstore/v2/home/courses`;
const courseApiLinkV2 = `${getApiBaseUrl()}/api/contentstore/v4/home/courses/`;

const tabSectionComponent = (overrideProps) => (
<TabsSection
Expand Down