Revert "Revert "Factor out MessageEvent.from()
usage (#9882)""
This reverts commit 99e38ca88e
.
This commit is contained in:
parent
edc44922c2
commit
19ba620de2
5 changed files with 127 additions and 61 deletions
|
@ -16,10 +16,8 @@ limitations under the License.
|
|||
|
||||
/// <reference types="cypress" />
|
||||
|
||||
import { MessageEvent } from "matrix-events-sdk";
|
||||
|
||||
import type { ISendEventResponse } from "matrix-js-sdk/src/@types/requests";
|
||||
import type { EventType } from "matrix-js-sdk/src/@types/event";
|
||||
import type { EventType, MsgType } from "matrix-js-sdk/src/@types/event";
|
||||
import { SynapseInstance } from "../../plugins/synapsedocker";
|
||||
import { SettingLevel } from "../../../src/settings/SettingLevel";
|
||||
import { Layout } from "../../../src/settings/enums/Layout";
|
||||
|
@ -55,12 +53,17 @@ const expectAvatar = (e: JQuery<HTMLElement>, avatarUrl: string): void => {
|
|||
};
|
||||
|
||||
const sendEvent = (roomId: string, html = false): Chainable<ISendEventResponse> => {
|
||||
return cy.sendEvent(
|
||||
roomId,
|
||||
null,
|
||||
"m.room.message" as EventType,
|
||||
MessageEvent.from("Message", html ? "<b>Message</b>" : undefined).serialize().content,
|
||||
);
|
||||
const content = {
|
||||
msgtype: "m.text" as MsgType,
|
||||
body: "Message",
|
||||
format: undefined,
|
||||
formatted_body: undefined,
|
||||
};
|
||||
if (html) {
|
||||
content.format = "org.matrix.custom.html";
|
||||
content.formatted_body = "<b>Message</b>";
|
||||
}
|
||||
return cy.sendEvent(roomId, null, "m.room.message" as EventType, content);
|
||||
};
|
||||
|
||||
describe("Timeline", () => {
|
||||
|
@ -314,12 +317,10 @@ describe("Timeline", () => {
|
|||
},
|
||||
}).as("preview_url");
|
||||
|
||||
cy.sendEvent(
|
||||
roomId,
|
||||
null,
|
||||
"m.room.message" as EventType,
|
||||
MessageEvent.from("https://call.element.io/").serialize().content,
|
||||
);
|
||||
cy.sendEvent(roomId, null, "m.room.message" as EventType, {
|
||||
msgtype: "m.text" as MsgType,
|
||||
body: "https://call.element.io/",
|
||||
});
|
||||
cy.visit("/#/room/" + roomId);
|
||||
|
||||
cy.get(".mx_LinkPreviewWidget").should("exist").should("contain.text", "Element Call");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue