Playwright tests for file uploads (#33319)

* Refactor tests to use helper method for composer uploads.

* Add drag and drop tests

* lint

* Add commentary

* fixup test

* More precise selector
This commit is contained in:
Will Hunt
2026-04-30 12:49:27 +00:00
committed by GitHub
parent b0ee6f5323
commit af20018ea2
5 changed files with 148 additions and 46 deletions
@@ -9,6 +9,7 @@ import { SettingLevel } from "../../../src/settings/SettingLevel";
import { Layout } from "../../../src/settings/enums/Layout";
import { test, expect } from "../../element-web-test";
import { isDendrite } from "../../plugins/homeserver/dendrite";
import { getSampleFilePath } from "../../sample-files";
test.describe("Threads", () => {
test.skip(isDendrite, "due to a Dendrite bug https://github.com/element-hq/dendrite/issues/3489");
@@ -360,6 +361,50 @@ test.describe("Threads", () => {
await app.getComposer(true).getByRole("button", { name: "Send voice message" }).click();
await expect(page.locator(".mx_ThreadView .mx_MVoiceMessageBody")).toHaveCount(1);
});
test("can send files", async ({ page, app, user }) => {
// Increase right-panel size, so that files fit
await page.evaluate(() => {
window.localStorage.setItem("mx_rhs_size", "600");
});
const roomId = await app.client.createRoom({});
await page.goto("/#/room/" + roomId);
// Send message
const locator = page.locator(".mx_RoomView_body");
await locator.getByRole("textbox", { name: "Send an unencrypted message…" }).fill("Hello Mr. Bot");
await locator.getByRole("textbox", { name: "Send an unencrypted message…" }).press("Enter");
// Create thread
const locator2 = locator.locator(".mx_EventTile[data-scroll-tokens]").filter({ hasText: "Hello Mr. Bot" });
await locator2.hover();
await locator2.getByRole("button", { name: "Reply in thread" }).click();
await expect(page.locator(".mx_ThreadView_timelinePanelWrapper")).toHaveCount(1);
await app.composerUploadFiles("thread", getSampleFilePath("riot.png"));
await expect(page.locator(".mx_ThreadView .mx_EventTile_image")).toHaveCount(1);
});
test("can send files via drag&drop", async ({ page, app, user }) => {
// Increase right-panel size, so that files fit
await page.evaluate(() => {
window.localStorage.setItem("mx_rhs_size", "600");
});
const roomId = await app.client.createRoom({});
await page.goto("/#/room/" + roomId);
// Send message
const locator = page.locator(".mx_RoomView_body");
await locator.getByRole("textbox", { name: "Send an unencrypted message…" }).fill("Hello Mr. Bot");
await locator.getByRole("textbox", { name: "Send an unencrypted message…" }).press("Enter");
// Create thread
const locator2 = locator.locator(".mx_EventTile[data-scroll-tokens]").filter({ hasText: "Hello Mr. Bot" });
await locator2.hover();
await locator2.getByRole("button", { name: "Reply in thread" }).click();
await expect(page.locator(".mx_ThreadView_timelinePanelWrapper")).toHaveCount(1);
await app.composerDragAndUploadFiles("thread", getSampleFilePath("riot.png"), "image/png");
await expect(page.locator(".mx_ThreadView .mx_EventTile_image")).toHaveCount(1);
});
});
test(