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

Commit db7748b

Browse files
authored
Fix the hidden view source toggle on IRC layout (#10266)
* Display view source toggle on IRC layout Signed-off-by: Suguru Hirahara <[email protected]> * Add a test Signed-off-by: Suguru Hirahara <[email protected]> * Merge tests Signed-off-by: Suguru Hirahara <[email protected]> * Collapse hidden event source before checking clickability of view source toggle on IRC layout Signed-off-by: Suguru Hirahara <[email protected]> * Select view source event under the edited line on the test Signed-off-by: Suguru Hirahara <[email protected]> * Fix the test Signed-off-by: Suguru Hirahara <[email protected]> * lint Signed-off-by: Suguru Hirahara <[email protected]> --------- Signed-off-by: Suguru Hirahara <[email protected]>
1 parent 4f1e5a7 commit db7748b

File tree

2 files changed

+49
-4
lines changed

2 files changed

+49
-4
lines changed

cypress/e2e/timeline/timeline.spec.ts

+43-3
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,11 @@ describe("Timeline", () => {
238238
});
239239
});
240240

241-
it("should click top left of view source event toggle", () => {
241+
it("should click view source event toggle", () => {
242+
// This test checks:
243+
// 1. clickability of top left of view source event toggle
244+
// 2. clickability of view source toggle on IRC layout
245+
242246
sendEvent(roomId);
243247
cy.visit("/#/room/" + roomId);
244248
cy.setSettingValue("showHiddenEventsInTimeline", null, SettingLevel.DEVICE, true);
@@ -254,16 +258,52 @@ describe("Timeline", () => {
254258
});
255259
cy.contains(".mx_RoomView_body .mx_EventTile[data-scroll-tokens]", "MessageEdit").should("exist");
256260

261+
// 1. clickability of top left of view source event toggle
262+
257263
// Click top left of the event toggle, which should not be covered by MessageActionBar's safe area
258-
cy.get(".mx_EventTile:not(:first-child) .mx_ViewSourceEvent")
264+
cy.get(".mx_EventTile_last[data-layout=group] .mx_ViewSourceEvent")
265+
.should("exist")
266+
.realHover()
267+
.within(() => {
268+
cy.get(".mx_ViewSourceEvent_toggle").click("topLeft", { force: false });
269+
});
270+
271+
// Make sure the expand toggle worked
272+
cy.get(".mx_EventTile .mx_ViewSourceEvent_expanded").should("be.visible");
273+
274+
// Click again to collapse the source
275+
cy.get(".mx_EventTile_last[data-layout=group] .mx_ViewSourceEvent")
276+
.should("exist")
277+
.realHover()
278+
.within(() => {
279+
cy.get(".mx_ViewSourceEvent_toggle").click("topLeft", { force: false });
280+
});
281+
cy.get(".mx_EventTile .mx_ViewSourceEvent_expanded").should("not.exist");
282+
283+
// 2. clickability of view source toggle on IRC layout
284+
285+
// Enable IRC layout
286+
cy.setSettingValue("layout", null, SettingLevel.DEVICE, Layout.IRC);
287+
288+
// Exclude timestamp from snapshot
289+
const percyCSS = ".mx_MessageTimestamp { visibility: hidden !important; }";
290+
291+
// Hover the view source toggle on IRC layout
292+
cy.get(".mx_GenericEventListSummary[data-layout=irc] .mx_EventTile .mx_ViewSourceEvent")
293+
.should("exist")
294+
.realHover()
295+
.percySnapshotElement("Hovered hidden event line on IRC layout", { percyCSS });
296+
297+
// Click view source event toggle
298+
cy.get(".mx_GenericEventListSummary[data-layout=irc] .mx_EventTile .mx_ViewSourceEvent")
259299
.should("exist")
260300
.realHover()
261301
.within(() => {
262302
cy.get(".mx_ViewSourceEvent_toggle").click("topLeft", { force: false });
263303
});
264304

265305
// Make sure the expand toggle worked
266-
cy.get(".mx_EventTile .mx_ViewSourceEvent_expanded .mx_ViewSourceEvent_toggle").should("be.visible");
306+
cy.get(".mx_EventTile[data-layout=irc] .mx_ViewSourceEvent_expanded").should("be.visible");
267307
});
268308

269309
it("should click 'collapse' link button on the first hovered info event line on bubble layout", () => {

res/css/views/rooms/_IRCLayout.pcss

+6-1
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,17 @@ $irc-line-height: $font-18px;
130130
.mx_TextualEvent,
131131
.mx_ViewSourceEvent,
132132
.mx_MTextBody {
133-
display: inline-block;
134133
/* add a 1px padding top and bottom because our larger
135134
emoji font otherwise gets cropped by anti-zalgo */
136135
padding: var(--EventTile_irc_line-padding-block) 0;
137136
}
138137

138+
.mx_EventTile_e2eIcon,
139+
.mx_TextualEvent,
140+
.mx_MTextBody {
141+
display: inline-block;
142+
}
143+
139144
.mx_ReplyTile {
140145
.mx_MTextBody {
141146
display: -webkit-box; /* Enable -webkit-line-clamp */

0 commit comments

Comments
 (0)