From 4186b8e8e83912f3dfa9ea96ceda46a0cf020e40 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Date: Fri, 10 Apr 2026 16:52:59 +0100 Subject: [PATCH] Convert TextualBody-test to out-of-line snapshots (#33104) Sonar complains about duplication in the inline snapshots --- .../views/messages/TextualBody-test.tsx | 20 +++++-------------- .../__snapshots__/TextualBody-test.tsx.snap | 10 ++++++++++ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/apps/web/test/unit-tests/components/views/messages/TextualBody-test.tsx b/apps/web/test/unit-tests/components/views/messages/TextualBody-test.tsx index 0fd8c7106b..286808abd6 100644 --- a/apps/web/test/unit-tests/components/views/messages/TextualBody-test.tsx +++ b/apps/web/test/unit-tests/components/views/messages/TextualBody-test.tsx @@ -214,36 +214,28 @@ describe("", () => { const ev = mkRoomTextMessage("Chat with @user:example.com"); const { container } = getComponent({ mxEvent: ev }); const content = container.querySelector(".mx_EventTile_body"); - expect(content.innerHTML).toMatchInlineSnapshot( - `"Chat with @user:example.com"`, - ); + expect(content.innerHTML).toMatchSnapshot(); }); it("should pillify an MXID permalink", () => { const ev = mkRoomTextMessage("Chat with https://matrix.to/#/@user:example.com"); const { container } = getComponent({ mxEvent: ev }); const content = container.querySelector(".mx_EventTile_body"); - expect(content.innerHTML).toMatchInlineSnapshot( - `"Chat with Member"`, - ); + expect(content.innerHTML).toMatchSnapshot(); }); it("should not pillify room aliases", () => { const ev = mkRoomTextMessage("Visit #room:example.com"); const { container } = getComponent({ mxEvent: ev }); const content = container.querySelector(".mx_EventTile_body"); - expect(content.innerHTML).toMatchInlineSnapshot( - `"Visit #room:example.com"`, - ); + expect(content.innerHTML).toMatchSnapshot(); }); it("should pillify a room alias permalink", () => { const ev = mkRoomTextMessage("Visit https://matrix.to/#/#room:example.com"); const { container } = getComponent({ mxEvent: ev }); const content = container.querySelector(".mx_EventTile_body"); - expect(content.innerHTML).toMatchInlineSnapshot( - `"Visit #room:example.com"`, - ); + expect(content.innerHTML).toMatchSnapshot(); }); it("should pillify a permalink to a message in the same room with the label »Message from Member«", () => { @@ -279,9 +271,7 @@ describe("", () => { }); const { container } = getComponent({ mxEvent: ev }); const content = container.querySelector(".mx_EventTile_body"); - expect(content.innerHTML).toMatchInlineSnapshot( - `"foo bar baz"`, - ); + expect(content.innerHTML).toMatchSnapshot(); }); }); diff --git a/apps/web/test/unit-tests/components/views/messages/__snapshots__/TextualBody-test.tsx.snap b/apps/web/test/unit-tests/components/views/messages/__snapshots__/TextualBody-test.tsx.snap index 3e071d8cbf..b5f7f5c98d 100644 --- a/apps/web/test/unit-tests/components/views/messages/__snapshots__/TextualBody-test.tsx.snap +++ b/apps/web/test/unit-tests/components/views/messages/__snapshots__/TextualBody-test.tsx.snap @@ -567,6 +567,12 @@ exports[` renders plain-text m.text correctly linkification get a `; +exports[` renders plain-text m.text correctly should not pillify MXIDs 1`] = `"Chat with @user:example.com"`; + +exports[` renders plain-text m.text correctly should not pillify room aliases 1`] = `"Visit #room:example.com"`; + +exports[` renders plain-text m.text correctly should pillify a keyword responsible for triggering a notification 1`] = `"foo bar baz"`; + exports[` renders plain-text m.text correctly should pillify a permalink to a message in the same room with the label »Message from Member« 1`] = `"Visit Message from Member"`; exports[` renders plain-text m.text correctly should pillify a permalink to an event in another room with the label »Message in Room 2« 1`] = `"Visit Message in Room 2"`; @@ -604,6 +610,10 @@ exports[` renders plain-text m.text correctly should pillify a pe `; +exports[` renders plain-text m.text correctly should pillify a room alias permalink 1`] = `"Visit #room:example.com"`; + +exports[` renders plain-text m.text correctly should pillify an MXID permalink 1`] = `"Chat with Member"`; + exports[` renders plain-text m.text correctly simple message renders as expected 1`] = `