diff --git a/package.json b/package.json index aac1d92518..b36807f7c3 100644 --- a/package.json +++ b/package.json @@ -90,7 +90,7 @@ "@types/png-chunks-extract": "^1.0.2", "@vector-im/compound-design-tokens": "^2.0.1", "@vector-im/compound-web": "^7.5.0", - "@vector-im/matrix-wysiwyg": "2.37.13", + "@vector-im/matrix-wysiwyg": "2.38.0", "@zxcvbn-ts/core": "^3.0.4", "@zxcvbn-ts/language-common": "^3.0.4", "@zxcvbn-ts/language-en": "^3.0.2", diff --git a/test/unit-tests/components/views/elements/SyntaxHighlight-test.tsx b/test/unit-tests/components/views/elements/SyntaxHighlight-test.tsx index ff18022a8c..5fd169adac 100644 --- a/test/unit-tests/components/views/elements/SyntaxHighlight-test.tsx +++ b/test/unit-tests/components/views/elements/SyntaxHighlight-test.tsx @@ -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("", () => { const { container } = render(// Hello, World); 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); }); }); diff --git a/test/unit-tests/components/views/rooms/MessageComposer-test.tsx b/test/unit-tests/components/views/rooms/MessageComposer-test.tsx index 953294d191..270d685a18 100644 --- a/test/unit-tests/components/views/rooms/MessageComposer-test.tsx +++ b/test/unit-tests/components/views/rooms/MessageComposer-test.tsx @@ -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(); diff --git a/test/unit-tests/components/views/rooms/wysiwyg_composer/EditWysiwygComposer-test.tsx b/test/unit-tests/components/views/rooms/wysiwyg_composer/EditWysiwygComposer-test.tsx index a76c7a8b90..6b0051d703 100644 --- a/test/unit-tests/components/views/rooms/wysiwyg_composer/EditWysiwygComposer-test.tsx +++ b/test/unit-tests/components/views/rooms/wysiwyg_composer/EditWysiwygComposer-test.tsx @@ -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); diff --git a/test/unit-tests/components/views/rooms/wysiwyg_composer/SendWysiwygComposer-test.tsx b/test/unit-tests/components/views/rooms/wysiwyg_composer/SendWysiwygComposer-test.tsx index 89415448b7..c5c767b432 100644 --- a/test/unit-tests/components/views/rooms/wysiwyg_composer/SendWysiwygComposer-test.tsx +++ b/test/unit-tests/components/views/rooms/wysiwyg_composer/SendWysiwygComposer-test.tsx @@ -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(); diff --git a/test/unit-tests/components/views/rooms/wysiwyg_composer/components/PlainTextComposer-test.tsx b/test/unit-tests/components/views/rooms/wysiwyg_composer/components/PlainTextComposer-test.tsx index ae37afe860..059cf0967a 100644 --- a/test/unit-tests/components/views/rooms/wysiwyg_composer/components/PlainTextComposer-test.tsx +++ b/test/unit-tests/components/views/rooms/wysiwyg_composer/components/PlainTextComposer-test.tsx @@ -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, diff --git a/test/unit-tests/components/views/rooms/wysiwyg_composer/components/WysiwygAutocomplete-test.tsx b/test/unit-tests/components/views/rooms/wysiwyg_composer/components/WysiwygAutocomplete-test.tsx index b0f4bbb5bd..ae9f8d8402 100644 --- a/test/unit-tests/components/views/rooms/wysiwyg_composer/components/WysiwygAutocomplete-test.tsx +++ b/test/unit-tests/components/views/rooms/wysiwyg_composer/components/WysiwygAutocomplete-test.tsx @@ -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 diff --git a/test/unit-tests/components/views/rooms/wysiwyg_composer/components/WysiwygComposer-test.tsx b/test/unit-tests/components/views/rooms/wysiwyg_composer/components/WysiwygComposer-test.tsx index 4075788901..a911bac3d4 100644 --- a/test/unit-tests/components/views/rooms/wysiwyg_composer/components/WysiwygComposer-test.tsx +++ b/test/unit-tests/components/views/rooms/wysiwyg_composer/components/WysiwygComposer-test.tsx @@ -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(); diff --git a/test/unit-tests/components/views/rooms/wysiwyg_composer/utils/createMessageContent-test.ts b/test/unit-tests/components/views/rooms/wysiwyg_composer/utils/createMessageContent-test.ts index 74852e9c6d..68d23733e2 100644 --- a/test/unit-tests/components/views/rooms/wysiwyg_composer/utils/createMessageContent-test.ts +++ b/test/unit-tests/components/views/rooms/wysiwyg_composer/utils/createMessageContent-test.ts @@ -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 = "hello world"; @@ -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, {}); diff --git a/yarn.lock b/yarn.lock index 80c96f634c..e72b11a5ed 100644 --- a/yarn.lock +++ b/yarn.lock @@ -259,11 +259,6 @@ resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.25.9.tgz#1aabb72ee72ed35789b4bbcad3ca2862ce614e8c" integrity sha512-4A/SCr/2KLd5jrtOMFzaKjVtAei3+2r/NChoBNoZ3EyP/+GlhoaEGoWOZUmFmoITP7zOJyHIMm+DYRd8o3PvHA== -"@babel/helper-validator-identifier@^7.24.5": - version "7.25.7" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.7.tgz#77b7f60c40b15c97df735b38a66ba1d7c3e93da5" - integrity sha512-AM6TzwYqGChO45oiuPqwL2t20/HdMC1rTPAesnBCgPCSF1x3oN9MVUwQV2iyz4xqWrctwK5RNC8LV22kaQCNYg== - "@babel/helper-validator-identifier@^7.24.7", "@babel/helper-validator-identifier@^7.25.7", "@babel/helper-validator-identifier@^7.25.9": version "7.25.9" resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.9.tgz#24b64e2c3ec7cd3b3c547729b8d16871f22cbdc7" @@ -1542,21 +1537,6 @@ minimatch "^3.1.2" strip-json-comments "^3.1.1" -"@eslint/eslintrc@^3.0.2": - version "3.1.0" - resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-3.1.0.tgz#dbd3482bfd91efa663cbe7aa1f506839868207b6" - integrity sha512-4Bfj15dVJdoy3RfZmmo86RK1Fwzn6SstsvK9JS+BaVKqC6QQQQyXekNaC+g+LKNgkQ+2VhGAzm6hO40AhMR3zQ== - dependencies: - ajv "^6.12.4" - debug "^4.3.2" - espree "^10.0.1" - globals "^14.0.0" - ignore "^5.2.0" - import-fresh "^3.2.1" - js-yaml "^4.1.0" - minimatch "^3.1.2" - strip-json-comments "^3.1.1" - "@eslint/js@8.57.1": version "8.57.1" resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.57.1.tgz#de633db3ec2ef6a3c89e2f19038063e8a122e2c2" @@ -3410,12 +3390,16 @@ ts-xor "^1.3.0" vaul "^1.0.0" -"@vector-im/matrix-wysiwyg@2.37.13": - version "2.37.13" - resolved "https://registry.yarnpkg.com/@vector-im/matrix-wysiwyg/-/matrix-wysiwyg-2.37.13.tgz#7b64e7652a196e811c0470dcbff8d36e2229cd46" - integrity sha512-3ilnJBJSzeTfAQXNJJ29EAqa14exrkca3acTPssdoh3WhTKwXyQ0xU8sS50d6gqlAP/Nahw1y2k+PzajXo1SsQ== +"@vector-im/matrix-wysiwyg-wasm@link:../../bindings/wysiwyg-wasm": + version "0.0.0" + uid "" + +"@vector-im/matrix-wysiwyg@2.38.0": + version "2.38.0" + resolved "https://registry.yarnpkg.com/@vector-im/matrix-wysiwyg/-/matrix-wysiwyg-2.38.0.tgz#af862ffd231dc0a6b8d6f2cb3601e68456c0ff24" + integrity sha512-cMEVicFYVzFxuSyWON0aVGjAJMcgJZ+LxuLTEp8EGuu8cRacuh0RN5rapb11YVZygzFvE7X1cMedJ/fKd5vRLA== dependencies: - eslint-plugin-unicorn "^54.0.0" + "@vector-im/matrix-wysiwyg-wasm" "link:../../Library/Caches/Yarn/v6/npm-@vector-im-matrix-wysiwyg-2.38.0-af862ffd231dc0a6b8d6f2cb3601e68456c0ff24-integrity/node_modules/bindings/wysiwyg-wasm" "@webassemblyjs/ast@1.14.1", "@webassemblyjs/ast@^1.14.1": version "1.14.1" @@ -3613,7 +3597,7 @@ acorn-walk@^8.0.0, acorn-walk@^8.0.2, acorn-walk@^8.1.1: dependencies: acorn "^8.11.0" -acorn@^8.0.4, acorn@^8.1.0, acorn@^8.11.0, acorn@^8.12.0, acorn@^8.4.1, acorn@^8.9.0: +acorn@^8.0.4, acorn@^8.1.0, acorn@^8.11.0, acorn@^8.4.1, acorn@^8.9.0: version "8.13.0" resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.13.0.tgz#2a30d670818ad16ddd6a35d3842dacec9e5d7ca3" integrity sha512-8zSiw54Oxrdym50NlZ9sUusyO1Z1ZchgRLWRaK6c86XJFClyCgFKetdowBg5bKxyp/u+CDBJG4Mpp0m3HLZl9w== @@ -4616,13 +4600,6 @@ copy-webpack-plugin@^12.0.0: schema-utils "^4.2.0" serialize-javascript "^6.0.2" -core-js-compat@^3.37.0: - version "3.38.1" - resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.38.1.tgz#2bc7a298746ca5a7bcb9c164bcb120f2ebc09a09" - integrity sha512-JRH6gfXxGmrzF3tZ57lFx97YARxCXPaMzPo6jELZhv88pBH5VXpQ+y0znKGlFnzuaihqhLbefxSJxWJMPtfDzw== - dependencies: - browserslist "^4.23.3" - core-js-compat@^3.38.0, core-js-compat@^3.38.1: version "3.39.0" resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.39.0.tgz#b12dccb495f2601dc860bdbe7b4e3ffa8ba63f61" @@ -5696,28 +5673,6 @@ eslint-plugin-react@^7.28.0: string.prototype.matchall "^4.0.11" string.prototype.repeat "^1.0.0" -eslint-plugin-unicorn@^54.0.0: - version "54.0.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-unicorn/-/eslint-plugin-unicorn-54.0.0.tgz#ce3ea853e8fd7ca2bda2fd6065bf065adb5d8b6d" - integrity sha512-XxYLRiYtAWiAjPv6z4JREby1TAE2byBC7wlh0V4vWDCpccOSU1KovWV//jqPXF6bq3WKxqX9rdjoRQ1EhdmNdQ== - dependencies: - "@babel/helper-validator-identifier" "^7.24.5" - "@eslint-community/eslint-utils" "^4.4.0" - "@eslint/eslintrc" "^3.0.2" - ci-info "^4.0.0" - clean-regexp "^1.0.0" - core-js-compat "^3.37.0" - esquery "^1.5.0" - indent-string "^4.0.0" - is-builtin-module "^3.2.1" - jsesc "^3.0.2" - pluralize "^8.0.0" - read-pkg-up "^7.0.1" - regexp-tree "^0.1.27" - regjsparser "^0.10.0" - semver "^7.6.1" - strip-indent "^3.0.0" - eslint-plugin-unicorn@^56.0.0: version "56.0.1" resolved "https://registry.yarnpkg.com/eslint-plugin-unicorn/-/eslint-plugin-unicorn-56.0.1.tgz#d10a3df69ba885939075bdc95a65a0c872e940d4" @@ -5771,11 +5726,6 @@ eslint-visitor-keys@^3.3.0, eslint-visitor-keys@^3.4.1, eslint-visitor-keys@^3.4 resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz#0cd72fe8550e3c2eae156a96a4dddcd1c8ac5800" integrity sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag== -eslint-visitor-keys@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-4.1.0.tgz#1f785cc5e81eb7534523d85922248232077d2f8c" - integrity sha512-Q7lok0mqMUSf5a/AdAZkA5a/gHcO6snwQClVNNvFKCAVlxXucdU8pKydU5ZVZjBx5xr37vGbFFWtLQYreLzrZg== - eslint-visitor-keys@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz#687bacb2af884fcdda8a6e7d65c606f46a14cd45" @@ -5825,15 +5775,6 @@ eslint@8.57.1: strip-ansi "^6.0.1" text-table "^0.2.0" -espree@^10.0.1: - version "10.2.0" - resolved "https://registry.yarnpkg.com/espree/-/espree-10.2.0.tgz#f4bcead9e05b0615c968e85f83816bc386a45df6" - integrity sha512-upbkBJbckcCNBDBDXEbuhjbP68n+scUd3k/U2EkyM9nw+I/jPiL4cLF/Al06CF96wRltFda16sxDFrxsI1v0/g== - dependencies: - acorn "^8.12.0" - acorn-jsx "^5.3.2" - eslint-visitor-keys "^4.1.0" - espree@^10.3.0: version "10.3.0" resolved "https://registry.yarnpkg.com/espree/-/espree-10.3.0.tgz#29267cf5b0cb98735b65e64ba07e0ed49d1eed8a" @@ -5857,7 +5798,7 @@ esprima@^4.0.0, esprima@^4.0.1: resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== -esquery@^1.4.2, esquery@^1.5.0, esquery@^1.6.0: +esquery@^1.4.2, esquery@^1.6.0: version "1.6.0" resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.6.0.tgz#91419234f804d852a82dceec3e16cdc22cf9dae7" integrity sha512-ca9pw9fomFcKPvFLXhBKUK90ZvGibiGOvRJNbjljY7s7uq/5YO4BOzcYtJqExdx99rF6aAcnRxHmcUHcz6sQsg== @@ -6498,11 +6439,6 @@ globals@^13.19.0: dependencies: type-fest "^0.20.2" -globals@^14.0.0: - version "14.0.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-14.0.0.tgz#898d7413c29babcf6bafe56fcadded858ada724e" - integrity sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ== - globals@^15.9.0: version "15.13.0" resolved "https://registry.yarnpkg.com/globals/-/globals-15.13.0.tgz#bbec719d69aafef188ecd67954aae76a696010fc" @@ -10531,7 +10467,7 @@ semver@^6.3.0, semver@^6.3.1: resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4" integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA== -semver@^7.5.2, semver@^7.5.3, semver@^7.5.4, semver@^7.6.0, semver@^7.6.1, semver@^7.6.3: +semver@^7.5.2, semver@^7.5.3, semver@^7.5.4, semver@^7.6.0, semver@^7.6.3: version "7.6.3" resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.3.tgz#980f7b5550bc175fb4dc09403085627f9eb33143" integrity sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==