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

Commit c6922c9

Browse files
authored
Fix reply message truncation on 2 lines (#12929)
* Fix reply message truncation on 2 lines * Add e2e tests for reply
1 parent ea3c5cf commit c6922c9

File tree

8 files changed

+69
-4
lines changed

8 files changed

+69
-4
lines changed

playwright/e2e/messages/messages.spec.ts

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,34 @@ async function sendMessage(page: Page, message: string): Promise<Locator> {
2424
await page.getByRole("textbox", { name: "Send a message…" }).fill(message);
2525
await page.getByRole("button", { name: "Send message" }).click();
2626

27-
const msgTile = await page.locator(".mx_EventTile_last");
27+
const msgTile = page.locator(".mx_EventTile_last");
28+
await msgTile.locator(".mx_EventTile_receiptSent").waitFor();
29+
return msgTile;
30+
}
31+
32+
async function sendMultilineMessages(page: Page, messages: string[]) {
33+
await page.getByRole("textbox", { name: "Send a message…" }).focus();
34+
for (let i = 0; i < messages.length; i++) {
35+
await page.keyboard.type(messages[i]);
36+
if (i < messages.length - 1) await page.keyboard.press("Shift+Enter");
37+
}
38+
39+
await page.getByRole("button", { name: "Send message" }).click();
40+
41+
const msgTile = page.locator(".mx_EventTile_last");
42+
await msgTile.locator(".mx_EventTile_receiptSent").waitFor();
43+
return msgTile;
44+
}
45+
46+
async function replyMessage(page: Page, message: Locator, replyMessage: string): Promise<Locator> {
47+
const line = message.locator(".mx_EventTile_line");
48+
await line.hover();
49+
await line.getByRole("button", { name: "Reply", exact: true }).click();
50+
51+
await page.getByRole("textbox", { name: "Send a reply…" }).fill(replyMessage);
52+
await page.getByRole("button", { name: "Send message" }).click();
53+
54+
const msgTile = page.locator(".mx_EventTile_last");
2855
await msgTile.locator(".mx_EventTile_receiptSent").waitFor();
2956
return msgTile;
3057
}
@@ -88,6 +115,22 @@ test.describe("Message rendering", () => {
88115
});
89116
});
90117

118+
test("should render a reply of a LTR message", async ({ page, user, app, room }) => {
119+
await page.goto(`#/room/${room.roomId}`);
120+
121+
const msgTile = await sendMultilineMessages(page, [
122+
"Fist line",
123+
"Second line",
124+
"Third line",
125+
"Fourth line",
126+
]);
127+
128+
await replyMessage(page, msgTile, "response to multiline message");
129+
await expect(msgTile).toMatchScreenshot(`reply-message-ltr-${direction}displayname.png`, {
130+
mask: [page.locator(".mx_MessageTimestamp")],
131+
});
132+
});
133+
91134
test("should render a basic RTL text message", async ({ page, user, app, room }) => {
92135
await page.goto(`#/room/${room.roomId}`);
93136

@@ -122,6 +165,22 @@ test.describe("Message rendering", () => {
122165
mask: [page.locator(".mx_MessageTimestamp")],
123166
});
124167
});
168+
169+
test("should render a reply of a RTL message", async ({ page, user, app, room }) => {
170+
await page.goto(`#/room/${room.roomId}`);
171+
172+
const msgTile = await sendMultilineMessages(page, [
173+
"مرحبا بالعالم!",
174+
"مرحبا بالعالم!",
175+
"مرحبا بالعالم!",
176+
"مرحبا بالعالم!",
177+
]);
178+
179+
await replyMessage(page, msgTile, "مرحبا بالعالم!");
180+
await expect(msgTile).toMatchScreenshot(`reply-message-trl-${direction}displayname.png`, {
181+
mask: [page.locator(".mx_MessageTimestamp")],
182+
});
183+
});
125184
});
126185
});
127186
});
Loading
Loading
Loading
Loading

res/css/views/elements/_ReplyChain.pcss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ limitations under the License.
2525
white-space: nowrap; /* Enforce 'In reply to' to be a single line */
2626
color: $secondary-content;
2727
transition: color ease 0.15s;
28-
font-weight: var(--cpd-font-weight-normal);
28+
font-weight: var(--cpd-font-weight-regular);
2929
text-decoration: inherit;
3030

3131
&:hover {

res/css/views/rooms/_EventTile.pcss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ $left-gutter: 64px;
126126

127127
.mx_ReplyChain--expanded {
128128
.mx_EventTile_body {
129-
display: block;
129+
/* !important needed to override .mx_ReplyTile .mx_EventTile_content .mx_EventTile_body */
130+
display: block !important;
130131
overflow-y: scroll;
131132
}
132133

@@ -899,7 +900,7 @@ $left-gutter: 64px;
899900
object-fit: contain;
900901
object-position: left top;
901902

902-
/* Override the default colors of the 'github-markdown-css' library
903+
/* Override the default colors of the 'github-markdown-css' library
903904
(#fff for light theme, #000 for dark theme) to match the inherited theme */
904905
background-color: inherit !important;
905906
}

res/css/views/rooms/_ReplyTile.pcss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ limitations under the License.
7777
font-size: $font-14px !important; /* Override the big emoji override */
7878
}
7979

80+
// in order to keep the message on two lines, we need to make the body inline
81+
.mx_EventTile_body {
82+
display: inline;
83+
}
84+
8085
// Hide line numbers and edited indicator
8186
.mx_EventTile_lineNumbers,
8287
.mx_EventTile_edited {

0 commit comments

Comments
 (0)