Files
documenso/packages/app-tests/e2e/fixtures/generic.ts
T
2026-05-08 16:04:22 +10:00

30 lines
1.0 KiB
TypeScript

import type { Locator } from '@playwright/test';
import { expect, type Page } from '@playwright/test';
export const expectTextToBeVisible = async (page: Page, text: string) => {
await expect(page.getByText(text).first()).toBeVisible();
};
export const expectTextToNotBeVisible = async (page: Page, text: string) => {
await expect(page.getByText(text).first()).not.toBeVisible();
};
export const expectToastTextToBeVisible = async (page: Page, text: string) => {
await expect(page.locator('[role="status"]').getByText(text)).toBeVisible();
};
export const openDropdownMenu = async (page: Page, dropdownButton: Locator) => {
await page.waitForTimeout(500); // Initial timeout incase table remounts which will close the dropdown.
await dropdownButton.focus();
await page.keyboard.press('Enter');
await page.waitForTimeout(500);
await page.keyboard.press('Escape');
await page.waitForTimeout(500);
await dropdownButton.focus();
await page.keyboard.press('Enter');
await expect(page.getByRole('menuitem').first()).toBeVisible();
};