Commit 406840df authored by Jérome Perrin's avatar Jérome Perrin

graph editor: test for dialog edition

parent 723a1c30
......@@ -528,13 +528,17 @@
return fieldset_gadget[0];
})
.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),
delete_promise
]);
return gadget.props.dialog_promise;
})
.push(function () {
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, $) {
"use strict";
......@@ -262,20 +262,49 @@
stop();
function runTest() {
return jsplumb_gadget.getContent().then(function () {
$("div[title='Node 1']").simulate("dblclick");
return jsplumb_gadget.getContent().then( function() {
// 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");
// and save
$("input[value='Validate']").click();
})
.then(function () {
return jsplumb_gadget.getContent();
})
.then(function (content) {
// resolve our test promise once the dialog handling promise is
// finished.
jsplumb_gadget.props.dialog_promise.then(resolve);
};
fillDialog();
} );
return promise.then( function () {
return jsplumb_gadget.getContent().then(function (content) {
var graph = JSON.parse(content).graph,
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