Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit ecebac6

Browse files
authored
Align info EventTile and normal EventTile on IRC layout (#10197)
* fixes alignment issue in IRC layout * adds cypress test for alignment --------- Contributed-by: Suguru Hirahara <[email protected]> Signed-off-by: Alun Turner <[email protected]>
1 parent b48b968 commit ecebac6

File tree

3 files changed

+120
-15
lines changed

3 files changed

+120
-15
lines changed

cypress/e2e/timeline/timeline.spec.ts

+111-3
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,11 @@ describe("Timeline", () => {
179179
// Check the event line has margin instead of inset property
180180
// cf. _EventTile.pcss
181181
// --EventTile_irc_line_info-margin-inline-start
182-
// = calc(var(--name-width) + 10px + var(--icon-width))
183-
// = 80 + 10 + 14 = 104px
182+
// = calc(var(--name-width) + var(--icon-width) + 1 * var(--right-padding))
183+
// = 80 + 14 + 5 = 99px
184+
184185
cy.get(".mx_EventTile[data-layout=irc].mx_EventTile_info:first-of-type .mx_EventTile_line")
185-
.should("have.css", "margin-inline-start", "104px")
186+
.should("have.css", "margin-inline-start", "99px")
186187
.should("have.css", "inset-inline-start", "0px");
187188

188189
// Exclude timestamp and read marker from snapshot
@@ -193,6 +194,113 @@ describe("Timeline", () => {
193194
cy.checkA11y();
194195
});
195196

197+
it("should align generic event list summary with messages and emote on IRC layout", () => {
198+
// This test aims to check:
199+
// 1. Alignment of collapsed GELS (generic event list summary) and messages
200+
// 2. Alignment of expanded GELS and messages
201+
// 3. Alignment of expanded GELS and placeholder of deleted message
202+
// 4. Alignment of expanded GELS, placeholder of deleted message, and emote
203+
204+
// Exclude timestamp from snapshot of mx_MainSplit
205+
const percyCSS = ".mx_MainSplit .mx_MessageTimestamp { visibility: hidden !important; }";
206+
207+
cy.visit("/#/room/" + roomId);
208+
cy.setSettingValue("layout", null, SettingLevel.DEVICE, Layout.IRC);
209+
210+
// Wait until configuration is finished
211+
cy.contains(
212+
".mx_RoomView_body .mx_GenericEventListSummary .mx_GenericEventListSummary_summary",
213+
"created and configured the room.",
214+
).should("exist");
215+
216+
// Send messages
217+
cy.get(".mx_RoomView_body .mx_BasicMessageComposer_input").type("Hello Mr. Bot{enter}");
218+
cy.get(".mx_RoomView_body .mx_BasicMessageComposer_input").type("Hello again, Mr. Bot{enter}");
219+
// Make sure the second message was sent
220+
cy.get(".mx_RoomView_MessageList > .mx_EventTile_last .mx_EventTile_receiptSent").should("be.visible");
221+
222+
// 1. Alignment of collapsed GELS (generic event list summary) and messages
223+
// Check inline start spacing of collapsed GELS
224+
// See: _EventTile.pcss
225+
// .mx_GenericEventListSummary[data-layout="irc"] > .mx_EventTile_line
226+
// = var(--name-width) + var(--icon-width) + $MessageTimestamp_width + 2 * var(--right-padding)
227+
// = 80 + 14 + 46 + 2 * 5
228+
// = 150px
229+
cy.get(".mx_GenericEventListSummary[data-layout=irc] > .mx_EventTile_line").should(
230+
"have.css",
231+
"padding-inline-start",
232+
"150px",
233+
);
234+
// Check width and spacing values of elements in .mx_EventTile, which should be equal to 150px
235+
// --right-padding should be applied
236+
cy.get(".mx_EventTile > *").should("have.css", "margin-right", "5px");
237+
// --name-width width zero inline end margin should be applied
238+
cy.get(".mx_EventTile .mx_DisambiguatedProfile")
239+
.should("have.css", "width", "80px")
240+
.should("have.css", "margin-inline-end", "0px");
241+
// --icon-width should be applied
242+
cy.get(".mx_EventTile .mx_EventTile_avatar > .mx_BaseAvatar").should("have.css", "width", "14px");
243+
// $MessageTimestamp_width should be applied
244+
cy.get(".mx_EventTile > a").should("have.css", "min-width", "46px");
245+
// Record alignment of collapsed GELS and messages on messagePanel
246+
cy.get(".mx_MainSplit").percySnapshotElement("Collapsed GELS and messages on IRC layout", { percyCSS });
247+
248+
// 2. Alignment of expanded GELS and messages
249+
// Click "expand" link button
250+
cy.get(".mx_GenericEventListSummary_toggle[aria-expanded=false]").click();
251+
// Check inline start spacing of info line on expanded GELS
252+
cy.get(".mx_EventTile[data-layout=irc].mx_EventTile_info:first-of-type .mx_EventTile_line")
253+
// See: _EventTile.pcss
254+
// --EventTile_irc_line_info-margin-inline-start
255+
// = 80 + 14 + 1 * 5
256+
.should("have.css", "margin-inline-start", "99px");
257+
// Record alignment of expanded GELS and messages on messagePanel
258+
cy.get(".mx_MainSplit").percySnapshotElement("Expanded GELS and messages on IRC layout", { percyCSS });
259+
260+
// 3. Alignment of expanded GELS and placeholder of deleted message
261+
// Delete the second (last) message
262+
cy.get(".mx_RoomView_MessageList > .mx_EventTile_last").realHover();
263+
cy.get(".mx_RoomView_MessageList > .mx_EventTile_last .mx_MessageActionBar_optionsButton", {
264+
timeout: 1000,
265+
})
266+
.should("exist")
267+
.realHover()
268+
.click({ force: false });
269+
cy.get(".mx_IconizedContextMenu_item[aria-label=Remove]").should("be.visible").click({ force: false });
270+
// Confirm deletion
271+
cy.get(".mx_Dialog_buttons button[data-testid=dialog-primary-button]")
272+
.should("have.text", "Remove")
273+
.click({ force: false });
274+
// Make sure the dialog was closed and the second (last) message was redacted
275+
cy.get(".mx_Dialog").should("not.exist");
276+
cy.get(".mx_GenericEventListSummary .mx_EventTile_last .mx_RedactedBody").should("be.visible");
277+
cy.get(".mx_GenericEventListSummary .mx_EventTile_last .mx_EventTile_receiptSent").should("be.visible");
278+
// Record alignment of expanded GELS and placeholder of deleted message on messagePanel
279+
cy.get(".mx_MainSplit").percySnapshotElement("Expanded GELS and with placeholder of deleted message", {
280+
percyCSS,
281+
});
282+
283+
// 4. Alignment of expanded GELS, placeholder of deleted message, and emote
284+
// Send a emote
285+
cy.get(".mx_RoomView_body .mx_BasicMessageComposer_input").type("/me says hello to Mr. Bot{enter}");
286+
// Check inline start margin of its avatar
287+
// Here --right-padding is for the avatar on the message line
288+
// See: _IRCLayout.pcss
289+
// .mx_IRCLayout .mx_EventTile_emote .mx_EventTile_avatar
290+
// = calc(var(--name-width) + var(--icon-width) + 1 * var(--right-padding))
291+
// = 80 + 14 + 1 * 5
292+
cy.get(".mx_EventTile_emote .mx_EventTile_avatar").should("have.css", "margin-left", "99px");
293+
// Make sure emote was sent
294+
cy.get(".mx_EventTile_last.mx_EventTile_emote .mx_EventTile_receiptSent").should("be.visible");
295+
// Record alignment of expanded GELS, placeholder of deleted message, and emote
296+
cy.get(".mx_MainSplit").percySnapshotElement(
297+
"Expanded GELS and with emote and placeholder of deleted message",
298+
{
299+
percyCSS,
300+
},
301+
);
302+
});
303+
196304
it("should set inline start padding to a hidden event line", () => {
197305
sendEvent(roomId);
198306
cy.visit("/#/room/" + roomId);

res/css/views/rooms/_EventTile.pcss

+7-11
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,11 @@ $left-gutter: 64px;
270270
}
271271

272272
&[data-layout="irc"] {
273-
--EventTile_irc_line_info-margin-inline-start: calc(var(--name-width) + 10px + var(--icon-width));
273+
/* add --right-padding value of MessageTimestamp only */
274+
/* stylelint-disable-next-line declaration-colon-space-after */
275+
--EventTile_irc_line_info-margin-inline-start: calc(
276+
var(--name-width) + var(--icon-width) + 1 * var(--right-padding)
277+
);
274278

275279
.mx_EventTile_msgOption {
276280
.mx_ReadReceiptGroup {
@@ -483,20 +487,12 @@ $left-gutter: 64px;
483487
}
484488

485489
&[data-layout="irc"] {
486-
.mx_EventTile_line .mx_RedactedBody {
487-
padding-left: 24px; /* 25px - 1px */
488-
489-
&::before {
490-
left: var(--right-padding);
491-
}
492-
}
493-
494490
/* Apply only collapsed events block */
495491
> .mx_EventTile_line {
496-
/* 15 px of padding */
492+
/* add --right-padding value of MessageTimestamp and avatar only */
497493
/* stylelint-disable-next-line declaration-colon-space-after */
498494
padding-left: calc(
499-
var(--name-width) + var(--icon-width) + $MessageTimestamp_width + 3 * var(--right-padding)
495+
var(--name-width) + var(--icon-width) + $MessageTimestamp_width + 2 * var(--right-padding)
500496
);
501497
}
502498
}

res/css/views/rooms/_IRCLayout.pcss

+2-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ $irc-line-height: $font-18px;
159159

160160
.mx_EventTile_emote {
161161
.mx_EventTile_avatar {
162-
margin-left: calc(var(--name-width) + var(--icon-width) + var(--right-padding));
162+
/* add --right-padding value of MessageTimestamp only */
163+
margin-left: calc(var(--name-width) + var(--icon-width) + 1 * var(--right-padding));
163164
}
164165
}
165166

0 commit comments

Comments
 (0)