mirror of
https://github.com/enso-org/enso.git
synced 2024-12-23 04:21:54 +03:00
736134e491
Fixes #11604 Most issues were caused by a problem with Project List flooding the network with its requests - this was fixed on develop. But one assertion was flaky - it assumed we will see the "real" run result on `write` node, but sometimes it is immediately overwritten by dry run. But the most important part of this PR is adding traces to Electron packages - it's should be much easier now to debug E2E test failures. Also renamed the previously misnamed "E2E tests" to "[GUI] integration tests".
27 lines
1.1 KiB
TypeScript
27 lines
1.1 KiB
TypeScript
import type { ElementHandle } from 'playwright'
|
|
|
|
/**
|
|
* Returns text content of the element, including CSS ::before and ::after content in the element's tree.
|
|
* Currently whitespace produced around pseudo-elements is unspecified; block/inline logic is not implemented.
|
|
*/
|
|
export function computedContent(element: ElementHandle<HTMLElement | SVGElement>): Promise<string> {
|
|
return element.evaluate<string>((element) => {
|
|
const getPseudoElement = (element: HTMLElement | SVGElement, pseudo: string) => {
|
|
const value = window.getComputedStyle(element, `::${pseudo}`).getPropertyValue('content')
|
|
if (value.match(/['"]/)) return value.replace(/['"]/g, '')
|
|
}
|
|
const recurse = (element: HTMLElement | SVGElement): string => {
|
|
return [
|
|
getPseudoElement(element, 'before') ?? '',
|
|
...Array.from(element.childNodes, (child) =>
|
|
child instanceof HTMLElement || child instanceof SVGElement ?
|
|
recurse(child)
|
|
: child.textContent,
|
|
),
|
|
getPseudoElement(element, 'after') ?? '',
|
|
].join('')
|
|
}
|
|
return recurse(element)
|
|
})
|
|
}
|