Playwright test for history sharing on invite (#30948)
* Playwright: `getCurrentRoomIdFromUrl` Helper function to fish a room ID out of the URL * Playwright: use updated `Credentials` class from common lib Pick up the extended `Credentials` interface that was added in https://github.com/element-hq/element-modules/pull/80. * Playwright: use `routeConfigJson` from common lib https://github.com/element-hq/element-modules/pull/81 added a utility function for building and routing `config.json`; we should use it. * Playwright test for history sharing on invite Fixes https://github.com/element-hq/element-meta/issues/2920 * Avoid use of CSS in playwright locators
This commit is contained in:
@@ -69,6 +69,20 @@ export class ElementAppPage {
|
||||
return await this.page.evaluate(() => navigator.clipboard.readText());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the room ID from the current URL.
|
||||
*
|
||||
* @returns The room ID.
|
||||
* @throws if the current URL does not contain a room ID.
|
||||
*/
|
||||
public async getCurrentRoomIdFromUrl(): Promise<string> {
|
||||
const urlHash = await this.page.evaluate(() => window.location.hash);
|
||||
if (!urlHash.startsWith("#/room/")) {
|
||||
throw new Error("URL hash suggests we are not in a room");
|
||||
}
|
||||
return urlHash.replace("#/room/", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the given room by name. The room must be visible in the
|
||||
* room list and the room may contain unread messages.
|
||||
@@ -197,6 +211,21 @@ export class ElementAppPage {
|
||||
return memberlist;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the room info panel, and use it to send an invite to the given user.
|
||||
*
|
||||
* @param userId - The user to invite to the room.
|
||||
*/
|
||||
public async inviteUserToCurrentRoom(userId: string): Promise<void> {
|
||||
await this.toggleRoomInfoPanel(); // TODO skip this if the room info panel is already open
|
||||
await this.page.getByLabel("Right panel").getByRole("menuitem", { name: "Invite" }).click();
|
||||
|
||||
const input = this.page.getByRole("dialog").getByTestId("invite-dialog-input");
|
||||
await input.fill(userId);
|
||||
await input.press("Enter");
|
||||
await this.page.getByRole("dialog").getByRole("button", { name: "Invite" }).click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a locator for the tooltip associated with an element
|
||||
* @param e The element with the tooltip
|
||||
|
||||
Reference in New Issue
Block a user