Compare commits

...

2 Commits

Author SHA1 Message Date
Adolfo R. Brandes
14f035435c fix: Fix data API URL handling
All configuration calls must handled asynchronously, otherwise they risk
failure in runtime configuration scenarios.
2023-11-21 16:57:44 -03:00
Stanislav
fa25150e3d fix: Missed favicon in Safari (#635)
Co-authored-by: Stanislav Lunyachek <lunyachek@MacBook-Pro-M1.local>
2023-11-01 16:38:39 -04:00
5 changed files with 11 additions and 11 deletions

View File

@@ -4,7 +4,7 @@
<title>Course Authoring | <%= process.env.SITE_NAME %></title> <title>Course Authoring | <%= process.env.SITE_NAME %></title>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="<%= process.env.FAVICON_URL %>" type="image/x-icon" /> <link rel="shortcut icon" href="<%=htmlWebpackPlugin.options.FAVICON_URL%>" type="image/x-icon" />
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>

View File

@@ -153,7 +153,7 @@ describe('<CreateOrRerunCourseForm />', () => {
userEvent.type(runInput, '1'); userEvent.type(runInput, '1');
userEvent.click(createBtn); 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); await executeThunk(updateCreateOrRerunCourseQuery({ org: 'testX', run: 'some' }), store.dispatch);
expect(window.location.assign).toHaveBeenCalledWith(`${process.env.STUDIO_BASE_URL}${url}`); expect(window.location.assign).toHaveBeenCalledWith(`${process.env.STUDIO_BASE_URL}${url}`);
@@ -168,7 +168,7 @@ describe('<CreateOrRerunCourseForm />', () => {
const numberInput = screen.getByPlaceholderText(messages.courseNumberPlaceholder.defaultMessage); const numberInput = screen.getByPlaceholderText(messages.courseNumberPlaceholder.defaultMessage);
const runInput = screen.getByPlaceholderText(messages.courseRunPlaceholder.defaultMessage); const runInput = screen.getByPlaceholderText(messages.courseRunPlaceholder.defaultMessage);
const createBtn = screen.getByRole('button', { name: messages.createButton.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 () => { await act(async () => {
userEvent.type(displayNameInput, 'foo course name'); userEvent.type(displayNameInput, 'foo course name');
@@ -250,7 +250,7 @@ describe('<CreateOrRerunCourseForm />', () => {
it('shows alert error if postErrors presents', async () => { it('shows alert error if postErrors presents', async () => {
render(<RootWrapper {...props} />); render(<RootWrapper {...props} />);
await mockStore(); 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); await executeThunk(updateCreateOrRerunCourseQuery({ org: 'testX', run: 'some' }), store.dispatch);
expect(screen.getByText('aaa')).toBeInTheDocument(); expect(screen.getByText('aaa')).toBeInTheDocument();

View File

@@ -4,9 +4,9 @@ import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
import { convertObjectToSnakeCase } from '../../utils'; import { convertObjectToSnakeCase } from '../../utils';
export const getApiBaseUrl = () => getConfig().STUDIO_BASE_URL; 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 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. * Get's organizations data.
@@ -14,7 +14,7 @@ export const getOrganizationsUrl = new URL('organizations', getApiBaseUrl()).hre
*/ */
export async function getOrganizations() { export async function getOrganizations() {
const { data } = await getAuthenticatedHttpClient().get( const { data } = await getAuthenticatedHttpClient().get(
getOrganizationsUrl, getOrganizationsUrl(),
); );
return camelCaseObject(data); return camelCaseObject(data);
} }
@@ -37,7 +37,7 @@ export async function getCourseRerun(courseId) {
*/ */
export async function createOrRerunCourse(courseData) { export async function createOrRerunCourse(courseData) {
const { data } = await getAuthenticatedHttpClient().post( const { data } = await getAuthenticatedHttpClient().post(
getCreateOrRerunCourseUrl, getCreateOrRerunCourseUrl(),
convertObjectToSnakeCase(courseData, true), convertObjectToSnakeCase(courseData, true),
); );
return camelCaseObject(data); return camelCaseObject(data);

View File

@@ -66,10 +66,10 @@ describe('generic api calls', () => {
org: 'edX', org: 'edX',
run: 'Demo_Course', run: 'Demo_Course',
}; };
axiosMock.onPost(getCreateOrRerunCourseUrl).reply(200, courseRerunData); axiosMock.onPost(getCreateOrRerunCourseUrl()).reply(200, courseRerunData);
const result = await createOrRerunCourse(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); expect(result).toEqual(courseRerunData);
}); });
}); });

View File

@@ -42,7 +42,7 @@ describe('<OrganizationSection />', async () => {
}); });
store = initializeStore(); store = initializeStore();
axiosMock = new MockAdapter(getAuthenticatedHttpClient()); axiosMock = new MockAdapter(getAuthenticatedHttpClient());
axiosMock.onDelete(getOrganizationsUrl).reply(200); axiosMock.onDelete(getOrganizationsUrl()).reply(200);
await executeThunk(fetchOrganizationsQuery(), store.dispatch); await executeThunk(fetchOrganizationsQuery(), store.dispatch);
useSelector.mockReturnValue(['edX', 'org']); useSelector.mockReturnValue(['edX', 'org']);
}); });