mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-09-06 13:10:39 +02:00
* empty * empty * empty * Begin move from cypress to playwright. * Switch remaining tests to playwright, remove old cypress suppport files. * Clean up playwright config * Enable ff, and safari when on mac. * Fix safari/ff mentions test * Fix code-highlighting test on ff/safari * Add a local retry as a few tests are flaky. * Replace cypress w/ playwright in gitignore. * Update to latest yarn to fix ci install? * Update yarn.lock w/ yarn command. * Fix mocha tests. * Fix prettier
39 lines
1.3 KiB
TypeScript
39 lines
1.3 KiB
TypeScript
import { test, expect, Page } from '@playwright/test'
|
|
|
|
test.describe('paste html example', () => {
|
|
test.beforeEach(
|
|
async ({ page }) =>
|
|
await page.goto('http://localhost:3000/examples/paste-html')
|
|
)
|
|
|
|
const pasteHtml = async (page: Page, htmlContent: string) => {
|
|
await page.getByRole('textbox').click()
|
|
await page.getByRole('textbox').selectText()
|
|
await page.keyboard.press('Backspace')
|
|
await page
|
|
.getByRole('textbox')
|
|
.evaluate((el: HTMLElement, htmlContent: string) => {
|
|
const clipboardEvent = Object.assign(
|
|
new Event('paste', { bubbles: true, cancelable: true }),
|
|
{
|
|
clipboardData: {
|
|
getData: (type = 'text/html') => htmlContent,
|
|
types: ['text/html'],
|
|
},
|
|
}
|
|
)
|
|
el.dispatchEvent(clipboardEvent)
|
|
}, htmlContent)
|
|
}
|
|
|
|
test('pasted bold text uses <strong>', async ({ page }) => {
|
|
await pasteHtml(page, '<strong>Hello Bold</strong>')
|
|
expect(await page.locator('strong').textContent()).toContain('Hello')
|
|
})
|
|
|
|
test('pasted code uses <code>', async ({ page }) => {
|
|
await pasteHtml(page, '<code>console.log("hello from slate!")</code>')
|
|
expect(await page.locator('code').textContent()).toContain('slate!')
|
|
})
|
|
})
|