Make viewRoomByName dismiss toasts on each retry (#33542)
Otherwise it can just race, as per comment
This commit is contained in:
@@ -100,15 +100,31 @@ export class ElementAppPage {
|
|||||||
// otherwise we may race with page loading
|
// otherwise we may race with page loading
|
||||||
await this.page.getByTestId("room-list").waitFor();
|
await this.page.getByTestId("room-list").waitFor();
|
||||||
|
|
||||||
await rejectToastIfExists(this.page, "Verify this device", { timeout: 50 });
|
const dismissToasts = async (): Promise<void> => {
|
||||||
const keyStorageToastRejected = await rejectToastIfExists(this.page, "Turn on key storage", { timeout: 50 });
|
await rejectToastIfExists(this.page, "Verify this device", { timeout: 50 });
|
||||||
if (keyStorageToastRejected) {
|
const keyStorageToastRejected = await rejectToastIfExists(this.page, "Turn on key storage", {
|
||||||
await this.page.getByRole("button", { name: "Yes, dismiss" }).click();
|
timeout: 50,
|
||||||
}
|
});
|
||||||
await rejectToastIfExists(this.page, "Notifications", { timeout: 50 });
|
if (keyStorageToastRejected) {
|
||||||
|
await this.page.getByRole("button", { name: "Yes, dismiss" }).click();
|
||||||
|
}
|
||||||
|
await rejectToastIfExists(this.page, "Notifications", { timeout: 50 });
|
||||||
|
};
|
||||||
|
|
||||||
// We get the room list by test-id which is a listbox and matching title=name
|
await dismissToasts();
|
||||||
return this.page.getByTestId("room-list").locator(`[title="${name}"]`).first().click();
|
|
||||||
|
// We get the room list by test-id which is a listbox and matching title=name.
|
||||||
|
// Retry, closing toasts each time, as otherwise it can race and the toast can appear after we try to close them
|
||||||
|
const roomTile = this.page.getByTestId("room-list").locator(`[title="${name}"]`).first();
|
||||||
|
for (let attemptsLeft = 10; attemptsLeft > 0; attemptsLeft--) {
|
||||||
|
try {
|
||||||
|
await roomTile.click({ timeout: 500 });
|
||||||
|
return;
|
||||||
|
} catch (e) {
|
||||||
|
if (attemptsLeft === 1) throw e;
|
||||||
|
await dismissToasts();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user