File size: 1,365 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
import { test, expect } from '@playwright/test'
test.describe('Inlines example', () => {
test.beforeEach(async ({ page }) => {
await page.goto('http://localhost:3000/examples/inlines')
})
test('contains link', async ({ page }) => {
expect(
await page.getByRole('textbox').locator('a').nth(0).innerText()
).toContain('hyperlink')
})
// FIXME: unstable, has issues with selection.anchorNode
test.skip('arrow keys skip over read-only inline', async ({ page }) => {
const badge = page.locator('text=Approved >> xpath=../../..')
// Put cursor after the badge
await badge.evaluate(badgeElement => {
const range = document.createRange()
range.setStartAfter(badgeElement)
range.setEndAfter(badgeElement)
const selection = window.getSelection()!
selection.removeAllRanges()
selection.addRange(range)
})
const getSelectionContainerText = () =>
page.evaluate(() => {
const selection = window.getSelection()!
return selection.anchorNode!.textContent
})
expect(await getSelectionContainerText()).toBe('.')
await page.keyboard.press('ArrowLeft')
expect(await getSelectionContainerText()).toBe(
'! Here is a read-only inline: '
)
await page.keyboard.press('ArrowRight')
expect(await getSelectionContainerText()).toBe('.')
})
})
|