mirror of https://gitee.com/bigwinds/arangodb
setFromAndTo Test
This commit is contained in:
commit
618bc28a24
|
@ -5,7 +5,7 @@ require 'json'
|
|||
require 'arangodb.rb'
|
||||
|
||||
PREFIX = "api-general-graph"
|
||||
URLPREFIX = "/system/gharial"
|
||||
URLPREFIX = "/_api/gharial"
|
||||
|
||||
def drop_graph(graph_name)
|
||||
cmd = URLPREFIX + "/" + graph_name
|
||||
|
|
|
@ -206,6 +206,16 @@ namespace triagens {
|
|||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief set counters, used in replication client to transfer transactions
|
||||
/// between threads.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void setNumbers (int numberInScope, int numberActive) {
|
||||
_numberTrxInScope = numberInScope;
|
||||
_numberTrxActive = numberActive;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief assert that a transaction object is in scope in the current thread
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
"applications": "applications",
|
||||
"application/documentation/:key": "appDocumentation",
|
||||
"graph": "graphManagement",
|
||||
"graphManagement": "graphManagement",
|
||||
"userManagement": "userManagement",
|
||||
"userProfile": "userProfile",
|
||||
"logs": "logs"
|
||||
|
@ -211,22 +210,6 @@
|
|||
this.dashboardView.render();
|
||||
},
|
||||
|
||||
graph: function () {
|
||||
var self = this;
|
||||
if (!this.graphView) {
|
||||
this.graphView = new window.GraphView({
|
||||
graphs: new window.GraphCollection(),
|
||||
collection: this.arangoCollectionsStore
|
||||
});
|
||||
}
|
||||
this.arangoCollectionsStore.fetch({
|
||||
success: function () {
|
||||
self.graphView.render();
|
||||
self.naviView.selectMenuItem('graphviewer-menu');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
graphManagement: function () {
|
||||
if (!this.graphManagementView) {
|
||||
this.graphManagementView =
|
||||
|
@ -265,20 +248,9 @@
|
|||
if (this.dashboardView) {
|
||||
this.dashboardView.resize();
|
||||
}
|
||||
if (this.graphView) {
|
||||
this.graphView.handleResize($("#content").width());
|
||||
if (this.graphManagementView) {
|
||||
this.graphManagementView.handleResize($("#content").width());
|
||||
}
|
||||
/*
|
||||
var oldWidth = $('#content').width();
|
||||
var containerWidth = $(window).width() - 70;
|
||||
var spanWidth = 240;
|
||||
var divider = containerWidth / spanWidth;
|
||||
var roundDiv = parseInt(divider, 10);
|
||||
var newWidth = roundDiv * spanWidth - 2;
|
||||
if (newWidth !== oldWidth && this.graphView) {
|
||||
this.graphView.handleResize(newWidth);
|
||||
}
|
||||
*/
|
||||
},
|
||||
|
||||
userManagement: function () {
|
||||
|
|
|
@ -42,12 +42,21 @@
|
|||
}, true);
|
||||
},
|
||||
|
||||
handleResize: function(w) {
|
||||
if (!this.width || this.width !== w) {
|
||||
this.width = w;
|
||||
if (this.ui) {
|
||||
this.ui.changeWidth(w);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
addNewGraph: function(e) {
|
||||
e.preventDefault();
|
||||
this.createEditGraphModal();
|
||||
},
|
||||
|
||||
deleteGraph: function(e) {
|
||||
deleteGraph: function() {
|
||||
var self = this;
|
||||
var name = $("#editGraphName")[0].value;
|
||||
this.collection.get(name).destroy({
|
||||
|
@ -144,7 +153,6 @@
|
|||
editedVertexCollections = _.pluck($('#newVertexCollections').select2("data"), "text"),
|
||||
edgeDefinitions = [],
|
||||
newEdgeDefinitions = {},
|
||||
self = this,
|
||||
collection,
|
||||
from,
|
||||
to,
|
||||
|
|
|
@ -31,6 +31,7 @@ div.resizecontainer {
|
|||
}
|
||||
|
||||
@for $i from 1 through 11 {
|
||||
$white-space: 10px;
|
||||
$min: $tile-width * $i;
|
||||
$content-size: $min - 12px;
|
||||
|
||||
|
@ -138,7 +139,7 @@ div.resizecontainer {
|
|||
$dashboard-height: 400px;
|
||||
}
|
||||
|
||||
@media (min-width: $min) and (max-width: $min + $tile-width - 1) {
|
||||
@media (min-width: $min + $white-space) and (max-width: $min + $tile-width - 1 + $white-space) {
|
||||
div.resizecontainer {
|
||||
width: $content-size;
|
||||
}
|
||||
|
|
|
@ -1449,9 +1449,9 @@ nav.navbar, footer.footer {
|
|||
background-color: #f87c0f; }
|
||||
|
||||
.button-inactive {
|
||||
background-color: lightgray; }
|
||||
background-color: lightgrey; }
|
||||
.button-inactive:hover, .button-inactive:focus {
|
||||
background-color: gray; }
|
||||
background-color: grey; }
|
||||
|
||||
ul.link-dropdown-menu, ul.user-dropdown-menu, ul.gv-dropdown-menu {
|
||||
-moz-border-radius: 3px;
|
||||
|
@ -2111,7 +2111,7 @@ div.resizecontainer {
|
|||
@media (min-width: 1042px) and (max-width: 1284px) {
|
||||
#arangoCollectionUl a {
|
||||
font-size: 14px; } }
|
||||
@media (min-width: 240px) and (max-width: 479px) {
|
||||
@media (min-width: 250px) and (max-width: 489px) {
|
||||
div.resizecontainer {
|
||||
width: 228px; }
|
||||
|
||||
|
@ -2292,7 +2292,7 @@ div.resizecontainer {
|
|||
font-size: 10px;
|
||||
height: 100px;
|
||||
width: 0; } }
|
||||
@media (min-width: 480px) and (max-width: 719px) {
|
||||
@media (min-width: 490px) and (max-width: 729px) {
|
||||
div.resizecontainer {
|
||||
width: 468px; }
|
||||
|
||||
|
@ -2473,7 +2473,7 @@ div.resizecontainer {
|
|||
font-size: 10px;
|
||||
height: 100px;
|
||||
width: 0; } }
|
||||
@media (min-width: 720px) and (max-width: 959px) {
|
||||
@media (min-width: 730px) and (max-width: 969px) {
|
||||
div.resizecontainer {
|
||||
width: 708px; }
|
||||
|
||||
|
@ -2654,7 +2654,7 @@ div.resizecontainer {
|
|||
font-size: 10px;
|
||||
height: 100px;
|
||||
width: 0; } }
|
||||
@media (min-width: 960px) and (max-width: 1199px) {
|
||||
@media (min-width: 970px) and (max-width: 1209px) {
|
||||
div.resizecontainer {
|
||||
width: 948px; }
|
||||
|
||||
|
@ -2832,7 +2832,7 @@ div.resizecontainer {
|
|||
font-size: 11px;
|
||||
height: 117.5px;
|
||||
width: 60px; } }
|
||||
@media (min-width: 1200px) and (max-width: 1439px) {
|
||||
@media (min-width: 1210px) and (max-width: 1449px) {
|
||||
div.resizecontainer {
|
||||
width: 1188px; }
|
||||
|
||||
|
@ -3010,7 +3010,7 @@ div.resizecontainer {
|
|||
font-size: 12px;
|
||||
height: 135px;
|
||||
width: 65px; } }
|
||||
@media (min-width: 1440px) and (max-width: 1679px) {
|
||||
@media (min-width: 1450px) and (max-width: 1689px) {
|
||||
div.resizecontainer {
|
||||
width: 1428px; }
|
||||
|
||||
|
@ -3188,7 +3188,7 @@ div.resizecontainer {
|
|||
font-size: 13px;
|
||||
height: 150px;
|
||||
width: 70px; } }
|
||||
@media (min-width: 1680px) and (max-width: 1919px) {
|
||||
@media (min-width: 1690px) and (max-width: 1929px) {
|
||||
div.resizecontainer {
|
||||
width: 1668px; }
|
||||
|
||||
|
@ -3366,7 +3366,7 @@ div.resizecontainer {
|
|||
font-size: 14px;
|
||||
height: 170px;
|
||||
width: 80px; } }
|
||||
@media (min-width: 1920px) and (max-width: 2159px) {
|
||||
@media (min-width: 1930px) and (max-width: 2169px) {
|
||||
div.resizecontainer {
|
||||
width: 1908px; }
|
||||
|
||||
|
@ -3544,7 +3544,7 @@ div.resizecontainer {
|
|||
font-size: 15px;
|
||||
height: 200px;
|
||||
width: 85px; } }
|
||||
@media (min-width: 2160px) and (max-width: 2399px) {
|
||||
@media (min-width: 2170px) and (max-width: 2409px) {
|
||||
div.resizecontainer {
|
||||
width: 2148px; }
|
||||
|
||||
|
@ -3722,7 +3722,7 @@ div.resizecontainer {
|
|||
font-size: 15px;
|
||||
height: 150px;
|
||||
width: 70px; } }
|
||||
@media (min-width: 2400px) and (max-width: 2639px) {
|
||||
@media (min-width: 2410px) and (max-width: 2649px) {
|
||||
div.resizecontainer {
|
||||
width: 2388px; }
|
||||
|
||||
|
@ -3900,7 +3900,7 @@ div.resizecontainer {
|
|||
font-size: 15px;
|
||||
height: 150px;
|
||||
width: 70px; } }
|
||||
@media (min-width: 2640px) and (max-width: 2879px) {
|
||||
@media (min-width: 2650px) and (max-width: 2889px) {
|
||||
div.resizecontainer {
|
||||
width: 2628px; }
|
||||
|
||||
|
@ -4672,7 +4672,7 @@ pre.gv-object-view {
|
|||
width: 5%; }
|
||||
|
||||
.user-menu-img {
|
||||
background-color: lightgray;
|
||||
background-color: lightgrey;
|
||||
-moz-border-radius: 3px;
|
||||
-webkit-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
|
@ -5359,7 +5359,7 @@ pre.gv-object-view {
|
|||
color: #66ff00; }
|
||||
|
||||
.jqconsole-cursor {
|
||||
background-color: gray; }
|
||||
background-color: grey; }
|
||||
|
||||
.jqconsole-blurred .jqconsole-header .jqconsole-cursor {
|
||||
color: #c4cccc; }
|
||||
|
|
|
@ -562,7 +562,7 @@
|
|||
});
|
||||
|
||||
it("should handle resizing", function () {
|
||||
r.graphView = graphDummy;
|
||||
r.graphManagementView = graphDummy;
|
||||
r.dashboardView = dashboardDummy;
|
||||
spyOn(graphDummy, "handleResize");
|
||||
spyOn(dashboardDummy, "resize");
|
||||
|
@ -654,15 +654,6 @@
|
|||
);
|
||||
});
|
||||
|
||||
it("should route to the graph management tab", function () {
|
||||
simpleNavigationCheck(
|
||||
"graphManagement",
|
||||
"GraphManagementView",
|
||||
"graphviewer-menu",
|
||||
{ collection: graphsDummy ,
|
||||
collectionCollection : { id : 'store', fetch : jasmine.any(Function) } }
|
||||
);
|
||||
});
|
||||
|
||||
it("should route to the applications tab", function () {
|
||||
simpleNavigationCheck(
|
||||
|
|
|
@ -4,494 +4,352 @@
|
|||
/*global GraphManagementView, _, jasmine, $*/
|
||||
|
||||
(function () {
|
||||
"use strict";
|
||||
"use strict";
|
||||
|
||||
describe("Graph Management View", function () {
|
||||
describe("Graph Management View", function () {
|
||||
|
||||
var view,
|
||||
div,
|
||||
modalDiv,
|
||||
graphs,
|
||||
collections,
|
||||
e1, e2, e3,
|
||||
f1, f2, f3,
|
||||
t1, t2, t3,
|
||||
o1, o2, o3,
|
||||
sys1, cols;
|
||||
var view,
|
||||
div,
|
||||
modalDiv,
|
||||
graphs,
|
||||
collections,
|
||||
e1, e2, e3,
|
||||
f1, f2, f3,
|
||||
t1, t2, t3,
|
||||
o1, o2, o3,
|
||||
sys1, cols;
|
||||
|
||||
beforeEach(function () {
|
||||
modalDiv = document.createElement("div");
|
||||
modalDiv.id = "modalPlaceholder";
|
||||
document.body.appendChild(modalDiv);
|
||||
window.modalView = new window.ModalView();
|
||||
collections = new window.arangoCollections(cols);
|
||||
graphs = new window.GraphCollection();
|
||||
div = document.createElement("div");
|
||||
div.id = "content";
|
||||
document.body.appendChild(div);
|
||||
view = new window.GraphManagementView({
|
||||
collection: graphs,
|
||||
collectionCollection: new window.arangoCollections()
|
||||
});
|
||||
beforeEach(function () {
|
||||
modalDiv = document.createElement("div");
|
||||
modalDiv.id = "modalPlaceholder";
|
||||
document.body.appendChild(modalDiv);
|
||||
window.modalView = new window.ModalView();
|
||||
collections = new window.arangoCollections(cols);
|
||||
graphs = new window.GraphCollection();
|
||||
div = document.createElement("div");
|
||||
div.id = "content";
|
||||
document.body.appendChild(div);
|
||||
view = new window.GraphManagementView({
|
||||
collection: graphs,
|
||||
collectionCollection: new window.arangoCollections()
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
document.body.removeChild(div);
|
||||
document.body.removeChild(modalDiv);
|
||||
});
|
||||
|
||||
it("should fetch the graphs on render", function () {
|
||||
spyOn(graphs, "fetch");
|
||||
view.render();
|
||||
expect(graphs.fetch).toHaveBeenCalledWith({async: false});
|
||||
});
|
||||
|
||||
|
||||
describe("after rendering", function () {
|
||||
|
||||
var g1, g2, g3;
|
||||
|
||||
beforeEach(function () {
|
||||
g1 = {
|
||||
_id: "_graphs/g1",
|
||||
_key: "g1",
|
||||
_rev: "123",
|
||||
edgeDefinitions: [
|
||||
{
|
||||
collection: e1,
|
||||
from: ["f1"],
|
||||
to: ["t1"]
|
||||
|
||||
}
|
||||
],
|
||||
orphanCollections: ["o1"]
|
||||
};
|
||||
g2 = {
|
||||
_id: "_graphs/g2",
|
||||
_key: "g2",
|
||||
_rev: "321",
|
||||
edgeDefinitions: [
|
||||
{
|
||||
collection: e2,
|
||||
from: ["f2"],
|
||||
to: ["t2"]
|
||||
|
||||
}
|
||||
],
|
||||
orphanCollections: ["o2"]
|
||||
};
|
||||
g3 = {
|
||||
_id: "_graphs/g3",
|
||||
_key: "g3",
|
||||
_rev: "111",
|
||||
edgeDefinitions: [
|
||||
{
|
||||
collection: e3,
|
||||
from: ["f3"],
|
||||
to: ["t3"]
|
||||
|
||||
}
|
||||
],
|
||||
orphanCollections: ["o3"]
|
||||
};
|
||||
spyOn(graphs, "fetch");
|
||||
graphs.add(g1);
|
||||
graphs.add(g2);
|
||||
graphs.add(g3);
|
||||
view.render();
|
||||
});
|
||||
|
||||
it("should set to and from for added definition", function () {
|
||||
view.removedECollList = [];
|
||||
var model = view.collection.create({
|
||||
_key: "blub",
|
||||
name: "blub",
|
||||
edgeDefinitions: [{
|
||||
collection: "blub",
|
||||
from: ["bla"],
|
||||
to: ["blob"]
|
||||
}],
|
||||
orphanCollections: []
|
||||
});
|
||||
var e = {
|
||||
currentTarget: {
|
||||
id: "blabalblub"
|
||||
},
|
||||
stopPropagation : function () {},
|
||||
added : {
|
||||
id : "moppel"
|
||||
|
||||
afterEach(function () {
|
||||
document.body.removeChild(div);
|
||||
document.body.removeChild(modalDiv);
|
||||
},
|
||||
val : "newEdgeDefintion"
|
||||
},
|
||||
a = {
|
||||
select2: function () {},
|
||||
attr: function () {},
|
||||
length : 2,
|
||||
0 : {id : 1},
|
||||
1 : {id : 2}
|
||||
},collReturn = {
|
||||
destroy : function (a) {
|
||||
a.error("", {responseText : '{"errorMessage" : "errorMessage"}'});
|
||||
}
|
||||
};
|
||||
|
||||
spyOn(e, "stopPropagation");
|
||||
|
||||
spyOn(window, "$").andReturn(a);
|
||||
|
||||
spyOn(window.modalView, "hide").andReturn(a);
|
||||
|
||||
view.setFromAndTo(e);
|
||||
|
||||
expect(e.stopPropagation).toHaveBeenCalled();
|
||||
|
||||
model.destroy();
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
it("should set to and from for added definition for already known def", function () {
|
||||
view.removedECollList = [];
|
||||
var model = view.collection.create({
|
||||
_key: "blub2",
|
||||
name: "blub2",
|
||||
edgeDefinitions: [{
|
||||
collection: "blub",
|
||||
from: ["bla"],
|
||||
to: ["blob"]
|
||||
}],
|
||||
orphanCollections: []
|
||||
});
|
||||
var e = {
|
||||
currentTarget: {
|
||||
id: "blabalblub"
|
||||
},
|
||||
stopPropagation : function () {},
|
||||
added : {
|
||||
id : "moppel"
|
||||
|
||||
it("should fetch the graphs on render", function () {
|
||||
spyOn(graphs, "fetch");
|
||||
view.render();
|
||||
expect(graphs.fetch).toHaveBeenCalledWith({async: false});
|
||||
},
|
||||
val : "blub"
|
||||
},
|
||||
a = {
|
||||
select2: function () {},
|
||||
attr: function () {},
|
||||
length : 2,
|
||||
0 : {id : 1},
|
||||
1 : {id : 2}
|
||||
},collReturn = {
|
||||
destroy : function (a) {
|
||||
a.error("", {responseText : '{"errorMessage" : "errorMessage"}'});
|
||||
}
|
||||
};
|
||||
|
||||
spyOn(e, "stopPropagation");
|
||||
|
||||
spyOn(window, "$").andReturn(a);
|
||||
|
||||
spyOn(window.modalView, "hide").andReturn(a);
|
||||
|
||||
view.setFromAndTo(e);
|
||||
|
||||
expect(e.stopPropagation).toHaveBeenCalled();
|
||||
|
||||
model.destroy();
|
||||
|
||||
|
||||
});
|
||||
|
||||
it("should not set to and from for added definition as already in use and has been entered manually", function () {
|
||||
view.removedECollList = ["moppel"];
|
||||
var model = view.collection.create({
|
||||
_key: "blub2",
|
||||
name: "blub2",
|
||||
edgeDefinitions: [{
|
||||
collection: "blub",
|
||||
from: ["bla"],
|
||||
to: ["blob"]
|
||||
}],
|
||||
orphanCollections: []
|
||||
});
|
||||
var e = {
|
||||
currentTarget: {
|
||||
id: "blabalblub"
|
||||
},
|
||||
stopPropagation : function () {},
|
||||
added : {
|
||||
id : "moppel"
|
||||
|
||||
describe("after rendering", function () {
|
||||
},
|
||||
val : "blub"
|
||||
},
|
||||
a = {
|
||||
select2: function () {},
|
||||
attr: function () {},
|
||||
length : 2,
|
||||
0 : {id : 1},
|
||||
1 : {id : 2}
|
||||
},collReturn = {
|
||||
destroy : function (a) {
|
||||
a.error("", {responseText : '{"errorMessage" : "errorMessage"}'});
|
||||
}
|
||||
};
|
||||
|
||||
var g1, g2, g3;
|
||||
spyOn(e, "stopPropagation");
|
||||
|
||||
beforeEach(function () {
|
||||
g1 = {
|
||||
_id: "_graphs/g1",
|
||||
_key: "g1",
|
||||
_rev: "123",
|
||||
edgeDefinitions:
|
||||
[
|
||||
{
|
||||
collection: e1,
|
||||
from: ["f1"],
|
||||
to: ["t1"]
|
||||
spyOn(window, "$").andReturn(a);
|
||||
|
||||
}
|
||||
],
|
||||
orphanCollections: ["o1"]
|
||||
};
|
||||
g2 = {
|
||||
_id: "_graphs/g2",
|
||||
_key: "g2",
|
||||
_rev: "321",
|
||||
edgeDefinitions:
|
||||
[
|
||||
{
|
||||
collection: e2,
|
||||
from: ["f2"],
|
||||
to: ["t2"]
|
||||
spyOn(window.modalView, "hide").andReturn(a);
|
||||
|
||||
}
|
||||
],
|
||||
orphanCollections: ["o2"]
|
||||
};
|
||||
g3 = {
|
||||
_id: "_graphs/g3",
|
||||
_key: "g3",
|
||||
_rev: "111",
|
||||
edgeDefinitions:
|
||||
[
|
||||
{
|
||||
collection: e3,
|
||||
from: ["f3"],
|
||||
to: ["t3"]
|
||||
view.setFromAndTo(e);
|
||||
|
||||
}
|
||||
],
|
||||
orphanCollections: ["o3"]
|
||||
};
|
||||
spyOn(graphs, "fetch");
|
||||
graphs.add(g1);
|
||||
graphs.add(g2);
|
||||
graphs.add(g3);
|
||||
view.render();
|
||||
});
|
||||
expect(e.stopPropagation).toHaveBeenCalled();
|
||||
|
||||
it("should create a sorted list of all graphs", function () {
|
||||
var list = $("div.tile h5.collectionName", "#graphManagementThumbnailsIn");
|
||||
expect(list.length).toEqual(3);
|
||||
// Order would be g2, g3, g1
|
||||
expect($(list[0]).html()).toEqual(g1._key);
|
||||
expect($(list[1]).html()).toEqual(g2._key);
|
||||
expect($(list[2]).html()).toEqual(g3._key);
|
||||
});
|
||||
model.destroy();
|
||||
|
||||
|
||||
it("should loadGraphViewer", function () {
|
||||
var e = {
|
||||
currentTarget: {
|
||||
id: "blabalblub"
|
||||
}
|
||||
},
|
||||
a = {
|
||||
attr: function (x) {
|
||||
return "blabalblub";
|
||||
},
|
||||
width : function () {
|
||||
return 100
|
||||
},
|
||||
html : function () {
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
spyOn(window, "GraphViewerUI");
|
||||
it("should not set to and from for removed definition as already in use and has been entered manually", function () {
|
||||
view.removedECollList = ["moppel"];
|
||||
var model = view.collection.create({
|
||||
_key: "blub2",
|
||||
name: "blub2",
|
||||
edgeDefinitions: [{
|
||||
collection: "blub",
|
||||
from: ["bla"],
|
||||
to: ["blob"]
|
||||
}],
|
||||
orphanCollections: []
|
||||
});
|
||||
var e = {
|
||||
currentTarget: {
|
||||
id: "blabalblub"
|
||||
},
|
||||
stopPropagation : function () {},
|
||||
val : "blub",
|
||||
removed : {id : "moppel"}
|
||||
},
|
||||
a = {
|
||||
select2: function () {},
|
||||
attr: function () {},
|
||||
length : 2,
|
||||
0 : {id : 1},
|
||||
1 : {id : 2}
|
||||
},collReturn = {
|
||||
destroy : function (a) {
|
||||
a.error("", {responseText : '{"errorMessage" : "errorMessage"}'});
|
||||
}
|
||||
};
|
||||
|
||||
spyOn(window, "$").andReturn(a);
|
||||
spyOn(e, "stopPropagation");
|
||||
|
||||
spyOn(window, "$").andReturn(a);
|
||||
|
||||
spyOn(window.modalView, "hide").andReturn(a);
|
||||
|
||||
view.setFromAndTo(e);
|
||||
|
||||
expect(e.stopPropagation).toHaveBeenCalled();
|
||||
expect(view.removedECollList.indexOf("moppel")).toEqual(-1)
|
||||
expect(view.eCollList.indexOf("moppel")).not.toEqual(-1)
|
||||
model.destroy();
|
||||
|
||||
|
||||
view.loadGraphViewer(e);
|
||||
});
|
||||
|
||||
expect(window.GraphViewerUI).toHaveBeenCalledWith(
|
||||
undefined,
|
||||
it("should create a sorted list of all graphs", function () {
|
||||
var list = $("div.tile h5.collectionName", "#graphManagementThumbnailsIn");
|
||||
expect(list.length).toEqual(3);
|
||||
// Order would be g2, g3, g1
|
||||
expect($(list[0]).html()).toEqual(g1._key);
|
||||
expect($(list[1]).html()).toEqual(g2._key);
|
||||
expect($(list[2]).html()).toEqual(g3._key);
|
||||
});
|
||||
|
||||
describe("creating a new graph", function () {
|
||||
|
||||
it("should create a new empty graph", function () {
|
||||
runs(function () {
|
||||
$("#createGraph").click();
|
||||
});
|
||||
waitsFor(function () {
|
||||
return $("#modal-dialog").css("display") === "block";
|
||||
});
|
||||
runs(function () {
|
||||
$("#createNewGraphName").val("newGraph");
|
||||
$("#s2id_newEdgeDefinitions0").select2("val", ["newEdgeCol"]);
|
||||
$("#s2id_fromCollections0").select2("val", ["newFrom1", "newFrom2"]);
|
||||
$("#s2id_toCollections0").select2("val", ["newTo1", "newTo2"]);
|
||||
$("#s2id_newVertexCollections").select2("val", ["newOrphan1", "newOrphan2"]);
|
||||
$("#newGraphEdges").val("newEdges");
|
||||
spyOn($, "ajax").andCallFake(function (opts) {
|
||||
expect(opts.type).toEqual("POST");
|
||||
expect(opts.url).toEqual("/_api/gharial");
|
||||
expect(opts.data).toEqual(JSON.stringify(
|
||||
{
|
||||
type : 'gharial',
|
||||
graphName : 'blaba',
|
||||
baseUrl : '/_db/_system/'
|
||||
}, 25, 680,
|
||||
{
|
||||
nodeShaper :
|
||||
{
|
||||
label : '_key',
|
||||
color : { type : 'attribute', key : '_key' }
|
||||
}
|
||||
}, true
|
||||
);
|
||||
"name": "newGraph",
|
||||
"edgeDefinitions": [
|
||||
{
|
||||
collection: "newEdgeCol",
|
||||
from: ["newFrom1", "newFrom2"],
|
||||
to: ["newTo1", "newTo2"]
|
||||
}
|
||||
],
|
||||
"orphanCollections": ["newOrphan1", "newOrphan2"]
|
||||
}));
|
||||
});
|
||||
|
||||
it("should delete graph", function () {
|
||||
var e = {
|
||||
currentTarget: {
|
||||
id: "blabalblub"
|
||||
}
|
||||
},
|
||||
a = [{
|
||||
value: "blabalblub"
|
||||
}],collReturn = {
|
||||
destroy : function (a) {
|
||||
a.success();
|
||||
}
|
||||
};
|
||||
|
||||
spyOn(graphs, "get").andReturn(collReturn);
|
||||
|
||||
spyOn(window, "$").andReturn(a);
|
||||
|
||||
spyOn(window.modalView, "hide").andReturn(a);
|
||||
|
||||
view.deleteGraph(e);
|
||||
|
||||
expect(graphs.get).toHaveBeenCalledWith("blabalblub");
|
||||
expect(window.modalView.hide).toHaveBeenCalled();
|
||||
$("#modalButton1").click();
|
||||
expect($.ajax).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should NOT delete graph", function () {
|
||||
var e = {
|
||||
currentTarget: {
|
||||
id: "blabalblub"
|
||||
}
|
||||
},
|
||||
a = [{
|
||||
value: "blabalblub"
|
||||
}],collReturn = {
|
||||
destroy : function (a) {
|
||||
a.error("", {responseText : '{"errorMessage" : "errorMessage"}'});
|
||||
}
|
||||
};
|
||||
|
||||
spyOn(graphs, "get").andReturn(collReturn);
|
||||
|
||||
spyOn(window, "$").andReturn(a);
|
||||
spyOn(arangoHelper, "arangoError");
|
||||
|
||||
spyOn(window.modalView, "hide").andReturn(a);
|
||||
|
||||
view.deleteGraph(e);
|
||||
|
||||
expect(graphs.get).toHaveBeenCalledWith("blabalblub");
|
||||
expect(arangoHelper.arangoError).toHaveBeenCalledWith("errorMessage");
|
||||
expect(window.modalView.hide).toHaveBeenCalled();
|
||||
|
||||
|
||||
});
|
||||
|
||||
it("should set to and from for added definition", function () {
|
||||
view.removedECollList = [];
|
||||
var model = view.collection.create({
|
||||
_key: "blub",
|
||||
name: "blub",
|
||||
edgeDefinitions: [{
|
||||
collection: "blub",
|
||||
from: ["bla"],
|
||||
to: ["blob"]
|
||||
}],
|
||||
orphanCollections: []
|
||||
});
|
||||
var e = {
|
||||
currentTarget: {
|
||||
id: "blabalblub"
|
||||
},
|
||||
stopPropagation : function () {},
|
||||
added : {
|
||||
id : "moppel"
|
||||
|
||||
},
|
||||
val : "newEdgeDefintion"
|
||||
},
|
||||
a = {
|
||||
select2: function () {},
|
||||
attr: function () {},
|
||||
length : 2,
|
||||
0 : {id : 1},
|
||||
1 : {id : 2}
|
||||
},collReturn = {
|
||||
destroy : function (a) {
|
||||
a.error("", {responseText : '{"errorMessage" : "errorMessage"}'});
|
||||
}
|
||||
};
|
||||
|
||||
spyOn(e, "stopPropagation");
|
||||
|
||||
spyOn(window, "$").andReturn(a);
|
||||
|
||||
spyOn(window.modalView, "hide").andReturn(a);
|
||||
|
||||
view.setFromAndTo(e);
|
||||
|
||||
expect(e.stopPropagation).toHaveBeenCalled();
|
||||
|
||||
model.destroy();
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
it("should set to and from for added definition for already known def", function () {
|
||||
view.removedECollList = [];
|
||||
var model = view.collection.create({
|
||||
_key: "blub2",
|
||||
name: "blub2",
|
||||
edgeDefinitions: [{
|
||||
collection: "blub",
|
||||
from: ["bla"],
|
||||
to: ["blob"]
|
||||
}],
|
||||
orphanCollections: []
|
||||
});
|
||||
var e = {
|
||||
currentTarget: {
|
||||
id: "blabalblub"
|
||||
},
|
||||
stopPropagation : function () {},
|
||||
added : {
|
||||
id : "moppel"
|
||||
|
||||
},
|
||||
val : "blub"
|
||||
},
|
||||
a = {
|
||||
select2: function () {},
|
||||
attr: function () {},
|
||||
length : 2,
|
||||
0 : {id : 1},
|
||||
1 : {id : 2}
|
||||
},collReturn = {
|
||||
destroy : function (a) {
|
||||
a.error("", {responseText : '{"errorMessage" : "errorMessage"}'});
|
||||
}
|
||||
};
|
||||
|
||||
spyOn(e, "stopPropagation");
|
||||
|
||||
spyOn(window, "$").andReturn(a);
|
||||
|
||||
spyOn(window.modalView, "hide").andReturn(a);
|
||||
|
||||
view.setFromAndTo(e);
|
||||
|
||||
expect(e.stopPropagation).toHaveBeenCalled();
|
||||
|
||||
model.destroy();
|
||||
|
||||
|
||||
});
|
||||
|
||||
it("should not set to and from for added definition as already in use and has been entered manually", function () {
|
||||
view.removedECollList = ["moppel"];
|
||||
var model = view.collection.create({
|
||||
_key: "blub2",
|
||||
name: "blub2",
|
||||
edgeDefinitions: [{
|
||||
collection: "blub",
|
||||
from: ["bla"],
|
||||
to: ["blob"]
|
||||
}],
|
||||
orphanCollections: []
|
||||
});
|
||||
var e = {
|
||||
currentTarget: {
|
||||
id: "blabalblub"
|
||||
},
|
||||
stopPropagation : function () {},
|
||||
added : {
|
||||
id : "moppel"
|
||||
|
||||
},
|
||||
val : "blub"
|
||||
},
|
||||
a = {
|
||||
select2: function () {},
|
||||
attr: function () {},
|
||||
length : 2,
|
||||
0 : {id : 1},
|
||||
1 : {id : 2}
|
||||
},collReturn = {
|
||||
destroy : function (a) {
|
||||
a.error("", {responseText : '{"errorMessage" : "errorMessage"}'});
|
||||
}
|
||||
};
|
||||
|
||||
spyOn(e, "stopPropagation");
|
||||
|
||||
spyOn(window, "$").andReturn(a);
|
||||
|
||||
spyOn(window.modalView, "hide").andReturn(a);
|
||||
|
||||
view.setFromAndTo(e);
|
||||
|
||||
expect(e.stopPropagation).toHaveBeenCalled();
|
||||
|
||||
model.destroy();
|
||||
|
||||
|
||||
});
|
||||
|
||||
it("should not set to and from for removed definition as already in use and has been entered manually", function () {
|
||||
view.removedECollList = ["moppel"];
|
||||
var model = view.collection.create({
|
||||
_key: "blub2",
|
||||
name: "blub2",
|
||||
edgeDefinitions: [{
|
||||
collection: "blub",
|
||||
from: ["bla"],
|
||||
to: ["blob"]
|
||||
}],
|
||||
orphanCollections: []
|
||||
});
|
||||
var e = {
|
||||
currentTarget: {
|
||||
id: "blabalblub"
|
||||
},
|
||||
stopPropagation : function () {},
|
||||
val : "blub",
|
||||
removed : {id : "moppel"}
|
||||
},
|
||||
a = {
|
||||
select2: function () {},
|
||||
attr: function () {},
|
||||
length : 2,
|
||||
0 : {id : 1},
|
||||
1 : {id : 2}
|
||||
},collReturn = {
|
||||
destroy : function (a) {
|
||||
a.error("", {responseText : '{"errorMessage" : "errorMessage"}'});
|
||||
}
|
||||
};
|
||||
|
||||
spyOn(e, "stopPropagation");
|
||||
|
||||
spyOn(window, "$").andReturn(a);
|
||||
|
||||
spyOn(window.modalView, "hide").andReturn(a);
|
||||
|
||||
view.setFromAndTo(e);
|
||||
|
||||
expect(e.stopPropagation).toHaveBeenCalled();
|
||||
expect(view.removedECollList.indexOf("moppel")).toEqual(-1)
|
||||
expect(view.eCollList.indexOf("moppel")).not.toEqual(-1)
|
||||
model.destroy();
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
/*setFromAndTo : function (e) {
|
||||
e.stopPropagation();
|
||||
var map = this.calculateEdgeDefinitionMap(), id, i, tmp;
|
||||
|
||||
if (e.added) {
|
||||
if (this.eCollList.indexOf(e.added.id) === -1 &&
|
||||
this.removedECollList.indexOf(e.added.id) !== -1) {
|
||||
id = e.currentTarget.id.split("row_newEdgeDefinitions")[1];
|
||||
$('input[id*="newEdgeDefinitions' + id + '"]').select2("val", null);
|
||||
$('input[id*="newEdgeDefinitions' + id + '"]').attr(
|
||||
"placeholder","The collection "+ e.added.id + " is already used."
|
||||
);
|
||||
return;
|
||||
}
|
||||
this.removedECollList.push(e.added.id);
|
||||
this.eCollList.splice(this.eCollList.indexOf(e.added.id),1);
|
||||
} else {
|
||||
this.eCollList.push(e.removed.id);
|
||||
this.removedECollList.splice(this.removedECollList.indexOf(e.removed.id),1);
|
||||
}
|
||||
|
||||
if (map[e.val]) {
|
||||
id = e.currentTarget.id.split("row_newEdgeDefinitions")[1];
|
||||
$('#s2id_fromCollections'+id).select2("val", map[e.val].from);
|
||||
$('#fromCollections'+id).attr('disabled', true);
|
||||
$('#s2id_toCollections'+id).select2("val", map[e.val].to);
|
||||
$('#toCollections'+id).attr('disabled', true);
|
||||
} else {
|
||||
id = e.currentTarget.id.split("row_newEdgeDefinitions")[1];
|
||||
$('#s2id_fromCollections'+id).select2("val", null);
|
||||
$('#fromCollections'+id).attr('disabled', false);
|
||||
$('#s2id_toCollections'+id).select2("val", null);
|
||||
$('#toCollections'+id).attr('disabled', false);
|
||||
}
|
||||
tmp = $('input[id*="newEdgeDefinitions"]');
|
||||
for (i = 0; i < tmp.length ; i++) {
|
||||
id = tmp[i].id;
|
||||
$('#' + id).select2({
|
||||
tags : this.eCollList,
|
||||
showSearchBox: false,
|
||||
minimumResultsForSearch: -1,
|
||||
width: "336px",
|
||||
maximumSelectionSize: 1
|
||||
});
|
||||
}
|
||||
|
||||
},*/
|
||||
|
||||
describe("creating a new graph", function () {
|
||||
|
||||
it("should create a new empty graph", function () {
|
||||
runs(function () {
|
||||
$("#createGraph").click();
|
||||
});
|
||||
waitsFor(function () {
|
||||
return $("#modal-dialog").css("display") === "block";
|
||||
});
|
||||
runs(function () {
|
||||
$("#createNewGraphName").val("newGraph");
|
||||
$("#s2id_newEdgeDefinitions0").val(["newEdgeCol"]);
|
||||
$("#newGraphEdges").val("newEdges");
|
||||
spyOn($, "ajax").andCallFake(function (opts) {
|
||||
expect(opts.type).toEqual("POST");
|
||||
expect(opts.url).toEqual("/_api/gharial");
|
||||
expect(opts.data).toEqual(JSON.stringify(
|
||||
{
|
||||
"name":"newGraph",
|
||||
"edgeDefinitions":[],
|
||||
"orphanCollections":[]
|
||||
}));
|
||||
});
|
||||
$("#modalButton1").click();
|
||||
expect($.ajax).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}());
|
||||
});
|
||||
|
||||
}());
|
|
@ -67,7 +67,7 @@ function changeOperationModeNegativeCaseTestSuite () {
|
|||
collections: {},
|
||||
action: function () {
|
||||
var db = require('internal').db;
|
||||
var result = db._changeMode('ReadOnly');
|
||||
var result = db._changeMode('NoCreate');
|
||||
return result;
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue