Files
upstream-tldraw/apps/examples/e2e-device/tests/pinch.e2e.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

50 lines
1.7 KiB
TypeScript

import { expect } from '@wdio/globals'
import type { Editor } from 'tldraw'
import { getSelectedShapeIds, getZoom, openEditor } from '../helpers/app'
import { pinchCanvas } from '../helpers/pinch'
declare const editor: Editor
/**
* Device-realistic pinch tests. These mirror the intent of the Playwright camera
* tests (apps/examples/e2e/tests/test-camera.spec.ts) but run through the real
* OS touch pipeline on a simulator/emulator, so they cover the browser's own
* gesture recogniser — the part synthetic CDP touch can't reach.
*/
describe('pinch to zoom', () => {
beforeEach(async () => {
await openEditor()
})
it('spreading two fingers zooms in', async () => {
expect(await getZoom()).toBe(1)
await pinchCanvas({ scale: 2.5 })
expect(await getZoom()).toBeGreaterThan(1)
})
it('pinching two fingers together zooms out', async () => {
expect(await getZoom()).toBe(1)
await pinchCanvas({ scale: 0.4 })
expect(await getZoom()).toBeLessThan(1)
})
it('a two-finger pinch does not change the selection', async () => {
// Place a shape under where the pinch lands, plus a second shape that we
// pre-select off to the side. The pinch must not steal the selection.
await browser.execute(() => {
editor.createShapes([
{ id: 'shape:a', type: 'geo', x: -400, y: -400, props: { w: 100, h: 100 } },
{ id: 'shape:b', type: 'geo', x: 0, y: 0, props: { w: 400, h: 400 } },
] as any)
editor.setSelectedShapes(['shape:a'] as any)
})
expect(await getSelectedShapeIds()).toEqual(['shape:a'])
await pinchCanvas({ scale: 2 })
// Selection is preserved and the gesture really did zoom.
expect(await getSelectedShapeIds()).toEqual(['shape:a'])
expect(await getZoom()).not.toBe(1)
})
})