mirror of
https://github.com/vector-im/element-web.git
synced 2026-05-17 18:36:18 +02:00
Add commentary
This commit is contained in:
parent
3a05172cc1
commit
a698261a56
@ -187,9 +187,19 @@ export class ElementAppPage {
|
||||
await this.page.locator(".mx_Dialog").getByRole("button", { name: "Upload" }).click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Drags a "file" into the specified composer and automatically uploads it.
|
||||
* @param location Should the drop target the main room or the thread.
|
||||
* @param path The path to the sample file so it can be read.
|
||||
* @param type The mimetype of the file.
|
||||
*/
|
||||
public async composerDragAndUploadFiles(location: "room" | "thread", path: string, type: string): Promise<void> {
|
||||
// Based on https://github.com/microsoft/playwright/issues/10667#issuecomment-2742123424
|
||||
// This read a file, encodes it into base64 and then sends it along to the page to be treated
|
||||
// as a DataTransfer (the mechanism for drag and dropped files).
|
||||
const buffer = await readFile(path);
|
||||
const name = basename(path);
|
||||
|
||||
const dataTransfer = await this.page.evaluateHandle(
|
||||
async ([buffer, name, type]) => {
|
||||
const dt = new DataTransfer();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user