-
-
Notifications
You must be signed in to change notification settings - Fork 372
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* test(e2e): add Cypress This includes three very simple tests (click the canvas, place a node, place two nodes and connect them with an edge). These should ensure that the library is not completely broken though they test only a small part of the library. * ci: run e2e tests in CI
- Loading branch information
Showing
17 changed files
with
2,033 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
context("Manipulation GUI", () => { | ||
beforeEach(() => { | ||
cy.visit("http://localhost:58253/cypress/pages/simple.html"); | ||
}); | ||
|
||
it("Add a node", () => { | ||
cy.visPlaceNode(101, 102); | ||
}); | ||
|
||
it("Add 2 nodes and 1 edge", () => { | ||
const a = { x: 101, y: 102 }; | ||
const b = { x: 201, y: 202 }; | ||
|
||
cy.visPlaceNode(a.x, a.y); | ||
cy.visPlaceNode(b.x, b.y); | ||
cy.visConnectNodes(a, b); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
context("Simple", () => { | ||
beforeEach(() => { | ||
cy.visit("http://localhost:58253/cypress/pages/simple.html"); | ||
}); | ||
|
||
it("Click the canvas", () => { | ||
const x = 101; | ||
const y = 102; | ||
|
||
cy.get("#mynetwork").click(x, y); | ||
|
||
cy.get("#events .click .pointer.DOM.x").should("have.text", "" + x); | ||
cy.get("#events .click .pointer.DOM.y").should("have.text", "" + y); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Vis Network | Cypress | Simple</title> | ||
|
||
<script | ||
type="text/javascript" | ||
src="../../standalone/umd/vis-network.min.js" | ||
></script> | ||
|
||
<style type="text/css"> | ||
html, | ||
body, | ||
#mynetwork { | ||
margin: 0px; | ||
padding: 0px; | ||
} | ||
|
||
#mynetwork { | ||
position: fixed; | ||
left: 0px; | ||
top: 0px; | ||
bottom: 0px; | ||
right: 50%; | ||
min-height: 100vh; | ||
border-right: 1px solid lightgray; | ||
background: white; | ||
} | ||
|
||
#text { | ||
position: absolute; | ||
left: 50%; | ||
padding: 1em; | ||
} | ||
|
||
#title { | ||
margin-bottom: 5em; | ||
} | ||
</style> | ||
|
||
<script | ||
type="text/javascript" | ||
src="../../../../dist/vis-network.min.js" | ||
></script> | ||
<link | ||
href="../../../../dist/vis-network.min.css" | ||
rel="stylesheet" | ||
type="text/css" | ||
/> | ||
</head> | ||
|
||
<body> | ||
<div id="text"> | ||
<div id="title"> | ||
<h1>Vis Network</h1> | ||
<h2>Cypress</h2> | ||
<h3>Simple</h3> | ||
</div> | ||
|
||
<div id="events"></div> | ||
</div> | ||
|
||
<div id="mynetwork"></div> | ||
<script type="text/javascript"> | ||
/* | ||
* create a network | ||
*/ | ||
const container = document.getElementById("mynetwork"); | ||
const data = { nodes: [], edges: [] }; | ||
const options = { | ||
manipulation: true, | ||
physics: false | ||
}; | ||
const network = new vis.Network(container, data, options); | ||
|
||
/* | ||
* Events | ||
*/ | ||
function add(root, names, content) { | ||
names = Array.isArray(names) ? names : [names]; | ||
|
||
const elem = document.createElement("pre"); | ||
elem.classList.add(...names); | ||
elem.innerText = content; | ||
|
||
root.appendChild(elem); | ||
} | ||
|
||
const root = document.getElementById("events"); | ||
["click"].forEach(eventName => { | ||
network.on(eventName, function(params) { | ||
console.log({ eventName, params }); | ||
|
||
const oldElem = root.querySelector(`#events > .${eventName}`); | ||
if (oldElem) { | ||
oldElem.parentNode.removeChild(oldElem); | ||
} | ||
|
||
const el = document.createElement("div"); | ||
el.classList.add(eventName); | ||
|
||
add(el, ["pointer", "DOM", "x"], params.pointer.DOM.x); | ||
add(el, ["pointer", "DOM", "y"], params.pointer.DOM.y); | ||
add(el, ["pointer", "canvas", "x"], params.pointer.canvas.x); | ||
add(el, ["pointer", "canvas", "y"], params.pointer.canvas.y); | ||
|
||
params.edges.forEach(edgeId => { | ||
add(el, ["edge", edgeId], edgeId); | ||
}); | ||
params.nodes.forEach(nodeId => { | ||
add(el, ["node", nodeId], nodeId); | ||
}); | ||
|
||
root.appendChild(el); | ||
}); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.