1
0
mirror of https://github.com/element-hq/element-web.git synced 2025-07-30 08:43:13 +03:00
Files
element-web/playwright/pages/toasts.ts
renovate[bot] 4a381c2a10 Update all non-major dependencies (#29194)
* Update all non-major dependencies

* Delint

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Iterate

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Prettier

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

---------

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
2025-02-05 13:25:06 +00:00

53 lines
1.8 KiB
TypeScript

/*
Copyright 2024 New Vector Ltd.
Copyright 2023 The Matrix.org Foundation C.I.C.
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/
import { type Page, expect, type Locator } from "@playwright/test";
export class Toasts {
public constructor(private readonly page: Page) {}
/**
* Assert that a toast with the given title exists, and return it
*
* @param expectedTitle - Expected title of the toast
* @returns the Locator for the matching toast
*/
public async getToast(expectedTitle: string): Promise<Locator> {
const toast = this.page.locator(".mx_Toast_toast", { hasText: expectedTitle }).first();
await expect(toast).toBeVisible();
return toast;
}
/**
* Assert that no toasts exist
*/
public async assertNoToasts(): Promise<void> {
await expect(this.page.locator(".mx_Toast_toast")).not.toBeVisible();
}
/**
* Accept a toast with the given title, only works for the first toast in the stack
*
* @param expectedTitle - Expected title of the toast
*/
public async acceptToast(expectedTitle: string): Promise<void> {
const toast = await this.getToast(expectedTitle);
await toast.locator('.mx_Toast_buttons button[data-kind="primary"]').click();
}
/**
* Reject a toast with the given title, only works for the first toast in the stack
*
* @param expectedTitle - Expected title of the toast
*/
public async rejectToast(expectedTitle: string): Promise<void> {
const toast = await this.getToast(expectedTitle);
await toast.locator('.mx_Toast_buttons button[data-kind="secondary"]').click();
}
}