##// END OF EJS Templates
Merge pull request #6951 from ccordoba12/fix-draft76...
Merge pull request #6951 from ccordoba12/fix-draft76 Websockets are not started correctly on QtWebKit 4

File last commit:

r18755:fcadd773
r18923:a70bd067 merge
Show More
save.js
112 lines | 3.8 KiB | application/javascript | JavascriptLexer
MinRK
test save_notebook with escaped name
r13860 //
// Test saving a notebook with escaped characters
//
casper.notebook_test(function () {
// don't use unicode with ambiguous composed/decomposed normalization
// because the filesystem may use a different normalization than literals.
// This causes no actual problems, but will break string comparison.
var nbname = "has#hash and space and unicø∂e.ipynb";
MinRK
test saving with problematic cell contents
r18353 this.append_cell("s = '??'", 'code');
this.thenEvaluate(function (nbname) {
MinRK
use global events in js tests
r17324 require(['base/js/events'], function (events) {
Min RK
update save test...
r18755 IPython.notebook.set_notebook_name(nbname);
MinRK
use global events in js tests
r17324 IPython._save_success = IPython._save_failed = false;
events.on('notebook_saved.Notebook', function () {
IPython._save_success = true;
});
events.on('notebook_save_failed.Notebook',
Min RK
update save test...
r18755 function (event, error) {
IPython._save_failed = "save failed with " + error;
MinRK
use global events in js tests
r17324 });
IPython.notebook.save_notebook();
MinRK
test save_notebook with escaped name
r13860 });
}, {nbname:nbname});
this.waitFor(function () {
return this.evaluate(function(){
return IPython._save_failed || IPython._save_success;
});
});
this.then(function(){
var success_failure = this.evaluate(function(){
return [IPython._save_success, IPython._save_failed];
});
this.test.assertEquals(success_failure[1], false, "Save did not fail");
this.test.assertEquals(success_failure[0], true, "Save OK");
var current_name = this.evaluate(function(){
return IPython.notebook.notebook_name;
});
this.test.assertEquals(current_name, nbname, "Save with complicated name");
Min RK
update save test...
r18755 var current_path = this.evaluate(function(){
return IPython.notebook.notebook_path;
});
this.test.assertEquals(current_path, nbname, "path OK");
MinRK
test save_notebook with escaped name
r13860 });
this.thenEvaluate(function(){
IPython._checkpoint_created = false;
MinRK
use global events in js tests
r17324 require(['base/js/events'], function (events) {
events.on('checkpoint_created.Notebook', function (evt, data) {
IPython._checkpoint_created = true;
});
});
MinRK
test save_notebook with escaped name
r13860 IPython.notebook.save_checkpoint();
});
this.waitFor(function () {
return this.evaluate(function(){
return IPython._checkpoint_created;
});
});
this.then(function(){
var checkpoints = this.evaluate(function(){
return IPython.notebook.checkpoints;
});
this.test.assertEquals(checkpoints.length, 1, "checkpoints OK");
});
this.then(function(){
Min RK
update save test...
r18755 this.open_dashboard();
MinRK
test save_notebook with escaped name
r13860 });
this.then(function(){
var notebook_url = this.evaluate(function(nbname){
var escaped_name = encodeURIComponent(nbname);
MinRK
use global events in js tests
r17324 var return_this_thing = null;
MinRK
test save_notebook with escaped name
r13860 $("a.item_link").map(function (i,a) {
if (a.href.indexOf(escaped_name) >= 0) {
return_this_thing = a.href;
return;
}
});
return return_this_thing;
}, {nbname:nbname});
Thomas Kluyver
Update JS for kernels and sessions APIs
r17223 this.test.assertNotEquals(notebook_url, null, "Escaped URL in notebook list");
MinRK
test save_notebook with escaped name
r13860 // open the notebook
this.open(notebook_url);
});
// wait for the notebook
Min RK
update save test...
r18755 this.waitFor(this.kernel_running);
MinRK
test save_notebook with escaped name
r13860
Min RK
update save test...
r18755 this.waitFor(function() {
return this.evaluate(function () {
return IPython && IPython.notebook && true;
MinRK
test save_notebook with escaped name
r13860 });
});
this.then(function(){
// check that the notebook name is correct
var notebook_name = this.evaluate(function(){
return IPython.notebook.notebook_name;
});
this.test.assertEquals(notebook_name, nbname, "Notebook name is correct");
});
});