Commit 5b0ca42e authored by Jérome Perrin's avatar Jérome Perrin

graph editor: test for dialog edition

parent b45cb38b
...@@ -528,13 +528,17 @@ ...@@ -528,13 +528,17 @@
return fieldset_gadget[0]; return fieldset_gadget[0];
}) })
.push(function (fieldset_gadget) { .push(function (fieldset_gadget) {
return RSVP.any([ // Expose the dialog handling promise so that we can wait for it in
// test.
gadget.props.dialog_promise = RSVP.any([
save_promise(fieldset_gadget, node_id), save_promise(fieldset_gadget, node_id),
delete_promise delete_promise
]); ]);
return gadget.props.dialog_promise;
}) })
.push(function () { .push(function () {
node_edit_popup.popup('close'); node_edit_popup.popup('close');
delete gadget.props.dialog_promise;
}); });
} }
......
/*global rJS, JSON, QUnit, jQuery, RSVP, console*/ /*global rJS, JSON, QUnit, jQuery, RSVP, console, setTimeout*/
(function (rJS, JSON, QUnit, RSVP, $) { (function (rJS, JSON, QUnit, RSVP, $) {
"use strict"; "use strict";
...@@ -262,20 +262,49 @@ ...@@ -262,20 +262,49 @@
stop(); stop();
function runTest() { function runTest() {
return jsplumb_gadget.getContent().then(function () { return jsplumb_gadget.getContent().then( function() {
$("div[title='Node 1']").simulate("dblclick"); // click on a node to see display the popup
$("div[title='Node 1']").simulate('dblclick');
// XXX popup not displayed // Promises that handle the dialog actions are not available
// immediately after clicking.
var promise = RSVP.Promise( function (resolve) {
var fillDialog = function() {
if (! jsplumb_gadget.props.dialog_promise ) {
// Dialog not ready. Let's retry later.
// XXX this condition is actually incorrect. We need to wait
// for the event listener to have been registered for the
// dialog buttons. This setTimeout is good enough for now.
return setTimeout(fillDialog, 1000);
}
// check displayed values
equal($("input[name='id']").val(), "N1");
equal($("input[name='name']").val(), "Node 1");
equal($("input[name='shape']").val(), "square");
// change the name
$("input[name='name']").val("Modified Name"); $("input[name='name']").val("Modified Name");
// and save
$("input[value='Validate']").click(); $("input[value='Validate']").click();
})
.then(function () { // resolve our test promise once the dialog handling promise is
return jsplumb_gadget.getContent(); // finished.
}) jsplumb_gadget.props.dialog_promise.then(resolve);
.then(function (content) { };
fillDialog();
} );
return promise.then( function () {
return jsplumb_gadget.getContent().then(function (content) {
var graph = JSON.parse(content).graph, var graph = JSON.parse(content).graph,
node = graph.node.N1; node = graph.node.N1;
equal(node.name, "Modified Name"); // check the data is well modified.
equal("Modified Name", node.name);
});
});
}); });
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment