|
@@ -310,95 +310,4 @@ describe("flow chart navigation", () => {
|
|
|
Keyboard.keyUp(KEYS.ALT);
|
|
|
expect(h.state.selectedElementIds[rectangle.id]).toBe(true);
|
|
|
});
|
|
|
-
|
|
|
- it("take the most obvious link when possible", () => {
|
|
|
- /**
|
|
|
- * ▨ → ▨ ▨ → ▨
|
|
|
- * ↓ ↑
|
|
|
- * ▨ → ▨
|
|
|
- */
|
|
|
-
|
|
|
- API.clearSelection();
|
|
|
- const rectangle = API.createElement({
|
|
|
- type: "rectangle",
|
|
|
- width: 200,
|
|
|
- height: 100,
|
|
|
- });
|
|
|
-
|
|
|
- API.setElements([rectangle]);
|
|
|
- API.setSelectedElements([rectangle]);
|
|
|
-
|
|
|
- Keyboard.withModifierKeys({ ctrl: true }, () => {
|
|
|
- Keyboard.keyPress(KEYS.ARROW_RIGHT);
|
|
|
- });
|
|
|
- Keyboard.keyUp(KEYS.CTRL_OR_CMD);
|
|
|
-
|
|
|
- Keyboard.withModifierKeys({ ctrl: true }, () => {
|
|
|
- Keyboard.keyPress(KEYS.ARROW_DOWN);
|
|
|
- });
|
|
|
- Keyboard.keyUp(KEYS.CTRL_OR_CMD);
|
|
|
-
|
|
|
- Keyboard.withModifierKeys({ ctrl: true }, () => {
|
|
|
- Keyboard.keyPress(KEYS.ARROW_RIGHT);
|
|
|
- });
|
|
|
- Keyboard.keyUp(KEYS.CTRL_OR_CMD);
|
|
|
-
|
|
|
- Keyboard.withModifierKeys({ ctrl: true }, () => {
|
|
|
- Keyboard.keyPress(KEYS.ARROW_UP);
|
|
|
- });
|
|
|
- Keyboard.keyUp(KEYS.CTRL_OR_CMD);
|
|
|
-
|
|
|
- Keyboard.withModifierKeys({ ctrl: true }, () => {
|
|
|
- Keyboard.keyPress(KEYS.ARROW_RIGHT);
|
|
|
- });
|
|
|
- Keyboard.keyUp(KEYS.CTRL_OR_CMD);
|
|
|
-
|
|
|
- // last node should be the one that's selected
|
|
|
- const rightMostNode = h.elements[h.elements.length - 2];
|
|
|
- expect(rightMostNode.type).toBe("rectangle");
|
|
|
- expect(h.state.selectedElementIds[rightMostNode.id]).toBe(true);
|
|
|
-
|
|
|
- Keyboard.withModifierKeys({ alt: true }, () => {
|
|
|
- Keyboard.keyPress(KEYS.ARROW_LEFT);
|
|
|
- Keyboard.keyPress(KEYS.ARROW_LEFT);
|
|
|
- Keyboard.keyPress(KEYS.ARROW_LEFT);
|
|
|
- Keyboard.keyPress(KEYS.ARROW_LEFT);
|
|
|
- Keyboard.keyPress(KEYS.ARROW_LEFT);
|
|
|
- });
|
|
|
- Keyboard.keyUp(KEYS.ALT);
|
|
|
-
|
|
|
- expect(h.state.selectedElementIds[rectangle.id]).toBe(true);
|
|
|
-
|
|
|
- // going any direction takes us to the predecessor as well
|
|
|
- const predecessorToRightMostNode = h.elements[h.elements.length - 4];
|
|
|
- expect(predecessorToRightMostNode.type).toBe("rectangle");
|
|
|
-
|
|
|
- API.setSelectedElements([rightMostNode]);
|
|
|
- Keyboard.withModifierKeys({ alt: true }, () => {
|
|
|
- Keyboard.keyPress(KEYS.ARROW_RIGHT);
|
|
|
- });
|
|
|
- Keyboard.keyUp(KEYS.ALT);
|
|
|
- expect(h.state.selectedElementIds[rightMostNode.id]).not.toBe(true);
|
|
|
- expect(h.state.selectedElementIds[predecessorToRightMostNode.id]).toBe(
|
|
|
- true,
|
|
|
- );
|
|
|
- API.setSelectedElements([rightMostNode]);
|
|
|
- Keyboard.withModifierKeys({ alt: true }, () => {
|
|
|
- Keyboard.keyPress(KEYS.ARROW_UP);
|
|
|
- });
|
|
|
- Keyboard.keyUp(KEYS.ALT);
|
|
|
- expect(h.state.selectedElementIds[rightMostNode.id]).not.toBe(true);
|
|
|
- expect(h.state.selectedElementIds[predecessorToRightMostNode.id]).toBe(
|
|
|
- true,
|
|
|
- );
|
|
|
- API.setSelectedElements([rightMostNode]);
|
|
|
- Keyboard.withModifierKeys({ alt: true }, () => {
|
|
|
- Keyboard.keyPress(KEYS.ARROW_DOWN);
|
|
|
- });
|
|
|
- Keyboard.keyUp(KEYS.ALT);
|
|
|
- expect(h.state.selectedElementIds[rightMostNode.id]).not.toBe(true);
|
|
|
- expect(h.state.selectedElementIds[predecessorToRightMostNode.id]).toBe(
|
|
|
- true,
|
|
|
- );
|
|
|
- });
|
|
|
});
|