1
0
mirror of https://github.com/element-hq/element-web.git synced 2025-08-06 16:22:46 +03:00

Fix playwright flakes due to floating promises (#28981)

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski
2025-01-13 17:29:22 +00:00
committed by GitHub
parent 2cddb16a9f
commit 1a21b718d8
16 changed files with 22 additions and 21 deletions

View File

@@ -271,6 +271,7 @@ module.exports = {
}, },
rules: { rules: {
"react-hooks/rules-of-hooks": ["off"], "react-hooks/rules-of-hooks": ["off"],
"@typescript-eslint/no-floating-promises": ["error"],
}, },
}, },
{ {

View File

@@ -123,7 +123,7 @@ test.describe("Landmark navigation tests", () => {
await expect(page.getByText("Bob joined the room")).toBeVisible(); await expect(page.getByText("Bob joined the room")).toBeVisible();
// Close the room // Close the room
page.goto("/#/home"); await page.goto("/#/home");
// Pressing Control+F6 will first focus the space button // Pressing Control+F6 will first focus the space button
await page.keyboard.press("ControlOrMeta+F6"); await page.keyboard.press("ControlOrMeta+F6");

View File

@@ -95,7 +95,7 @@ test.describe("HTML Export", () => {
async ({ page, app, room }) => { async ({ page, app, room }) => {
// Set a fixed time rather than masking off the line with the time in it: we don't need to worry // Set a fixed time rather than masking off the line with the time in it: we don't need to worry
// about the width changing and we can actually test this line looks correct. // about the width changing and we can actually test this line looks correct.
page.clock.setSystemTime(new Date("2024-01-01T00:00:00Z")); await page.clock.setSystemTime(new Date("2024-01-01T00:00:00Z"));
// Send a bunch of messages to populate the room // Send a bunch of messages to populate the room
for (let i = 1; i < 10; i++) { for (let i = 1; i < 10; i++) {

View File

@@ -165,7 +165,7 @@ test.describe("Composer", () => {
// Type another // Type another
await page.locator("div[contenteditable=true]").pressSequentially("my message 1"); await page.locator("div[contenteditable=true]").pressSequentially("my message 1");
// Send message // Send message
page.locator("div[contenteditable=true]").press("Enter"); await page.locator("div[contenteditable=true]").press("Enter");
// It was sent // It was sent
await expect(page.locator(".mx_EventTile_last .mx_EventTile_body").getByText("my message 1")).toBeVisible(); await expect(page.locator(".mx_EventTile_last .mx_EventTile_body").getByText("my message 1")).toBeVisible();
}); });

View File

@@ -212,7 +212,7 @@ test.describe("Device verification", { tag: "@no-webkit" }, () => {
/* on the bot side, wait for the verifier to exist ... */ /* on the bot side, wait for the verifier to exist ... */
const verifier = await awaitVerifier(botVerificationRequest); const verifier = await awaitVerifier(botVerificationRequest);
// ... confirm ... // ... confirm ...
botVerificationRequest.evaluate((verificationRequest) => verificationRequest.verifier.verify()); void botVerificationRequest.evaluate((verificationRequest) => verificationRequest.verifier.verify());
// ... and then check the emoji match // ... and then check the emoji match
await doTwoWaySasVerification(page, verifier); await doTwoWaySasVerification(page, verifier);

View File

@@ -74,7 +74,7 @@ test.describe("User verification", () => {
/* on the bot side, wait for the verifier to exist ... */ /* on the bot side, wait for the verifier to exist ... */
const botVerifier = await awaitVerifier(bobVerificationRequest); const botVerifier = await awaitVerifier(bobVerificationRequest);
// ... confirm ... // ... confirm ...
botVerifier.evaluate((verifier) => verifier.verify()); void botVerifier.evaluate((verifier) => verifier.verify());
// ... and then check the emoji match // ... and then check the emoji match
await doTwoWaySasVerification(page, botVerifier); await doTwoWaySasVerification(page, botVerifier);

View File

@@ -59,7 +59,7 @@ export function handleSasVerification(verifier: JSHandle<Verifier>): Promise<Emo
return new Promise<EmojiMapping[]>((resolve) => { return new Promise<EmojiMapping[]>((resolve) => {
const onShowSas = (event: ShowSasCallbacks) => { const onShowSas = (event: ShowSasCallbacks) => {
verifier.off("show_sas" as VerifierEvent, onShowSas); verifier.off("show_sas" as VerifierEvent, onShowSas);
event.confirm(); void event.confirm();
resolve(event.sas.emoji); resolve(event.sas.emoji);
}; };
@@ -313,7 +313,7 @@ export async function autoJoin(client: Client) {
await client.evaluate((cli) => { await client.evaluate((cli) => {
cli.on(window.matrixcs.RoomMemberEvent.Membership, (event, member) => { cli.on(window.matrixcs.RoomMemberEvent.Membership, (event, member) => {
if (member.membership === "invite" && member.userId === cli.getUserId()) { if (member.membership === "invite" && member.userId === cli.getUserId()) {
cli.joinRoom(member.roomId); void cli.joinRoom(member.roomId);
} }
}); });
}); });

View File

@@ -50,7 +50,7 @@ test.describe("Manage Knocks", () => {
}); });
test("should deny knock using bar", async ({ page, app, bot, room }) => { test("should deny knock using bar", async ({ page, app, bot, room }) => {
bot.knockRoom(room.roomId); await bot.knockRoom(room.roomId);
const roomKnocksBar = page.locator(".mx_RoomKnocksBar"); const roomKnocksBar = page.locator(".mx_RoomKnocksBar");
await expect(roomKnocksBar.getByRole("heading", { name: "Asking to join" })).toBeVisible(); await expect(roomKnocksBar.getByRole("heading", { name: "Asking to join" })).toBeVisible();

View File

@@ -92,7 +92,7 @@ export async function interceptRequestsWithSoftLogout(page: Page, user: Credenti
// do something to make the active /sync return: create a new room // do something to make the active /sync return: create a new room
await page.evaluate(() => { await page.evaluate(() => {
// don't wait for this to complete: it probably won't, because of the broken sync // don't wait for this to complete: it probably won't, because of the broken sync
window.mxMatrixClientPeg.get().createRoom({}); void window.mxMatrixClientPeg.get().createRoom({});
}); });
await promise; await promise;

View File

@@ -134,7 +134,7 @@ test.describe("Poll history", () => {
await expect(dialog.getByText(pollParams2.title)).toBeAttached(); await expect(dialog.getByText(pollParams2.title)).toBeAttached();
await expect(dialog.getByText(pollParams1.title)).toBeAttached(); await expect(dialog.getByText(pollParams1.title)).toBeAttached();
dialog.getByText("Active polls").click(); await dialog.getByText("Active polls").click();
// no more active polls // no more active polls
await expect(page.getByText("There are no active polls in this room")).toBeAttached(); await expect(page.getByText("There are no active polls in this room")).toBeAttached();

View File

@@ -48,6 +48,6 @@ test.describe("Mark as Unread", () => {
await roomTile.getByRole("button", { name: "Room options" }).click(); await roomTile.getByRole("button", { name: "Room options" }).click();
await page.getByRole("menuitem", { name: "Mark as unread" }).click(); await page.getByRole("menuitem", { name: "Mark as unread" }).click();
expect(page.getByLabel(TEST_ROOM_NAME + " Unread messages.")).toBeVisible(); await expect(page.getByLabel(TEST_ROOM_NAME + " Unread messages.")).toBeVisible();
}); });
}); });

View File

@@ -34,14 +34,14 @@ test.describe("Account user settings tab", () => {
await expect(profile.getByRole("textbox", { name: "Display Name" })).toHaveValue(USER_NAME); await expect(profile.getByRole("textbox", { name: "Display Name" })).toHaveValue(USER_NAME);
// Assert that a userId is rendered // Assert that a userId is rendered
expect(uut.getByLabel("Username")).toHaveText(user.userId); await expect(uut.getByLabel("Username")).toHaveText(user.userId);
// Wait until spinners disappear // Wait until spinners disappear
await expect(uut.getByTestId("accountSection").locator(".mx_Spinner")).not.toBeVisible(); await expect(uut.getByTestId("accountSection").locator(".mx_Spinner")).not.toBeVisible();
await expect(uut.getByTestId("discoverySection").locator(".mx_Spinner")).not.toBeVisible(); await expect(uut.getByTestId("discoverySection").locator(".mx_Spinner")).not.toBeVisible();
const accountSection = uut.getByTestId("accountSection"); const accountSection = uut.getByTestId("accountSection");
accountSection.scrollIntoViewIfNeeded(); await accountSection.scrollIntoViewIfNeeded();
// Assert that input areas for changing a password exists // Assert that input areas for changing a password exists
await expect(accountSection.getByLabel("Current password")).toBeVisible(); await expect(accountSection.getByLabel("Current password")).toBeVisible();
await expect(accountSection.getByLabel("New Password")).toBeVisible(); await expect(accountSection.getByLabel("New Password")).toBeVisible();

View File

@@ -24,7 +24,7 @@ test.describe("Preferences user settings tab", () => {
}); });
test("should be rendered properly", { tag: "@screenshot" }, async ({ app, page, user }) => { test("should be rendered properly", { tag: "@screenshot" }, async ({ app, page, user }) => {
page.setViewportSize({ width: 1024, height: 3300 }); await page.setViewportSize({ width: 1024, height: 3300 });
const tab = await app.settings.openUserSettings("Preferences"); const tab = await app.settings.openUserSettings("Preferences");
// Assert that the top heading is rendered // Assert that the top heading is rendered
await expect(tab.getByRole("heading", { name: "Preferences" })).toBeVisible(); await expect(tab.getByRole("heading", { name: "Preferences" })).toBeVisible();
@@ -61,7 +61,7 @@ test.describe("Preferences user settings tab", () => {
// Click the button to display the dropdown menu // Click the button to display the dropdown menu
await timezoneInput.getByRole("button", { name: "Set timezone" }).click(); await timezoneInput.getByRole("button", { name: "Set timezone" }).click();
// Select a different value // Select a different value
timezoneInput.getByRole("option", { name: /Africa\/Abidjan/ }).click(); await timezoneInput.getByRole("option", { name: /Africa\/Abidjan/ }).click();
// Check the new value // Check the new value
await expect(timezoneValue.getByText("Africa/Abidjan")).toBeVisible(); await expect(timezoneValue.getByText("Africa/Abidjan")).toBeVisible();
}); });

View File

@@ -275,7 +275,7 @@ test.describe("Sliding Sync", () => {
// now rescind the invite // now rescind the invite
await bot.evaluate( await bot.evaluate(
async (client, { roomRescind, clientUserId }) => { async (client, { roomRescind, clientUserId }) => {
client.kick(roomRescind, clientUserId); await client.kick(roomRescind, clientUserId);
}, },
{ roomRescind, clientUserId }, { roomRescind, clientUserId },
); );
@@ -294,7 +294,7 @@ test.describe("Sliding Sync", () => {
is_direct: true, is_direct: true,
}); });
await app.client.evaluate(async (client, roomId) => { await app.client.evaluate(async (client, roomId) => {
client.setRoomTag(roomId, "m.favourite", { order: 0.5 }); await client.setRoomTag(roomId, "m.favourite", { order: 0.5 });
}, roomId); }, roomId);
await expect(page.getByRole("group", { name: "Favourites" }).getByText("Favourite DM")).toBeVisible(); await expect(page.getByRole("group", { name: "Favourites" }).getByText("Favourite DM")).toBeVisible();
await expect(page.getByRole("group", { name: "People" }).getByText("Favourite DM")).not.toBeAttached(); await expect(page.getByRole("group", { name: "People" }).getByText("Favourite DM")).not.toBeAttached();

View File

@@ -150,7 +150,7 @@ test.describe("Stickers", { tag: ["@no-firefox", "@no-webkit"] }, () => {
const { content_uri: contentUri } = await app.client.uploadContent(STICKER_IMAGE, { type: "image/png" }); const { content_uri: contentUri } = await app.client.uploadContent(STICKER_IMAGE, { type: "image/png" });
const widgetHtml = getWidgetHtml(contentUri, "image/png"); const widgetHtml = getWidgetHtml(contentUri, "image/png");
stickerPickerUrl = webserver.start(widgetHtml); stickerPickerUrl = webserver.start(widgetHtml);
setWidgetAccountData(app, user, stickerPickerUrl); await setWidgetAccountData(app, user, stickerPickerUrl);
await app.viewRoomByName(ROOM_NAME_1); await app.viewRoomByName(ROOM_NAME_1);
await expect(page).toHaveURL(`/#/room/${room.roomId}`); await expect(page).toHaveURL(`/#/room/${room.roomId}`);
@@ -177,7 +177,7 @@ test.describe("Stickers", { tag: ["@no-firefox", "@no-webkit"] }, () => {
const { content_uri: contentUri } = await app.client.uploadContent(STICKER_IMAGE, { type: "image/png" }); const { content_uri: contentUri } = await app.client.uploadContent(STICKER_IMAGE, { type: "image/png" });
const widgetHtml = getWidgetHtml(contentUri, "image/png"); const widgetHtml = getWidgetHtml(contentUri, "image/png");
stickerPickerUrl = webserver.start(widgetHtml); stickerPickerUrl = webserver.start(widgetHtml);
setWidgetAccountData(app, user, stickerPickerUrl, false); await setWidgetAccountData(app, user, stickerPickerUrl, false);
await app.viewRoomByName(ROOM_NAME_1); await app.viewRoomByName(ROOM_NAME_1);
await expect(page).toHaveURL(`/#/room/${room.roomId}`); await expect(page).toHaveURL(`/#/room/${room.roomId}`);
@@ -192,7 +192,7 @@ test.describe("Stickers", { tag: ["@no-firefox", "@no-webkit"] }, () => {
}); });
const widgetHtml = getWidgetHtml(contentUri, "application/octet-stream"); const widgetHtml = getWidgetHtml(contentUri, "application/octet-stream");
stickerPickerUrl = webserver.start(widgetHtml); stickerPickerUrl = webserver.start(widgetHtml);
setWidgetAccountData(app, user, stickerPickerUrl); await setWidgetAccountData(app, user, stickerPickerUrl);
await app.viewRoomByName(ROOM_NAME_1); await app.viewRoomByName(ROOM_NAME_1);
await expect(page).toHaveURL(`/#/room/${room.roomId}`); await expect(page).toHaveURL(`/#/room/${room.roomId}`);

View File

@@ -171,7 +171,7 @@ export class Bot extends Client {
if (opts.autoAcceptInvites) { if (opts.autoAcceptInvites) {
cli.on(window.matrixcs.RoomMemberEvent.Membership, (event, member) => { cli.on(window.matrixcs.RoomMemberEvent.Membership, (event, member) => {
if (member.membership === "invite" && member.userId === cli.getUserId()) { if (member.membership === "invite" && member.userId === cli.getUserId()) {
cli.joinRoom(member.roomId); void cli.joinRoom(member.roomId);
} }
}); });
} }