2023-11-27 18:48:37 +03:00
|
|
|
import { expect, type Locator } from 'playwright/test'
|
|
|
|
|
|
|
|
/** Ensures that at least one of the elements that the Locator points to,
|
|
|
|
* is an attached and visible DOM node. */
|
|
|
|
export function toExist(locator: Locator) {
|
|
|
|
// Counter-intuitive, but correct:
|
|
|
|
// https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-be-visible
|
|
|
|
return expect(locator.first()).toBeVisible()
|
|
|
|
}
|
2024-02-02 20:11:28 +03:00
|
|
|
|
|
|
|
export function toBeSelected(locator: Locator) {
|
|
|
|
return expect(locator).toHaveClass(/(?<=^| )selected(?=$| )/)
|
|
|
|
}
|
2024-02-28 16:14:48 +03:00
|
|
|
|
|
|
|
export module not {
|
|
|
|
export function toBeSelected(locator: Locator) {
|
|
|
|
return expect(locator).not.toHaveClass(/(?<=^| )selected(?=$| )/)
|
|
|
|
}
|
|
|
|
}
|