2022-07-11 14:58:20 +02:00
|
|
|
/*
|
|
|
|
Copyright 2022 The Matrix.org Foundation C.I.C.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/// <reference types="cypress" />
|
|
|
|
|
|
|
|
import type { ISendEventResponse } from "matrix-js-sdk/src/@types/requests";
|
2023-01-10 17:20:10 +01:00
|
|
|
import type { EventType, MsgType } from "matrix-js-sdk/src/@types/event";
|
2023-01-11 00:29:56 +01:00
|
|
|
import { HomeserverInstance } from "../../plugins/utils/homeserver";
|
2022-07-11 14:58:20 +02:00
|
|
|
import { SettingLevel } from "../../../src/settings/SettingLevel";
|
2022-07-16 11:31:29 +02:00
|
|
|
import { Layout } from "../../../src/settings/enums/Layout";
|
2023-03-07 12:44:32 +01:00
|
|
|
import { MatrixClient } from "../../global";
|
2022-07-11 14:58:20 +02:00
|
|
|
import Chainable = Cypress.Chainable;
|
|
|
|
|
|
|
|
// The avatar size used in the timeline
|
|
|
|
const AVATAR_SIZE = 30;
|
|
|
|
// The resize method used in the timeline
|
|
|
|
const AVATAR_RESIZE_METHOD = "crop";
|
|
|
|
|
|
|
|
const ROOM_NAME = "Test room";
|
|
|
|
const OLD_AVATAR = "avatar_image1";
|
|
|
|
const NEW_AVATAR = "avatar_image2";
|
|
|
|
const OLD_NAME = "Alan";
|
|
|
|
const NEW_NAME = "Alan (away)";
|
|
|
|
|
|
|
|
const getEventTilesWithBodies = (): Chainable<JQuery> => {
|
|
|
|
return cy.get(".mx_EventTile").filter((_i, e) => e.getElementsByClassName("mx_EventTile_body").length > 0);
|
|
|
|
};
|
|
|
|
|
|
|
|
const expectDisplayName = (e: JQuery<HTMLElement>, displayName: string): void => {
|
|
|
|
expect(e.find(".mx_DisambiguatedProfile_displayName").text()).to.equal(displayName);
|
|
|
|
};
|
|
|
|
|
|
|
|
const expectAvatar = (e: JQuery<HTMLElement>, avatarUrl: string): void => {
|
2022-12-12 12:24:14 +01:00
|
|
|
cy.all([cy.window({ log: false }), cy.getClient()]).then(([win, cli]) => {
|
2022-08-01 09:31:14 +02:00
|
|
|
const size = AVATAR_SIZE * win.devicePixelRatio;
|
2022-07-11 14:58:20 +02:00
|
|
|
expect(e.find(".mx_BaseAvatar_image").attr("src")).to.equal(
|
|
|
|
// eslint-disable-next-line no-restricted-properties
|
2022-08-01 09:31:14 +02:00
|
|
|
cli.mxcUrlToHttp(avatarUrl, size, size, AVATAR_RESIZE_METHOD),
|
2022-07-11 14:58:20 +02:00
|
|
|
);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2022-08-05 09:08:56 +02:00
|
|
|
const sendEvent = (roomId: string, html = false): Chainable<ISendEventResponse> => {
|
2023-01-10 17:20:10 +01:00
|
|
|
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);
|
2022-07-11 14:58:20 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
describe("Timeline", () => {
|
2023-01-11 00:29:56 +01:00
|
|
|
let homeserver: HomeserverInstance;
|
2022-07-11 14:58:20 +02:00
|
|
|
|
|
|
|
let roomId: string;
|
|
|
|
|
|
|
|
let oldAvatarUrl: string;
|
|
|
|
let newAvatarUrl: string;
|
|
|
|
|
2022-07-26 10:38:05 +02:00
|
|
|
beforeEach(() => {
|
2023-01-11 00:29:56 +01:00
|
|
|
cy.startHomeserver("default").then((data) => {
|
|
|
|
homeserver = data;
|
|
|
|
cy.initTestUser(homeserver, OLD_NAME).then(() =>
|
2022-12-12 12:24:14 +01:00
|
|
|
cy.createRoom({ name: ROOM_NAME }).then((_room1Id) => {
|
2022-08-01 09:31:14 +02:00
|
|
|
roomId = _room1Id;
|
2022-07-26 10:38:05 +02:00
|
|
|
}),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2022-08-01 09:31:14 +02:00
|
|
|
afterEach(() => {
|
2023-01-11 00:29:56 +01:00
|
|
|
cy.stopHomeserver(homeserver);
|
2022-08-01 09:31:14 +02:00
|
|
|
});
|
|
|
|
|
2022-07-11 14:58:20 +02:00
|
|
|
describe("useOnlyCurrentProfiles", () => {
|
|
|
|
beforeEach(() => {
|
2022-10-12 19:59:07 +02:00
|
|
|
cy.uploadContent(OLD_AVATAR).then(({ content_uri: url }) => {
|
2022-07-26 10:38:05 +02:00
|
|
|
oldAvatarUrl = url;
|
|
|
|
cy.setAvatarUrl(url);
|
|
|
|
});
|
2022-10-12 19:59:07 +02:00
|
|
|
cy.uploadContent(NEW_AVATAR).then(({ content_uri: url }) => {
|
2022-07-26 10:38:05 +02:00
|
|
|
newAvatarUrl = url;
|
2022-07-11 14:58:20 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should show historical profiles if disabled", () => {
|
|
|
|
cy.setSettingValue("useOnlyCurrentProfiles", null, SettingLevel.ACCOUNT, false);
|
|
|
|
sendEvent(roomId);
|
|
|
|
cy.setDisplayName("Alan (away)");
|
|
|
|
cy.setAvatarUrl(newAvatarUrl);
|
|
|
|
// XXX: If we send the second event too quickly, there won't be
|
|
|
|
// enough time for the client to register the profile change
|
|
|
|
cy.wait(500);
|
|
|
|
sendEvent(roomId);
|
|
|
|
cy.viewRoomByName(ROOM_NAME);
|
|
|
|
|
|
|
|
const events = getEventTilesWithBodies();
|
|
|
|
|
|
|
|
events.should("have.length", 2);
|
|
|
|
events.each((e, i) => {
|
|
|
|
if (i === 0) {
|
|
|
|
expectDisplayName(e, OLD_NAME);
|
|
|
|
expectAvatar(e, oldAvatarUrl);
|
|
|
|
} else if (i === 1) {
|
|
|
|
expectDisplayName(e, NEW_NAME);
|
|
|
|
expectAvatar(e, newAvatarUrl);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should not show historical profiles if enabled", () => {
|
|
|
|
cy.setSettingValue("useOnlyCurrentProfiles", null, SettingLevel.ACCOUNT, true);
|
|
|
|
sendEvent(roomId);
|
|
|
|
cy.setDisplayName(NEW_NAME);
|
|
|
|
cy.setAvatarUrl(newAvatarUrl);
|
|
|
|
// XXX: If we send the second event too quickly, there won't be
|
|
|
|
// enough time for the client to register the profile change
|
|
|
|
cy.wait(500);
|
|
|
|
sendEvent(roomId);
|
|
|
|
cy.viewRoomByName(ROOM_NAME);
|
|
|
|
|
|
|
|
const events = getEventTilesWithBodies();
|
|
|
|
|
|
|
|
events.should("have.length", 2);
|
|
|
|
events.each((e) => {
|
|
|
|
expectDisplayName(e, NEW_NAME);
|
|
|
|
expectAvatar(e, newAvatarUrl);
|
|
|
|
});
|
2022-07-16 14:15:12 +02:00
|
|
|
});
|
2022-07-26 10:38:05 +02:00
|
|
|
});
|
2022-07-16 14:15:12 +02:00
|
|
|
|
2022-07-26 10:38:05 +02:00
|
|
|
describe("message displaying", () => {
|
2022-08-01 09:31:14 +02:00
|
|
|
beforeEach(() => {
|
|
|
|
cy.injectAxe();
|
|
|
|
});
|
|
|
|
|
2022-07-16 14:15:12 +02:00
|
|
|
it("should create and configure a room on IRC layout", () => {
|
|
|
|
cy.visit("/#/room/" + roomId);
|
|
|
|
cy.setSettingValue("layout", null, SettingLevel.DEVICE, Layout.IRC);
|
2022-12-12 12:24:14 +01:00
|
|
|
cy.contains(
|
|
|
|
".mx_RoomView_body .mx_GenericEventListSummary[data-layout=irc] " +
|
|
|
|
".mx_GenericEventListSummary_summary",
|
|
|
|
"created and configured the room.",
|
|
|
|
).should("exist");
|
2023-02-23 04:57:48 +01:00
|
|
|
|
2023-03-21 10:10:13 +01:00
|
|
|
cy.get(".mx_IRCLayout").within(() => {
|
|
|
|
// Check room name line-height is reset
|
|
|
|
cy.get(".mx_NewRoomIntro h2").should("have.css", "line-height", "normal");
|
|
|
|
|
|
|
|
// Check the profile resizer's place
|
|
|
|
// See: _IRCLayout
|
|
|
|
// --RoomView_MessageList-padding = 18px (See: _RoomView.pcss)
|
|
|
|
// --MessageTimestamp-width = $MessageTimestamp_width = 46px (See: _common.pcss)
|
|
|
|
// --icon-width = 14px
|
|
|
|
// --right-padding = 5px
|
|
|
|
// --name-width = 80px
|
|
|
|
// --resizer-width = 15px
|
|
|
|
// --resizer-a11y = 3px
|
|
|
|
// 18px + 46px + 14px + 5px + 80px + 5px - 15px - 3px
|
|
|
|
// = 150px
|
|
|
|
cy.get(".mx_ProfileResizer").should("have.css", "inset-inline-start", "150px");
|
|
|
|
});
|
2023-03-14 15:32:12 +01:00
|
|
|
|
2023-02-23 04:57:48 +01:00
|
|
|
cy.get(".mx_MainSplit").percySnapshotElement("Configured room on IRC layout");
|
2022-07-18 09:41:01 +02:00
|
|
|
});
|
|
|
|
|
2022-07-25 11:05:32 +02:00
|
|
|
it("should add inline start margin to an event line on IRC layout", () => {
|
|
|
|
cy.visit("/#/room/" + roomId);
|
|
|
|
cy.setSettingValue("layout", null, SettingLevel.DEVICE, Layout.IRC);
|
|
|
|
|
|
|
|
// Wait until configuration is finished
|
2022-12-12 12:24:14 +01:00
|
|
|
cy.contains(
|
|
|
|
".mx_RoomView_body .mx_GenericEventListSummary " + ".mx_GenericEventListSummary_summary",
|
|
|
|
"created and configured the room.",
|
|
|
|
).should("exist");
|
2022-07-25 11:05:32 +02:00
|
|
|
|
|
|
|
// Click "expand" link button
|
|
|
|
cy.get(".mx_GenericEventListSummary_toggle[aria-expanded=false]").click();
|
|
|
|
|
|
|
|
// Check the event line has margin instead of inset property
|
|
|
|
// cf. _EventTile.pcss
|
|
|
|
// --EventTile_irc_line_info-margin-inline-start
|
2023-03-03 10:32:38 +01:00
|
|
|
// = calc(var(--name-width) + var(--icon-width) + 1 * var(--right-padding))
|
|
|
|
// = 80 + 14 + 5 = 99px
|
|
|
|
|
2022-07-25 11:05:32 +02:00
|
|
|
cy.get(".mx_EventTile[data-layout=irc].mx_EventTile_info:first-of-type .mx_EventTile_line")
|
2023-03-03 10:32:38 +01:00
|
|
|
.should("have.css", "margin-inline-start", "99px")
|
2022-12-12 12:24:14 +01:00
|
|
|
.should("have.css", "inset-inline-start", "0px");
|
2022-07-25 11:05:32 +02:00
|
|
|
|
2023-02-27 10:16:49 +01:00
|
|
|
// Exclude timestamp and read marker from snapshot
|
|
|
|
const percyCSS = ".mx_MessageTimestamp, .mx_RoomView_myReadMarker { visibility: hidden !important; }";
|
2023-02-23 04:57:48 +01:00
|
|
|
cy.get(".mx_MainSplit").percySnapshotElement("Event line with inline start margin on IRC layout", {
|
|
|
|
percyCSS,
|
|
|
|
});
|
2022-08-01 09:31:14 +02:00
|
|
|
cy.checkA11y();
|
2022-07-25 11:05:32 +02:00
|
|
|
});
|
|
|
|
|
2023-03-03 10:32:38 +01:00
|
|
|
it("should align generic event list summary with messages and emote on IRC layout", () => {
|
|
|
|
// This test aims to check:
|
|
|
|
// 1. Alignment of collapsed GELS (generic event list summary) and messages
|
|
|
|
// 2. Alignment of expanded GELS and messages
|
|
|
|
// 3. Alignment of expanded GELS and placeholder of deleted message
|
|
|
|
// 4. Alignment of expanded GELS, placeholder of deleted message, and emote
|
|
|
|
|
|
|
|
// Exclude timestamp from snapshot of mx_MainSplit
|
|
|
|
const percyCSS = ".mx_MainSplit .mx_MessageTimestamp { visibility: hidden !important; }";
|
|
|
|
|
|
|
|
cy.visit("/#/room/" + roomId);
|
|
|
|
cy.setSettingValue("layout", null, SettingLevel.DEVICE, Layout.IRC);
|
|
|
|
|
|
|
|
// Wait until configuration is finished
|
|
|
|
cy.contains(
|
|
|
|
".mx_RoomView_body .mx_GenericEventListSummary .mx_GenericEventListSummary_summary",
|
|
|
|
"created and configured the room.",
|
|
|
|
).should("exist");
|
|
|
|
|
|
|
|
// Send messages
|
|
|
|
cy.get(".mx_RoomView_body .mx_BasicMessageComposer_input").type("Hello Mr. Bot{enter}");
|
|
|
|
cy.get(".mx_RoomView_body .mx_BasicMessageComposer_input").type("Hello again, Mr. Bot{enter}");
|
|
|
|
// Make sure the second message was sent
|
|
|
|
cy.get(".mx_RoomView_MessageList > .mx_EventTile_last .mx_EventTile_receiptSent").should("be.visible");
|
|
|
|
|
|
|
|
// 1. Alignment of collapsed GELS (generic event list summary) and messages
|
|
|
|
// Check inline start spacing of collapsed GELS
|
|
|
|
// See: _EventTile.pcss
|
|
|
|
// .mx_GenericEventListSummary[data-layout="irc"] > .mx_EventTile_line
|
|
|
|
// = var(--name-width) + var(--icon-width) + $MessageTimestamp_width + 2 * var(--right-padding)
|
|
|
|
// = 80 + 14 + 46 + 2 * 5
|
|
|
|
// = 150px
|
|
|
|
cy.get(".mx_GenericEventListSummary[data-layout=irc] > .mx_EventTile_line").should(
|
|
|
|
"have.css",
|
|
|
|
"padding-inline-start",
|
|
|
|
"150px",
|
|
|
|
);
|
|
|
|
// Check width and spacing values of elements in .mx_EventTile, which should be equal to 150px
|
|
|
|
// --right-padding should be applied
|
|
|
|
cy.get(".mx_EventTile > *").should("have.css", "margin-right", "5px");
|
|
|
|
// --name-width width zero inline end margin should be applied
|
|
|
|
cy.get(".mx_EventTile .mx_DisambiguatedProfile")
|
|
|
|
.should("have.css", "width", "80px")
|
|
|
|
.should("have.css", "margin-inline-end", "0px");
|
|
|
|
// --icon-width should be applied
|
|
|
|
cy.get(".mx_EventTile .mx_EventTile_avatar > .mx_BaseAvatar").should("have.css", "width", "14px");
|
|
|
|
// $MessageTimestamp_width should be applied
|
|
|
|
cy.get(".mx_EventTile > a").should("have.css", "min-width", "46px");
|
|
|
|
// Record alignment of collapsed GELS and messages on messagePanel
|
|
|
|
cy.get(".mx_MainSplit").percySnapshotElement("Collapsed GELS and messages on IRC layout", { percyCSS });
|
|
|
|
|
|
|
|
// 2. Alignment of expanded GELS and messages
|
|
|
|
// Click "expand" link button
|
|
|
|
cy.get(".mx_GenericEventListSummary_toggle[aria-expanded=false]").click();
|
|
|
|
// Check inline start spacing of info line on expanded GELS
|
|
|
|
cy.get(".mx_EventTile[data-layout=irc].mx_EventTile_info:first-of-type .mx_EventTile_line")
|
|
|
|
// See: _EventTile.pcss
|
|
|
|
// --EventTile_irc_line_info-margin-inline-start
|
|
|
|
// = 80 + 14 + 1 * 5
|
|
|
|
.should("have.css", "margin-inline-start", "99px");
|
|
|
|
// Record alignment of expanded GELS and messages on messagePanel
|
|
|
|
cy.get(".mx_MainSplit").percySnapshotElement("Expanded GELS and messages on IRC layout", { percyCSS });
|
|
|
|
|
|
|
|
// 3. Alignment of expanded GELS and placeholder of deleted message
|
|
|
|
// Delete the second (last) message
|
|
|
|
cy.get(".mx_RoomView_MessageList > .mx_EventTile_last").realHover();
|
|
|
|
cy.get(".mx_RoomView_MessageList > .mx_EventTile_last .mx_MessageActionBar_optionsButton", {
|
|
|
|
timeout: 1000,
|
|
|
|
})
|
|
|
|
.should("exist")
|
|
|
|
.realHover()
|
|
|
|
.click({ force: false });
|
|
|
|
cy.get(".mx_IconizedContextMenu_item[aria-label=Remove]").should("be.visible").click({ force: false });
|
|
|
|
// Confirm deletion
|
|
|
|
cy.get(".mx_Dialog_buttons button[data-testid=dialog-primary-button]")
|
|
|
|
.should("have.text", "Remove")
|
|
|
|
.click({ force: false });
|
|
|
|
// Make sure the dialog was closed and the second (last) message was redacted
|
|
|
|
cy.get(".mx_Dialog").should("not.exist");
|
|
|
|
cy.get(".mx_GenericEventListSummary .mx_EventTile_last .mx_RedactedBody").should("be.visible");
|
|
|
|
cy.get(".mx_GenericEventListSummary .mx_EventTile_last .mx_EventTile_receiptSent").should("be.visible");
|
|
|
|
// Record alignment of expanded GELS and placeholder of deleted message on messagePanel
|
|
|
|
cy.get(".mx_MainSplit").percySnapshotElement("Expanded GELS and with placeholder of deleted message", {
|
|
|
|
percyCSS,
|
|
|
|
});
|
|
|
|
|
|
|
|
// 4. Alignment of expanded GELS, placeholder of deleted message, and emote
|
|
|
|
// Send a emote
|
|
|
|
cy.get(".mx_RoomView_body .mx_BasicMessageComposer_input").type("/me says hello to Mr. Bot{enter}");
|
|
|
|
// Check inline start margin of its avatar
|
|
|
|
// Here --right-padding is for the avatar on the message line
|
|
|
|
// See: _IRCLayout.pcss
|
|
|
|
// .mx_IRCLayout .mx_EventTile_emote .mx_EventTile_avatar
|
|
|
|
// = calc(var(--name-width) + var(--icon-width) + 1 * var(--right-padding))
|
|
|
|
// = 80 + 14 + 1 * 5
|
|
|
|
cy.get(".mx_EventTile_emote .mx_EventTile_avatar").should("have.css", "margin-left", "99px");
|
|
|
|
// Make sure emote was sent
|
|
|
|
cy.get(".mx_EventTile_last.mx_EventTile_emote .mx_EventTile_receiptSent").should("be.visible");
|
|
|
|
// Record alignment of expanded GELS, placeholder of deleted message, and emote
|
|
|
|
cy.get(".mx_MainSplit").percySnapshotElement(
|
|
|
|
"Expanded GELS and with emote and placeholder of deleted message",
|
|
|
|
{
|
|
|
|
percyCSS,
|
|
|
|
},
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2023-03-17 08:48:34 +01:00
|
|
|
it("should render EventTiles on IRC, modern (group), and bubble layout", () => {
|
|
|
|
// Exclude timestamp and read marker from snapshots
|
|
|
|
const percyCSS = ".mx_MessageTimestamp, .mx_RoomView_myReadMarker { visibility: hidden !important; }";
|
|
|
|
|
|
|
|
sendEvent(roomId);
|
|
|
|
sendEvent(roomId); // check continuation
|
|
|
|
sendEvent(roomId); // check the last EventTile
|
|
|
|
|
|
|
|
cy.visit("/#/room/" + roomId);
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// IRC layout
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
cy.setSettingValue("layout", null, SettingLevel.DEVICE, Layout.IRC);
|
|
|
|
|
|
|
|
// Wait until configuration is finished
|
|
|
|
cy.contains(
|
|
|
|
".mx_RoomView_body .mx_GenericEventListSummary[data-layout=irc] .mx_GenericEventListSummary_summary",
|
|
|
|
"created and configured the room.",
|
|
|
|
).should("exist");
|
|
|
|
|
|
|
|
cy.get(".mx_RoomView_body[data-layout=irc]").within(() => {
|
|
|
|
// Ensure CSS declarations which cannot be detected with a screenshot test are applied as expected
|
|
|
|
cy.get(".mx_EventTile")
|
|
|
|
.should("have.css", "max-width", "100%")
|
|
|
|
.should("have.css", "clear", "both")
|
|
|
|
.should("have.css", "position", "relative");
|
|
|
|
|
|
|
|
// Check mx_EventTile_continuation
|
|
|
|
// Block start padding of the second message should not be overridden
|
|
|
|
cy.get(".mx_EventTile_continuation").should("have.css", "padding-block-start", "0px");
|
|
|
|
cy.get(".mx_EventTile_continuation .mx_EventTile_line").should("have.css", "clear", "both");
|
|
|
|
|
|
|
|
// Select the last event tile
|
|
|
|
cy.get(".mx_EventTile_last")
|
|
|
|
.within(() => {
|
|
|
|
// The last tile is also a continued one
|
|
|
|
cy.get(".mx_EventTile_line").should("have.css", "clear", "both");
|
|
|
|
})
|
|
|
|
// Check that zero block padding is set
|
|
|
|
.should("have.css", "padding-block-start", "0px");
|
|
|
|
});
|
|
|
|
|
|
|
|
cy.get(".mx_MainSplit").percySnapshotElement("EventTiles on IRC layout", { percyCSS });
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Group/modern layout
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
cy.setSettingValue("layout", null, SettingLevel.DEVICE, Layout.Group);
|
|
|
|
|
|
|
|
cy.get(".mx_RoomView_body[data-layout=group]").within(() => {
|
|
|
|
// Ensure CSS declarations which cannot be detected with a screenshot test are applied as expected
|
|
|
|
cy.get(".mx_EventTile")
|
|
|
|
.should("have.css", "max-width", "100%")
|
|
|
|
.should("have.css", "clear", "both")
|
|
|
|
.should("have.css", "position", "relative");
|
|
|
|
|
|
|
|
// Check mx_EventTile_continuation
|
|
|
|
// Block start padding of the second message should not be overridden
|
|
|
|
cy.get(".mx_EventTile_continuation").should("have.css", "padding-block-start", "0px");
|
|
|
|
cy.get(".mx_EventTile_continuation .mx_EventTile_line").should("have.css", "clear", "both");
|
|
|
|
|
|
|
|
// Check that the last EventTile is rendered
|
|
|
|
cy.get(".mx_EventTile.mx_EventTile_last").should("exist");
|
|
|
|
});
|
|
|
|
|
|
|
|
cy.get(".mx_MainSplit").percySnapshotElement("EventTiles on modern layout", { percyCSS });
|
|
|
|
|
|
|
|
// Check the same thing for compact layout
|
|
|
|
cy.setSettingValue("useCompactLayout", null, SettingLevel.DEVICE, true);
|
|
|
|
|
|
|
|
cy.get(".mx_MatrixChat_useCompactLayout").within(() => {
|
|
|
|
// Ensure CSS declarations which cannot be detected with a screenshot test are applied as expected
|
|
|
|
cy.get(".mx_EventTile")
|
|
|
|
.should("have.css", "max-width", "100%")
|
|
|
|
.should("have.css", "clear", "both")
|
|
|
|
.should("have.css", "position", "relative");
|
|
|
|
|
|
|
|
// Check cascading works
|
|
|
|
cy.get(".mx_EventTile_continuation").should("have.css", "padding-block-start", "0px");
|
|
|
|
|
|
|
|
// Check that the last EventTile is rendered
|
|
|
|
cy.get(".mx_EventTile.mx_EventTile_last").should("exist");
|
|
|
|
});
|
|
|
|
|
|
|
|
cy.get(".mx_MainSplit").percySnapshotElement("EventTiles on compact modern layout", { percyCSS });
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Message bubble layout
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
cy.setSettingValue("layout", null, SettingLevel.DEVICE, Layout.Bubble);
|
|
|
|
|
|
|
|
cy.get(".mx_RoomView_body[data-layout=bubble]").within(() => {
|
|
|
|
// Ensure CSS declarations which cannot be detected with a screenshot test are applied as expected
|
|
|
|
cy.get(".mx_EventTile")
|
|
|
|
.should("have.css", "max-width", "none")
|
|
|
|
.should("have.css", "clear", "both")
|
|
|
|
.should("have.css", "position", "relative");
|
|
|
|
|
|
|
|
// Check that block start padding of the second message is not overridden
|
|
|
|
cy.get(".mx_EventTile.mx_EventTile_continuation").should("have.css", "margin-block-start", "2px");
|
|
|
|
|
|
|
|
// Select the last bubble
|
|
|
|
cy.get(".mx_EventTile_last")
|
|
|
|
.within(() => {
|
|
|
|
// calc(var(--gutterSize) - 1px)
|
|
|
|
cy.get(".mx_EventTile_line").should("have.css", "padding-block-start", "10px");
|
|
|
|
})
|
|
|
|
.should("have.css", "margin-block-start", "2px"); // The last bubble is also a continued one
|
|
|
|
});
|
|
|
|
|
|
|
|
cy.get(".mx_MainSplit").percySnapshotElement("EventTiles on bubble layout", { percyCSS });
|
|
|
|
});
|
|
|
|
|
2022-08-01 08:19:22 +02:00
|
|
|
it("should set inline start padding to a hidden event line", () => {
|
|
|
|
sendEvent(roomId);
|
|
|
|
cy.visit("/#/room/" + roomId);
|
|
|
|
cy.setSettingValue("showHiddenEventsInTimeline", null, SettingLevel.DEVICE, true);
|
2022-12-12 12:24:14 +01:00
|
|
|
cy.contains(
|
|
|
|
".mx_RoomView_body .mx_GenericEventListSummary .mx_GenericEventListSummary_summary",
|
|
|
|
"created and configured the room.",
|
|
|
|
).should("exist");
|
2022-08-01 08:19:22 +02:00
|
|
|
|
|
|
|
// Edit message
|
|
|
|
cy.contains(".mx_RoomView_body .mx_EventTile .mx_EventTile_line", "Message").within(() => {
|
|
|
|
cy.get('[aria-label="Edit"]').click({ force: true }); // Cypress has no ability to hover
|
|
|
|
cy.get(".mx_BasicMessageComposer_input").type("Edit{enter}");
|
|
|
|
});
|
2022-08-10 10:40:17 +02:00
|
|
|
cy.contains(".mx_EventTile[data-scroll-tokens]", "MessageEdit").should("exist");
|
2022-08-01 08:19:22 +02:00
|
|
|
|
|
|
|
// Click timestamp to highlight hidden event line
|
|
|
|
cy.get(".mx_RoomView_body .mx_EventTile_info .mx_MessageTimestamp").click();
|
|
|
|
|
2023-02-27 10:16:49 +01:00
|
|
|
// Exclude timestamp and read marker from snapshot
|
|
|
|
const percyCSS = ".mx_MessageTimestamp, .mx_RoomView_myReadMarker { visibility: hidden !important; }";
|
2022-08-01 08:19:22 +02:00
|
|
|
|
|
|
|
// should not add inline start padding to a hidden event line on IRC layout
|
|
|
|
cy.setSettingValue("layout", null, SettingLevel.DEVICE, Layout.IRC);
|
2022-12-12 12:24:14 +01:00
|
|
|
cy.get(".mx_EventTile[data-layout=irc].mx_EventTile_info .mx_EventTile_line").should(
|
|
|
|
"have.css",
|
|
|
|
"padding-inline-start",
|
|
|
|
"0px",
|
|
|
|
);
|
2023-02-23 04:57:48 +01:00
|
|
|
|
2023-03-24 10:25:48 +01:00
|
|
|
// Disabled because flaky - see https://github.com/vector-im/element-web/issues/24881
|
|
|
|
/*cy.get(".mx_MainSplit").percySnapshotElement("Hidden event line with zero padding on IRC layout", {
|
2023-02-23 04:57:48 +01:00
|
|
|
percyCSS,
|
2023-03-24 10:25:48 +01:00
|
|
|
});*/
|
2022-08-01 08:19:22 +02:00
|
|
|
|
|
|
|
// should add inline start padding to a hidden event line on modern layout
|
|
|
|
cy.setSettingValue("layout", null, SettingLevel.DEVICE, Layout.Group);
|
|
|
|
cy.get(".mx_EventTile[data-layout=group].mx_EventTile_info .mx_EventTile_line")
|
|
|
|
// calc(var(--EventTile_group_line-spacing-inline-start) + 20px) = 64 + 20 = 84px
|
2022-12-12 12:24:14 +01:00
|
|
|
.should("have.css", "padding-inline-start", "84px");
|
2023-02-23 04:57:48 +01:00
|
|
|
|
|
|
|
cy.get(".mx_MainSplit").percySnapshotElement("Hidden event line with padding on modern layout", {
|
|
|
|
percyCSS,
|
|
|
|
});
|
2022-08-01 08:19:22 +02:00
|
|
|
});
|
|
|
|
|
2023-03-01 15:41:56 +01:00
|
|
|
it("should click view source event toggle", () => {
|
|
|
|
// This test checks:
|
|
|
|
// 1. clickability of top left of view source event toggle
|
|
|
|
// 2. clickability of view source toggle on IRC layout
|
|
|
|
|
2023-03-06 11:01:18 +01:00
|
|
|
// Exclude timestamp from snapshot
|
|
|
|
const percyCSS = ".mx_MessageTimestamp { visibility: hidden !important; }";
|
|
|
|
|
2022-07-18 09:41:01 +02:00
|
|
|
sendEvent(roomId);
|
|
|
|
cy.visit("/#/room/" + roomId);
|
|
|
|
cy.setSettingValue("showHiddenEventsInTimeline", null, SettingLevel.DEVICE, true);
|
2022-12-12 12:24:14 +01:00
|
|
|
cy.contains(
|
|
|
|
".mx_RoomView_body .mx_GenericEventListSummary " + ".mx_GenericEventListSummary_summary",
|
|
|
|
"created and configured the room.",
|
|
|
|
).should("exist");
|
2022-07-18 09:41:01 +02:00
|
|
|
|
|
|
|
// Edit message
|
2022-07-25 11:05:32 +02:00
|
|
|
cy.contains(".mx_RoomView_body .mx_EventTile .mx_EventTile_line", "Message").within(() => {
|
2022-07-18 09:41:01 +02:00
|
|
|
cy.get('[aria-label="Edit"]').click({ force: true }); // Cypress has no ability to hover
|
|
|
|
cy.get(".mx_BasicMessageComposer_input").type("Edit{enter}");
|
|
|
|
});
|
2022-08-10 10:40:17 +02:00
|
|
|
cy.contains(".mx_RoomView_body .mx_EventTile[data-scroll-tokens]", "MessageEdit").should("exist");
|
2022-07-18 09:41:01 +02:00
|
|
|
|
2023-03-01 15:41:56 +01:00
|
|
|
// 1. clickability of top left of view source event toggle
|
|
|
|
|
2022-07-18 09:41:01 +02:00
|
|
|
// Click top left of the event toggle, which should not be covered by MessageActionBar's safe area
|
2023-03-01 15:41:56 +01:00
|
|
|
cy.get(".mx_EventTile_last[data-layout=group] .mx_ViewSourceEvent")
|
|
|
|
.should("exist")
|
|
|
|
.realHover()
|
|
|
|
.within(() => {
|
|
|
|
cy.get(".mx_ViewSourceEvent_toggle").click("topLeft", { force: false });
|
|
|
|
});
|
|
|
|
|
2023-03-06 11:01:18 +01:00
|
|
|
// Make sure the expand toggle works
|
|
|
|
cy.get(".mx_EventTile_last[data-layout=group] .mx_ViewSourceEvent_expanded")
|
|
|
|
.should("be.visible")
|
2023-03-01 15:41:56 +01:00
|
|
|
.realHover()
|
|
|
|
.within(() => {
|
2023-03-06 11:01:18 +01:00
|
|
|
cy.get(".mx_ViewSourceEvent_toggle")
|
|
|
|
// Check size and position of toggle on expanded view source event
|
|
|
|
// See: _ViewSourceEvent.pcss
|
|
|
|
.should("have.css", "height", "12px") // --ViewSourceEvent_toggle-size
|
|
|
|
.should("have.css", "align-self", "flex-end")
|
|
|
|
|
|
|
|
// Click again to collapse the source
|
|
|
|
.click("topLeft", { force: false });
|
2023-03-01 15:41:56 +01:00
|
|
|
});
|
2023-03-06 11:01:18 +01:00
|
|
|
|
|
|
|
// Make sure the collapse toggle works
|
|
|
|
cy.get(".mx_EventTile_last[data-layout=group] .mx_ViewSourceEvent_expanded").should("not.exist");
|
2023-03-01 15:41:56 +01:00
|
|
|
|
|
|
|
// 2. clickability of view source toggle on IRC layout
|
|
|
|
|
|
|
|
// Enable IRC layout
|
|
|
|
cy.setSettingValue("layout", null, SettingLevel.DEVICE, Layout.IRC);
|
|
|
|
|
|
|
|
// Hover the view source toggle on IRC layout
|
|
|
|
cy.get(".mx_GenericEventListSummary[data-layout=irc] .mx_EventTile .mx_ViewSourceEvent")
|
|
|
|
.should("exist")
|
|
|
|
.realHover()
|
|
|
|
.percySnapshotElement("Hovered hidden event line on IRC layout", { percyCSS });
|
|
|
|
|
|
|
|
// Click view source event toggle
|
|
|
|
cy.get(".mx_GenericEventListSummary[data-layout=irc] .mx_EventTile .mx_ViewSourceEvent")
|
2022-12-12 12:24:14 +01:00
|
|
|
.should("exist")
|
|
|
|
.realHover()
|
|
|
|
.within(() => {
|
|
|
|
cy.get(".mx_ViewSourceEvent_toggle").click("topLeft", { force: false });
|
|
|
|
});
|
2022-07-18 09:41:01 +02:00
|
|
|
|
|
|
|
// Make sure the expand toggle worked
|
2023-03-01 15:41:56 +01:00
|
|
|
cy.get(".mx_EventTile[data-layout=irc] .mx_ViewSourceEvent_expanded").should("be.visible");
|
2022-07-11 14:58:20 +02:00
|
|
|
});
|
2022-07-16 11:31:29 +02:00
|
|
|
|
|
|
|
it("should click 'collapse' link button on the first hovered info event line on bubble layout", () => {
|
|
|
|
cy.visit("/#/room/" + roomId);
|
|
|
|
cy.setSettingValue("layout", null, SettingLevel.DEVICE, Layout.Bubble);
|
2022-12-12 12:24:14 +01:00
|
|
|
cy.contains(
|
|
|
|
".mx_RoomView_body .mx_GenericEventListSummary[data-layout=bubble] " +
|
|
|
|
".mx_GenericEventListSummary_summary",
|
|
|
|
"created and configured the room.",
|
|
|
|
).should("exist");
|
2022-07-16 11:31:29 +02:00
|
|
|
|
|
|
|
// Click "expand" link button
|
|
|
|
cy.get(".mx_GenericEventListSummary_toggle[aria-expanded=false]").click();
|
|
|
|
|
|
|
|
// Click "collapse" link button on the first hovered info event line
|
2022-08-10 10:40:17 +02:00
|
|
|
cy.get(".mx_GenericEventListSummary_unstyledList .mx_EventTile_info:first-of-type").realHover();
|
|
|
|
cy.get(".mx_GenericEventListSummary_toggle[aria-expanded=true]").click({ force: false });
|
2022-07-16 11:31:29 +02:00
|
|
|
|
|
|
|
// Make sure "collapse" link button worked
|
2022-08-10 10:40:17 +02:00
|
|
|
cy.get(".mx_GenericEventListSummary_toggle[aria-expanded=false]").should("exist");
|
2022-07-16 11:31:29 +02:00
|
|
|
});
|
2022-08-05 09:08:56 +02:00
|
|
|
|
|
|
|
it("should highlight search result words regardless of formatting", () => {
|
|
|
|
sendEvent(roomId);
|
|
|
|
sendEvent(roomId, true);
|
|
|
|
cy.visit("/#/room/" + roomId);
|
|
|
|
|
|
|
|
cy.get(".mx_RoomHeader_searchButton").click();
|
|
|
|
cy.get(".mx_SearchBar_input input").type("Message{enter}");
|
|
|
|
|
2022-10-12 19:59:07 +02:00
|
|
|
cy.get(".mx_EventTile:not(.mx_EventTile_contextual) .mx_EventTile_searchHighlight").should("exist");
|
2022-08-05 09:08:56 +02:00
|
|
|
cy.get(".mx_RoomView_searchResultsPanel").percySnapshotElement("Highlighted search results");
|
|
|
|
});
|
2022-08-17 18:07:18 +02:00
|
|
|
|
|
|
|
it("should render url previews", () => {
|
|
|
|
cy.intercept("**/_matrix/media/r0/thumbnail/matrix.org/2022-08-16_yaiSVSRIsNFfxDnV?*", {
|
|
|
|
statusCode: 200,
|
|
|
|
fixture: "riot.png",
|
|
|
|
headers: {
|
|
|
|
"Content-Type": "image/png",
|
|
|
|
},
|
|
|
|
}).as("mxc");
|
|
|
|
cy.intercept("**/_matrix/media/r0/preview_url?url=https%3A%2F%2Fcall.element.io%2F&ts=*", {
|
|
|
|
statusCode: 200,
|
|
|
|
body: {
|
|
|
|
"og:title": "Element Call",
|
|
|
|
"og:description": null,
|
|
|
|
"og:image:width": 48,
|
|
|
|
"og:image:height": 48,
|
|
|
|
"og:image": "mxc://matrix.org/2022-08-16_yaiSVSRIsNFfxDnV",
|
|
|
|
"og:image:type": "image/png",
|
|
|
|
"matrix:image:size": 2121,
|
|
|
|
},
|
|
|
|
headers: {
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
},
|
|
|
|
}).as("preview_url");
|
|
|
|
|
2023-01-10 17:20:10 +01:00
|
|
|
cy.sendEvent(roomId, null, "m.room.message" as EventType, {
|
|
|
|
msgtype: "m.text" as MsgType,
|
|
|
|
body: "https://call.element.io/",
|
|
|
|
});
|
2022-08-17 18:07:18 +02:00
|
|
|
cy.visit("/#/room/" + roomId);
|
|
|
|
|
|
|
|
cy.get(".mx_LinkPreviewWidget").should("exist").should("contain.text", "Element Call");
|
|
|
|
|
|
|
|
cy.wait("@preview_url");
|
|
|
|
cy.wait("@mxc");
|
|
|
|
|
|
|
|
cy.checkA11y();
|
2023-02-23 04:57:48 +01:00
|
|
|
|
2023-02-27 10:16:49 +01:00
|
|
|
// Exclude timestamp and read marker from snapshot
|
|
|
|
const percyCSS = ".mx_MessageTimestamp, .mx_RoomView_myReadMarker { visibility: hidden !important; }";
|
2022-08-17 18:07:18 +02:00
|
|
|
cy.get(".mx_EventTile_last").percySnapshotElement("URL Preview", {
|
2023-02-23 04:57:48 +01:00
|
|
|
percyCSS,
|
2022-08-17 18:07:18 +02:00
|
|
|
widths: [800, 400],
|
|
|
|
});
|
|
|
|
});
|
2022-07-11 14:58:20 +02:00
|
|
|
});
|
2022-07-26 10:38:05 +02:00
|
|
|
|
|
|
|
describe("message sending", () => {
|
|
|
|
const MESSAGE = "Hello world";
|
2023-03-07 12:44:32 +01:00
|
|
|
const reply = "Reply";
|
2022-07-26 10:38:05 +02:00
|
|
|
const viewRoomSendMessageAndSetupReply = () => {
|
|
|
|
// View room
|
|
|
|
cy.visit("/#/room/" + roomId);
|
|
|
|
|
|
|
|
// Send a message
|
|
|
|
cy.getComposer().type(`${MESSAGE}{enter}`);
|
|
|
|
|
|
|
|
// Reply to the message
|
2022-10-18 18:07:23 +02:00
|
|
|
cy.contains(".mx_RoomView_body .mx_EventTile_line", "Hello world").within(() => {
|
2022-07-26 10:38:05 +02:00
|
|
|
cy.get('[aria-label="Reply"]').click({ force: true }); // Cypress has no ability to hover
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
it("can reply with a text message", () => {
|
|
|
|
viewRoomSendMessageAndSetupReply();
|
|
|
|
|
|
|
|
cy.getComposer().type(`${reply}{enter}`);
|
|
|
|
|
2022-12-12 12:24:14 +01:00
|
|
|
cy.get(".mx_RoomView_body .mx_EventTile .mx_EventTile_line .mx_ReplyTile .mx_MTextBody").should(
|
|
|
|
"contain",
|
|
|
|
MESSAGE,
|
|
|
|
);
|
|
|
|
cy.contains(".mx_RoomView_body .mx_EventTile > .mx_EventTile_line > .mx_MTextBody", reply).should(
|
|
|
|
"have.length",
|
|
|
|
1,
|
|
|
|
);
|
2022-07-26 10:38:05 +02:00
|
|
|
});
|
|
|
|
|
2022-08-10 10:40:17 +02:00
|
|
|
it("can reply with a voice message", () => {
|
2022-07-26 10:38:05 +02:00
|
|
|
viewRoomSendMessageAndSetupReply();
|
|
|
|
|
2022-08-10 10:40:17 +02:00
|
|
|
cy.openMessageComposerOptions().within(() => {
|
|
|
|
cy.get(`[aria-label="Voice Message"]`).click();
|
|
|
|
});
|
2022-07-26 10:38:05 +02:00
|
|
|
cy.wait(3000);
|
2022-08-10 10:40:17 +02:00
|
|
|
cy.get(".mx_RoomView_body .mx_MessageComposer .mx_MessageComposer_sendMessage").click();
|
2022-07-26 10:38:05 +02:00
|
|
|
|
2022-12-12 12:24:14 +01:00
|
|
|
cy.get(".mx_RoomView_body .mx_EventTile .mx_EventTile_line .mx_ReplyTile .mx_MTextBody").should(
|
|
|
|
"contain",
|
|
|
|
MESSAGE,
|
|
|
|
);
|
|
|
|
cy.get(".mx_RoomView_body .mx_EventTile > .mx_EventTile_line > .mx_MVoiceMessageBody").should(
|
|
|
|
"have.length",
|
|
|
|
1,
|
|
|
|
);
|
2022-07-26 10:38:05 +02:00
|
|
|
});
|
2023-01-31 14:08:35 +01:00
|
|
|
|
|
|
|
it("should not be possible to send flag with regional emojis", () => {
|
|
|
|
cy.visit("/#/room/" + roomId);
|
|
|
|
|
|
|
|
// Send a message
|
|
|
|
cy.getComposer().type(":regional_indicator_a");
|
|
|
|
cy.contains(".mx_Autocomplete_Completion_title", ":regional_indicator_a:").click();
|
|
|
|
cy.getComposer().type(":regional_indicator_r");
|
|
|
|
cy.contains(".mx_Autocomplete_Completion_title", ":regional_indicator_r:").click();
|
|
|
|
cy.getComposer().type(" :regional_indicator_z");
|
|
|
|
cy.contains(".mx_Autocomplete_Completion_title", ":regional_indicator_z:").click();
|
|
|
|
cy.getComposer().type(":regional_indicator_a");
|
|
|
|
cy.contains(".mx_Autocomplete_Completion_title", ":regional_indicator_a:").click();
|
|
|
|
cy.getComposer().type("{enter}");
|
|
|
|
|
|
|
|
cy.get(".mx_RoomView_body .mx_EventTile .mx_EventTile_line .mx_MTextBody .mx_EventTile_bigEmoji")
|
|
|
|
.children()
|
|
|
|
.should("have.length", 4);
|
|
|
|
});
|
2023-03-07 12:44:32 +01:00
|
|
|
|
|
|
|
it("should display a reply chain", () => {
|
|
|
|
let bot: MatrixClient;
|
|
|
|
const reply2 = "Reply again";
|
|
|
|
|
|
|
|
// For clicking the reply button on the last line
|
|
|
|
const clickButtonReply = () => {
|
|
|
|
cy.get(".mx_RoomView_MessageList").within(() => {
|
|
|
|
cy.get(".mx_EventTile_last").realHover();
|
|
|
|
cy.get(".mx_EventTile_last .mx_MessageActionBar_optionsButton", {
|
|
|
|
timeout: 1000,
|
|
|
|
})
|
|
|
|
.should("exist")
|
|
|
|
.realHover()
|
|
|
|
.get('.mx_EventTile_last [aria-label="Reply"]')
|
|
|
|
.click({ force: false });
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
cy.visit("/#/room/" + roomId);
|
|
|
|
|
|
|
|
// Wait until configuration is finished
|
|
|
|
cy.contains(
|
|
|
|
".mx_RoomView_body .mx_GenericEventListSummary .mx_GenericEventListSummary_summary",
|
|
|
|
"created and configured the room.",
|
|
|
|
).should("exist");
|
|
|
|
|
|
|
|
// Create a bot "BotBob" and invite it
|
|
|
|
cy.getBot(homeserver, {
|
|
|
|
displayName: "BotBob",
|
|
|
|
autoAcceptInvites: false,
|
|
|
|
}).then((_bot) => {
|
|
|
|
bot = _bot;
|
|
|
|
cy.inviteUser(roomId, bot.getUserId());
|
|
|
|
bot.joinRoom(roomId);
|
|
|
|
|
|
|
|
// Make sure the bot joined the room
|
|
|
|
cy.contains(
|
|
|
|
".mx_GenericEventListSummary .mx_EventTile_info.mx_EventTile_last",
|
|
|
|
"BotBob joined the room",
|
|
|
|
).should("exist");
|
|
|
|
|
|
|
|
// Have bot send MESSAGE to roomId
|
|
|
|
cy.botSendMessage(bot, roomId, MESSAGE);
|
|
|
|
});
|
|
|
|
|
|
|
|
// Reply to the message
|
|
|
|
clickButtonReply();
|
|
|
|
cy.getComposer().type(`${reply}{enter}`);
|
|
|
|
|
|
|
|
// Make sure 'reply' was sent
|
|
|
|
cy.contains(".mx_RoomView_MessageList .mx_EventTile_last", reply).should("exist");
|
|
|
|
|
|
|
|
// Reply again to create a replyChain
|
|
|
|
clickButtonReply();
|
|
|
|
cy.getComposer().type(`${reply2}{enter}`);
|
|
|
|
|
|
|
|
// Make sure 'reply2' was sent
|
|
|
|
cy.contains(".mx_RoomView_MessageList .mx_EventTile_last", reply2).should("exist");
|
|
|
|
|
|
|
|
// Exclude timestamp and read marker from snapshot
|
2023-03-24 10:25:48 +01:00
|
|
|
//const percyCSS = ".mx_MessageTimestamp, .mx_RoomView_myReadMarker { visibility: hidden !important; }";
|
2023-03-07 12:44:32 +01:00
|
|
|
|
|
|
|
// Check the margin value of ReplyChains of EventTile at the bottom on IRC layout
|
|
|
|
cy.setSettingValue("layout", null, SettingLevel.DEVICE, Layout.IRC);
|
|
|
|
cy.get(".mx_EventTile_last[data-layout='irc'] .mx_ReplyChain").should("have.css", "margin", "0px");
|
|
|
|
|
|
|
|
// Take a snapshot on IRC layout
|
2023-03-22 09:40:08 +01:00
|
|
|
// Disabled because flaky - see https://github.com/vector-im/element-web/issues/24881
|
|
|
|
/*cy.get(".mx_EventTile_last").percySnapshotElement("EventTile with reply chains on IRC layout", {
|
2023-03-07 12:44:32 +01:00
|
|
|
percyCSS,
|
2023-03-22 09:40:08 +01:00
|
|
|
});*/
|
2023-03-07 12:44:32 +01:00
|
|
|
|
|
|
|
// Check the margin value of ReplyChains of EventTile at the bottom on group/modern layout
|
|
|
|
cy.setSettingValue("layout", null, SettingLevel.DEVICE, Layout.Group);
|
|
|
|
cy.get(".mx_EventTile_last[data-layout='group'] .mx_ReplyChain").should("have.css", "margin-bottom", "8px");
|
|
|
|
|
|
|
|
// Take a snapshot on modern layout
|
2023-03-24 10:25:48 +01:00
|
|
|
// Disabled because flaky - see https://github.com/vector-im/element-web/issues/24881
|
|
|
|
/*cy.get(".mx_EventTile_last").percySnapshotElement("EventTile with reply chains on modern layout", {
|
2023-03-07 12:44:32 +01:00
|
|
|
percyCSS,
|
2023-03-24 10:25:48 +01:00
|
|
|
});*/
|
2023-03-07 12:44:32 +01:00
|
|
|
|
|
|
|
// Check the margin value of ReplyChains of EventTile at the bottom on group/modern compact layout
|
|
|
|
cy.setSettingValue("useCompactLayout", null, SettingLevel.DEVICE, true);
|
|
|
|
cy.get(".mx_EventTile_last[data-layout='group'] .mx_ReplyChain").should("have.css", "margin-bottom", "4px");
|
|
|
|
|
|
|
|
// Take a snapshot on compact modern layout
|
2023-03-22 09:40:08 +01:00
|
|
|
// Disabled because flaky - see https://github.com/vector-im/element-web/issues/24881
|
|
|
|
/*cy.get(".mx_EventTile_last").percySnapshotElement("EventTile with reply chains on compact modern layout", {
|
2023-03-07 12:44:32 +01:00
|
|
|
percyCSS,
|
2023-03-22 09:40:08 +01:00
|
|
|
});*/
|
2023-03-07 12:44:32 +01:00
|
|
|
|
|
|
|
// Check the margin value of ReplyChains of EventTile at the bottom on bubble layout
|
|
|
|
cy.setSettingValue("layout", null, SettingLevel.DEVICE, Layout.Bubble);
|
|
|
|
cy.get(".mx_EventTile_last[data-layout='bubble'] .mx_ReplyChain").should(
|
|
|
|
"have.css",
|
|
|
|
"margin-bottom",
|
|
|
|
"8px",
|
|
|
|
);
|
|
|
|
|
|
|
|
// Take a snapshot on bubble layout
|
2023-03-22 09:40:08 +01:00
|
|
|
// Disabled because flaky - see https://github.com/vector-im/element-web/issues/24881
|
|
|
|
/*cy.get(".mx_EventTile_last").percySnapshotElement("EventTile with reply chains on bubble layout", {
|
2023-03-07 12:44:32 +01:00
|
|
|
percyCSS,
|
2023-03-22 09:40:08 +01:00
|
|
|
});*/
|
2023-03-07 12:44:32 +01:00
|
|
|
});
|
2023-03-10 11:47:14 +01:00
|
|
|
|
|
|
|
it("should send, reply, and display long strings without overflowing", () => {
|
|
|
|
// Max 256 characters for display name
|
|
|
|
const LONG_STRING =
|
|
|
|
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut " +
|
|
|
|
"et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut " +
|
|
|
|
"aliquip";
|
|
|
|
|
|
|
|
// Create a bot with a long display name
|
|
|
|
let bot: MatrixClient;
|
|
|
|
cy.getBot(homeserver, {
|
|
|
|
displayName: LONG_STRING,
|
|
|
|
autoAcceptInvites: false,
|
|
|
|
}).then((_bot) => {
|
|
|
|
bot = _bot;
|
|
|
|
});
|
|
|
|
|
|
|
|
// Create another room with a long name, invite the bot, and open the room
|
|
|
|
cy.createRoom({ name: LONG_STRING })
|
|
|
|
.as("testRoomId")
|
|
|
|
.then((_roomId) => {
|
|
|
|
roomId = _roomId;
|
|
|
|
cy.inviteUser(roomId, bot.getUserId());
|
|
|
|
bot.joinRoom(roomId);
|
|
|
|
cy.visit("/#/room/" + roomId);
|
|
|
|
});
|
|
|
|
|
|
|
|
// Wait until configuration is finished
|
|
|
|
cy.contains(
|
|
|
|
".mx_RoomView_body .mx_GenericEventListSummary .mx_GenericEventListSummary_summary",
|
|
|
|
"created and configured the room.",
|
|
|
|
).should("exist");
|
|
|
|
|
|
|
|
// Set the display name to "LONG_STRING 2" in order to avoid a warning in Percy tests from being triggered
|
|
|
|
// due to the generated random mxid being displayed inside the GELS summary.
|
|
|
|
cy.setDisplayName(`${LONG_STRING} 2`);
|
|
|
|
|
|
|
|
// Have the bot send a long message
|
|
|
|
cy.get<string>("@testRoomId").then((roomId) => {
|
|
|
|
bot.sendMessage(roomId, {
|
|
|
|
body: LONG_STRING,
|
|
|
|
msgtype: "m.text",
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// Wait until the message is rendered
|
|
|
|
cy.get(".mx_EventTile_last .mx_MTextBody .mx_EventTile_body").should("have.text", LONG_STRING);
|
|
|
|
|
|
|
|
// Reply to the message
|
|
|
|
cy.get(".mx_EventTile_last")
|
|
|
|
.realHover()
|
|
|
|
.within(() => {
|
|
|
|
cy.get('[aria-label="Reply"]').click({ force: false });
|
|
|
|
});
|
|
|
|
cy.getComposer().type(`${reply}{enter}`);
|
|
|
|
|
2023-03-22 13:19:03 +01:00
|
|
|
// Make sure the reply tile is rendered
|
2023-03-10 11:47:14 +01:00
|
|
|
cy.get(".mx_EventTile_last").within(() => {
|
|
|
|
cy.get(".mx_ReplyTile .mx_MTextBody").should("have.text", LONG_STRING);
|
|
|
|
cy.get(".mx_EventTile_line > .mx_MTextBody").should("have.text", reply);
|
|
|
|
});
|
|
|
|
|
2023-03-22 13:19:03 +01:00
|
|
|
// Change the viewport size
|
|
|
|
cy.viewport(1600, 1200);
|
|
|
|
|
2023-03-10 11:47:14 +01:00
|
|
|
// Exclude timestamp and read marker from snapshots
|
2023-03-24 10:25:48 +01:00
|
|
|
//const percyCSS = ".mx_MessageTimestamp, .mx_RoomView_myReadMarker { visibility: hidden !important; }";
|
2023-03-10 11:47:14 +01:00
|
|
|
|
|
|
|
// Make sure the strings do not overflow on IRC layout
|
|
|
|
cy.setSettingValue("layout", null, SettingLevel.DEVICE, Layout.IRC);
|
2023-03-22 13:19:03 +01:00
|
|
|
// Scroll to the bottom to have Percy take a snapshot of the whole viewport
|
|
|
|
cy.get(".mx_ScrollPanel").scrollTo("bottom", { ensureScrollable: false });
|
|
|
|
// Assert that both avatar in the introduction and the last message are visible at the same time
|
|
|
|
cy.get(".mx_NewRoomIntro .mx_BaseAvatar").should("be.visible");
|
|
|
|
cy.get(".mx_EventTile_last[data-layout='irc']").within(() => {
|
|
|
|
cy.get(".mx_MTextBody").should("be.visible");
|
|
|
|
cy.get(".mx_EventTile_receiptSent").should("be.visible"); // rendered at the bottom of EventTile
|
|
|
|
});
|
|
|
|
// Take a snapshot in IRC layout
|
2023-03-24 10:25:48 +01:00
|
|
|
// Disabled because flaky - see https://github.com/vector-im/element-web/issues/24881
|
|
|
|
//cy.get(".mx_ScrollPanel").percySnapshotElement("Long strings with a reply on IRC layout", { percyCSS });
|
2023-03-10 11:47:14 +01:00
|
|
|
|
|
|
|
// Make sure the strings do not overflow on modern layout
|
|
|
|
cy.setSettingValue("layout", null, SettingLevel.DEVICE, Layout.Group);
|
2023-03-22 13:19:03 +01:00
|
|
|
cy.get(".mx_ScrollPanel").scrollTo("bottom", { ensureScrollable: false }); // Scroll again in case
|
|
|
|
cy.get(".mx_NewRoomIntro .mx_BaseAvatar").should("be.visible");
|
|
|
|
cy.get(".mx_EventTile_last[data-layout='group']").within(() => {
|
|
|
|
cy.get(".mx_MTextBody").should("be.visible");
|
|
|
|
cy.get(".mx_EventTile_receiptSent").should("be.visible");
|
|
|
|
});
|
2023-03-24 10:25:48 +01:00
|
|
|
// Disabled because flaky - see https://github.com/vector-im/element-web/issues/24881
|
|
|
|
//cy.get(".mx_ScrollPanel").percySnapshotElement("Long strings with a reply on modern layout", { percyCSS });
|
2023-03-10 11:47:14 +01:00
|
|
|
|
|
|
|
// Make sure the strings do not overflow on bubble layout
|
|
|
|
cy.setSettingValue("layout", null, SettingLevel.DEVICE, Layout.Bubble);
|
2023-03-22 13:19:03 +01:00
|
|
|
cy.get(".mx_ScrollPanel").scrollTo("bottom", { ensureScrollable: false }); // Scroll again in case
|
|
|
|
cy.get(".mx_NewRoomIntro .mx_BaseAvatar").should("be.visible");
|
|
|
|
cy.get(".mx_EventTile_last[data-layout='bubble']").within(() => {
|
|
|
|
cy.get(".mx_MTextBody").should("be.visible");
|
|
|
|
cy.get(".mx_EventTile_receiptSent").should("be.visible");
|
|
|
|
});
|
2023-03-24 10:25:48 +01:00
|
|
|
// Disabled because flaky - see https://github.com/vector-im/element-web/issues/24881
|
|
|
|
//cy.get(".mx_ScrollPanel").percySnapshotElement("Long strings with a reply on bubble layout", { percyCSS });
|
2023-03-10 11:47:14 +01:00
|
|
|
});
|
2022-07-26 10:38:05 +02:00
|
|
|
});
|
2022-07-11 14:58:20 +02:00
|
|
|
});
|