re-use test helper in other files

This commit is contained in:
Valere
2026-01-15 11:50:37 +01:00
parent 0d1488af4c
commit 243f369a24
2 changed files with 9 additions and 28 deletions

View File

@@ -36,15 +36,7 @@ widgetTest("Create and join a group call", async ({ addUser, browserName }) => {
// Accept the invite
// This isn't super stable to get this as this super generic locator,
// but it works for now.
await expect(
user.page.getByRole("option", { name: roomName }),
).toBeVisible();
await user.page.getByRole("option", { name: roomName }).click();
await user.page.getByRole("button", { name: "Accept" }).click();
await expect(
user.page.getByRole("main").getByRole("heading", { name: roomName }),
).toBeVisible();
await TestHelpers.acceptRoomInvite(roomName, user.page);
}
// Start the call as Valere
@@ -53,24 +45,10 @@ widgetTest("Create and join a group call", async ({ addUser, browserName }) => {
valere.page.locator('iframe[title="Element Call"]'),
).toBeVisible();
await expect(
valere.page
.locator('iframe[title="Element Call"]')
.contentFrame()
.getByTestId("lobby_joinCall"),
).toBeVisible();
await valere.page
.locator('iframe[title="Element Call"]')
.contentFrame()
.getByTestId("lobby_joinCall")
.click();
await TestHelpers.joinCallFromLobby(valere.page);
for (const user of [timo, robin, halfshot, florian]) {
// THis is the header button that notifies about an ongoing call
await expect(user.page.getByText("Video call started")).toBeVisible();
await expect(user.page.getByRole("button", { name: "Join" })).toBeVisible();
await user.page.getByRole("button", { name: "Join" }).click();
await TestHelpers.joinCallInCurrentRoom(user.page);
}
for (const user of [timo, robin, halfshot, florian]) {
@@ -155,6 +133,4 @@ widgetTest("Create and join a group call", async ({ addUser, browserName }) => {
// this kind of stuff way easier to test if we could look out for aria attributes.
expect(blockDisplayCount).toBe(4);
}
await valere.page.pause();
});

View File

@@ -53,6 +53,7 @@ export class TestHelpers {
page: Page,
audioOnly: boolean = false,
): Promise<void> {
// This is the header button that notifies about an ongoing call
const label = audioOnly ? "Voice call started" : "Video call started";
await expect(page.getByText(label)).toBeVisible();
await expect(page.getByRole("button", { name: "Join" })).toBeVisible();
@@ -128,7 +129,6 @@ export class TestHelpers {
page: Page,
andInvite: string[] = [],
): Promise<void> {
await page.pause();
await page
.getByRole("navigation", { name: "Room list" })
.getByRole("button", { name: "New conversation" })
@@ -157,6 +157,11 @@ export class TestHelpers {
}
}
/**
* Accepts a room invite using the room name.
* Locatest the invite in the room list.
*
*/
public static async acceptRoomInvite(
roomName: string,
page: Page,