Update matrix-wysiwyg to consume WASM asset (#28838)
* Update matrix-wysiwyg to consume WASM asset Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Update matrix-wysiwyg to consume WASM asset Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
committed by
GitHub
parent
afa7ec695d
commit
4e151f8d03
@@ -1,4 +1,3 @@
|
||||
/* eslint @typescript-eslint/no-unused-vars: ["error", { "varsIgnorePattern": "^_" }] */
|
||||
// Copyright 2024 New Vector Ltd.
|
||||
// Copyright 2023 The Matrix.org Foundation C.I.C.
|
||||
//
|
||||
@@ -24,7 +23,7 @@ describe("<SyntaxHighlight />", () => {
|
||||
const { container } = render(<SyntaxHighlight language={lang}>// Hello, World</SyntaxHighlight>);
|
||||
await waitFor(() => expect(container.querySelector(`.language-${lang}`)).toBeTruthy());
|
||||
|
||||
const [_lang, opts] = mock.mock.lastCall!;
|
||||
const [, opts] = mock.mock.lastCall!;
|
||||
expect((opts as unknown as HighlightOptions)["language"]).toBe(lang);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -10,6 +10,7 @@ import * as React from "react";
|
||||
import { EventType, MatrixEvent, RoomMember, THREAD_RELATION_TYPE } from "matrix-js-sdk/src/matrix";
|
||||
import { act, fireEvent, render, screen, waitFor } from "jest-matrix-react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { initOnce } from "@vector-im/matrix-wysiwyg";
|
||||
|
||||
import {
|
||||
clearAllModals,
|
||||
@@ -52,6 +53,8 @@ const expectVoiceMessageRecordingTriggered = (): void => {
|
||||
expect(screen.getByText("No microphone found")).toBeInTheDocument();
|
||||
};
|
||||
|
||||
beforeAll(initOnce, 10000);
|
||||
|
||||
describe("MessageComposer", () => {
|
||||
stubClient();
|
||||
const cli = createTestClient();
|
||||
|
||||
@@ -9,6 +9,7 @@ Please see LICENSE files in the repository root for full details.
|
||||
import "@testing-library/jest-dom";
|
||||
import React from "react";
|
||||
import { fireEvent, render, screen, waitFor } from "jest-matrix-react";
|
||||
import { initOnce } from "@vector-im/matrix-wysiwyg";
|
||||
|
||||
import MatrixClientContext from "../../../../../../src/contexts/MatrixClientContext";
|
||||
import defaultDispatcher from "../../../../../../src/dispatcher/dispatcher";
|
||||
@@ -24,6 +25,8 @@ import * as EmojiButton from "../../../../../../src/components/views/rooms/Emoji
|
||||
import { createMocks } from "./utils";
|
||||
import { ScopedRoomContextProvider } from "../../../../../../src/contexts/ScopedRoomContext.tsx";
|
||||
|
||||
beforeAll(initOnce, 10000);
|
||||
|
||||
describe("EditWysiwygComposer", () => {
|
||||
afterEach(() => {
|
||||
jest.resetAllMocks();
|
||||
@@ -46,17 +49,6 @@ describe("EditWysiwygComposer", () => {
|
||||
);
|
||||
};
|
||||
|
||||
beforeAll(
|
||||
async () => {
|
||||
// Load the dynamic import
|
||||
const component = customRender(false);
|
||||
await component.findByRole("textbox");
|
||||
component.unmount();
|
||||
},
|
||||
// it can take a while to load the wasm
|
||||
20000,
|
||||
);
|
||||
|
||||
it("Should not render the component when not ready", async () => {
|
||||
// When
|
||||
const { rerender } = customRender(false);
|
||||
|
||||
@@ -9,6 +9,7 @@ Please see LICENSE files in the repository root for full details.
|
||||
import "@testing-library/jest-dom";
|
||||
import React from "react";
|
||||
import { act, fireEvent, render, screen, waitFor } from "jest-matrix-react";
|
||||
import { initOnce } from "@vector-im/matrix-wysiwyg";
|
||||
|
||||
import MatrixClientContext from "../../../../../../src/contexts/MatrixClientContext";
|
||||
import defaultDispatcher from "../../../../../../src/dispatcher/dispatcher";
|
||||
@@ -31,6 +32,8 @@ jest.mock("../../../../../../src/components/views/rooms/EmojiButton", () => ({
|
||||
},
|
||||
}));
|
||||
|
||||
beforeAll(initOnce, 10000);
|
||||
|
||||
describe("SendWysiwygComposer", () => {
|
||||
afterEach(() => {
|
||||
jest.resetAllMocks();
|
||||
|
||||
@@ -9,6 +9,7 @@ Please see LICENSE files in the repository root for full details.
|
||||
import React from "react";
|
||||
import { act, render, screen } from "jest-matrix-react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { initOnce } from "@vector-im/matrix-wysiwyg";
|
||||
|
||||
import { PlainTextComposer } from "../../../../../../../src/components/views/rooms/wysiwyg_composer/components/PlainTextComposer";
|
||||
import * as mockUseSettingsHook from "../../../../../../../src/hooks/useSettings";
|
||||
@@ -16,6 +17,8 @@ import * as mockKeyboard from "../../../../../../../src/Keyboard";
|
||||
import { createMocks } from "../utils";
|
||||
import { ScopedRoomContextProvider } from "../../../../../../../src/contexts/ScopedRoomContext.tsx";
|
||||
|
||||
beforeAll(initOnce, 10000);
|
||||
|
||||
describe("PlainTextComposer", () => {
|
||||
const customRender = (
|
||||
onChange = (_content: string): void => void 0,
|
||||
|
||||
@@ -9,6 +9,7 @@ Please see LICENSE files in the repository root for full details.
|
||||
import "@testing-library/jest-dom";
|
||||
import React, { createRef } from "react";
|
||||
import { render, screen, waitFor } from "jest-matrix-react";
|
||||
import { initOnce } from "@vector-im/matrix-wysiwyg";
|
||||
|
||||
import MatrixClientContext from "../../../../../../../src/contexts/MatrixClientContext";
|
||||
import { WysiwygAutocomplete } from "../../../../../../../src/components/views/rooms/wysiwyg_composer/components/WysiwygAutocomplete";
|
||||
@@ -42,6 +43,8 @@ const constructMockProvider = (data: ICompletion[]) =>
|
||||
renderCompletions: jest.fn().mockImplementation((components) => components),
|
||||
}) as unknown as AutocompleteProvider;
|
||||
|
||||
beforeAll(initOnce, 10000);
|
||||
|
||||
describe("WysiwygAutocomplete", () => {
|
||||
beforeAll(() => {
|
||||
// scrollTo not implemented in JSDOM
|
||||
|
||||
@@ -10,6 +10,7 @@ import "@testing-library/jest-dom";
|
||||
import React from "react";
|
||||
import { act, fireEvent, render, screen, waitFor } from "jest-matrix-react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { initOnce } from "@vector-im/matrix-wysiwyg";
|
||||
|
||||
import { WysiwygComposer } from "../../../../../../../src/components/views/rooms/wysiwyg_composer/components/WysiwygComposer";
|
||||
import SettingsStore from "../../../../../../../src/settings/SettingsStore";
|
||||
@@ -33,6 +34,8 @@ import * as Permalinks from "../../../../../../../src/utils/permalinks/Permalink
|
||||
import { PermalinkParts } from "../../../../../../../src/utils/permalinks/PermalinkConstructor";
|
||||
import { ScopedRoomContextProvider } from "../../../../../../../src/contexts/ScopedRoomContext.tsx";
|
||||
|
||||
beforeAll(initOnce, 10000);
|
||||
|
||||
describe("WysiwygComposer", () => {
|
||||
const customRender = (onChange = jest.fn(), onSend = jest.fn(), disabled = false, initialContent?: string) => {
|
||||
const { mockClient, defaultRoomContext } = createMocks();
|
||||
|
||||
@@ -5,7 +5,9 @@ Copyright 2022 The Matrix.org Foundation C.I.C.
|
||||
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
|
||||
Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { MsgType } from "matrix-js-sdk/src/matrix";
|
||||
import { initOnce } from "@vector-im/matrix-wysiwyg";
|
||||
|
||||
import { filterConsole, mkEvent } from "../../../../../../test-utils";
|
||||
import {
|
||||
@@ -13,6 +15,8 @@ import {
|
||||
EMOTE_PREFIX,
|
||||
} from "../../../../../../../src/components/views/rooms/wysiwyg_composer/utils/createMessageContent";
|
||||
|
||||
beforeAll(initOnce, 10000);
|
||||
|
||||
describe("createMessageContent", () => {
|
||||
const message = "<em><b>hello</b> world</em>";
|
||||
|
||||
@@ -25,13 +29,6 @@ describe("createMessageContent", () => {
|
||||
"WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm`",
|
||||
);
|
||||
|
||||
beforeAll(async () => {
|
||||
// Warm up by creating the component once, with a long timeout.
|
||||
// This prevents tests timing out because of the time spent loading
|
||||
// the WASM component.
|
||||
await createMessageContent(message, true, {});
|
||||
}, 10000);
|
||||
|
||||
it("Should create html message", async () => {
|
||||
// When
|
||||
const content = await createMessageContent(message, true, {});
|
||||
|
||||
Reference in New Issue
Block a user