diff --git a/playwright/e2e/timeline/timeline.spec.ts b/playwright/e2e/timeline/timeline.spec.ts index 8f4af33da8..5c1f99511e 100644 --- a/playwright/e2e/timeline/timeline.spec.ts +++ b/playwright/e2e/timeline/timeline.spec.ts @@ -875,6 +875,40 @@ test.describe("Timeline", () => { ); }); }); + + test("should render a code block", { tag: "@screenshot" }, async ({ page, app, room }) => { + await page.goto(`/#/room/${room.roomId}`); + await app.settings.setValue("layout", null, SettingLevel.DEVICE, Layout.IRC); + + // Wait until configuration is finished + await expect( + page + .locator(".mx_GenericEventListSummary_summary") + .getByText(`${OLD_NAME} created and configured the room.`), + ).toBeVisible(); + + // Send a code block + const composer = app.getComposerField(); + await composer.fill("```\nconsole.log('Hello, world!');\n```"); + await composer.press("Enter"); + + const tile = page.locator(".mx_EventTile"); + await expect(tile).toBeVisible(); + await expect(tile).toMatchScreenshot("code-block.png", { mask: [page.locator(".mx_MessageTimestamp")] }); + + // Edit a code block and assert the edited code block has been correctly rendered + await tile.hover(); + await page.getByRole("toolbar", { name: "Message Actions" }).getByRole("button", { name: "Edit" }).click(); + await page + .getByRole("textbox", { name: "Edit message" }) + .fill("```\nconsole.log('Edited: Hello, world!');\n```"); + await page.getByRole("textbox", { name: "Edit message" }).press("Enter"); + + const newTile = page.locator(".mx_EventTile"); + await expect(newTile).toMatchScreenshot("edited-code-block.png", { + mask: [page.locator(".mx_MessageTimestamp")], + }); + }); }); test.describe("message sending", { tag: ["@no-firefox", "@no-webkit"] }, () => { diff --git a/playwright/snapshots/timeline/timeline.spec.ts/code-block-linux.png b/playwright/snapshots/timeline/timeline.spec.ts/code-block-linux.png new file mode 100644 index 0000000000..2f62d0dec6 Binary files /dev/null and b/playwright/snapshots/timeline/timeline.spec.ts/code-block-linux.png differ diff --git a/playwright/snapshots/timeline/timeline.spec.ts/edited-code-block-linux.png b/playwright/snapshots/timeline/timeline.spec.ts/edited-code-block-linux.png new file mode 100644 index 0000000000..46f5cf1a7a Binary files /dev/null and b/playwright/snapshots/timeline/timeline.spec.ts/edited-code-block-linux.png differ diff --git a/res/css/views/rooms/_EventTile.pcss b/res/css/views/rooms/_EventTile.pcss index 35097fb3b8..54f91bd5f4 100644 --- a/res/css/views/rooms/_EventTile.pcss +++ b/res/css/views/rooms/_EventTile.pcss @@ -683,6 +683,7 @@ $left-gutter: 64px; line-height: inherit !important; background-color: inherit; color: inherit; /* inherit the colour from the dark or light theme by default (but not for code blocks) */ + flex: 1; pre, code {