tldraw/apps/examples/e2e/tests/test-routes.spec.ts

74 lines
2 KiB
TypeScript
Raw Normal View History

[refactor] User-facing APIs (#1478) This PR updates our user-facing APIs for the Tldraw and TldrawEditor components, as well as the Editor (App). It mainly incorporates surface changes from #1450 without any changes to validators or migrators, incorporating feedback / discussion with @SomeHats and @ds300. Here we: - remove the TldrawEditorConfig - bring back a loose version of shape definitions - make a separation between "core" shapes and "default" shapes - do not allow custom shapes, migrators or validators to overwrite core shapes - but _do_ allow new shapes ## `<Tldraw>` component In this PR, the `Tldraw` component wraps both the `TldrawEditor` component and our `TldrawUi` component. It accepts a union of props for both components. Previously, this component also added local syncing via a `useLocalSyncClient` hook call, however that has been pushed down to the `TldrawEditor` component. ## `<TldrawEditor>` component The `TldrawEditor` component now more neatly wraps up the different ways that the editor can be configured. ## The store prop (`TldrawEditorProps.store`) There are three main ways for the `TldrawEditor` component to be run: 1. with an externally defined store 2. with an externally defined syncing store (local or remote) 3. with an internally defined store 4. with an internally defined locally syncing store The `store` prop allows for these configurations. If the `store` prop is defined, it may be defined either as a `TLStore` or as a `SyncedStore`. If the store is a `TLStore`, then the Editor will assume that the store is ready to go; if it is defined as a SyncedStore, then the component will display the loading / error screens as needed, or the final editor once the store's status is "synced". When the store is left undefined, then the `TldrawEditor` will create its own internal store using the optional `instanceId`, `initialData`, or `shapes` props to define the store / store schema. If the `persistenceKey` prop is left undefined, then the store will not be synced. If the `persistenceKey` is defined, then the store will be synced locally. In the future, we may also here accept the API key / roomId / etc for creating a remotely synced store. The `SyncedStore` type has been expanded to also include types used for remote syncing, e.g. with `ConnectionStatus`. ## Tools By default, the App has two "baked-in" tools: the select tool and the zoom tool. These cannot (for now) be replaced or removed. The default tools are used by default, but may be replaced by other tools if provided. ## Shapes By default, the App has a set of "core" shapes: - group - embed - bookmark - image - video - text That cannot by overwritten because they're created by the app at different moments, such as when double clicking on the canvas or via a copy and paste event. In follow up PRs, we'll split these out so that users can replace parts of the code where these shapes are created. ### Change Type - [x] `major` — Breaking Change ### Test Plan - [x] Unit Tests
2023-06-01 15:47:34 +00:00
import test from '@playwright/test'
test.describe('Routes', () => {
test('end-to-end', async ({ page }) => {
await page.goto('http://localhost:5420/end-to-end')
await page.waitForSelector('.tl-canvas')
})
test('basic', async ({ page }) => {
await page.goto('http://localhost:5420/')
await page.waitForSelector('.tl-canvas')
})
test('api', async ({ page }) => {
await page.goto('http://localhost:5420/api')
await page.waitForSelector('.tl-canvas')
})
test('hide-ui', async ({ page }) => {
await page.goto('http://localhost:5420/custom-config')
await page.waitForSelector('.tl-canvas')
})
test('custom-config', async ({ page }) => {
await page.goto('http://localhost:5420/custom-config')
await page.waitForSelector('.tl-canvas')
})
test('custom-ui', async ({ page }) => {
await page.goto('http://localhost:5420/custom-ui')
await page.waitForSelector('.tl-canvas')
})
test('exploded', async ({ page }) => {
await page.goto('http://localhost:5420/exploded')
await page.waitForSelector('.tl-canvas')
})
test('scroll', async ({ page }) => {
await page.goto('http://localhost:5420/scroll')
await page.waitForSelector('.tl-canvas')
})
test('multiple', async ({ page }) => {
await page.goto('http://localhost:5420/multiple')
await page.waitForSelector('.tl-canvas')
})
test('error-boundary', async ({ page }) => {
await page.goto('http://localhost:5420/error-boundary')
await page.waitForSelector('.tl-canvas')
})
test('user-presence', async ({ page }) => {
await page.goto('http://localhost:5420/user-presence')
await page.waitForSelector('.tl-canvas')
})
test('ui-events', async ({ page }) => {
await page.goto('http://localhost:5420/ui-events')
await page.waitForSelector('.tl-canvas')
})
test('store-events', async ({ page }) => {
await page.goto('http://localhost:5420/store-events')
await page.waitForSelector('.tl-canvas')
})
test('persistence', async ({ page }) => {
await page.goto('http://localhost:5420/persistence')
await page.waitForSelector('.tl-canvas')
})
})