Show More
@@ -381,16 +381,18 b' define([' | |||||
381 | }; |
|
381 | }; | |
382 |
|
382 | |||
383 | // Get the views that are displayed *now*. |
|
383 | // Get the views that are displayed *now*. | |
|
384 | (function(local_state) { | |||
384 | model_promises.push(utils.resolve_promises_dict(model.views).then(function(model_views) { |
|
385 | model_promises.push(utils.resolve_promises_dict(model.views).then(function(model_views) { | |
385 | for (var id in model_views) { |
|
386 | for (var id in model_views) { | |
386 | if (model_views.hasOwnProperty(id)) { |
|
387 | if (model_views.hasOwnProperty(id)) { | |
387 | var view = model_views[id]; |
|
388 | var view = model_views[id]; | |
388 | if (view.options.cell_index) { |
|
389 | if (view.options.cell_index) { | |
389 |
state |
|
390 | local_state.views.push(view.options.cell_index); | |
390 | } |
|
391 | } | |
391 | } |
|
392 | } | |
392 | } |
|
393 | } | |
393 | })); |
|
394 | })); | |
|
395 | })(state[model_id]); | |||
394 | } |
|
396 | } | |
395 | } |
|
397 | } | |
396 | } |
|
398 | } |
@@ -42,4 +42,53 b' casper.notebook_test(function () {' | |||||
42 | var slider_id = this.evaluate(function() { return window.slider_id; }); |
|
42 | var slider_id = this.evaluate(function() { return window.slider_id; }); | |
43 | this.test.assertEquals(output, slider_id, "Widget created from the front-end."); |
|
43 | this.test.assertEquals(output, slider_id, "Widget created from the front-end."); | |
44 | }); |
|
44 | }); | |
|
45 | ||||
|
46 | // Widget persistence tests. | |||
|
47 | index = this.append_cell( | |||
|
48 | 'from IPython.html.widgets import HTML\n' + | |||
|
49 | 'from IPython.display import display\n' + | |||
|
50 | 'display(HTML(value="<div id=\'hello\'></div>"))'); | |||
|
51 | this.execute_cell_then(index, function() {}); | |||
|
52 | ||||
|
53 | index = this.append_cell( | |||
|
54 | 'display(HTML(value="<div id=\'world\'></div>"))'); | |||
|
55 | this.execute_cell_then(index, function() {}); | |||
|
56 | ||||
|
57 | var that = this; | |||
|
58 | this.then(function() { | |||
|
59 | // Wait for the widgets to be shown. | |||
|
60 | that.waitForSelector('#hello', function() { | |||
|
61 | that.waitForSelector('#world', function() { | |||
|
62 | that.test.assertExists('#hello', 'Hello HTML widget constructed.'); | |||
|
63 | that.test.assertExists('#world', 'World HTML widget constructed.'); | |||
|
64 | ||||
|
65 | // Save the notebook. | |||
|
66 | that.evaluate(function() { | |||
|
67 | IPython.notebook.save_notebook(false).then(function() { | |||
|
68 | window.was_saved = true; | |||
|
69 | }); | |||
|
70 | }); | |||
|
71 | that.waitFor(function check() { | |||
|
72 | return that.evaluate(function() { | |||
|
73 | return window.was_saved; | |||
|
74 | }); | |||
|
75 | }, function then() { | |||
|
76 | ||||
|
77 | // Reload the page | |||
|
78 | that.reload(function() { | |||
|
79 | ||||
|
80 | // Wait for the elements to show up again. | |||
|
81 | that.waitForSelector('#hello', function() { | |||
|
82 | that.waitForSelector('#world', function() { | |||
|
83 | that.test.assertExists('#hello', 'Hello HTML widget persisted.'); | |||
|
84 | that.test.assertExists('#world', 'World HTML widget persisted.'); | |||
|
85 | }); | |||
|
86 | }); | |||
|
87 | }); | |||
|
88 | }); | |||
|
89 | }); | |||
|
90 | }); | |||
|
91 | }); | |||
|
92 | ||||
|
93 | ||||
45 | }); |
|
94 | }); |
General Comments 0
You need to be logged in to leave comments.
Login now