diff --git a/apps/web/playwright/e2e/timeline/event-tile-view.spec.ts b/apps/web/playwright/e2e/timeline/event-tile-view.spec.ts new file mode 100644 index 0000000000..441e1e74a6 --- /dev/null +++ b/apps/web/playwright/e2e/timeline/event-tile-view.spec.ts @@ -0,0 +1,313 @@ +/* +Copyright 2026 Element Creations Ltd. + +SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial +Please see LICENSE files in the repository root for full details. +*/ + +import type { Page } from "@playwright/test"; +import { expect, test } from "../../element-web-test"; +import { SettingLevel } from "../../../src/settings/SettingLevel"; +import { Layout } from "../../../src/settings/enums/Layout"; + +const roomMessageList = (page: Page) => page.locator(".mx_RoomView_MessageList"); + +test.describe("EventTileView application coverage", () => { + test.use({ + displayName: "Alice", + botCreateOpts: { + displayName: "Bob", + autoAcceptInvites: true, + }, + }); + + test( + "renders grouped messages from both users in each layout", + { tag: "@screenshot" }, + async ({ page, app, bot }) => { + const roomId = await app.client.createRoom({ name: "EventTile layouts" }); + await app.client.inviteUser(roomId, bot.credentials!.userId); + await bot.joinRoom(roomId); + + await app.client.sendMessage(roomId, "Alice first"); + await app.client.sendMessage(roomId, "Alice continuation"); + await bot.sendMessage(roomId, "Bob first"); + await bot.sendMessage(roomId, "Bob continuation"); + + await app.viewRoomById(roomId); + const messages = roomMessageList(page); + + for (const layout of [Layout.Group, Layout.Bubble, Layout.IRC]) { + await app.settings.setValue("layout", null, SettingLevel.DEVICE, layout); + await app.settings.setValue("useCompactLayout", null, SettingLevel.DEVICE, false); + + await expect( + messages.locator(`.mx_EventTile[data-layout='${layout}']`).filter({ + has: page.locator(".mx_EventTile_body"), + }), + ).toHaveCount(4); + + await expect(messages).toMatchScreenshot(`event-tile-${layout}.png`, { + css: ".mx_MessageTimestamp { visibility: hidden; }", + }); + } + + await app.settings.setValue("layout", null, SettingLevel.DEVICE, Layout.Group); + await app.settings.setValue("useCompactLayout", null, SettingLevel.DEVICE, true); + await expect( + messages + .locator(".mx_EventTile[data-layout='group']") + .filter({ has: page.locator(".mx_EventTile_body") }), + ).toHaveCount(4); + await expect(messages).toMatchScreenshot("event-tile-group-compact.png", { + css: ".mx_MessageTimestamp { visibility: hidden; }", + }); + }, + ); + + test( + "keeps tile interaction states in the application DOM", + { tag: "@screenshot" }, + async ({ page, app, bot, user }, testInfo) => { + const roomId = await app.client.createRoom({ name: "EventTile interactions" }); + await app.client.inviteUser(roomId, bot.credentials!.userId); + await bot.joinRoom(roomId); + + const event = await app.client.sendMessage(roomId, "Interaction target"); + await app.viewRoomById(roomId); + + const tile = page.locator(`.mx_RoomView_MessageList .mx_EventTile[data-event-id='${event.event_id}']`); + const line = tile.locator(".mx_EventTile_line"); + const actionBar = tile.locator(".mx_MessageActionBar"); + + await line.hover(); + await expect(actionBar).toBeVisible(); + await expect(tile.locator(".mx_MessageTimestamp")).toBeVisible(); + await expect(tile).toMatchScreenshot("event-tile-hovered.png", { + css: ".mx_MessageTimestamp { visibility: hidden; }", + }); + + // Move the pointer away so the following assertions exercise keyboard focus rather than hover. + await page.mouse.move(0, 0); + await expect(actionBar).not.toBeVisible(); + + await page.getByRole("textbox", { name: "Send an unencrypted message…" }).focus(); + // what-input listens for keyboard events and records the modality on . + await page.keyboard.press("ArrowRight"); + await expect(page.locator("html")).toHaveAttribute("data-whatinput", "keyboard"); + await tile.focus(); + await expect(tile).toBeFocused(); + await expect(actionBar).toBeVisible(); + await expect(tile.locator(".mx_MessageTimestamp")).toBeVisible(); + + await line.click({ button: "right" }); + await expect(page.locator(".mx_IconizedContextMenu")).toBeVisible(); + // The context menu is rendered in a portal above the tile, so capturing the tile alone clips its menu. + await expect(page).toMatchScreenshot("event-tile-context-menu-selected.png", { + css: ".mx_MessageTimestamp { visibility: hidden; }", + }); + await page.keyboard.press("Escape"); + await expect(tile).toMatchScreenshot("event-tile-context-menu-closed.png", { + css: ".mx_MessageTimestamp { visibility: hidden; }", + }); + + const highlightedEvent = await bot.sendMessage(roomId, { + "msgtype": "m.text", + "body": "Highlighted notification", + "format": "org.matrix.custom.html", + "formatted_body": `Highlighted notification`, + "m.mentions": { + user_ids: [user.userId], + }, + }); + if (!["Dendrite", "Pinecone"].includes(testInfo.project.name)) { + const highlightedTile = page.locator(`.mx_EventTile[data-event-id='${highlightedEvent.event_id}']`); + await expect(highlightedTile).toMatchScreenshot("event-tile-highlighted.png", { + css: ".mx_MessageTimestamp { visibility: hidden; }", + }); + } + + await page.goto(`/#/room/${roomId}/${event.event_id}`); + const selectedTile = page.locator(`.mx_EventTile[data-event-id='${event.event_id}']`); + await expect(selectedTile).toMatchScreenshot("event-tile-permalink-selected.png", { + css: ".mx_MessageTimestamp { visibility: hidden; }", + }); + + await selectedTile.locator(".mx_EventTile_line").hover(); + const editButton = selectedTile.getByRole("button", { name: "Edit", exact: true }); + await expect(editButton).toBeVisible(); + await editButton.click(); + await expect(selectedTile).toMatchScreenshot("event-tile-editing.png", { + css: ".mx_MessageTimestamp { visibility: hidden; }", + }); + await expect(page.getByRole("textbox", { name: "Edit message" })).toBeVisible(); + await page.getByRole("textbox", { name: "Edit message" }).fill("Interaction target edited"); + await page.getByRole("textbox", { name: "Edit message" }).press("Enter"); + await expect(page.locator(".mx_EventTile", { hasText: "Interaction target edited" })).toBeVisible(); + }, + ); + + test( + "distinguishes matching and contextual search tiles and preserves result links", + { tag: "@screenshot" }, + async ({ page, app, bot }, testInfo) => { + test.skip( + ["Dendrite", "Pinecone"].includes(testInfo.project.name), + "The configured homeserver has server-side search disabled", + ); + + const roomId = await app.client.createRoom({ + name: "EventTile search", + }); + await app.client.inviteUser(roomId, bot.credentials!.userId); + await bot.joinRoom(roomId); + + await app.client.sendMessage(roomId, "context before"); + const root = await app.client.sendMessage(roomId, "match root link https://example.org"); + const other = await bot.sendMessage(roomId, "match other link"); + await bot.sendMessage(roomId, "context after"); + + await app.viewRoomById(roomId); + await app.toggleRoomInfoPanel(); + const search = page.locator(".mx_RoomSummaryCard_search").getByRole("searchbox"); + await search.fill("match"); + await search.press("Enter"); + + const results = page.locator(".mx_RoomView_searchResultsPanel"); + const matching = results.locator(".mx_EventTile:not(.mx_EventTile_contextual)"); + const contextual = results.locator(".mx_EventTile.mx_EventTile_contextual"); + const rootTile = results.locator( + `.mx_EventTile[data-event-id='${root.event_id}']:not(.mx_EventTile_contextual)`, + ); + const otherTile = results.locator( + `.mx_EventTile[data-event-id='${other.event_id}']:not(.mx_EventTile_contextual)`, + ); + await expect(matching).toHaveCount(2); + expect(await contextual.count()).toBeGreaterThan(0); + await expect(contextual.first()).toHaveCSS("opacity", "0.4"); + + await expect(rootTile).toHaveCount(1); + await expect(otherTile).toHaveCount(1); + for (const tile of [rootTile, otherTile]) { + await expect(tile.locator(".mx_EventTile_searchHighlight")).toBeVisible(); + await expect(tile).toHaveAttribute("data-layout", /group|bubble|irc/); + } + + await expect(rootTile.locator(`a[href='#/room/${roomId}/${root.event_id}']`)).toBeVisible(); + await expect(otherTile.locator(`a[href='#/room/${roomId}/${other.event_id}']`)).toBeVisible(); + + await expect(results).toMatchScreenshot("search-results-event-tiles.png", { + css: ".mx_MessageTimestamp { visibility: hidden; }", + }); + + await app.settings.setValue("useCompactLayout", null, SettingLevel.DEVICE, true); + await expect( + results.locator(".mx_EventTile:not(.mx_EventTile_contextual)[data-layout='group']"), + ).toHaveCount(2); + }, + ); + + test( + "renders threaded search information and preserves the result link", + { tag: "@screenshot" }, + async ({ page, app, bot }, testInfo) => { + test.skip( + ["Dendrite", "Pinecone"].includes(testInfo.project.name), + "The configured homeserver has server-side search disabled", + ); + + const roomId = await app.client.createRoom({ name: "EventTile threaded search" }); + await app.client.inviteUser(roomId, bot.credentials!.userId); + await bot.joinRoom(roomId); + + const root = await app.client.sendMessage(roomId, "match root"); + const reply = await bot.sendMessage(roomId, "match threaded reply", root.event_id); + + await app.viewRoomById(roomId); + await app.toggleRoomInfoPanel(); + const search = page.locator(".mx_RoomSummaryCard_search").getByRole("searchbox"); + await search.fill("match"); + await search.press("Enter"); + + const results = page.locator(".mx_RoomView_searchResultsPanel"); + const replyTile = results.locator( + `.mx_EventTile[data-event-id='${reply.event_id}']:not(.mx_EventTile_contextual)`, + ); + await expect(replyTile).toHaveCount(1); + await expect(replyTile.locator(".mx_ThreadSummary_icon")).toBeVisible(); + await expect(replyTile.locator(".mx_ThreadSummary_icon")).toHaveAttribute( + "href", + `#/room/${roomId}/${reply.event_id}`, + ); + + const threadSummaries = results.locator(".mx_ThreadSummary"); + await expect(threadSummaries).toHaveCount(2); + for (const summary of await threadSummaries.all()) { + await expect(summary).toContainText("1 reply"); + } + + await expect(results).toMatchScreenshot("threaded-search-event-tiles.png", { + css: ".mx_MessageTimestamp { visibility: hidden; }", + }); + }, + ); + + test.describe("populated notification panel", () => { + test.use({ labsFlags: ["feature_notifications"] }); + + test( + "renders notification EventTiles as populated group-layout previews", + { tag: "@screenshot" }, + async ({ page, app, bot, user }, testInfo) => { + test.skip( + ["Dendrite", "Pinecone"].includes(testInfo.project.name), + "The configured homeserver does not populate the global notification timeline for this fixture", + ); + + const sourceRoomId = await app.client.createRoom({ + name: "Notification source", + }); + await app.client.inviteUser(sourceRoomId, bot.credentials!.userId); + await bot.joinRoom(sourceRoomId); + const parkingRoomId = await app.client.createRoom({ name: "Notification parking" }); + + await app.viewRoomById(parkingRoomId); + const notificationEvent = await bot.sendMessage(sourceRoomId, { + "msgtype": "m.text", + "body": "Notification event", + "format": "org.matrix.custom.html", + "formatted_body": `Notification event`, + "m.mentions": { + user_ids: [user.userId], + }, + }); + + await expect + .poll(() => + app.client.evaluate( + (client, eventId) => + client + .getNotifTimelineSet() + ?.getLiveTimeline() + .getEvents() + .some((event) => event.getId() === eventId), + notificationEvent.event_id, + ), + ) + .toBe(true); + + await page.getByRole("button", { name: "Notifications" }).click(); + const panel = page.locator(".mx_ThreadPanel"); + const tile = panel.locator(".mx_EventTile", { hasText: "Notification event" }); + await expect(tile).toBeVisible(); + await expect(tile).toHaveAttribute("data-layout", "group"); + await expect(tile).toHaveAttribute("data-self", "false"); + await expect(tile).toHaveClass(/mx_EventTile_clamp/); + await expect(tile.locator(".mx_EventTile_details")).toContainText("Bob"); + await expect(tile).toMatchScreenshot("notification-event-tile.png", { + css: ".mx_MessageTimestamp { visibility: hidden; }", + }); + }, + ); + }); +}); diff --git a/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/event-tile-bubble-linux.png b/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/event-tile-bubble-linux.png new file mode 100644 index 0000000000..f98a361ff5 Binary files /dev/null and b/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/event-tile-bubble-linux.png differ diff --git a/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/event-tile-context-menu-closed-linux.png b/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/event-tile-context-menu-closed-linux.png new file mode 100644 index 0000000000..cce1326791 Binary files /dev/null and b/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/event-tile-context-menu-closed-linux.png differ diff --git a/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/event-tile-context-menu-selected-linux.png b/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/event-tile-context-menu-selected-linux.png new file mode 100644 index 0000000000..bd610a9247 Binary files /dev/null and b/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/event-tile-context-menu-selected-linux.png differ diff --git a/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/event-tile-editing-linux.png b/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/event-tile-editing-linux.png new file mode 100644 index 0000000000..a2925dc50a Binary files /dev/null and b/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/event-tile-editing-linux.png differ diff --git a/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/event-tile-group-compact-linux.png b/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/event-tile-group-compact-linux.png new file mode 100644 index 0000000000..35b7e5e966 Binary files /dev/null and b/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/event-tile-group-compact-linux.png differ diff --git a/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/event-tile-group-linux.png b/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/event-tile-group-linux.png new file mode 100644 index 0000000000..ed77e00e48 Binary files /dev/null and b/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/event-tile-group-linux.png differ diff --git a/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/event-tile-highlighted-linux.png b/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/event-tile-highlighted-linux.png new file mode 100644 index 0000000000..f148296b02 Binary files /dev/null and b/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/event-tile-highlighted-linux.png differ diff --git a/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/event-tile-hovered-linux.png b/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/event-tile-hovered-linux.png new file mode 100644 index 0000000000..1a89391b8b Binary files /dev/null and b/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/event-tile-hovered-linux.png differ diff --git a/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/event-tile-irc-linux.png b/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/event-tile-irc-linux.png new file mode 100644 index 0000000000..8025d67a14 Binary files /dev/null and b/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/event-tile-irc-linux.png differ diff --git a/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/event-tile-permalink-selected-linux.png b/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/event-tile-permalink-selected-linux.png new file mode 100644 index 0000000000..3a38583fb8 Binary files /dev/null and b/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/event-tile-permalink-selected-linux.png differ diff --git a/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/notification-event-tile-linux.png b/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/notification-event-tile-linux.png new file mode 100644 index 0000000000..ad33d3137b Binary files /dev/null and b/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/notification-event-tile-linux.png differ diff --git a/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/search-results-event-tiles-linux.png b/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/search-results-event-tiles-linux.png new file mode 100644 index 0000000000..3321ea2bec Binary files /dev/null and b/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/search-results-event-tiles-linux.png differ diff --git a/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/threaded-search-event-tiles-linux.png b/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/threaded-search-event-tiles-linux.png new file mode 100644 index 0000000000..40f4727a3b Binary files /dev/null and b/apps/web/playwright/snapshots/timeline/event-tile-view.spec.ts/threaded-search-event-tiles-linux.png differ