This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 830
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix alignment of RTL messages (#12837)
* Fix alignment of RTL messages Inspired by #5453 but hopefully with the edited marker in the right place. This is a PoC: types aren't correct and the style needs pulling out to a class. Plus it would probably need more visual tests added. If this looks acceptable, I can make these changes. * Fix spacing between text and edited annotation * Update snapshot * Update more snapshots * More snapshots * More more snapshots * Split out style * Fix emotes This will cause them always be right-justified if the display name is rtl. * Add playwright test for ltr/rtl message rendering * Better snapshots * Await on message sending * Better waiting, hopefully * Old snapshot files * Really hopefully fixed screenshots this time * Don't include the message action bar in the screenshots
- Loading branch information
Showing
24 changed files
with
242 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
/* | ||
Copyright 2024 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. | ||
*/ | ||
|
||
/* See readme.md for tips on writing these tests. */ | ||
|
||
import { Locator, Page } from "playwright-core"; | ||
|
||
import { test, expect } from "../../element-web-test"; | ||
|
||
async function sendMessage(page: Page, message: string): Promise<Locator> { | ||
await page.getByRole("textbox", { name: "Send a messageโฆ" }).fill(message); | ||
await page.getByRole("button", { name: "Send message" }).click(); | ||
|
||
const msgTile = await page.locator(".mx_EventTile_last"); | ||
await msgTile.locator(".mx_EventTile_receiptSent").waitFor(); | ||
return msgTile; | ||
} | ||
|
||
async function editMessage(page: Page, message: Locator, newMsg: string): Promise<void> { | ||
const line = message.locator(".mx_EventTile_line"); | ||
await line.hover(); | ||
await line.getByRole("button", { name: "Edit" }).click(); | ||
const editComposer = page.getByRole("textbox", { name: "Edit message" }); | ||
await page.getByLabel("User menu").hover(); // Just to un-hover the message line | ||
await editComposer.fill(newMsg); | ||
await editComposer.press("Enter"); | ||
} | ||
|
||
test.describe("Message rendering", () => { | ||
[ | ||
{ direction: "ltr", displayName: "Quentin" }, | ||
{ direction: "rtl", displayName: "ููููุชูู" }, | ||
].forEach(({ direction, displayName }) => { | ||
test.describe(`with ${direction} display name`, () => { | ||
test.use({ | ||
displayName, | ||
room: async ({ user, app }, use) => { | ||
const roomId = await app.client.createRoom({ name: "Test room" }); | ||
await use({ roomId }); | ||
}, | ||
}); | ||
|
||
test("should render a basic LTR text message", async ({ page, user, app, room }) => { | ||
await page.goto(`#/room/${room.roomId}`); | ||
|
||
const msgTile = await sendMessage(page, "Hello, world!"); | ||
await expect(msgTile).toMatchScreenshot(`basic-message-ltr-${direction}displayname.png`, { | ||
mask: [page.locator(".mx_MessageTimestamp")], | ||
}); | ||
}); | ||
|
||
test("should render an LTR emote", async ({ page, user, app, room }) => { | ||
await page.goto(`#/room/${room.roomId}`); | ||
|
||
const msgTile = await sendMessage(page, "/me lays an egg"); | ||
await expect(msgTile).toMatchScreenshot(`emote-ltr-${direction}displayname.png`); | ||
}); | ||
|
||
test("should render an edited LTR message", async ({ page, user, app, room }) => { | ||
await page.goto(`#/room/${room.roomId}`); | ||
|
||
const msgTile = await sendMessage(page, "Hello, world!"); | ||
|
||
await editMessage(page, msgTile, "Hello, universe!"); | ||
|
||
await expect(msgTile).toMatchScreenshot(`edited-message-ltr-${direction}displayname.png`, { | ||
mask: [page.locator(".mx_MessageTimestamp")], | ||
}); | ||
}); | ||
|
||
test("should render a basic RTL text message", async ({ page, user, app, room }) => { | ||
await page.goto(`#/room/${room.roomId}`); | ||
|
||
const msgTile = await sendMessage(page, "ู ุฑุญุจุง ุจุงูุนุงูู !"); | ||
await expect(msgTile).toMatchScreenshot(`basic-message-rtl-${direction}displayname.png`, { | ||
mask: [page.locator(".mx_MessageTimestamp")], | ||
}); | ||
}); | ||
|
||
test("should render an RTL emote", async ({ page, user, app, room }) => { | ||
await page.goto(`#/room/${room.roomId}`); | ||
|
||
const msgTile = await sendMessage(page, "/me ูุถุน ุจูุถุฉ"); | ||
await expect(msgTile).toMatchScreenshot(`emote-rtl-${direction}displayname.png`); | ||
}); | ||
|
||
test("should render an edited RTL message", async ({ page, user, app, room }) => { | ||
await page.goto(`#/room/${room.roomId}`); | ||
|
||
const msgTile = await sendMessage(page, "ู ุฑุญุจุง ุจุงูุนุงูู !"); | ||
|
||
await editMessage(page, msgTile, "ู ุฑุญุจุง ุจุงูููู!"); | ||
|
||
await expect(msgTile).toMatchScreenshot(`edited-message-rtl-${direction}displayname.png`, { | ||
mask: [page.locator(".mx_MessageTimestamp")], | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
Binary file added
BIN
+3.96 KB
.../snapshots/messages/messages.spec.ts/basic-message-ltr-ltrdisplayname-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.97 KB
.../snapshots/messages/messages.spec.ts/basic-message-ltr-rtldisplayname-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.98 KB
.../snapshots/messages/messages.spec.ts/basic-message-rtl-ltrdisplayname-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.98 KB
.../snapshots/messages/messages.spec.ts/basic-message-rtl-rtldisplayname-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.64 KB
...snapshots/messages/messages.spec.ts/edited-message-ltr-ltrdisplayname-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.65 KB
...snapshots/messages/messages.spec.ts/edited-message-ltr-rtldisplayname-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.85 KB
...snapshots/messages/messages.spec.ts/edited-message-rtl-ltrdisplayname-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.85 KB
...snapshots/messages/messages.spec.ts/edited-message-rtl-rtldisplayname-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.73 KB
playwright/snapshots/messages/messages.spec.ts/emote-ltr-ltrdisplayname-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.89 KB
playwright/snapshots/messages/messages.spec.ts/emote-ltr-rtldisplayname-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.69 KB
playwright/snapshots/messages/messages.spec.ts/emote-rtl-ltrdisplayname-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.5 KB
playwright/snapshots/messages/messages.spec.ts/emote-rtl-rtldisplayname-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.