enso/app/gui2/e2e/customExpect.ts
Paweł Grabarz b7a8909818
Vue dependency update, better selection performance, visible quotes in text inputs (#9204)
- Improved performance by batching simulatenous node edits, including metadata updates when dragging many selected nodes together.
- Updated Vue to new version, allowing us to use `defineModel`.
- Fixed #9161
- Unified all handling of auto-blur by making `useAutoBlur` cheap to register - all logic goes through a single window event handler.
- Combined all `ResizeObserver`s into one.
- Fixed the behaviour of repeated toast messages. Now only the latest compilation status is visible at any given time, and the errors disappear once compilation passes.
- Actually fixed broken interaction of node and visualization widths. There no longer is a style feedback loop and the visible node backdrop width no longer jumps or randomly fails to update.
2024-03-06 15:34:07 +00:00

53 lines
1.3 KiB
TypeScript

import { expect as baseExpect, type Locator } from 'playwright/test'
export const expect = baseExpect.extend({
/** Ensures that at least one of the elements that the Locator points to,
* is an attached and visible DOM node. */
async toExist(locator: Locator) {
// Counter-intuitive, but correct:
// https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-be-visible
const assertionName = 'toExist'
let pass: boolean
try {
await expect(locator.first()).toBeVisible()
pass = true
} catch (e: any) {
console.log(e)
pass = false
}
const message = () =>
this.utils.matcherHint(assertionName, locator, '', {
isNot: this.isNot,
})
return {
message,
pass,
name: assertionName,
}
},
async toBeSelected(locator: Locator) {
const assertionName = 'toBeSelected'
let pass: boolean
try {
await baseExpect(locator).toHaveClass(/(?<=^| )selected(?=$| )/, { timeout: 50 })
pass = true
} catch (e: any) {
pass = false
}
const message = () =>
this.utils.matcherHint(assertionName, locator, '', {
isNot: this.isNot,
})
return {
message,
pass,
name: assertionName,
}
},
})