|
| 1 | +import { Point, VisEvent } from "../helpers"; |
| 2 | + |
| 3 | +const NETWORK_DATA = { |
| 4 | + nodes: [ |
| 5 | + { id: "N_1", label: "node 1", x: 0, y: 0 }, |
| 6 | + { id: "N_2", label: "node 2", x: 200, y: 0 }, |
| 7 | + { id: "N_3", label: "node 3", x: 0, y: 200 }, |
| 8 | + { id: "N_4", label: "node 4", x: -200, y: 0 }, |
| 9 | + { id: "N_5", label: "node 5", x: 0, y: -200 }, |
| 10 | + ], |
| 11 | + edges: [ |
| 12 | + { id: "E_1-2", label: "edge 1-2", from: "N_1", to: "N_2" }, |
| 13 | + { id: "E_1-3", label: "edge 1-3", from: "N_1", to: "N_3" }, |
| 14 | + { id: "E_1-4", label: "edge 1-4", from: "N_1", to: "N_4" }, |
| 15 | + { id: "E_1-5", label: "edge 1-5", from: "N_1", to: "N_5" }, |
| 16 | + |
| 17 | + { id: "E_2-3", label: "edge 2-3", from: "N_2", to: "N_3" }, |
| 18 | + { id: "E_3-4", label: "edge 3-4", from: "N_3", to: "N_4" }, |
| 19 | + { id: "E_4-5", label: "edge 4-5", from: "N_4", to: "N_5" }, |
| 20 | + { id: "E_5-2", label: "edge 5-2", from: "N_5", to: "N_2" }, |
| 21 | + ], |
| 22 | + physics: false, |
| 23 | +}; |
| 24 | + |
| 25 | +context("Drags", (): void => { |
| 26 | + it("Select one by click", function (): void { |
| 27 | + cy.visVisitUniversal(NETWORK_DATA); |
| 28 | + |
| 29 | + cy.visClickPoint({ x: 500 + 0, y: 500 + 0 }); |
| 30 | + cy.visAssertSelection({ |
| 31 | + nodes: ["N_1"], |
| 32 | + edges: ["E_1-2", "E_1-3", "E_1-4", "E_1-5"], |
| 33 | + }); |
| 34 | + |
| 35 | + cy.visClickPoint({ x: 500 + 200, y: 500 + 0 }); |
| 36 | + cy.visAssertSelection({ |
| 37 | + nodes: ["N_2"], |
| 38 | + edges: ["E_5-2", "E_1-2", "E_2-3"], |
| 39 | + }); |
| 40 | + }); |
| 41 | + |
| 42 | + it("Select none by single drag", function (): void { |
| 43 | + cy.visVisitUniversal(NETWORK_DATA); |
| 44 | + cy.visDrag([ |
| 45 | + { |
| 46 | + from: { x: 500 + 200 + 70, y: 500 + 200 - 70 }, |
| 47 | + to: { x: 500 + 200 - 70, y: 500 + 200 + 70 }, |
| 48 | + button: 0, |
| 49 | + shiftKey: true, |
| 50 | + }, |
| 51 | + ]); |
| 52 | + cy.visAssertSelection({ |
| 53 | + nodes: [], |
| 54 | + edges: [], |
| 55 | + }); |
| 56 | + }); |
| 57 | + |
| 58 | + it("Select one by single drag (TL to BR)", function (): void { |
| 59 | + cy.visVisitUniversal(NETWORK_DATA); |
| 60 | + cy.visDrag([ |
| 61 | + { |
| 62 | + from: { x: 500 + 0 - 70, y: 500 + 0 - 70 }, |
| 63 | + to: { x: 500 + 0 + 70, y: 500 + 0 + 70 }, |
| 64 | + button: 0, |
| 65 | + shiftKey: true, |
| 66 | + }, |
| 67 | + ]); |
| 68 | + cy.visAssertSelection({ |
| 69 | + nodes: ["N_1"], |
| 70 | + edges: ["E_1-2", "E_1-3", "E_1-4", "E_1-5"], |
| 71 | + }); |
| 72 | + }); |
| 73 | + |
| 74 | + it("Select three by single drag (BR to TL)", function (): void { |
| 75 | + cy.visVisitUniversal(NETWORK_DATA); |
| 76 | + cy.visDrag([ |
| 77 | + { |
| 78 | + from: { x: 500 + 200 + 70, y: 500 + 200 + 70 }, |
| 79 | + to: { x: 500 + 0 - 70, y: 500 + 0 - 70 }, |
| 80 | + button: 0, |
| 81 | + shiftKey: true, |
| 82 | + }, |
| 83 | + ]); |
| 84 | + cy.visAssertSelection({ |
| 85 | + nodes: ["N_1", "N_2", "N_3"], |
| 86 | + edges: ["E_1-2", "E_1-3", "E_1-4", "E_1-5", "E_3-4", "E_2-3", "E_5-2"], |
| 87 | + }); |
| 88 | + }); |
| 89 | + |
| 90 | + it("Select three by two drags (TR to BL then BL to TR)", function (): void { |
| 91 | + cy.visVisitUniversal(NETWORK_DATA); |
| 92 | + |
| 93 | + cy.visDrag([ |
| 94 | + { |
| 95 | + from: { x: 500 + 0 + 70, y: 500 + 0 - 70 }, |
| 96 | + to: { x: 500 + 0 - 70, y: 500 + 200 + 70 }, |
| 97 | + button: 0, |
| 98 | + shiftKey: true, |
| 99 | + }, |
| 100 | + ]); |
| 101 | + cy.visAssertSelection({ |
| 102 | + nodes: ["N_1", "N_3"], |
| 103 | + edges: ["E_1-2", "E_1-3", "E_1-4", "E_1-5", "E_3-4", "E_2-3"], |
| 104 | + }); |
| 105 | + |
| 106 | + cy.visDrag([ |
| 107 | + { |
| 108 | + from: { x: 500 + 200 - 70, y: 500 + 0 + 70 }, |
| 109 | + to: { x: 500 + 200 + 70, y: 500 + 0 - 70 }, |
| 110 | + button: 0, |
| 111 | + shiftKey: true, |
| 112 | + }, |
| 113 | + ]); |
| 114 | + cy.visAssertSelection({ |
| 115 | + nodes: ["N_1", "N_2", "N_3"], |
| 116 | + edges: ["E_1-2", "E_1-3", "E_1-4", "E_1-5", "E_3-4", "E_2-3", "E_5-2"], |
| 117 | + }); |
| 118 | + }); |
| 119 | +}); |
0 commit comments