fix: update mapToStateProps to match changes in TinyMceWidget (#1133)
* fix: update mapToStateProps to match changes in TinyMceWidget * feat: bump frontend-lib-content-components
This commit is contained in:
@@ -5,14 +5,18 @@ import {
|
||||
waitFor,
|
||||
act,
|
||||
} from '@testing-library/react';
|
||||
import { AppProvider } from '@edx/frontend-platform/react';
|
||||
import { IntlProvider } from '@edx/frontend-platform/i18n';
|
||||
import { initializeMockApp } from '@edx/frontend-platform';
|
||||
import moment from 'moment/moment';
|
||||
|
||||
import initializeStore from '../../store';
|
||||
import { REQUEST_TYPES } from '../constants';
|
||||
import { courseHandoutsMock, courseUpdatesMock } from '../__mocks__';
|
||||
import UpdateForm from './UpdateForm';
|
||||
import messages from './messages';
|
||||
|
||||
let store;
|
||||
const closeMock = jest.fn();
|
||||
const onSubmitMock = jest.fn();
|
||||
const addNewUpdateMock = { id: 0, date: moment().utc().toDate(), content: 'Some content' };
|
||||
@@ -48,18 +52,32 @@ const courseUpdatesInitialValues = (requestType) => {
|
||||
};
|
||||
|
||||
const renderComponent = ({ requestType }) => render(
|
||||
<IntlProvider locale="en">
|
||||
<UpdateForm
|
||||
isOpen
|
||||
close={closeMock}
|
||||
requestType={requestType}
|
||||
onSubmit={onSubmitMock}
|
||||
courseUpdatesInitialValues={courseUpdatesInitialValues(requestType)}
|
||||
/>
|
||||
</IntlProvider>,
|
||||
<AppProvider store={store}>
|
||||
<IntlProvider locale="en">
|
||||
<UpdateForm
|
||||
isOpen
|
||||
close={closeMock}
|
||||
requestType={requestType}
|
||||
onSubmit={onSubmitMock}
|
||||
courseUpdatesInitialValues={courseUpdatesInitialValues(requestType)}
|
||||
/>
|
||||
</IntlProvider>
|
||||
</AppProvider>,
|
||||
);
|
||||
|
||||
describe('<UpdateForm />', () => {
|
||||
beforeEach(() => {
|
||||
initializeMockApp({
|
||||
authenticatedUser: {
|
||||
userId: 3,
|
||||
username: 'abc123',
|
||||
administrator: true,
|
||||
roles: [],
|
||||
},
|
||||
});
|
||||
|
||||
store = initializeStore();
|
||||
});
|
||||
it('render Add new update form correctly', async () => {
|
||||
const { getByText, getByDisplayValue, getByRole } = renderComponent({ requestType: REQUEST_TYPES.add_new_update });
|
||||
const { date } = courseUpdatesInitialValues(REQUEST_TYPES.add_new_update);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { connect, Provider } from 'react-redux';
|
||||
import { connect, Provider, useSelector } from 'react-redux';
|
||||
import { createStore } from 'redux';
|
||||
import { getConfig } from '@edx/frontend-platform';
|
||||
import {
|
||||
@@ -18,20 +18,20 @@ export const SUPPORTED_TEXT_EDITORS = {
|
||||
};
|
||||
|
||||
const mapStateToProps = () => ({
|
||||
assets: {},
|
||||
images: {},
|
||||
lmsEndpointUrl: getConfig().LMS_BASE_URL,
|
||||
studioEndpointUrl: getConfig().STUDIO_BASE_URL,
|
||||
isLibrary: true,
|
||||
onEditorChange: () => ({}),
|
||||
});
|
||||
|
||||
const Editor = connect(mapStateToProps)(TinyMceWidget);
|
||||
|
||||
export const WysiwygEditor = ({
|
||||
initialValue, editorType, onChange, minHeight,
|
||||
}) => {
|
||||
// const courseId = "course+test+test+test"
|
||||
const { editorRef, refReady, setEditorRef } = prepareEditorRef();
|
||||
|
||||
const { courseId } = useSelector((state) => state.courseDetail);
|
||||
const isEquivalentCodeExtraSpaces = (first, second) => {
|
||||
// Utils allows to compare code extra spaces
|
||||
const removeWhitespace = (str) => str.replace(/\s/g, '');
|
||||
@@ -75,6 +75,7 @@ export const WysiwygEditor = ({
|
||||
setEditorRef={setEditorRef}
|
||||
onChange={handleUpdate}
|
||||
initializeEditor={() => ({})}
|
||||
learningContextId={courseId}
|
||||
/>
|
||||
</Provider>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user