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 // Accept the invite
// This isn't super stable to get this as this super generic locator, // This isn't super stable to get this as this super generic locator,
// but it works for now. // but it works for now.
await expect( await TestHelpers.acceptRoomInvite(roomName, user.page);
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();
} }
// Start the call as Valere // 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"]'), valere.page.locator('iframe[title="Element Call"]'),
).toBeVisible(); ).toBeVisible();
await expect( await TestHelpers.joinCallFromLobby(valere.page);
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();
for (const user of [timo, robin, halfshot, florian]) { for (const user of [timo, robin, halfshot, florian]) {
// THis is the header button that notifies about an ongoing call await TestHelpers.joinCallInCurrentRoom(user.page);
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();
} }
for (const user of [timo, robin, halfshot, florian]) { 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. // this kind of stuff way easier to test if we could look out for aria attributes.
expect(blockDisplayCount).toBe(4); expect(blockDisplayCount).toBe(4);
} }
await valere.page.pause();
}); });

View File

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