@nmfa wrote:
I'm adapting a test to test that the undo/redo functionality is working correctly, but whilst it works fine with manual testing I'm having trouble getting it to work automatically.
` it('check Analytics block moving ', () => {
const diagram: go.Diagram = component.getGoJSDiagramProvider().getGoJSDiagram();
console.log(diagram.undoManager.isEnabled);diagram.startTransaction('blockmove'); if (instanceOfAnalyticsCanvasModel(diagram.model)) { diagram.model.addBlock(testUtil.getAnalyticsBlock('MY_BLOCK'), new go.Point(20, 40)); let node: go.Node = testUtil.getBlockNode(diagram, 'MY_BLOCK'); expect(node.location.x).toBe(20); expect(node.location.y).toBe(40); // moving node node.moveTo(10, 15); node = testUtil.getBlockNode(diagram, 'MY_BLOCK'); expect(node.position.x).toBe(10); expect(node.position.y).toBe(15); console.log("HERE"); } diagram.commitTransaction('blockmove'); // Now check undo/redo fixture.detectChanges(); console.log(diagram.commandHandler.canUndo()); const undo: HTMLElement = document.getElementById('undo'); expect(undo).toBeTruthy(); expect(undo.classList.contains('disabled')).toBe(false); const redo: HTMLElement = document.getElementById('redo'); expect(redo).toBeTruthy(); expect(redo.classList.contains('disabled')).toBe(true); });`
The section between the transaction statements is the pre-existing test which works fine. The undoManager.isEnabled logs as true, as expected. However, the section after commitTransaction has canUndo() still false and the undo element still disabled. I'm not clear on why the diagram undo functionality isn't to be working.
GoJS 1.8.16, Windows 7
Posts: 2
Participants: 2