Files
upstream-tldraw/apps/examples/e2e/tests/test-rich-text.spec.ts
upstream-mirror a774ac673a
Some checks failed
Deploy analytics worker / Deploy analytics worker to ${{ (github.ref == 'refs/heads/production' && 'production') || (github.ref == 'refs/heads/main' && 'staging') || 'preview' }} (push) Failing after 1s
i18n upload strings / Upload latest strings (push) Failing after 1s
Deploy bemo / Deploy bemo to ${{ (github.ref == 'refs/heads/bemo-production' && 'production') || (github.ref == 'refs/heads/main' && 'staging') || 'preview' }} (push) Failing after 1s
Deploy grafana resources / ${{ github.event_name == 'push' && 'Deploy grafana resources' || 'Validate grafana resources (dry run)' }} (push) Failing after 0s
End to end tests (dotcom) / Check for relevant changes (push) Failing after 0s
End to end tests (examples) / Check for relevant changes (push) Failing after 0s
End to end tests (mermaid readability) / Check for relevant changes (push) Failing after 1s
End to end tests (perf) / Check for relevant changes (push) Failing after 0s
Publish editor extensions / Publish editor extensions (push) Failing after 1s
Publish SDK packages / Remove the publish-packages label (push) Has been skipped
Checks / Tests & checks (push) Has been cancelled
Checks / Build all projects (push) Has been cancelled
Deploy templates / Deploy templates (push) Has been cancelled
End to end tests (dotcom) / End to end tests (dotcom) (push) Has been cancelled
End to end tests (mermaid readability) / End to end tests (mermaid readability) (push) Has been cancelled
End to end tests (perf) / End to end tests (perf) (push) Has been cancelled
Deploy .com / Deploy dotcom to ${{ (github.ref == 'refs/heads/production' && 'production') || (github.ref == 'refs/heads/main' && 'staging') || 'preview' }} (push) Has been cancelled
End to end tests (examples) / End to end tests (examples) (push) Has been cancelled
Publish SDK packages / Publish SDK packages (push) Has been cancelled
Publish SDK packages / Tell user released version (push) Has been cancelled
Publish SDK packages / Publishes code templates to separate repositories (push) Has been cancelled
Publish SDK packages / Deploys the template demos with the new SDK version (push) Has been cancelled
snapshot of https://github.com/tldraw/tldraw.git (main, 2026-09-23; blobs > 131072B omitted)
2026-09-23 16:12:52 +05:00

66 lines
2.5 KiB
TypeScript

import { expect } from '@playwright/test'
import test from '../fixtures/fixtures'
import { setupOrReset } from '../shared-e2e'
test.describe('more rich text', () => {
test.beforeEach(setupOrReset)
test('Double click from select tool to create and edit text on the canvas', async ({
page,
toolbar,
}) => {
await toolbar.tools.select.click()
await page.mouse.dblclick(150, 150)
// Wait for the contenteditable to actually be focused, not just visible.
// The editor focuses on a deferred timeout after mounting, so typing as
// soon as the element is visible drops the first keystroke.
await page.waitForFunction(
() => document.activeElement === document.querySelector('.tl-shape [contenteditable]')
)
await page.keyboard.type('id like to go to india')
await expect(page.getByTestId('rich-text-area')).toHaveText('id like to go to india')
})
test('Click with text tool to create and edit text on the canvas', async ({ page, toolbar }) => {
await toolbar.tools.text.click()
await page.mouse.click(150, 150)
// Wait for the contenteditable to actually be focused (not just visible)
// so the first keystroke isn't dropped.
await page.waitForFunction(
() => document.activeElement === document.querySelector('.tl-shape [contenteditable]')
)
await page.keyboard.type('Live in a big white house in the forest')
await expect(page.getByTestId('rich-text-area')).toHaveText(
'Live in a big white house in the forest'
)
// expect canvas overlays to be visible (indicators render there when editing)
const canvasIndicator = page.locator('.tl-canvas-overlays')
await expect(canvasIndicator).toBeVisible()
})
test('Click and drag with text tool to create and edit fixed-width text on the canvas', async ({
page,
toolbar,
}) => {
await toolbar.tools.text.click()
await page.mouse.move(150, 150)
await page.mouse.down()
await page.mouse.move(350, 150, { steps: 10 })
await page.mouse.up()
// Wait for the contenteditable to actually be focused (not just visible)
// so the first keystroke isn't dropped.
await page.waitForFunction(
() => document.activeElement === document.querySelector('.tl-shape [contenteditable]')
)
await page.keyboard.type('Drink gin and tonic and play a grand piano')
await expect(page.getByTestId('rich-text-area')).toHaveText(
'Drink gin and tonic and play a grand piano'
)
// expect canvas overlays to be visible (indicators render there when editing)
const canvasIndicator = page.locator('.tl-canvas-overlays')
await expect(canvasIndicator).toBeVisible()
})
})