From 18ef337aef805c3bb0cf7216511e620ab13862a9 Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Fri, 23 Feb 2024 11:48:23 +1300 Subject: [PATCH] Add test case for unreachable emojis This test is for commit 6e41f85 --- m2d/converters/event-to-message.test.js | 27 ++++++++++++++++++++++++- test/ooye-test-data.sql | 1 + 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/m2d/converters/event-to-message.test.js b/m2d/converters/event-to-message.test.js index 3865999e..1573a943 100644 --- a/m2d/converters/event-to-message.test.js +++ b/m2d/converters/event-to-message.test.js @@ -3522,7 +3522,7 @@ test("event2message: guessed @mentions work with other matrix bridge old users", ) }) -slow()("event2message: unknown emoji in the end is reuploaded as a sprite sheet", async t => { +slow()("event2message: unknown emoji at the end is reuploaded as a sprite sheet", async t => { const messages = await eventToMessage({ type: "m.room.message", sender: "@cadence:cadence.moe", @@ -3547,6 +3547,31 @@ slow()("event2message: unknown emoji in the end is reuploaded as a sprite sheet" }) }) +slow()("event2message: known emoji from an unreachable server at the end is reuploaded as a sprite sheet", async t => { + const messages = await eventToMessage({ + type: "m.room.message", + sender: "@cadence:cadence.moe", + content: { + msgtype: "m.text", + body: "wrong body", + format: "org.matrix.custom.html", + formatted_body: 'a b \":emoji_from_unreachable_server:\"' + }, + event_id: "$g07oYSZFWBkxohNEfywldwgcWj1hbhDzQ1sBAKvqOOU", + room_id: "!kLRqKKUQXcibIMtOpl:cadence.moe" + }) + const testResult = { + content: messages.messagesToSend[0].content, + fileName: messages.messagesToSend[0].pendingFiles[0].name, + fileContentStart: messages.messagesToSend[0].pendingFiles[0].buffer.subarray(0, 90).toString("base64") + } + t.deepEqual(testResult, { + content: "a b", + fileName: "emojis.png", + fileContentStart: "iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAPoAAAD6AG1e1JrAAAOnUlEQVR4nM1aCXCb1Z3/kig+5NjWaeu+LOuWLFnHJ8l2" + }) +}) + slow()("event2message: known and unknown emojis in the end are reuploaded as a sprite sheet", async t => { const messages = await eventToMessage({ type: "m.room.message", diff --git a/test/ooye-test-data.sql b/test/ooye-test-data.sql index d9a8263a..d7dfd211 100644 --- a/test/ooye-test-data.sql +++ b/test/ooye-test-data.sql @@ -104,6 +104,7 @@ INSERT INTO file (discord_url, mxc_url) VALUES INSERT INTO emoji (emoji_id, name, animated, mxc_url) VALUES ('230201364309868544', 'hippo', 0, 'mxc://cadence.moe/qWmbXeRspZRLPcjseyLmeyXC'), ('393635038903926784', 'hipposcope', 1, 'mxc://cadence.moe/WbYqNlACRuicynBfdnPYtmvc'), +('457898385297815911', 'emoji_from_unreachable_server', 0, 'mxc://cadence.moe/bZFuuUSEebJYXUMSxuuSuLTa'), ('362741439211503616', 'bn_re', 0, 'mxc://cadence.moe/OIpqpfxTnHKokcsYqDusxkBT'), ('551636841284108289', 'ae_botrac4r', 0, 'mxc://cadence.moe/skqfuItqxNmBYekzmVKyoLzs'), ('975572106295259148', 'brillillillilliant_move', 0, 'mxc://cadence.moe/scfRIDOGKWFDEBjVXocWYQHik'),