Fix history initialization (#2115)

This commit is contained in:
David Luzar 2020-09-09 21:08:06 +02:00 committed by GitHub
parent 9cac7816cc
commit aaddde5dd9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 1052 additions and 48 deletions

View file

@ -451,10 +451,7 @@ describe("regression tests", () => {
});
it("noop interaction after undo shouldn't create history entry", () => {
// NOTE: this will fail if this test case is run in isolation. There's
// some leaking state or race conditions in initialization/teardown
// (couldn't figure out)
expect(API.getStateHistory().length).toBe(0);
expect(API.getStateHistory().length).toBe(1);
UI.clickTool("rectangle");
mouse.down(10, 10);
@ -468,35 +465,35 @@ describe("regression tests", () => {
const secondElementEndPoint = mouse.getPosition();
expect(API.getStateHistory().length).toBe(2);
expect(API.getStateHistory().length).toBe(3);
Keyboard.withModifierKeys({ ctrl: true }, () => {
Keyboard.keyPress("z");
});
expect(API.getStateHistory().length).toBe(1);
expect(API.getStateHistory().length).toBe(2);
// clicking an element shouldn't add to history
mouse.restorePosition(...firstElementEndPoint);
mouse.click();
expect(API.getStateHistory().length).toBe(1);
expect(API.getStateHistory().length).toBe(2);
Keyboard.withModifierKeys({ shift: true, ctrl: true }, () => {
Keyboard.keyPress("z");
});
expect(API.getStateHistory().length).toBe(2);
expect(API.getStateHistory().length).toBe(3);
// clicking an element shouldn't add to history
mouse.click();
expect(API.getStateHistory().length).toBe(2);
expect(API.getStateHistory().length).toBe(3);
const firstSelectedElementId = API.getSelectedElement().id;
// same for clicking the element just redo-ed
mouse.restorePosition(...secondElementEndPoint);
mouse.click();
expect(API.getStateHistory().length).toBe(2);
expect(API.getStateHistory().length).toBe(3);
expect(API.getSelectedElement().id).not.toEqual(firstSelectedElementId);
});