fix: undoing and redoing deleting procedures (#6722)

* fix: undoing and redoing deleting procedure defs

* chore: added tests for undoing and redoing procedure def deletes

* fix: dragging blocks from flyout

* chore: PR comments

* chore: fixup from rebase
This commit is contained in:
Beka Westberg
2023-01-07 00:02:45 +00:00
committed by GitHub
parent 23fb76b9f2
commit d27f7c81b4
3 changed files with 48 additions and 4 deletions

View File

@@ -1338,6 +1338,35 @@ suite('Procedures', function() {
chai.assert.isTrue(
callBlock2.disposed, 'Expected the second caller to be disposed');
});
test('undoing and redoing a procedure delete will still associate ' +
'procedure and caller with the same model',
function() {
const defBlock = createProcDefBlock(this.workspace);
createProcCallBlock(this.workspace);
// TODO: Apparently we need to call checkAndDelete to handle event
// grouping, this seems like possibly a bug.
const oldModel = defBlock.getProcedureModel();
defBlock.checkAndDelete();
this.clock.runAll();
this.workspace.undo();
this.clock.runAll();
const newDefBlock =
this.workspace.getBlocksByType('procedures_defnoreturn')[0];
const newCallBlock =
this.workspace.getBlocksByType('procedures_callnoreturn')[0];
chai.assert.equal(
newDefBlock.getProcedureModel(),
newCallBlock.getProcedureModel(),
'Expected both new blocks to be associated with the same model');
chai.assert.equal(
oldModel.getId(),
newDefBlock.getProcedureModel().getId(),
'Expected the new model to have the same ID as the old model');
});
});
suite('caller blocks creating new def blocks', function() {