2021-11-16 16:01:29 +00:00
|
|
|
import { mockDocument, TldrawTestApp } from '~test'
|
|
|
|
import { GroupShape, SessionType, TDShapeType, TDStatus } from '~types'
|
2021-08-10 16:12:55 +00:00
|
|
|
|
2021-09-01 19:12:56 +00:00
|
|
|
describe('Translate session', () => {
|
2021-10-13 13:55:31 +00:00
|
|
|
it('begins, updateSession', () => {
|
2021-11-16 16:01:29 +00:00
|
|
|
const app = new TldrawTestApp()
|
2021-08-10 16:12:55 +00:00
|
|
|
.loadDocument(mockDocument)
|
2021-11-16 16:01:29 +00:00
|
|
|
.pointShape('rect1', [5, 5])
|
|
|
|
.movePointer([10, 10])
|
2021-08-10 16:12:55 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
expect(app.getShape('rect1').point).toStrictEqual([5, 5])
|
2021-08-10 16:12:55 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
app.completeSession()
|
2021-08-10 16:12:55 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
expect(app.status).toBe(TDStatus.Idle)
|
2021-08-17 21:38:37 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
expect(app.getShape('rect1').point).toStrictEqual([5, 5])
|
2021-08-10 16:12:55 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
app.undo()
|
2021-08-10 16:12:55 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
expect(app.getShape('rect1').point).toStrictEqual([0, 0])
|
2021-08-10 16:12:55 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
app.redo()
|
2021-08-10 16:12:55 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
expect(app.getShape('rect1').point).toStrictEqual([5, 5])
|
2021-08-10 16:12:55 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
it('cancels session', () => {
|
2021-11-16 16:01:29 +00:00
|
|
|
const app = new TldrawTestApp()
|
2021-08-10 16:12:55 +00:00
|
|
|
.loadDocument(mockDocument)
|
|
|
|
.select('rect1', 'rect2')
|
2021-11-16 16:01:29 +00:00
|
|
|
.pointBounds([5, 5])
|
|
|
|
.movePointer([10, 10])
|
2021-08-10 16:12:55 +00:00
|
|
|
.cancelSession()
|
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
expect(app.getShape('rect1').point).toStrictEqual([0, 0])
|
2021-08-10 16:12:55 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
it('moves a single shape', () => {
|
2021-11-16 16:01:29 +00:00
|
|
|
const app = new TldrawTestApp()
|
2021-08-10 16:12:55 +00:00
|
|
|
.loadDocument(mockDocument)
|
2021-11-16 16:01:29 +00:00
|
|
|
.pointShape('rect1', [10, 10])
|
|
|
|
.movePointer([20, 20])
|
2021-08-10 16:12:55 +00:00
|
|
|
.completeSession()
|
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
expect(app.getShape('rect1').point).toStrictEqual([10, 10])
|
2021-08-10 16:12:55 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
it('moves a single shape along a locked axis', () => {
|
2021-11-16 16:01:29 +00:00
|
|
|
const app = new TldrawTestApp()
|
2021-08-10 16:12:55 +00:00
|
|
|
.loadDocument(mockDocument)
|
|
|
|
.select('rect1')
|
2021-11-16 16:01:29 +00:00
|
|
|
.pointShape('rect1', [10, 10])
|
|
|
|
.movePointer({ x: 20, y: 20, shiftKey: true })
|
2021-08-10 16:12:55 +00:00
|
|
|
.completeSession()
|
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
expect(app.getShape('rect1').point).toStrictEqual([10, 0])
|
2021-08-10 16:12:55 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
it('moves two shapes', () => {
|
2021-11-16 16:01:29 +00:00
|
|
|
const app = new TldrawTestApp()
|
2021-08-10 16:12:55 +00:00
|
|
|
.loadDocument(mockDocument)
|
|
|
|
.select('rect1', 'rect2')
|
2021-11-16 16:01:29 +00:00
|
|
|
.pointBounds([10, 10])
|
|
|
|
.movePointer([20, 20])
|
2021-08-10 16:12:55 +00:00
|
|
|
.completeSession()
|
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
expect(app.getShape('rect1').point).toStrictEqual([10, 10])
|
|
|
|
expect(app.getShape('rect2').point).toStrictEqual([110, 110])
|
2021-08-10 16:12:55 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
it('undos and redos clones', () => {
|
2021-11-16 16:01:29 +00:00
|
|
|
const app = new TldrawTestApp()
|
2021-08-10 16:12:55 +00:00
|
|
|
.loadDocument(mockDocument)
|
|
|
|
.select('rect1', 'rect2')
|
2021-11-16 16:01:29 +00:00
|
|
|
.pointBounds([10, 10])
|
|
|
|
.movePointer({ x: 20, y: 20, altKey: true })
|
2021-08-10 16:12:55 +00:00
|
|
|
.completeSession()
|
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
expect(app.getShape('rect1').point).toStrictEqual([0, 0])
|
|
|
|
expect(app.getShape('rect2').point).toStrictEqual([100, 100])
|
2021-08-10 16:12:55 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
expect(Object.keys(app.getPage().shapes).length).toBe(5)
|
2021-08-10 16:12:55 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
app.undo()
|
2021-08-10 16:12:55 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
expect(Object.keys(app.getPage().shapes).length).toBe(3)
|
2021-08-10 16:12:55 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
app.redo()
|
2021-08-10 16:12:55 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
expect(Object.keys(app.getPage().shapes).length).toBe(5)
|
2021-08-10 16:12:55 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
it('clones shapes', () => {
|
2021-11-16 16:01:29 +00:00
|
|
|
const app = new TldrawTestApp()
|
2021-08-10 16:12:55 +00:00
|
|
|
.loadDocument(mockDocument)
|
|
|
|
.select('rect1', 'rect2')
|
2021-11-16 16:01:29 +00:00
|
|
|
.pointBounds([10, 10])
|
|
|
|
.movePointer({ x: 20, y: 20, altKey: true })
|
2021-08-10 16:12:55 +00:00
|
|
|
.completeSession()
|
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
expect(app.getShape('rect1').point).toStrictEqual([0, 0])
|
|
|
|
expect(app.getShape('rect2').point).toStrictEqual([100, 100])
|
2021-08-10 16:12:55 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
expect(Object.keys(app.getPage().shapes).length).toBe(5)
|
2021-08-10 16:12:55 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
it('destroys clones when last update is not cloning', () => {
|
2021-11-16 16:01:29 +00:00
|
|
|
const app = new TldrawTestApp().loadDocument(mockDocument)
|
2021-09-02 20:13:54 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
expect(Object.keys(app.getPage().shapes).length).toBe(3)
|
2021-09-02 20:13:54 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
app.select('rect1', 'rect2').pointBounds([10, 10]).movePointer({ x: 20, y: 20, altKey: true })
|
2021-09-02 20:13:54 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
expect(Object.keys(app.getPage().shapes).length).toBe(5)
|
2021-09-02 20:13:54 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
app.movePointer({ x: 30, y: 30 })
|
2021-09-02 20:13:54 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
expect(Object.keys(app.getPage().shapes).length).toBe(3)
|
2021-09-02 20:13:54 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
app.completeSession()
|
2021-08-10 16:12:55 +00:00
|
|
|
|
|
|
|
// Original position + delta
|
2021-11-16 16:01:29 +00:00
|
|
|
expect(app.getShape('rect1').point).toStrictEqual([30, 30])
|
|
|
|
expect(app.getShape('rect2').point).toStrictEqual([130, 130])
|
2021-08-10 16:12:55 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
expect(Object.keys(app.page.shapes)).toStrictEqual(['rect1', 'rect2', 'rect3'])
|
2021-08-10 16:12:55 +00:00
|
|
|
})
|
|
|
|
|
2021-08-12 13:39:41 +00:00
|
|
|
it('destroys bindings from the translating shape', () => {
|
2021-11-16 16:01:29 +00:00
|
|
|
const app = new TldrawTestApp()
|
2021-08-12 13:39:41 +00:00
|
|
|
.loadDocument(mockDocument)
|
|
|
|
.selectAll()
|
|
|
|
.delete()
|
2021-09-01 14:39:01 +00:00
|
|
|
.createShapes(
|
|
|
|
{
|
2021-08-12 13:39:41 +00:00
|
|
|
id: 'target1',
|
2021-11-16 16:01:29 +00:00
|
|
|
type: TDShapeType.Rectangle,
|
2021-08-12 13:39:41 +00:00
|
|
|
parentId: 'page1',
|
|
|
|
point: [0, 0],
|
|
|
|
size: [100, 100],
|
2021-09-01 14:39:01 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'arrow1',
|
2021-11-16 16:01:29 +00:00
|
|
|
type: TDShapeType.Arrow,
|
2021-09-01 14:39:01 +00:00
|
|
|
parentId: 'page1',
|
|
|
|
point: [200, 200],
|
|
|
|
}
|
2021-08-12 13:39:41 +00:00
|
|
|
)
|
2021-09-01 14:39:01 +00:00
|
|
|
.select('arrow1')
|
2021-11-16 16:01:29 +00:00
|
|
|
.movePointer([200, 200])
|
|
|
|
.startSession(SessionType.Arrow, 'arrow1', 'start')
|
|
|
|
.movePointer([50, 50])
|
2021-09-01 14:39:01 +00:00
|
|
|
.completeSession()
|
2021-08-13 10:49:35 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
expect(app.bindings.length).toBe(1)
|
2021-08-13 10:49:35 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
app.pointShape('arrow1', [10, 10]).movePointer([30, 30]).completeSession()
|
2021-08-13 10:49:35 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
// expect(app.bindings.length).toBe(0)
|
|
|
|
// expect(app.getShape<ArrowShape>('arrow1').handles.start.bindingId).toBe(undefined)
|
2021-08-13 10:49:35 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
// app.undo()
|
2021-08-13 10:49:35 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
// expect(app.bindings.length).toBe(1)
|
|
|
|
// expect(app.getShape<ArrowShape>('arrow1').handles.start.bindingId).toBeTruthy()
|
2021-08-13 10:49:35 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
// app.redo()
|
2021-08-13 10:49:35 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
// expect(app.bindings.length).toBe(0)
|
|
|
|
// expect(app.getShape<ArrowShape>('arrow1').handles.start.bindingId).toBe(undefined)
|
2021-08-12 13:39:41 +00:00
|
|
|
})
|
|
|
|
|
2021-09-01 18:49:40 +00:00
|
|
|
// it.todo('clones a shape with a parent shape')
|
|
|
|
|
2021-09-06 13:30:59 +00:00
|
|
|
describe('when translating a child of a group', () => {
|
|
|
|
it('translates the shape and updates the groups size / point', () => {
|
2021-11-16 16:01:29 +00:00
|
|
|
const app = new TldrawTestApp()
|
2021-09-06 13:30:59 +00:00
|
|
|
.loadDocument(mockDocument)
|
|
|
|
.select('rect1', 'rect2')
|
|
|
|
.group(['rect1', 'rect2'], 'groupA')
|
2021-11-16 16:01:29 +00:00
|
|
|
.pointShape('rect1', [10, 10])
|
|
|
|
.movePointer({ x: 20, y: 20 })
|
2021-09-06 13:30:59 +00:00
|
|
|
.completeSession()
|
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
expect(app.getShape('groupA').point).toStrictEqual([10, 10])
|
|
|
|
expect(app.getShape('rect1').point).toStrictEqual([10, 10])
|
|
|
|
expect(app.getShape('rect2').point).toStrictEqual([110, 110])
|
2021-09-06 13:30:59 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
app.undo()
|
2021-09-06 13:30:59 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
expect(app.getShape('groupA').point).toStrictEqual([0, 0])
|
|
|
|
expect(app.getShape('rect1').point).toStrictEqual([0, 0])
|
|
|
|
expect(app.getShape('rect2').point).toStrictEqual([100, 100])
|
2021-09-06 13:30:59 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
app.redo()
|
2021-09-06 13:30:59 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
expect(app.getShape('groupA').point).toStrictEqual([10, 10])
|
|
|
|
expect(app.getShape('rect1').point).toStrictEqual([10, 10])
|
|
|
|
expect(app.getShape('rect2').point).toStrictEqual([110, 110])
|
2021-09-06 13:30:59 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
it('clones the shape and updates the parent', () => {
|
2021-11-16 16:01:29 +00:00
|
|
|
const app = new TldrawTestApp()
|
2021-09-06 13:30:59 +00:00
|
|
|
.loadDocument(mockDocument)
|
|
|
|
.select('rect1', 'rect2')
|
|
|
|
.group(['rect1', 'rect2'], 'groupA')
|
2021-11-16 16:01:29 +00:00
|
|
|
.doubleClickShape('rect1')
|
|
|
|
.pointShape('rect1', [10, 10])
|
|
|
|
.movePointer({ x: 10, y: 10, altKey: true })
|
|
|
|
.movePointer({ x: 20, y: 20, altKey: true })
|
2021-09-06 13:30:59 +00:00
|
|
|
.completeSession()
|
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
const children = app.getShape<GroupShape>('groupA').children
|
2021-09-06 13:30:59 +00:00
|
|
|
const newShapeId = children[children.length - 1]
|
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
expect(app.getShape('groupA').point).toStrictEqual([0, 0])
|
|
|
|
expect(app.getShape<GroupShape>('groupA').children.length).toBe(3)
|
|
|
|
expect(app.getShape('rect1').point).toStrictEqual([0, 0])
|
|
|
|
expect(app.getShape('rect2').point).toStrictEqual([100, 100])
|
|
|
|
expect(app.getShape(newShapeId).point).toStrictEqual([20, 20])
|
|
|
|
expect(app.getShape(newShapeId).parentId).toBe('groupA')
|
|
|
|
|
|
|
|
app.undo()
|
|
|
|
|
|
|
|
expect(app.getShape('groupA').point).toStrictEqual([0, 0])
|
|
|
|
expect(app.getShape<GroupShape>('groupA').children.length).toBe(2)
|
|
|
|
expect(app.getShape('rect1').point).toStrictEqual([0, 0])
|
|
|
|
expect(app.getShape('rect2').point).toStrictEqual([100, 100])
|
|
|
|
expect(app.getShape(newShapeId)).toBeUndefined()
|
|
|
|
|
|
|
|
app.redo()
|
|
|
|
|
|
|
|
expect(app.getShape('groupA').point).toStrictEqual([0, 0])
|
|
|
|
expect(app.getShape<GroupShape>('groupA').children.length).toBe(3)
|
|
|
|
expect(app.getShape('rect1').point).toStrictEqual([0, 0])
|
|
|
|
expect(app.getShape('rect2').point).toStrictEqual([100, 100])
|
|
|
|
expect(app.getShape(newShapeId).point).toStrictEqual([20, 20])
|
|
|
|
expect(app.getShape(newShapeId).parentId).toBe('groupA')
|
2021-09-06 13:30:59 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2021-09-02 20:13:54 +00:00
|
|
|
describe('when translating a shape with children', () => {
|
|
|
|
it('translates the shapes children', () => {
|
2021-11-16 16:01:29 +00:00
|
|
|
const app = new TldrawTestApp()
|
2021-09-02 20:13:54 +00:00
|
|
|
.loadDocument(mockDocument)
|
|
|
|
.select('rect1', 'rect2')
|
2021-09-06 13:30:59 +00:00
|
|
|
.group(['rect1', 'rect2'], 'groupA')
|
2021-11-16 16:01:29 +00:00
|
|
|
.pointShape('groupA', [10, 10])
|
|
|
|
.movePointer({ x: 20, y: 20 })
|
2021-09-02 20:13:54 +00:00
|
|
|
.completeSession()
|
2021-09-06 13:30:59 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
expect(app.getShape('groupA').point).toStrictEqual([10, 10])
|
|
|
|
expect(app.getShape('rect1').point).toStrictEqual([10, 10])
|
|
|
|
expect(app.getShape('rect2').point).toStrictEqual([110, 110])
|
2021-09-06 13:30:59 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
app.undo()
|
2021-09-06 13:30:59 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
expect(app.getShape('groupA').point).toStrictEqual([0, 0])
|
|
|
|
expect(app.getShape('rect1').point).toStrictEqual([0, 0])
|
|
|
|
expect(app.getShape('rect2').point).toStrictEqual([100, 100])
|
2021-09-06 13:30:59 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
app.redo()
|
2021-09-06 13:30:59 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
expect(app.getShape('groupA').point).toStrictEqual([10, 10])
|
|
|
|
expect(app.getShape('rect1').point).toStrictEqual([10, 10])
|
|
|
|
expect(app.getShape('rect2').point).toStrictEqual([110, 110])
|
2021-09-02 20:13:54 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
it('clones the shapes and children', () => {
|
2021-11-16 16:01:29 +00:00
|
|
|
new TldrawTestApp()
|
2021-09-02 20:13:54 +00:00
|
|
|
.loadDocument(mockDocument)
|
|
|
|
.select('rect1', 'rect2')
|
2021-11-16 16:01:29 +00:00
|
|
|
.group(['rect1', 'rect2'], 'groupA')
|
|
|
|
.pointShape('groupA', [10, 10])
|
|
|
|
.movePointer({ x: 20, y: 20, altKey: true })
|
2021-09-02 20:13:54 +00:00
|
|
|
.completeSession()
|
|
|
|
})
|
2021-09-02 20:29:45 +00:00
|
|
|
|
2021-09-03 10:52:40 +00:00
|
|
|
it('deletes clones when not cloning anymore', () => {
|
2021-11-16 16:01:29 +00:00
|
|
|
const app = new TldrawTestApp()
|
2021-09-03 10:52:40 +00:00
|
|
|
.loadDocument(mockDocument)
|
|
|
|
.select('rect1', 'rect2')
|
2021-11-16 16:01:29 +00:00
|
|
|
.group(['rect1', 'rect2'], 'groupA')
|
|
|
|
.pointShape('groupA', [10, 10])
|
|
|
|
.movePointer({ x: 20, y: 20, altKey: true })
|
|
|
|
.movePointer({ x: 20, y: 20, altKey: false })
|
|
|
|
.movePointer({ x: 20, y: 20, altKey: true })
|
2021-09-03 10:52:40 +00:00
|
|
|
.completeSession()
|
2021-10-22 12:23:36 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
expect(app.shapes.filter((shape) => shape.type === TDShapeType.Group).length).toBe(2)
|
2021-10-22 12:23:36 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
it('deletes clones when not cloning anymore', () => {
|
2021-11-16 16:01:29 +00:00
|
|
|
const app = new TldrawTestApp()
|
2021-10-22 12:23:36 +00:00
|
|
|
.loadDocument(mockDocument)
|
|
|
|
.select('rect1', 'rect2')
|
2021-11-16 16:01:29 +00:00
|
|
|
.group(['rect1', 'rect2'], 'groupA')
|
|
|
|
.pointShape('groupA', [10, 10])
|
|
|
|
.movePointer({ x: 20, y: 20, altKey: true })
|
|
|
|
.movePointer({ x: 20, y: 20, altKey: false })
|
2021-10-22 12:23:36 +00:00
|
|
|
.completeSession()
|
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
expect(app.shapes.filter((shape) => shape.type === TDShapeType.Group).length).toBe(1)
|
2021-09-03 10:52:40 +00:00
|
|
|
})
|
|
|
|
|
2021-09-02 20:29:45 +00:00
|
|
|
it('clones the shapes and children when selecting a group and a different shape', () => {
|
2021-11-16 16:01:29 +00:00
|
|
|
const app = new TldrawTestApp()
|
2021-09-02 20:29:45 +00:00
|
|
|
.loadDocument(mockDocument)
|
|
|
|
.select('rect1', 'rect2')
|
|
|
|
.group(['rect1', 'rect2'], 'groupA')
|
|
|
|
.select('groupA', 'rect3')
|
2021-11-16 16:01:29 +00:00
|
|
|
.pointBounds([10, 10])
|
|
|
|
.movePointer({ x: 20, y: 20, altKey: true })
|
2021-09-02 20:29:45 +00:00
|
|
|
.completeSession()
|
|
|
|
})
|
2021-09-02 20:13:54 +00:00
|
|
|
})
|
2021-08-10 16:12:55 +00:00
|
|
|
})
|
2021-10-15 09:33:48 +00:00
|
|
|
|
|
|
|
describe('When creating with a translate session', () => {
|
|
|
|
it('Deletes the shape on undo', () => {
|
2021-11-16 16:01:29 +00:00
|
|
|
const app = new TldrawTestApp()
|
|
|
|
.selectTool(TDShapeType.Rectangle)
|
|
|
|
.pointCanvas([0, 0])
|
|
|
|
.movePointer([10, 10])
|
2021-10-15 09:33:48 +00:00
|
|
|
.completeSession()
|
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
expect(app.shapes.length).toBe(1)
|
|
|
|
|
|
|
|
app.undo()
|
|
|
|
|
|
|
|
expect(app.shapes.length).toBe(0)
|
2021-10-15 09:33:48 +00:00
|
|
|
})
|
|
|
|
})
|
2021-10-18 13:30:42 +00:00
|
|
|
|
|
|
|
describe('When snapping', () => {
|
|
|
|
it.todo('Does not snap when moving quicky')
|
|
|
|
it.todo('Snaps only matching edges when moving slowly')
|
|
|
|
it.todo('Snaps any edge to any edge when moving very slowly')
|
|
|
|
it.todo('Snaps a clone to its parent')
|
|
|
|
it.todo('Cleans up snap lines when cancelled')
|
|
|
|
it.todo('Cleans up snap lines when completed')
|
|
|
|
it.todo('Cleans up snap lines when starting to clone / not clone')
|
2021-10-18 14:26:34 +00:00
|
|
|
it.todo('Snaps the rotated bounding box of rotated shapes')
|
2021-10-21 22:38:37 +00:00
|
|
|
it.todo('Snaps to a shape on screen')
|
|
|
|
it.todo('Does not snap to a shape off screen.')
|
|
|
|
it.todo('Snaps while panning.')
|
2021-10-18 13:30:42 +00:00
|
|
|
})
|
2021-10-18 16:00:06 +00:00
|
|
|
|
|
|
|
describe('When translating linked shapes', () => {
|
2021-10-19 11:19:56 +00:00
|
|
|
it.todo('translates all linked shapes when center is dragged')
|
|
|
|
it.todo('translates all upstream linked shapes when left is dragged')
|
|
|
|
it.todo('translates all downstream linked shapes when right is dragged')
|
2021-10-18 16:00:06 +00:00
|
|
|
})
|