1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-09-06 21:20:40 +02:00
Files
slate/playwright/integration/examples/placeholder.test.ts
Ed Hager 5a0d3974d6 Fix/delete all closes keyboard (#5368)
* fix: clean up ref handling in leaf

* fix: delay rendering of placeholder to allow selections to settle

* fix: move placeholder height calculation into layout effect

* fix: add change set

* fix: handle placeholder resizing in a better way

* fix: fix placeholder integration test
2023-03-20 09:23:54 -07:00

37 lines
1.2 KiB
TypeScript

import { test, expect } from '@playwright/test'
test.describe('placeholder example', () => {
test.beforeEach(
async ({ page }) =>
await page.goto('http://localhost:3000/examples/custom-placeholder')
)
test('renders custom placeholder', async ({ page }) => {
const placeholderElement = page.locator('[data-slate-placeholder=true]')
expect(await placeholderElement.textContent()).toContain('Type something')
expect(await page.locator('pre').textContent()).toContain(
'renderPlaceholder'
)
})
test('renders editor tall enough to fit placeholder', async ({ page }) => {
const slateEditor = page.locator('[data-slate-editor=true]')
const placeholderElement = page.locator('[data-slate-placeholder=true]')
await expect(placeholderElement).toBeVisible()
const editorBoundingBox = await slateEditor.boundingBox()
const placeholderBoundingBox = await placeholderElement.boundingBox()
if (!editorBoundingBox)
throw new Error('Could not get bounding box for editor')
if (!placeholderBoundingBox)
throw new Error('Could not get bounding box for placeholder')
expect(editorBoundingBox.height).toBeGreaterThanOrEqual(
placeholderBoundingBox.height
)
})
})