Skip to content

Commit

Permalink
added a test for appending text content
Browse files Browse the repository at this point in the history
  • Loading branch information
redstar504 committed Jun 4, 2024
1 parent 59de0d9 commit 1c8ca31
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/e2e/anchor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,28 @@ test('typing links into the editor', async ({page}) => {
})

test('appending to URL when text content is not URL content', async ({page}) => {
await page.goto(`http://localhost:${E2E_PORT}/lexical-anchorpoint/`)
const editor = page.locator('div[contenteditable=true]').first()
await editor.focus()

await page.keyboard.type('http://example.com')
await page.keyboard.press('ArrowLeft');
await page.keyboard.type(' ')
await page.keyboard.press('ArrowRight');
await page.keyboard.type('. More text.')

const html = await page.locator('div[contenteditable=true]').first().innerHTML()

const expectedHtml = `
<p dir="ltr">
<a href="http://example.com" dir="ltr">
<span data-lexical-text="true">http://example.co m</span>
</a>
<span data-lexical-text="true">. More text.</span>
</p>
`

const expected = await prettifyHTML(expectedHtml.replace(/\n/gm, ''))
const actual = await prettifyHTML(html.replace(/\n/gm, ''))
expect(actual).toEqual(expected)
})

0 comments on commit 1c8ca31

Please sign in to comment.