Files
element-call/playwright/widget/huddle-call.test.ts
T

130 lines
4.0 KiB
TypeScript
Raw Normal View History

/*
Copyright 2026 Element Creations Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details.
*/
import { expect, test } from "@playwright/test";
import { widgetTest } from "../fixtures/widget-user.ts";
2026-04-22 09:03:57 +02:00
import { HOST1, TestHelpers } from "./test-helpers.ts";
widgetTest("Create and join a group call", async ({ addUser, browserName }) => {
2026-04-21 18:14:51 +02:00
// increase the timeouts, it is a long test and it is annoying to retry from the beginning for a single timeout.
test.slow();
test.skip(
browserName === "firefox",
"The is test is not working on firefox CI environment. No mic/audio device inputs so cam/mic are disabled",
);
2026-04-21 18:36:40 +02:00
const [valere, timo, robin, halfshot, florian] = await Promise.all([
addUser("Valere", HOST1),
addUser("Timo", HOST1),
addUser("Robin", HOST1),
addUser("Halfshot", HOST1),
addUser("florian", HOST1),
]);
const roomName = "Group Call Room";
await TestHelpers.createRoom(roomName, valere.page, [
timo.mxId,
robin.mxId,
halfshot.mxId,
florian.mxId,
]);
for (const user of [timo, robin, halfshot, florian]) {
// Accept the invite
2026-01-14 12:15:00 +01:00
// This isn't super stable to get this as this super generic locator,
// but it works for now.
2026-01-15 11:50:37 +01:00
await TestHelpers.acceptRoomInvite(roomName, user.page);
}
// Start the call as Valere
await TestHelpers.startCallInCurrentRoom(valere.page, false);
await expect(
valere.page.locator('iframe[title="Element Call"]'),
).toBeVisible();
2026-01-15 11:50:37 +01:00
await TestHelpers.joinCallFromLobby(valere.page);
2026-04-22 09:03:57 +02:00
await Promise.all(
[timo, robin, halfshot, florian].map(async (user) => {
await TestHelpers.joinCallInCurrentRoom(user.page);
}),
);
2026-04-22 09:03:57 +02:00
await Promise.all(
[timo, robin, halfshot, florian].map(async (user) => {
const frame = user.page
.locator('iframe[title="Element Call"]')
.contentFrame();
await expect(
frame.getByRole("switch", { name: "Stop video", checked: true }),
2026-04-22 17:25:14 +02:00
).toBeVisible({
timeout: 10000,
});
2026-04-22 09:03:57 +02:00
}),
);
// We should see 5 video tiles everywhere now
2026-04-22 09:03:57 +02:00
await Promise.all(
[valere, timo, robin, halfshot, florian].map(async (user) => {
const frame = user.page
.locator('iframe[title="Element Call"]')
.contentFrame();
await expect(frame.getByTestId("videoTile")).toHaveCount(5, {
2026-04-22 19:30:02 +02:00
timeout: 15000,
});
2026-04-24 11:21:14 +02:00
2026-04-24 11:29:34 +02:00
await Promise.all(
2026-04-24 11:21:14 +02:00
[valere, timo, robin, halfshot, florian].map(async (user) => {
// Check the names are correct
2026-04-24 11:29:34 +02:00
await expect(frame.getByText(user.displayName)).toBeVisible();
2026-04-24 11:21:14 +02:00
}),
2026-04-24 11:29:34 +02:00
);
2026-04-22 09:03:57 +02:00
// No one should be waiting for media
await expect(frame.getByText("Waiting for media...")).not.toBeVisible({
// Use a bigger timeout here
timeout: 10000,
});
// There should be 5 video elements, visible and autoplaying
await expect(frame.locator("video")).toHaveCount(5);
await expect(frame.locator("video[autoplay]")).toHaveCount(5);
await TestHelpers.expectVisibleVideoCount(frame, 5);
2026-04-22 09:03:57 +02:00
}),
);
// Quickly test muting one participant to see it reflects and that our asserts works
const florianFrame = florian.page
.locator('iframe[title="Element Call"]')
.contentFrame();
const florianVideoButton = florianFrame.getByRole("switch", {
name: /video/,
});
await expect(florianVideoButton).toHaveAccessibleName("Stop video");
await expect(florianVideoButton).toBeChecked();
await florianVideoButton.click();
// Now the button should indicate we can start video
await expect(florianVideoButton).toHaveAccessibleName("Start video");
await expect(florianVideoButton).not.toBeChecked();
{
const frame = valere.page
.locator('iframe[title="Element Call"]')
.contentFrame();
2026-04-22 09:03:57 +02:00
await expect(frame.locator("video")).toHaveCount(5, {
timeout: 10000,
});
2026-01-14 12:15:00 +01:00
// out of 5 ONLY 4 are visible (display:block) !!
await TestHelpers.expectVisibleVideoCount(frame, 4);
}
});