Discard provisional undo batches on graph replacement without replaying old document edits or clearing committed history. Reset failed preview controllers and refresh selected projections for plain-state SDK consumers while pausing inactive subscriptions. Cover the verified review findings with negative controls, fix static Vue host insertion, and preserve the shared exact renderer oracle with its independently verified sRGB selection color.
39 lines
976 B
TypeScript
39 lines
976 B
TypeScript
import { expect, test } from 'bun:test'
|
|
|
|
import { UndoManager } from '@open-pencil/scene-graph'
|
|
|
|
test('discarding nested batches preserves committed undo/redo without replay or notifications', () => {
|
|
let changes = 0
|
|
let replayed = 0
|
|
const undo = new UndoManager({
|
|
onChange: () => {
|
|
changes++
|
|
}
|
|
})
|
|
const noop = () => undefined
|
|
undo.push({ label: 'First', forward: noop, inverse: noop })
|
|
undo.push({ label: 'Second', forward: noop, inverse: noop })
|
|
undo.undo()
|
|
const pending = {
|
|
label: 'Pending',
|
|
forward: () => {
|
|
replayed++
|
|
},
|
|
inverse: () => {
|
|
replayed++
|
|
}
|
|
}
|
|
undo.beginBatch('Outer')
|
|
undo.push(pending)
|
|
undo.beginBatch('Inner')
|
|
undo.push(pending)
|
|
undo.discardBatches()
|
|
expect(undo.isBatching).toBe(false)
|
|
expect(replayed).toBe(0)
|
|
expect(changes).toBe(3)
|
|
expect(undo.undoLabel).toBe('First')
|
|
expect(undo.redoLabel).toBe('Second')
|
|
undo.commitBatch()
|
|
expect(undo.redo()).toBe('Second')
|
|
})
|