snapshot of https://github.com/tldraw/tldraw.git (main, 2026-09-23; blobs > 131072B omitted)
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

This commit is contained in:
upstream-mirror
2026-09-23 16:12:52 +05:00
commit a774ac673a
4541 changed files with 770499 additions and 0 deletions

View File

@@ -0,0 +1,137 @@
import { expect } from '@playwright/test'
import test from '../fixtures/fixtures'
import { getAllShapeTypes, setupOrReset } from '../shared-e2e'
test.describe('when selecting a tool from the toolbar', () => {
test.beforeEach(setupOrReset)
test('tool selection behaviors', async ({ toolbar }) => {
const { select, draw, arrow, cloud } = toolbar.tools
const { popoverCloud } = toolbar.popOverTools
await test.step('selecting a tool changes the button color', async () => {
await select.click()
await toolbar.isSelected(select)
await toolbar.isNotSelected(draw)
await draw.click()
await toolbar.isNotSelected(select)
await toolbar.isSelected(draw)
})
await test.step('selecting certain tools exposes the tool-lock button', async () => {
await draw.click()
expect(toolbar.toolLock).toBeHidden()
await arrow.click()
expect(toolbar.toolLock).toBeVisible()
})
await test.step('selecting a tool from the popover makes it appear on toolbar', async () => {
await expect(cloud).toBeHidden()
await expect(toolbar.moreToolsPopover).toBeHidden()
await toolbar.moreToolsButton.click()
await expect(toolbar.moreToolsPopover).toBeVisible()
await popoverCloud.click()
await expect(toolbar.moreToolsPopover).toBeHidden()
await expect(cloud).toBeVisible()
})
})
})
test.describe('when dragging a tool from the toolbar', () => {
test.beforeEach(setupOrReset)
test('dragging from main toolbar creates and positions shapes', async ({
page,
toolbar,
isMobile,
}) => {
if (isMobile) return
const { rectangle, arrow, text } = toolbar.tools
await test.step('dragging rectangle tool creates a rectangle', async () => {
const startPoint = { x: 100, y: 100 }
const endPoint = { x: 200, y: 200 }
// Start dragging from the rectangle tool
await rectangle.hover()
await page.mouse.down()
await page.mouse.move(startPoint.x, startPoint.y)
await page.mouse.move(endPoint.x, endPoint.y)
await page.mouse.up()
// Verify a rectangle was created
const shapes = await getAllShapeTypes(page)
expect(shapes).toHaveLength(1)
expect(shapes).toContain('geo')
})
await test.step('dragging arrow tool creates an arrow', async () => {
const startPoint = { x: 300, y: 100 }
const endPoint = { x: 400, y: 200 }
// Start dragging from the arrow tool
await arrow.hover()
await page.mouse.down()
await page.mouse.move(startPoint.x, startPoint.y)
await page.mouse.move(endPoint.x, endPoint.y)
await page.mouse.up()
// Verify an arrow was created
const shapes = await getAllShapeTypes(page)
expect(shapes).toHaveLength(2)
expect(shapes).toContain('geo')
expect(shapes).toContain('arrow')
})
await test.step('dragging text tool creates editable text', async () => {
const startPoint = { x: 500, y: 100 }
const endPoint = { x: 600, y: 200 }
// Start dragging from the text tool
await text.hover()
await page.mouse.down()
await page.mouse.move(startPoint.x, startPoint.y)
await page.mouse.move(endPoint.x, endPoint.y)
await page.mouse.up()
// Verify a text shape was created
const shapes = await getAllShapeTypes(page)
expect(shapes).toHaveLength(3)
expect(shapes).toContain('geo')
expect(shapes).toContain('arrow')
expect(shapes).toContain('text')
// Verify text is in edit mode
const hasTextInputFocused = await page.evaluate(() => {
return document.activeElement?.classList.contains('tiptap')
})
expect(hasTextInputFocused).toBe(true)
})
})
test('dragging from overflow toolbar creates shapes', async ({ page, toolbar }) => {
// Open the overflow menu
await toolbar.moreToolsButton.click()
await expect(toolbar.moreToolsPopover).toBeVisible()
const { popoverCloud } = toolbar.popOverTools
await test.step('dragging cloud tool from overflow creates a cloud', async () => {
const startPoint = { x: 100, y: 100 }
const endPoint = { x: 200, y: 200 }
// Start dragging from the cloud tool in overflow
await popoverCloud.hover()
await page.mouse.down()
await page.mouse.move(startPoint.x, startPoint.y)
await page.mouse.move(endPoint.x, endPoint.y)
await page.mouse.up()
// Verify a cloud shape was created
const shapes = await getAllShapeTypes(page)
expect(shapes).toHaveLength(1)
expect(shapes).toContain('geo')
})
})
})