diff --git a/src/generic/create-or-rerun-course/CreateOrRerunCourseForm.test.jsx b/src/generic/create-or-rerun-course/CreateOrRerunCourseForm.test.jsx index 52a2580ce..0383b789a 100644 --- a/src/generic/create-or-rerun-course/CreateOrRerunCourseForm.test.jsx +++ b/src/generic/create-or-rerun-course/CreateOrRerunCourseForm.test.jsx @@ -153,7 +153,7 @@ describe('', () => { userEvent.type(runInput, '1'); userEvent.click(createBtn); }); - await axiosMock.onPost(getCreateOrRerunCourseUrl).reply(200, { url }); + await axiosMock.onPost(getCreateOrRerunCourseUrl()).reply(200, { url }); await executeThunk(updateCreateOrRerunCourseQuery({ org: 'testX', run: 'some' }), store.dispatch); expect(window.location.assign).toHaveBeenCalledWith(`${process.env.STUDIO_BASE_URL}${url}`); @@ -168,7 +168,7 @@ describe('', () => { const numberInput = screen.getByPlaceholderText(messages.courseNumberPlaceholder.defaultMessage); const runInput = screen.getByPlaceholderText(messages.courseRunPlaceholder.defaultMessage); const createBtn = screen.getByRole('button', { name: messages.createButton.defaultMessage }); - await axiosMock.onPost(getCreateOrRerunCourseUrl).reply(200, { url, destinationCourseKey }); + await axiosMock.onPost(getCreateOrRerunCourseUrl()).reply(200, { url, destinationCourseKey }); await act(async () => { userEvent.type(displayNameInput, 'foo course name'); @@ -250,7 +250,7 @@ describe('', () => { it('shows alert error if postErrors presents', async () => { render(); await mockStore(); - await axiosMock.onPost(getCreateOrRerunCourseUrl).reply(200, { errMsg: 'aaa' }); + await axiosMock.onPost(getCreateOrRerunCourseUrl()).reply(200, { errMsg: 'aaa' }); await executeThunk(updateCreateOrRerunCourseQuery({ org: 'testX', run: 'some' }), store.dispatch); expect(screen.getByText('aaa')).toBeInTheDocument(); diff --git a/src/generic/data/api.js b/src/generic/data/api.js index 36dce24bd..7257fb689 100644 --- a/src/generic/data/api.js +++ b/src/generic/data/api.js @@ -4,9 +4,9 @@ import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth'; import { convertObjectToSnakeCase } from '../../utils'; export const getApiBaseUrl = () => getConfig().STUDIO_BASE_URL; -export const getCreateOrRerunCourseUrl = new URL('course/', getApiBaseUrl()).href; +export const getCreateOrRerunCourseUrl = () => new URL('course/', getApiBaseUrl()).href; export const getCourseRerunUrl = (courseId) => new URL(`/api/contentstore/v1/course_rerun/${courseId}`, getApiBaseUrl()).href; -export const getOrganizationsUrl = new URL('organizations', getApiBaseUrl()).href; +export const getOrganizationsUrl = () => new URL('organizations', getApiBaseUrl()).href; /** * Get's organizations data. @@ -14,7 +14,7 @@ export const getOrganizationsUrl = new URL('organizations', getApiBaseUrl()).hre */ export async function getOrganizations() { const { data } = await getAuthenticatedHttpClient().get( - getOrganizationsUrl, + getOrganizationsUrl(), ); return camelCaseObject(data); } @@ -37,7 +37,7 @@ export async function getCourseRerun(courseId) { */ export async function createOrRerunCourse(courseData) { const { data } = await getAuthenticatedHttpClient().post( - getCreateOrRerunCourseUrl, + getCreateOrRerunCourseUrl(), convertObjectToSnakeCase(courseData, true), ); return camelCaseObject(data); diff --git a/src/generic/data/api.test.js b/src/generic/data/api.test.js index fd9d561c3..7abd51794 100644 --- a/src/generic/data/api.test.js +++ b/src/generic/data/api.test.js @@ -66,10 +66,10 @@ describe('generic api calls', () => { org: 'edX', run: 'Demo_Course', }; - axiosMock.onPost(getCreateOrRerunCourseUrl).reply(200, courseRerunData); + axiosMock.onPost(getCreateOrRerunCourseUrl()).reply(200, courseRerunData); const result = await createOrRerunCourse(courseRerunData); - expect(axiosMock.history.post[0].url).toEqual(getCreateOrRerunCourseUrl); + expect(axiosMock.history.post[0].url).toEqual(getCreateOrRerunCourseUrl()); expect(result).toEqual(courseRerunData); }); }); diff --git a/src/studio-home/organization-section/OrganizationSection.test.jsx b/src/studio-home/organization-section/OrganizationSection.test.jsx index 1b8461d60..62b15987b 100644 --- a/src/studio-home/organization-section/OrganizationSection.test.jsx +++ b/src/studio-home/organization-section/OrganizationSection.test.jsx @@ -42,7 +42,7 @@ describe('', async () => { }); store = initializeStore(); axiosMock = new MockAdapter(getAuthenticatedHttpClient()); - axiosMock.onDelete(getOrganizationsUrl).reply(200); + axiosMock.onDelete(getOrganizationsUrl()).reply(200); await executeThunk(fetchOrganizationsQuery(), store.dispatch); useSelector.mockReturnValue(['edX', 'org']); });