P4-01: commit feature tasks to document history

This commit is contained in:
2026-08-02 03:21:04 -04:00
parent 52b7236803
commit 91e6414d2d
3 changed files with 68 additions and 6 deletions

View File

@@ -71,3 +71,24 @@ test('document mutations use the facade history boundary', () => {
facade.history.redo()
assert.equal(facade.app.document.getActive().label, 'Untitled document')
})
test('Part Design feature tasks commit a document object and remain undoable', () => {
const facade = createMockFacade()
const before = facade.app.document.getActive()
facade.gui.command.execute({ commandId: 'pad' })
assert.equal(facade.task.getActive()?.commandId, 'pad')
facade.task.update({ length: 42, reversed: false })
facade.task.apply()
const committed = facade.app.document.getActive()
const created = committed.tree.find((item) => item.id === 'pad001')
assert.equal(created?.label, 'Pad')
assert.equal(committed.version, before.version + 1)
assert.equal(facade.selection.getObjectId(), 'pad001')
assert.equal(committed.dirty, true)
facade.history.undo()
assert.equal(facade.app.document.getActive().tree.some((item) => item.id === 'pad001'), false)
facade.history.redo()
assert.equal(facade.app.document.getActive().tree.some((item) => item.id === 'pad001'), true)
})