diff --git a/package-lock.json b/package-lock.json index fe9612f9a..49bceefa4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -36,7 +36,7 @@ "devDependencies": { "@edx/frontend-build": "^11.0.2", "@edx/frontend-platform": "2.4.0", - "@edx/paragon": "^20.27.0", + "@edx/paragon": "^20.28.0", "@testing-library/dom": "^8.13.0", "@testing-library/react": "^12.1.1", "@testing-library/user-event": "^13.5.0", @@ -4327,9 +4327,9 @@ } }, "node_modules/@edx/paragon": { - "version": "20.27.0", - "resolved": "https://registry.npmjs.org/@edx/paragon/-/paragon-20.27.0.tgz", - "integrity": "sha512-jy62ZEBdAVlsP6tAm1/YDyMtc9fiD47H00whoW+y2Z+lLZqPsv6D5boIPQIcdBeg0W4f2gCU4TEy2+b2q8mYGA==", + "version": "20.28.0", + "resolved": "https://registry.npmjs.org/@edx/paragon/-/paragon-20.28.0.tgz", + "integrity": "sha512-ydM3DK2aqdYRXyNEC0+P9tFpckH9kx/b/HtgSGrNMreRGAJ90QNkI/zAdlwj8U9mmoaE9jfIpjsO4g84qnrk1A==", "dev": true, "dependencies": { "@fortawesome/fontawesome-svg-core": "^6.1.1", @@ -37695,9 +37695,9 @@ } }, "@edx/paragon": { - "version": "20.27.0", - "resolved": "https://registry.npmjs.org/@edx/paragon/-/paragon-20.27.0.tgz", - "integrity": "sha512-jy62ZEBdAVlsP6tAm1/YDyMtc9fiD47H00whoW+y2Z+lLZqPsv6D5boIPQIcdBeg0W4f2gCU4TEy2+b2q8mYGA==", + "version": "20.28.0", + "resolved": "https://registry.npmjs.org/@edx/paragon/-/paragon-20.28.0.tgz", + "integrity": "sha512-ydM3DK2aqdYRXyNEC0+P9tFpckH9kx/b/HtgSGrNMreRGAJ90QNkI/zAdlwj8U9mmoaE9jfIpjsO4g84qnrk1A==", "dev": true, "requires": { "@fortawesome/fontawesome-svg-core": "^6.1.1", diff --git a/package.json b/package.json index 3568e6685..114b4a719 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "devDependencies": { "@edx/frontend-build": "^11.0.2", "@edx/frontend-platform": "2.4.0", - "@edx/paragon": "^20.27.0", + "@edx/paragon": "^20.28.0", "@testing-library/dom": "^8.13.0", "@testing-library/react": "^12.1.1", "@testing-library/user-event": "^13.5.0", diff --git a/src/editors/containers/ProblemEditor/__snapshots__/index.test.jsx.snap b/src/editors/containers/ProblemEditor/__snapshots__/index.test.jsx.snap new file mode 100644 index 000000000..7cd7c9768 --- /dev/null +++ b/src/editors/containers/ProblemEditor/__snapshots__/index.test.jsx.snap @@ -0,0 +1,49 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ProblemEditor snapshots block not yet loaded, Spinner appears 1`] = ` +
+ +
+`; + +exports[`ProblemEditor snapshots renders EditProblemView 1`] = ` + +`; + +exports[`ProblemEditor snapshots renders SelectTypeModal 1`] = ` + +`; + +exports[`ProblemEditor snapshots renders as expected with default behavior 1`] = ` +
+ +
+`; + +exports[`ProblemEditor snapshots studio view not yet loaded, Spinner appears 1`] = ` +
+ +
+`; diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/QuestionWidget/__snapshots__/index.test.jsx.snap b/src/editors/containers/ProblemEditor/components/EditProblemView/QuestionWidget/__snapshots__/index.test.jsx.snap new file mode 100644 index 000000000..e07ebda7b --- /dev/null +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/QuestionWidget/__snapshots__/index.test.jsx.snap @@ -0,0 +1,26 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`QuestionWidget render snapshot: renders correct default 1`] = ` +
+
+ +
+ +
+`; diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/QuestionWidget/index.jsx b/src/editors/containers/ProblemEditor/components/EditProblemView/QuestionWidget/index.jsx index 7bb2ec677..17e23f5db 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/QuestionWidget/index.jsx +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/QuestionWidget/index.jsx @@ -8,12 +8,29 @@ import { selectors, actions } from '../../../../../data/redux'; import { messages } from './messages'; import './index.scss'; +import 'tinymce'; +import 'tinymce/themes/silver'; +import 'tinymce/skins/ui/oxide/skin.css'; +import 'tinymce/icons/default'; +import 'tinymce/plugins/link'; +import 'tinymce/plugins/lists'; +import 'tinymce/plugins/table'; +import 'tinymce/plugins/hr'; +import 'tinymce/plugins/codesample'; +import 'tinymce/plugins/emoticons'; +import 'tinymce/plugins/emoticons/js/emojis'; +import 'tinymce/plugins/charmap'; +import 'tinymce/plugins/code'; +import 'tinymce/plugins/autoresize'; +import 'tinymce/plugins/image'; +import 'tinymce/plugins/imagetools'; + // This widget should be connected, grab all questions from store, update them as needed. export const QuestionWidget = ({ question, updateQuestion, }) => { - const { editorRef, refReady, setEditorRef } = hooks.prepareEditorRef(); + const { refReady, setEditorRef } = hooks.prepareEditorRef(); if (!refReady) { return null; } return (
@@ -23,7 +40,6 @@ export const QuestionWidget = ({ ({ + actions: { + problem: { + updateQuestion: jest.fn().mockName('actions.problem.updateQuestion'), + }, + }, + selectors: { + problem: { + question: jest.fn(state => ({ question: state })), + }, + }, +})); + +// Per https://github.com/tinymce/tinymce-react/issues/91 React unit testing in JSDOM is not supported by tinymce. +// Consequently, mock the Editor out. +jest.mock('@tinymce/tinymce-react', () => { + const originalModule = jest.requireActual('@tinymce/tinymce-react'); + return { + __esModule: true, + ...originalModule, + Editor: () => 'TiNYmCE EDitOR', + }; +}); + +jest.mock('../../../hooks', () => ({ + prepareEditorRef: jest.fn(() => ({ + refReady: true, + setEditorRef: jest.fn().mockName('hooks.prepareEditorRef.setEditorRef'), + })), + problemEditorConfig: jest.fn(args => ({ problemEditorConfig: args })), +})); + +describe('QuestionWidget', () => { + const props = { + question: 'This is my question', + updateQuestion: jest.fn(), + }; + describe('render', () => { + test('snapshot: renders correct default', () => { + expect(shallow()).toMatchSnapshot(); + }); + }); + describe('mapStateToProps', () => { + const testState = { A: 'pple', B: 'anana', C: 'ucumber' }; + test('question from problem.question', () => { + expect(mapStateToProps(testState).question).toEqual(selectors.problem.question(testState)); + }); + }); + describe('mapDispatchToProps', () => { + test('updateField from actions.problem.updateQuestion', () => { + expect(mapDispatchToProps.updateQuestion).toEqual(actions.problem.updateQuestion); + }); + }); +}); diff --git a/src/editors/containers/ProblemEditor/data/OLXParser.js b/src/editors/containers/ProblemEditor/data/OLXParser.js index 6b8899589..c819c80f3 100644 --- a/src/editors/containers/ProblemEditor/data/OLXParser.js +++ b/src/editors/containers/ProblemEditor/data/OLXParser.js @@ -284,7 +284,6 @@ export class OLXParser { the parsed OLX. */ const tagMap = { - label: 'strong', description: 'em', }; diff --git a/src/editors/containers/ProblemEditor/data/mockData/olxTestData.js b/src/editors/containers/ProblemEditor/data/mockData/olxTestData.js index af19a8d1c..e2468e391 100644 --- a/src/editors/containers/ProblemEditor/data/mockData/olxTestData.js +++ b/src/editors/containers/ProblemEditor/data/mockData/olxTestData.js @@ -82,11 +82,11 @@ export const checkboxesOLXWithFeedbackAndHintsOLX = { }, ], }, - question: '

You can use this template as a guide to the simple editor markdown and OLX markup to use for checkboxes with hints and feedback problems. Edit this component to replace this template with your own assessment.

Add the question text, or prompt, here. This text is required.You can add an optional tip or note related to the prompt like this.', + question: '

You can use this template as a guide to the simple editor markdown and OLX markup to use for checkboxes with hints and feedback problems. Edit this component to replace this template with your own assessment.

You can add an optional tip or note related to the prompt like this.', buildOLX: `

You can use this template as a guide to the simple editor markdown and OLX markup to use for checkboxes with hints and feedback problems. Edit this component to replace this template with your own assessment.

- Add the question text, or prompt, here. This text is required. + You can add an optional tip or note related to the prompt like this. @@ -160,11 +160,11 @@ export const dropdownOLXWithFeedbackAndHintsOLX = { }, ], }, - question: '

You can use this template as a guide to the simple editor markdown and OLX markup to use for dropdown with hints and feedback problems. Edit this component to replace this template with your own assessment.

Add the question text, or prompt, here. This text is required.You can add an optional tip or note related to the prompt like this.', + question: '

You can use this template as a guide to the simple editor markdown and OLX markup to use for dropdown with hints and feedback problems. Edit this component to replace this template with your own assessment.

You can add an optional tip or note related to the prompt like this.', buildOLX: `

You can use this template as a guide to the simple editor markdown and OLX markup to use for dropdown with hints and feedback problems. Edit this component to replace this template with your own assessment.

- Add the question text, or prompt, here. This text is required. + You can add an optional tip or note related to the prompt like this.