From 935d0c5e3ec356aef77a681758210ed15573cdda Mon Sep 17 00:00:00 2001 From: Kshitij Sobti Date: Thu, 17 Mar 2022 11:50:22 +0530 Subject: [PATCH] fix: clear saved post or comment on submit (#88) If a post or comment has been submitted, clear it from autosaved drafts so that it doesn't show up anymore. --- .../comments/CommentsView.test.jsx | 173 +++++++++++++++++- .../comments/comment/CommentEditor.jsx | 82 +++++---- src/discussions/comments/messages.js | 4 + .../posts/post-editor/PostEditor.jsx | 13 +- 4 files changed, 225 insertions(+), 47 deletions(-) diff --git a/src/discussions/comments/CommentsView.test.jsx b/src/discussions/comments/CommentsView.test.jsx index 3c11131f..6e40fd57 100644 --- a/src/discussions/comments/CommentsView.test.jsx +++ b/src/discussions/comments/CommentsView.test.jsx @@ -1,3 +1,5 @@ +import PropTypes from 'prop-types'; + import { act, fireEvent, render, screen, waitFor, within, } from '@testing-library/react'; @@ -6,7 +8,7 @@ import { IntlProvider } from 'react-intl'; import { MemoryRouter, Route } from 'react-router'; import { Factory } from 'rosie'; -import { initializeMockApp } from '@edx/frontend-platform'; +import { camelCaseObject, initializeMockApp } from '@edx/frontend-platform'; import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth'; import { AppProvider } from '@edx/frontend-platform/react'; @@ -26,6 +28,37 @@ const courseId = 'course-v1:edX+TestX+Test_Course'; let store; let axiosMock; +// Provides a mock editor component that functions like tinyMCE without the overhead +function MockEditor({ + onBlur, + onEditorChange, +}) { + return ( +