Remove reply fallbacks as per merged MSC2781 (#28406)
* Remove reply fallbacks as per merged MSC2781 Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Update tests Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Improve coverage Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
73db771ff3
commit
349c9b0c26
14 changed files with 75 additions and 462 deletions
|
@ -351,7 +351,7 @@ describe("Notifier", () => {
|
|||
user: mockClient.getSafeUserId(),
|
||||
room: testRoom.roomId,
|
||||
});
|
||||
addReplyToMessageContent(reply.getContent(), event, { includeLegacyFallback: true });
|
||||
addReplyToMessageContent(reply.getContent(), event);
|
||||
Notifier.displayPopupNotification(reply, testRoom);
|
||||
expect(MockPlatform.displayNotification).toHaveBeenCalledWith(
|
||||
"@bob:example.org (!room1:server)",
|
||||
|
|
|
@ -6,42 +6,10 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
|
|||
Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
import {
|
||||
IContent,
|
||||
MatrixEvent,
|
||||
MsgType,
|
||||
M_BEACON_INFO,
|
||||
LocationAssetType,
|
||||
M_ASSET,
|
||||
M_POLL_END,
|
||||
Room,
|
||||
} from "matrix-js-sdk/src/matrix";
|
||||
import { Room } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import {
|
||||
getNestedReplyText,
|
||||
getParentEventId,
|
||||
shouldDisplayReply,
|
||||
stripHTMLReply,
|
||||
stripPlainReply,
|
||||
} from "../../src/utils/Reply";
|
||||
import { makePollStartEvent, mkEvent, stubClient } from "../test-utils";
|
||||
import { RoomPermalinkCreator } from "../../src/utils/permalinks/Permalinks";
|
||||
|
||||
function makeTestEvent(type: string, content: IContent): MatrixEvent {
|
||||
return mkEvent({
|
||||
event: true,
|
||||
type: type,
|
||||
user: "@user1:server",
|
||||
room: "!room1:server",
|
||||
content,
|
||||
});
|
||||
}
|
||||
|
||||
const mockPermalinkGenerator = {
|
||||
forEvent(eventId: string): string {
|
||||
return "$$permalink$$";
|
||||
},
|
||||
} as RoomPermalinkCreator;
|
||||
import { getParentEventId, shouldDisplayReply, stripHTMLReply, stripPlainReply } from "../../src/utils/Reply";
|
||||
import { mkEvent, stubClient } from "../test-utils";
|
||||
|
||||
// don't litter test console with logs
|
||||
jest.mock("matrix-js-sdk/src/logger");
|
||||
|
@ -122,50 +90,6 @@ But this is not
|
|||
});
|
||||
});
|
||||
|
||||
describe("getNestedReplyText", () => {
|
||||
it("Returns valid reply fallback text for m.text msgtypes", () => {
|
||||
const event = makeTestEvent(MsgType.Text, {
|
||||
body: "body",
|
||||
msgtype: "m.text",
|
||||
});
|
||||
|
||||
expect(getNestedReplyText(event, mockPermalinkGenerator)).toMatchSnapshot();
|
||||
});
|
||||
|
||||
(
|
||||
[
|
||||
["m.room.message", MsgType.Location, LocationAssetType.Pin],
|
||||
["m.room.message", MsgType.Location, LocationAssetType.Self],
|
||||
[M_BEACON_INFO.name, undefined, LocationAssetType.Pin],
|
||||
[M_BEACON_INFO.name, undefined, LocationAssetType.Self],
|
||||
] as const
|
||||
).forEach(([type, msgType, assetType]) => {
|
||||
it(`should create the expected fallback text for ${assetType} ${type}/${msgType}`, () => {
|
||||
const event = makeTestEvent(type, {
|
||||
body: "body",
|
||||
msgtype: msgType,
|
||||
[M_ASSET.name]: { type: assetType },
|
||||
});
|
||||
|
||||
expect(getNestedReplyText(event, mockPermalinkGenerator)).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
it("should create the expected fallback text for poll end events", () => {
|
||||
const event = makeTestEvent(M_POLL_END.name, {
|
||||
body: "body",
|
||||
});
|
||||
|
||||
expect(getNestedReplyText(event, mockPermalinkGenerator)).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("should create the expected fallback text for poll start events", () => {
|
||||
const event = makePollStartEvent("Will this test pass?", "@user:server.org");
|
||||
|
||||
expect(getNestedReplyText(event, mockPermalinkGenerator)).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
describe("shouldDisplayReply", () => {
|
||||
it("Returns false for redacted events", () => {
|
||||
const event = mkEvent({
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Reply getNestedReplyText Returns valid reply fallback text for m.text msgtypes 1`] = `
|
||||
{
|
||||
"body": "> <@user1:server> body
|
||||
|
||||
",
|
||||
"html": "<mx-reply><blockquote><a href="$$permalink$$">In reply to</a> <a href="https://matrix.to/#/@user1:server">@user1:server</a><br>body</blockquote></mx-reply>",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Reply getNestedReplyText should create the expected fallback text for m.pin m.room.message/m.location 1`] = `
|
||||
{
|
||||
"body": "> <@user1:server> shared a location.
|
||||
|
||||
",
|
||||
"html": "<mx-reply><blockquote><a href="$$permalink$$">In reply to</a> <a href="https://matrix.to/#/@user1:server">@user1:server</a><br>shared a location.</blockquote></mx-reply>",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Reply getNestedReplyText should create the expected fallback text for m.pin org.matrix.msc3672.beacon_info/undefined 1`] = `
|
||||
{
|
||||
"body": "> <@user1:server> shared a live location.
|
||||
|
||||
",
|
||||
"html": "<mx-reply><blockquote><a href="$$permalink$$">In reply to</a> <a href="https://matrix.to/#/@user1:server">@user1:server</a><br>shared a live location.</blockquote></mx-reply>",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Reply getNestedReplyText should create the expected fallback text for m.self m.room.message/m.location 1`] = `
|
||||
{
|
||||
"body": "> <@user1:server> shared their location.
|
||||
|
||||
",
|
||||
"html": "<mx-reply><blockquote><a href="$$permalink$$">In reply to</a> <a href="https://matrix.to/#/@user1:server">@user1:server</a><br>shared their location.</blockquote></mx-reply>",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Reply getNestedReplyText should create the expected fallback text for m.self org.matrix.msc3672.beacon_info/undefined 1`] = `
|
||||
{
|
||||
"body": "> <@user1:server> shared their live location.
|
||||
|
||||
",
|
||||
"html": "<mx-reply><blockquote><a href="$$permalink$$">In reply to</a> <a href="https://matrix.to/#/@user1:server">@user1:server</a><br>shared their live location.</blockquote></mx-reply>",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Reply getNestedReplyText should create the expected fallback text for poll end events 1`] = `
|
||||
{
|
||||
"body": "> <@user1:server>Ended poll
|
||||
|
||||
",
|
||||
"html": "<mx-reply><blockquote><a href="$$permalink$$">In reply to</a> <a href="https://matrix.to/#/@user1:server">@user1:server</a><br>Ended poll</blockquote></mx-reply>",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Reply getNestedReplyText should create the expected fallback text for poll start events 1`] = `
|
||||
{
|
||||
"body": "> <@user:server.org> started poll: Will this test pass?
|
||||
|
||||
",
|
||||
"html": "<mx-reply><blockquote><a href="$$permalink$$">In reply to</a> <a href="https://matrix.to/#/@user:server.org">@user:server.org</a><br>Poll: Will this test pass?</blockquote></mx-reply>",
|
||||
}
|
||||
`;
|
|
@ -27,7 +27,6 @@ import defaultDispatcher from "../../../../../src/dispatcher/dispatcher";
|
|||
import DocumentOffset from "../../../../../src/editor/offset";
|
||||
import { Layout } from "../../../../../src/settings/enums/Layout";
|
||||
import { IRoomState, MainSplitContentType } from "../../../../../src/components/structures/RoomView";
|
||||
import { RoomPermalinkCreator } from "../../../../../src/utils/permalinks/Permalinks";
|
||||
import { mockPlatformPeg } from "../../../../test-utils/platform";
|
||||
import { doMaybeLocalRoomAction } from "../../../../../src/utils/local-room";
|
||||
import { addTextToComposer } from "../../../../test-utils/composer";
|
||||
|
@ -80,14 +79,12 @@ describe("<SendMessageComposer/>", () => {
|
|||
viewRoomOpts: { buttons: [] },
|
||||
};
|
||||
describe("createMessageContent", () => {
|
||||
const permalinkCreator = jest.fn() as any;
|
||||
|
||||
it("sends plaintext messages correctly", () => {
|
||||
const model = new EditorModel([], createPartCreator());
|
||||
const documentOffset = new DocumentOffset(11, true);
|
||||
model.update("hello world", "insertText", documentOffset);
|
||||
|
||||
const content = createMessageContent("@alice:test", model, undefined, undefined, permalinkCreator);
|
||||
const content = createMessageContent("@alice:test", model, undefined, undefined);
|
||||
|
||||
expect(content).toEqual({
|
||||
"body": "hello world",
|
||||
|
@ -101,7 +98,7 @@ describe("<SendMessageComposer/>", () => {
|
|||
const documentOffset = new DocumentOffset(13, true);
|
||||
model.update("hello *world*", "insertText", documentOffset);
|
||||
|
||||
const content = createMessageContent("@alice:test", model, undefined, undefined, permalinkCreator);
|
||||
const content = createMessageContent("@alice:test", model, undefined, undefined);
|
||||
|
||||
expect(content).toEqual({
|
||||
"body": "hello *world*",
|
||||
|
@ -117,7 +114,7 @@ describe("<SendMessageComposer/>", () => {
|
|||
const documentOffset = new DocumentOffset(22, true);
|
||||
model.update("/me blinks __quickly__", "insertText", documentOffset);
|
||||
|
||||
const content = createMessageContent("@alice:test", model, undefined, undefined, permalinkCreator);
|
||||
const content = createMessageContent("@alice:test", model, undefined, undefined);
|
||||
|
||||
expect(content).toEqual({
|
||||
"body": "blinks __quickly__",
|
||||
|
@ -134,7 +131,7 @@ describe("<SendMessageComposer/>", () => {
|
|||
model.update("/me ✨sparkles✨", "insertText", documentOffset);
|
||||
expect(model.parts.length).toEqual(4); // Emoji count as non-text
|
||||
|
||||
const content = createMessageContent("@alice:test", model, undefined, undefined, permalinkCreator);
|
||||
const content = createMessageContent("@alice:test", model, undefined, undefined);
|
||||
|
||||
expect(content).toEqual({
|
||||
"body": "✨sparkles✨",
|
||||
|
@ -149,7 +146,7 @@ describe("<SendMessageComposer/>", () => {
|
|||
|
||||
model.update("//dev/null is my favourite place", "insertText", documentOffset);
|
||||
|
||||
const content = createMessageContent("@alice:test", model, undefined, undefined, permalinkCreator);
|
||||
const content = createMessageContent("@alice:test", model, undefined, undefined);
|
||||
|
||||
expect(content).toEqual({
|
||||
"body": "/dev/null is my favourite place",
|
||||
|
@ -364,7 +361,6 @@ describe("<SendMessageComposer/>", () => {
|
|||
const defaultProps = {
|
||||
room: mockRoom,
|
||||
toggleStickerPickerOpen: jest.fn(),
|
||||
permalinkCreator: new RoomPermalinkCreator(mockRoom),
|
||||
};
|
||||
const getRawComponent = (props = {}, roomContext = defaultRoomContext, client = mockClient) => (
|
||||
<MatrixClientContext.Provider value={client}>
|
||||
|
@ -482,6 +478,44 @@ describe("<SendMessageComposer/>", () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("correctly sends a reply using a slash command", async () => {
|
||||
stubClient();
|
||||
mocked(doMaybeLocalRoomAction).mockImplementation(
|
||||
<T,>(roomId: string, fn: (actualRoomId: string) => Promise<T>, _client?: MatrixClient) => {
|
||||
return fn(roomId);
|
||||
},
|
||||
);
|
||||
|
||||
const replyToEvent = mkEvent({
|
||||
type: "m.room.message",
|
||||
user: "@bob:test",
|
||||
room: "!abc:test",
|
||||
content: { "m.mentions": {} },
|
||||
event: true,
|
||||
});
|
||||
|
||||
mockPlatformPeg({ overrideBrowserShortcuts: jest.fn().mockReturnValue(false) });
|
||||
const { container } = getComponent({ replyToEvent });
|
||||
|
||||
addTextToComposer(container, "/tableflip");
|
||||
fireEvent.keyDown(container.querySelector(".mx_SendMessageComposer")!, { key: "Enter" });
|
||||
|
||||
await waitFor(() =>
|
||||
expect(mockClient.sendMessage).toHaveBeenCalledWith("myfakeroom", null, {
|
||||
"body": "(╯°□°)╯︵ ┻━┻",
|
||||
"msgtype": MsgType.Text,
|
||||
"m.mentions": {
|
||||
user_ids: ["@bob:test"],
|
||||
},
|
||||
"m.relates_to": {
|
||||
"m.in_reply_to": {
|
||||
event_id: replyToEvent.getId(),
|
||||
},
|
||||
},
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("shows chat effects on message sending", () => {
|
||||
mocked(doMaybeLocalRoomAction).mockImplementation(
|
||||
<T,>(roomId: string, fn: (actualRoomId: string) => Promise<T>, _client?: MatrixClient) => {
|
||||
|
|
|
@ -15,7 +15,6 @@ import VoiceRecordComposerTile from "../../../../../src/components/views/rooms/V
|
|||
import { doMaybeLocalRoomAction } from "../../../../../src/utils/local-room";
|
||||
import { MatrixClientPeg } from "../../../../../src/MatrixClientPeg";
|
||||
import { IUpload, VoiceMessageRecording } from "../../../../../src/audio/VoiceMessageRecording";
|
||||
import { RoomPermalinkCreator } from "../../../../../src/utils/permalinks/Permalinks";
|
||||
import { VoiceRecordingStore } from "../../../../../src/stores/VoiceRecordingStore";
|
||||
import { PlaybackClock } from "../../../../../src/audio/PlaybackClock";
|
||||
import { mkEvent } from "../../../../test-utils";
|
||||
|
@ -57,7 +56,6 @@ describe("<VoiceRecordComposerTile/>", () => {
|
|||
const props = {
|
||||
room,
|
||||
ref: voiceRecordComposerTile,
|
||||
permalinkCreator: new RoomPermalinkCreator(room),
|
||||
};
|
||||
mockUpload = {
|
||||
mxc: "mxc://example.com/voice",
|
||||
|
@ -142,7 +140,6 @@ describe("<VoiceRecordComposerTile/>", () => {
|
|||
const props = {
|
||||
room,
|
||||
ref: voiceRecordComposerTile,
|
||||
permalinkCreator: new RoomPermalinkCreator(room),
|
||||
replyToEvent,
|
||||
};
|
||||
render(<VoiceRecordComposerTile {...props} />);
|
||||
|
|
|
@ -8,26 +8,13 @@ Please see LICENSE files in the repository root for full details.
|
|||
import { MsgType } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import { filterConsole, mkEvent } from "../../../../../../test-utils";
|
||||
import { RoomPermalinkCreator } from "../../../../../../../src/utils/permalinks/Permalinks";
|
||||
import {
|
||||
createMessageContent,
|
||||
EMOTE_PREFIX,
|
||||
} from "../../../../../../../src/components/views/rooms/wysiwyg_composer/utils/createMessageContent";
|
||||
|
||||
describe("createMessageContent", () => {
|
||||
const permalinkCreator = {
|
||||
forEvent(eventId: string): string {
|
||||
return "$$permalink$$";
|
||||
},
|
||||
} as RoomPermalinkCreator;
|
||||
const message = "<em><b>hello</b> world</em>";
|
||||
const mockEvent = mkEvent({
|
||||
type: "m.room.message",
|
||||
room: "myfakeroom",
|
||||
user: "myfakeuser",
|
||||
content: { msgtype: "m.text", body: "Replying to this" },
|
||||
event: true,
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.resetAllMocks();
|
||||
|
@ -42,12 +29,12 @@ describe("createMessageContent", () => {
|
|||
// 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, { permalinkCreator });
|
||||
await createMessageContent(message, true, {});
|
||||
}, 10000);
|
||||
|
||||
it("Should create html message", async () => {
|
||||
// When
|
||||
const content = await createMessageContent(message, true, { permalinkCreator });
|
||||
const content = await createMessageContent(message, true, {});
|
||||
|
||||
// Then
|
||||
expect(content).toEqual({
|
||||
|
@ -58,34 +45,13 @@ describe("createMessageContent", () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("Should add reply to message content", async () => {
|
||||
// When
|
||||
const content = await createMessageContent(message, true, { permalinkCreator, replyToEvent: mockEvent });
|
||||
|
||||
// Then
|
||||
expect(content).toEqual({
|
||||
"body": "> <myfakeuser> Replying to this\n\n*__hello__ world*",
|
||||
"format": "org.matrix.custom.html",
|
||||
"formatted_body":
|
||||
'<mx-reply><blockquote><a href="$$permalink$$">In reply to</a>' +
|
||||
' <a href="https://matrix.to/#/myfakeuser">myfakeuser</a>' +
|
||||
"<br>Replying to this</blockquote></mx-reply><em><b>hello</b> world</em>",
|
||||
"msgtype": "m.text",
|
||||
"m.relates_to": {
|
||||
"m.in_reply_to": {
|
||||
event_id: mockEvent.getId(),
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("Should add relation to message", async () => {
|
||||
// When
|
||||
const relation = {
|
||||
rel_type: "m.thread",
|
||||
event_id: "myFakeThreadId",
|
||||
};
|
||||
const content = await createMessageContent(message, true, { permalinkCreator, relation });
|
||||
const content = await createMessageContent(message, true, { relation });
|
||||
|
||||
// Then
|
||||
expect(content).toEqual({
|
||||
|
@ -118,7 +84,7 @@ describe("createMessageContent", () => {
|
|||
},
|
||||
event: true,
|
||||
});
|
||||
const content = await createMessageContent(message, true, { permalinkCreator, editedEvent });
|
||||
const content = await createMessageContent(message, true, { editedEvent });
|
||||
|
||||
// Then
|
||||
expect(content).toEqual({
|
||||
|
@ -141,20 +107,20 @@ describe("createMessageContent", () => {
|
|||
|
||||
it("Should strip the /me prefix from a message", async () => {
|
||||
const textBody = "some body text";
|
||||
const content = await createMessageContent(EMOTE_PREFIX + textBody, true, { permalinkCreator });
|
||||
const content = await createMessageContent(EMOTE_PREFIX + textBody, true, {});
|
||||
|
||||
expect(content).toMatchObject({ body: textBody, formatted_body: textBody });
|
||||
});
|
||||
|
||||
it("Should strip single / from message prefixed with //", async () => {
|
||||
const content = await createMessageContent("//twoSlashes", true, { permalinkCreator });
|
||||
const content = await createMessageContent("//twoSlashes", true, {});
|
||||
|
||||
expect(content).toMatchObject({ body: "/twoSlashes", formatted_body: "/twoSlashes" });
|
||||
});
|
||||
|
||||
it("Should set the content type to MsgType.Emote when /me prefix is used", async () => {
|
||||
const textBody = "some body text";
|
||||
const content = await createMessageContent(EMOTE_PREFIX + textBody, true, { permalinkCreator });
|
||||
const content = await createMessageContent(EMOTE_PREFIX + textBody, true, {});
|
||||
|
||||
expect(content).toMatchObject({ msgtype: MsgType.Emote });
|
||||
});
|
||||
|
@ -164,14 +130,14 @@ describe("createMessageContent", () => {
|
|||
it("Should replace at-room mentions with `@room` in body", async () => {
|
||||
const messageComposerState = `<a href="#" contenteditable="false" data-mention-type="at-room" style="some styling">@room</a> `;
|
||||
|
||||
const content = await createMessageContent(messageComposerState, false, { permalinkCreator });
|
||||
const content = await createMessageContent(messageComposerState, false, {});
|
||||
expect(content).toMatchObject({ body: "@room " });
|
||||
});
|
||||
|
||||
it("Should replace user mentions with user name in body", async () => {
|
||||
const messageComposerState = `<a href="https://matrix.to/#/@test_user:element.io" contenteditable="false" data-mention-type="user" style="some styling">a test user</a> `;
|
||||
|
||||
const content = await createMessageContent(messageComposerState, false, { permalinkCreator });
|
||||
const content = await createMessageContent(messageComposerState, false, {});
|
||||
|
||||
expect(content).toMatchObject({ body: "a test user " });
|
||||
});
|
||||
|
@ -179,7 +145,7 @@ describe("createMessageContent", () => {
|
|||
it("Should replace room mentions with room mxid in body", async () => {
|
||||
const messageComposerState = `<a href="https://matrix.to/#/#test_room:element.io" contenteditable="false" data-mention-type="room" style="some styling">a test room</a> `;
|
||||
|
||||
const content = await createMessageContent(messageComposerState, false, { permalinkCreator });
|
||||
const content = await createMessageContent(messageComposerState, false, {});
|
||||
|
||||
expect(content).toMatchObject({
|
||||
body: "#test_room:element.io ",
|
||||
|
|
|
@ -17,7 +17,6 @@ import { createTestClient, getRoomContext, mkEvent, mkStubRoom } from "../../../
|
|||
import defaultDispatcher from "../../../../../../../src/dispatcher/dispatcher";
|
||||
import SettingsStore from "../../../../../../../src/settings/SettingsStore";
|
||||
import { SettingLevel } from "../../../../../../../src/settings/SettingLevel";
|
||||
import { RoomPermalinkCreator } from "../../../../../../../src/utils/permalinks/Permalinks";
|
||||
import EditorStateTransfer from "../../../../../../../src/utils/EditorStateTransfer";
|
||||
import * as ConfirmRedactDialog from "../../../../../../../src/components/views/dialogs/ConfirmRedactDialog";
|
||||
import * as SlashCommands from "../../../../../../../src/SlashCommands";
|
||||
|
@ -27,11 +26,6 @@ import { MatrixClientPeg } from "../../../../../../../src/MatrixClientPeg";
|
|||
import { Action } from "../../../../../../../src/dispatcher/actions";
|
||||
|
||||
describe("message", () => {
|
||||
const permalinkCreator = {
|
||||
forEvent(eventId: string): string {
|
||||
return "$$permalink$$";
|
||||
},
|
||||
} as RoomPermalinkCreator;
|
||||
const message = "<i><b>hello</b> world</i>";
|
||||
const mockEvent = mkEvent({
|
||||
type: "m.room.message",
|
||||
|
@ -71,7 +65,7 @@ describe("message", () => {
|
|||
describe("sendMessage", () => {
|
||||
it("Should not send empty html message", async () => {
|
||||
// When
|
||||
await sendMessage("", true, { roomContext: defaultRoomContext, mxClient: mockClient, permalinkCreator });
|
||||
await sendMessage("", true, { roomContext: defaultRoomContext, mxClient: mockClient });
|
||||
|
||||
// Then
|
||||
expect(mockClient.sendMessage).toHaveBeenCalledTimes(0);
|
||||
|
@ -86,7 +80,6 @@ describe("message", () => {
|
|||
await sendMessage(message, true, {
|
||||
roomContext: mockRoomContextWithoutId,
|
||||
mxClient: mockClient,
|
||||
permalinkCreator,
|
||||
});
|
||||
|
||||
// Then
|
||||
|
@ -100,7 +93,6 @@ describe("message", () => {
|
|||
await sendMessage(message, true, {
|
||||
roomContext: defaultRoomContext,
|
||||
mxClient: mockClient,
|
||||
permalinkCreator,
|
||||
});
|
||||
|
||||
// Then
|
||||
|
@ -111,7 +103,6 @@ describe("message", () => {
|
|||
await sendMessage(message, true, {
|
||||
roomContext: defaultRoomContext,
|
||||
mxClient: mockClient,
|
||||
permalinkCreator,
|
||||
relation: {},
|
||||
});
|
||||
|
||||
|
@ -123,7 +114,6 @@ describe("message", () => {
|
|||
await sendMessage(message, true, {
|
||||
roomContext: defaultRoomContext,
|
||||
mxClient: mockClient,
|
||||
permalinkCreator,
|
||||
relation: {
|
||||
event_id: "valid_id",
|
||||
rel_type: "m.does_not_match",
|
||||
|
@ -139,7 +129,6 @@ describe("message", () => {
|
|||
await sendMessage(message, true, {
|
||||
roomContext: defaultRoomContext,
|
||||
mxClient: mockClient,
|
||||
permalinkCreator,
|
||||
relation: {
|
||||
event_id: "valid_id",
|
||||
rel_type: "m.thread",
|
||||
|
@ -156,7 +145,6 @@ describe("message", () => {
|
|||
await sendMessage(message, true, {
|
||||
roomContext: defaultRoomContext,
|
||||
mxClient: mockClient,
|
||||
permalinkCreator,
|
||||
});
|
||||
|
||||
// Then
|
||||
|
@ -183,7 +171,6 @@ describe("message", () => {
|
|||
await sendMessage(message, true, {
|
||||
roomContext: defaultRoomContext,
|
||||
mxClient: mockClient,
|
||||
permalinkCreator,
|
||||
replyToEvent: mockReplyEvent,
|
||||
});
|
||||
|
||||
|
@ -195,12 +182,9 @@ describe("message", () => {
|
|||
});
|
||||
|
||||
const expectedContent = {
|
||||
"body": "> <myfakeuser2> My reply\n\n*__hello__ world*",
|
||||
"body": "*__hello__ world*",
|
||||
"format": "org.matrix.custom.html",
|
||||
"formatted_body":
|
||||
'<mx-reply><blockquote><a href="$$permalink$$">In reply to</a>' +
|
||||
' <a href="https://matrix.to/#/myfakeuser2">myfakeuser2</a>' +
|
||||
"<br>My reply</blockquote></mx-reply><i><b>hello</b> world</i>",
|
||||
"formatted_body": "<i><b>hello</b> world</i>",
|
||||
"msgtype": "m.text",
|
||||
"m.relates_to": {
|
||||
"m.in_reply_to": {
|
||||
|
@ -217,7 +201,6 @@ describe("message", () => {
|
|||
await sendMessage(message, true, {
|
||||
roomContext: defaultRoomContext,
|
||||
mxClient: mockClient,
|
||||
permalinkCreator,
|
||||
});
|
||||
|
||||
// Then
|
||||
|
@ -229,7 +212,7 @@ describe("message", () => {
|
|||
|
||||
it("Should handle emojis", async () => {
|
||||
// When
|
||||
await sendMessage("🎉", false, { roomContext: defaultRoomContext, mxClient: mockClient, permalinkCreator });
|
||||
await sendMessage("🎉", false, { roomContext: defaultRoomContext, mxClient: mockClient });
|
||||
|
||||
// Then
|
||||
expect(spyDispatcher).toHaveBeenCalledWith({ action: "effects.confetti" });
|
||||
|
@ -244,7 +227,6 @@ describe("message", () => {
|
|||
await sendMessage(validCommand, true, {
|
||||
roomContext: defaultRoomContext,
|
||||
mxClient: mockClient,
|
||||
permalinkCreator,
|
||||
});
|
||||
|
||||
// Then
|
||||
|
@ -257,7 +239,6 @@ describe("message", () => {
|
|||
await sendMessage(invalidPrefixCommand, true, {
|
||||
roomContext: defaultRoomContext,
|
||||
mxClient: mockClient,
|
||||
permalinkCreator,
|
||||
});
|
||||
|
||||
// Then
|
||||
|
@ -275,7 +256,6 @@ describe("message", () => {
|
|||
const result = await sendMessage(validCommand, true, {
|
||||
roomContext: defaultRoomContext,
|
||||
mxClient: mockClient,
|
||||
permalinkCreator,
|
||||
});
|
||||
|
||||
// Then
|
||||
|
@ -290,7 +270,6 @@ describe("message", () => {
|
|||
await sendMessage(inputText, true, {
|
||||
roomContext: defaultRoomContext,
|
||||
mxClient: mockClient,
|
||||
permalinkCreator,
|
||||
});
|
||||
expect(mockClient.sendMessage).toHaveBeenCalledWith(
|
||||
"myfakeroom",
|
||||
|
@ -309,7 +288,6 @@ describe("message", () => {
|
|||
await sendMessage(inputText, true, {
|
||||
roomContext: defaultRoomContext,
|
||||
mxClient: mockClient,
|
||||
permalinkCreator,
|
||||
relation: mockRelation,
|
||||
});
|
||||
|
||||
|
@ -326,7 +304,6 @@ describe("message", () => {
|
|||
await sendMessage("input", true, {
|
||||
roomContext: defaultRoomContext,
|
||||
mxClient: mockClient,
|
||||
permalinkCreator,
|
||||
replyToEvent: mockEvent,
|
||||
});
|
||||
|
||||
|
@ -341,7 +318,6 @@ describe("message", () => {
|
|||
const result = await sendMessage(input, true, {
|
||||
roomContext: defaultRoomContext,
|
||||
mxClient: mockClient,
|
||||
permalinkCreator,
|
||||
replyToEvent: mockEvent,
|
||||
});
|
||||
|
||||
|
@ -357,7 +333,6 @@ describe("message", () => {
|
|||
await sendMessage(invalidCommandInput, true, {
|
||||
roomContext: defaultRoomContext,
|
||||
mxClient: mockClient,
|
||||
permalinkCreator,
|
||||
});
|
||||
|
||||
// we expect the message to have been sent
|
||||
|
@ -378,7 +353,6 @@ describe("message", () => {
|
|||
const result = await sendMessage(invalidCommandInput, true, {
|
||||
roomContext: defaultRoomContext,
|
||||
mxClient: mockClient,
|
||||
permalinkCreator,
|
||||
});
|
||||
|
||||
expect(result).toBeUndefined();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue