##// END OF EJS Templates
test save_notebook with escaped name
MinRK -
Show More
@@ -0,0 +1,105 b''
1 //
2 // Test saving a notebook with escaped characters
3 //
4
5 casper.notebook_test(function () {
6 // don't use unicode with ambiguous composed/decomposed normalization
7 // because the filesystem may use a different normalization than literals.
8 // This causes no actual problems, but will break string comparison.
9 var nbname = "has#hash and space and unicΓΈβˆ‚e.ipynb";
10
11 this.evaluate(function (nbname) {
12 IPython.notebook.notebook_name = nbname;
13 IPython._save_success = IPython._save_failed = false;
14 $([IPython.events]).on('notebook_saved.Notebook', function () {
15 IPython._save_success = true;
16 });
17 $([IPython.events]).on('notebook_save_failed.Notebook',
18 function (event, xhr, status, error) {
19 IPython._save_failed = "save failed with " + xhr.status + xhr.responseText;
20 });
21 IPython.notebook.save_notebook();
22 }, {nbname:nbname});
23
24 this.waitFor(function () {
25 return this.evaluate(function(){
26 return IPython._save_failed || IPython._save_success;
27 });
28 });
29
30 this.then(function(){
31 var success_failure = this.evaluate(function(){
32 return [IPython._save_success, IPython._save_failed];
33 });
34 this.test.assertEquals(success_failure[1], false, "Save did not fail");
35 this.test.assertEquals(success_failure[0], true, "Save OK");
36
37 var current_name = this.evaluate(function(){
38 return IPython.notebook.notebook_name;
39 });
40 this.test.assertEquals(current_name, nbname, "Save with complicated name");
41 });
42
43 this.thenEvaluate(function(){
44 $([IPython.events]).on('checkpoint_created.Notebook', function (evt, data) {
45 IPython._checkpoint_created = true;
46 });
47 IPython._checkpoint_created = false;
48 IPython.notebook.save_checkpoint();
49 });
50
51 this.waitFor(function () {
52 return this.evaluate(function(){
53 return IPython._checkpoint_created;
54 });
55 });
56
57 this.then(function(){
58 var checkpoints = this.evaluate(function(){
59 return IPython.notebook.checkpoints;
60 });
61 this.test.assertEquals(checkpoints.length, 1, "checkpoints OK");
62 });
63
64 this.then(function(){
65 var baseUrl = this.get_notebook_server();
66 this.open(baseUrl);
67 });
68
69 this.waitForSelector('.list_item');
70
71 this.then(function(){
72 var notebook_url = this.evaluate(function(nbname){
73 var escaped_name = encodeURIComponent(nbname);
74 var return_this_thing;
75 $("a.item_link").map(function (i,a) {
76 if (a.href.indexOf(escaped_name) >= 0) {
77 return_this_thing = a.href;
78 return;
79 }
80 });
81 return return_this_thing;
82 }, {nbname:nbname});
83 this.test.assertEquals(notebook_url == null, false, "Escaped URL in notebook list");
84 // open the notebook
85 this.open(notebook_url);
86 });
87
88 // wait for the notebook
89 this.waitForSelector("#notebook");
90
91 this.waitFor(function(){
92 return this.evaluate(function(){
93 return IPython.notebook || false;
94 });
95 });
96
97 this.then(function(){
98 // check that the notebook name is correct
99 var notebook_name = this.evaluate(function(){
100 return IPython.notebook.notebook_name;
101 });
102 this.test.assertEquals(notebook_name, nbname, "Notebook name is correct");
103 });
104
105 });
General Comments 0
You need to be logged in to leave comments. Login now