enso/app/gui2/e2e/customExpect.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

20 lines
661 B
TypeScript
Raw Normal View History

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()
}
export function toBeSelected(locator: Locator) {
return expect(locator).toHaveClass(/(?<=^| )selected(?=$| )/)
}
export module not {
export function toBeSelected(locator: Locator) {
return expect(locator).not.toHaveClass(/(?<=^| )selected(?=$| )/)
}
}