[Backport staging] Load RTE component only when needed (#9807)

Use react lazy to load rte component

(cherry picked from commit d6e447b934)

Co-authored-by: Florian Duros <florianduros@element.io>
This commit is contained in:
ElementRobot 2022-12-21 10:04:11 +00:00 committed by GitHub
parent bf57a12ba4
commit 0f34702b35
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 92 additions and 28 deletions

View file

@ -24,7 +24,7 @@ import defaultDispatcher from "../../../../../src/dispatcher/dispatcher";
import { Action } from "../../../../../src/dispatcher/actions";
import { IRoomState } from "../../../../../src/components/structures/RoomView";
import { createTestClient, flushPromises, getRoomContext, mkEvent, mkStubRoom } from "../../../../test-utils";
import { SendWysiwygComposer } from "../../../../../src/components/views/rooms/wysiwyg_composer";
import { SendWysiwygComposer } from "../../../../../src/components/views/rooms/wysiwyg_composer/";
import { aboveLeftOf } from "../../../../../src/components/structures/ContextMenu";
import { ComposerInsertPayload, ComposerType } from "../../../../../src/dispatcher/payloads/ComposerInsertPayload";
import { setSelection } from "../../../../../src/components/views/rooms/wysiwyg_composer/utils/selection";
@ -101,12 +101,12 @@ describe("SendWysiwygComposer", () => {
);
};
it("Should render WysiwygComposer when isRichTextEnabled is at true", () => {
it("Should render WysiwygComposer when isRichTextEnabled is at true", async () => {
// When
customRender(jest.fn(), jest.fn(), false, true);
// Then
expect(screen.getByTestId("WysiwygComposer")).toBeTruthy();
await waitFor(() => expect(screen.getByTestId("WysiwygComposer")).toBeTruthy());
});
it("Should render PlainTextComposer when isRichTextEnabled is at false", () => {