##// END OF EJS Templates
Make all tests async display safe
Jonathan Frederic -
Show More
@@ -80,7 +80,7 b' define(["widgets/js/manager",'
80 80 this.trigger('msg:custom', msg.content.data.content);
81 81 break;
82 82 case 'display':
83 return that.widget_manager.display_view(msg, that);
83 this.widget_manager.display_view(msg, that);
84 84 break;
85 85 }
86 86 },
@@ -180,10 +180,31 b' casper.wait_for_widget = function (widget_info) {'
180 180 // widget_info : object
181 181 // Object which contains info related to the widget. The model_id property
182 182 // is used to identify the widget.
183
184 // Clear the results of a previous query, if they exist. Make sure a
185 // dictionary exists to store the async results in.
186 this.thenEvaluate(function(model_id) {
187 if (window.pending_msgs === undefined) {
188 window.pending_msgs = {};
189 } else {
190 window.pending_msgs[model_id] = -1;
191 }
192 }, {model_id: widget_info.model_id});
193
194 // Wait for the pending messages to be 0.
183 195 this.waitFor(function () {
184 var pending = this.evaluate(function (m) {
185 return IPython.notebook.kernel.widget_manager.get_model(m).pending_msgs;
186 }, {m: widget_info.model_id});
196 var pending = this.evaluate(function (model_id) {
197
198 // Get the model. Once the model is had, store it's pending_msgs
199 // count in the window's dictionary.
200 IPython.notebook.kernel.widget_manager.get_model(model_id)
201 .then(function(model) {
202 window.pending_msgs[model_id] = model.pending_msgs;
203 });
204
205 // Return the pending_msgs result.
206 return window.pending_msgs[model_id];
207 }, {model_id: widget_info.model_id});
187 208
188 209 if (pending === 0) {
189 210 return true;
@@ -314,13 +335,13 b' casper.execute_cell_then = function(index, then_callback, expect_failure) {'
314 335 return return_val;
315 336 };
316 337
317 casper.waitfor_cell_element = function(index, selector){
338 casper.wait_for_element = function(index, selector){
318 339 // Utility function that allows us to easily wait for an element
319 340 // within a cell. Uses JQuery selector to look for the element.
320 341 var that = this;
321 342 this.waitFor(function() {
322 343 return that.cell_element_exists(index, selector);
323 }, function() { console.log('FOUND!'); });
344 });
324 345 };
325 346
326 347 casper.cell_element_exists = function(index, selector){
@@ -131,7 +131,7 b' casper.notebook_test(function () {'
131 131 multiset.model_id = this.get_output_cell(index).text.trim();
132 132 });
133 133
134 this.wait_for_widget(multiset);
134 this.wait_for_widget(multiset);
135 135
136 136 index = this.append_cell(
137 137 'print("%d%d%d" % (multiset.a, multiset.b, multiset.c))');
@@ -1,9 +1,7 b''
1 1 // Test widget bool class
2 2 casper.notebook_test(function () {
3 // index = this.append_cell(
4 // 'print("Success")');
5 // this.execute_cell_then(index);
6 3
4 // Create a checkbox and togglebutton.
7 5 var bool_index = this.append_cell(
8 6 'from IPython.html import widgets\n' +
9 7 'from IPython.display import display, clear_output\n' +
@@ -17,20 +15,24 b' casper.notebook_test(function () {'
17 15 'Create bool widget cell executed with correct output.');
18 16 });
19 17
20 this.waitfor_cell_element(bool_index, '.widget-area .widget-subarea .widget-hbox input');
21 this.waitfor_cell_element(bool_index, '.widget-area .widget-subarea button');
18 // Wait for the widgets to actually display.
19 var widget_checkbox_selector = '.widget-area .widget-subarea .widget-hbox input';
20 var widget_togglebutton_selector = '.widget-area .widget-subarea button';
21 this.wait_for_element(bool_index, widget_checkbox_selector);
22 this.wait_for_element(bool_index, widget_togglebutton_selector);
22 23
24 // Continue the tests.
23 25 this.then(function() {
24 26 this.test.assert(this.cell_element_exists(bool_index,
25 27 '.widget-area .widget-subarea'),
26 28 'Widget subarea exists.');
27 29
28 30 this.test.assert(this.cell_element_exists(bool_index,
29 '.widget-area .widget-subarea .widget-hbox input'),
31 widget_checkbox_selector),
30 32 'Checkbox exists.');
31 33
32 34 this.test.assert(this.cell_element_function(bool_index,
33 '.widget-area .widget-subarea .widget-hbox input', 'prop', ['checked']),
35 widget_checkbox_selector, 'prop', ['checked']),
34 36 'Checkbox is checked.');
35 37
36 38 this.test.assert(this.cell_element_exists(bool_index,
@@ -42,18 +44,19 b' casper.notebook_test(function () {'
42 44 'Checkbox labeled correctly.');
43 45
44 46 this.test.assert(this.cell_element_exists(bool_index,
45 '.widget-area .widget-subarea button'),
47 widget_togglebutton_selector),
46 48 'Toggle button exists.');
47 49
48 50 this.test.assert(this.cell_element_function(bool_index,
49 '.widget-area .widget-subarea button', 'html')=="Title",
51 widget_togglebutton_selector, 'html')=="Title",
50 52 'Toggle button labeled correctly.');
51 53
52 54 this.test.assert(this.cell_element_function(bool_index,
53 '.widget-area .widget-subarea button', 'hasClass', ['active']),
55 widget_togglebutton_selector, 'hasClass', ['active']),
54 56 'Toggle button is toggled.');
55 57 });
56 58
59 // Try changing the state of the widgets programatically.
57 60 index = this.append_cell(
58 61 'bool_widgets[0].value = False\n' +
59 62 'bool_widgets[1].value = False\n' +
@@ -63,25 +66,25 b' casper.notebook_test(function () {'
63 66 'Change bool widget value cell executed with correct output.');
64 67
65 68 this.test.assert(! this.cell_element_function(bool_index,
66 '.widget-area .widget-subarea .widget-hbox input', 'prop', ['checked']),
69 widget_checkbox_selector, 'prop', ['checked']),
67 70 'Checkbox is not checked. (1)');
68 71
69 72 this.test.assert(! this.cell_element_function(bool_index,
70 '.widget-area .widget-subarea button', 'hasClass', ['active']),
73 widget_togglebutton_selector, 'hasClass', ['active']),
71 74 'Toggle button is not toggled. (1)');
72 75
73 76 // Try toggling the bool by clicking on the checkbox.
74 this.cell_element_function(bool_index, '.widget-area .widget-subarea .widget-hbox input', 'click');
77 this.cell_element_function(bool_index, widget_checkbox_selector, 'click');
75 78
76 79 this.test.assert(this.cell_element_function(bool_index,
77 '.widget-area .widget-subarea .widget-hbox input', 'prop', ['checked']),
80 widget_checkbox_selector, 'prop', ['checked']),
78 81 'Checkbox is checked. (2)');
79 82
80 83 // Try toggling the bool by clicking on the toggle button.
81 this.cell_element_function(bool_index, '.widget-area .widget-subarea button', 'click');
84 this.cell_element_function(bool_index, widget_togglebutton_selector, 'click');
82 85
83 86 this.test.assert(this.cell_element_function(bool_index,
84 '.widget-area .widget-subarea button', 'hasClass', ['active']),
87 widget_togglebutton_selector, 'hasClass', ['active']),
85 88 'Toggle button is toggled. (3)');
86 89
87 90 });
@@ -1,12 +1,10 b''
1 1 // Test container class
2 2 casper.notebook_test(function () {
3 index = this.append_cell(
4 'from IPython.html import widgets\n' +
5 'from IPython.display import display, clear_output\n' +
6 'print("Success")');
7 this.execute_cell_then(index);
8 3
4 // Create a box widget.
9 5 var container_index = this.append_cell(
6 'from IPython.html import widgets\n' +
7 'from IPython.display import display, clear_output\n' +
10 8 'container = widgets.Box()\n' +
11 9 'button = widgets.Button()\n'+
12 10 'container.children = [button]\n'+
@@ -14,24 +12,32 b' casper.notebook_test(function () {'
14 12 'container._dom_classes = ["my-test-class"]\n'+
15 13 'print("Success")\n');
16 14 this.execute_cell_then(container_index, function(index){
17
18 15 this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
19 16 'Create container cell executed with correct output.');
17 });
20 18
21 this.test.assert(this.cell_element_exists(index,
19 // Wait for the widgets to actually display.
20 var widget_box_selector = '.widget-area .widget-subarea .widget-box';
21 var widget_box_button_selector = '.widget-area .widget-subarea .widget-box button';
22 this.wait_for_element(container_index, widget_box_selector);
23 this.wait_for_element(container_index, widget_box_button_selector);
24
25 // Continue with the tests.
26 this.then(function() {
27 this.test.assert(this.cell_element_exists(container_index,
22 28 '.widget-area .widget-subarea'),
23 29 'Widget subarea exists.');
24 30
25 this.test.assert(this.cell_element_exists(index,
26 '.widget-area .widget-subarea .widget-box'),
31 this.test.assert(this.cell_element_exists(container_index,
32 widget_box_selector),
27 33 'Widget container exists.');
28 34
29 this.test.assert(this.cell_element_exists(index,
35 this.test.assert(this.cell_element_exists(container_index,
30 36 '.widget-area .widget-subarea .my-test-class'),
31 37 '_dom_classes works.');
32 38
33 this.test.assert(this.cell_element_exists(index,
34 '.widget-area .widget-subarea .my-test-class button'),
39 this.test.assert(this.cell_element_exists(container_index,
40 widget_box_button_selector),
35 41 'Container parent/child relationship works.');
36 42 });
37 43
@@ -61,20 +67,26 b' casper.notebook_test(function () {'
61 67 '_dom_classes can be used to remove a class.');
62 68 });
63 69
64 index = this.append_cell(
70 var boxalone_index = this.append_cell(
65 71 'display(button)\n'+
66 72 'print("Success")\n');
67 this.execute_cell_then(index, function(index){
68
73 this.execute_cell_then(boxalone_index, function(index){
69 74 this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
70 75 'Display container child executed with correct output.');
76 });
77
78 // Wait for the widget to actually display.
79 var widget_button_selector = '.widget-area .widget-subarea button';
80 this.wait_for_element(boxalone_index, widget_button_selector);
71 81
72 this.test.assert(! this.cell_element_exists(index,
73 '.widget-area .widget-subarea .widget-box'),
82 // Continue with the tests.
83 this.then(function() {
84 this.test.assert(! this.cell_element_exists(boxalone_index,
85 widget_box_selector),
74 86 'Parent container not displayed.');
75 87
76 this.test.assert(this.cell_element_exists(index,
77 '.widget-area .widget-subarea button'),
88 this.test.assert(this.cell_element_exists(boxalone_index,
89 widget_button_selector),
78 90 'Child displayed.');
79 91 });
80 92 }); No newline at end of file
@@ -1,12 +1,8 b''
1 1 // Test widget button class
2 2 casper.notebook_test(function () {
3 index = this.append_cell(
3 var button_index = this.append_cell(
4 4 'from IPython.html import widgets\n' +
5 5 'from IPython.display import display, clear_output\n' +
6 'print("Success")');
7 this.execute_cell_then(index);
8
9 var button_index = this.append_cell(
10 6 'button = widgets.Button(description="Title")\n' +
11 7 'display(button)\n' +
12 8 'print("Success")\n' +
@@ -14,24 +10,30 b' casper.notebook_test(function () {'
14 10 ' display("Clicked")\n' +
15 11 'button.on_click(handle_click)');
16 12 this.execute_cell_then(button_index, function(index){
17
18 13 this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
19 14 'Create button cell executed with correct output.');
15 });
16
17 // Wait for the widgets to actually display.
18 var widget_button_selector = '.widget-area .widget-subarea button';
19 this.wait_for_element(button_index, widget_button_selector);
20 20
21 this.test.assert(this.cell_element_exists(index,
21 // Continue with the tests.
22 this.then(function() {
23 this.test.assert(this.cell_element_exists(button_index,
22 24 '.widget-area .widget-subarea'),
23 25 'Widget subarea exists.');
24 26
25 this.test.assert(this.cell_element_exists(index,
26 '.widget-area .widget-subarea button'),
27 this.test.assert(this.cell_element_exists(button_index,
28 widget_button_selector),
27 29 'Widget button exists.');
28 30
29 this.test.assert(this.cell_element_function(index,
30 '.widget-area .widget-subarea button', 'html')=='Title',
31 this.test.assert(this.cell_element_function(button_index,
32 widget_button_selector, 'html')=='Title',
31 33 'Set button description.');
32 34
33 this.cell_element_function(index,
34 '.widget-area .widget-subarea button', 'click');
35 this.cell_element_function(button_index,
36 widget_button_selector, 'click');
35 37 });
36 38
37 39 this.wait_for_output(button_index, 1);
@@ -1,30 +1,34 b''
1 1 // Test widget float class
2 2 casper.notebook_test(function () {
3 index = this.append_cell(
4 'from IPython.html import widgets\n' +
5 'from IPython.display import display, clear_output\n' +
6 'print("Success")');
7 this.execute_cell_then(index);
8
9 3 var float_text = {};
10 4 float_text.query = '.widget-area .widget-subarea .my-second-float-text input';
11 5 float_text.index = this.append_cell(
6 'from IPython.html import widgets\n' +
7 'from IPython.display import display, clear_output\n' +
12 8 'float_widget = widgets.FloatText()\n' +
13 9 'display(float_widget)\n' +
14 10 'float_widget._dom_classes = ["my-second-float-text"]\n' +
15 11 'print(float_widget.model_id)\n');
16 12 this.execute_cell_then(float_text.index, function(index){
17 13 float_text.model_id = this.get_output_cell(index).text.trim();
18
19 this.test.assert(this.cell_element_exists(index,
14 });
15
16 // Wait for the widget to actually display.
17 this.wait_for_element(float_text.index, float_text.query);
18
19 // Continue with the tests
20 this.then(function(){
21 this.test.assert(this.cell_element_exists(float_text.index,
20 22 '.widget-area .widget-subarea'),
21 23 'Widget subarea exists.');
22 24
23 this.test.assert(this.cell_element_exists(index, float_text.query),
25 this.test.assert(this.cell_element_exists(float_text.index, float_text.query),
24 26 'Widget float textbox exists.');
25 27
26 28 this.cell_element_function(float_text.index, float_text.query, 'val', ['']);
29 console.log('send keys');
27 30 this.sendKeys(float_text.query, '1.05');
31 console.log('send keys done');
28 32 });
29 33
30 34 this.wait_for_widget(float_text);
@@ -64,18 +68,23 b' casper.notebook_test(function () {'
64 68 '[display(floatrange[i]) for i in range(2)]\n' +
65 69 'print("Success")\n');
66 70 this.execute_cell_then(slider.index, function(index){
67
68 71 this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
69 72 'Create float range cell executed with correct output.');
73 });
74
75 // Wait for the widgets to actually display.
76 this.wait_for_element(slider.index, slider.query);
77 this.wait_for_element(slider.index, float_text_query);
70 78
71 this.test.assert(this.cell_element_exists(index,
79 this.then(function(){
80 this.test.assert(this.cell_element_exists(slider.index,
72 81 '.widget-area .widget-subarea'),
73 82 'Widget subarea exists.');
74 83
75 this.test.assert(this.cell_element_exists(index, slider.query),
84 this.test.assert(this.cell_element_exists(slider.index, slider.query),
76 85 'Widget slider exists.');
77 86
78 this.test.assert(this.cell_element_exists(index, float_text_query),
87 this.test.assert(this.cell_element_exists(slider.index, float_text_query),
79 88 'Widget float textbox exists.');
80 89 });
81 90
@@ -26,19 +26,23 b' casper.notebook_test(function () {'
26 26 'display(image)\n' +
27 27 'print("Success")\n');
28 28 this.execute_cell_then(image_index, function(index){
29
30 29 this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
31 30 'Create image executed with correct output.');
31 });
32
33 // Wait for the widget to actually display.
34 var img_selector = '.widget-area .widget-subarea img';
35 this.wait_for_element(image_index, img_selector);
32 36
33 this.test.assert(this.cell_element_exists(index,
37 this.then(function(){
38 this.test.assert(this.cell_element_exists(image_index,
34 39 '.widget-area .widget-subarea'),
35 40 'Widget subarea exists.');
36 41
37 var img_sel = '.widget-area .widget-subarea img';
38 this.test.assert(this.cell_element_exists(index, img_sel), 'Image exists.');
42 this.test.assert(this.cell_element_exists(image_index, img_selector), 'Image exists.');
39 43
40 44 // Verify that the image's base64 data has made it into the DOM.
41 var img_src = this.cell_element_function(image_index, img_sel, 'attr', ['src']);
45 var img_src = this.cell_element_function(image_index, img_selector, 'attr', ['src']);
42 46 this.test.assert(img_src.indexOf(test_jpg) > -1, 'Image src data exists.');
43 47 });
44 48 }); No newline at end of file
@@ -1,26 +1,28 b''
1 1 // Test widget int class
2 2 casper.notebook_test(function () {
3 index = this.append_cell(
4 'from IPython.html import widgets\n' +
5 'from IPython.display import display, clear_output\n' +
6 'print("Success")');
7 this.execute_cell_then(index);
8
9 3 var int_text = {};
10 4 int_text.query = '.widget-area .widget-subarea .my-second-int-text input';
11 5 int_text.index = this.append_cell(
6 'from IPython.html import widgets\n' +
7 'from IPython.display import display, clear_output\n' +
12 8 'int_widget = widgets.IntText()\n' +
13 9 'display(int_widget)\n' +
14 10 'int_widget._dom_classes = ["my-second-int-text"]\n' +
15 11 'print(int_widget.model_id)\n');
16 12 this.execute_cell_then(int_text.index, function(index){
17 13 int_text.model_id = this.get_output_cell(index).text.trim();
18
19 this.test.assert(this.cell_element_exists(index,
14 });
15
16 // Wait for the widget to actually display.
17 this.wait_for_element(int_text.index, int_text.query);
18
19 // Continue with the tests.
20 this.then(function() {
21 this.test.assert(this.cell_element_exists(int_text.index,
20 22 '.widget-area .widget-subarea'),
21 23 'Widget subarea exists.');
22 24
23 this.test.assert(this.cell_element_exists(index, int_text.query),
25 this.test.assert(this.cell_element_exists(int_text.index, int_text.query),
24 26 'Widget int textbox exists.');
25 27
26 28 this.cell_element_function(int_text.index, int_text.query, 'val', ['']);
@@ -54,13 +56,6 b' casper.notebook_test(function () {'
54 56 this.test.assertEquals(this.get_output_cell(index).text, '12\n',
55 57 'Invald int textbox value caught and filtered.');
56 58 });
57
58 index = this.append_cell(
59 'from IPython.html import widgets\n' +
60 'from IPython.display import display, clear_output\n' +
61 'print("Success")');
62 this.execute_cell_then(index);
63
64 59
65 60 var slider_query = '.widget-area .widget-subarea .slider';
66 61 var int_text2 = {};
@@ -73,15 +68,22 b' casper.notebook_test(function () {'
73 68 'print(intrange[0].model_id)\n');
74 69 this.execute_cell_then(int_text2.index, function(index){
75 70 int_text2.model_id = this.get_output_cell(index).text.trim();
71 });
72
73 // Wait for the widgets to actually display.
74 this.wait_for_element(int_text2.index, int_text2.query);
75 this.wait_for_element(int_text2.index, slider_query);
76 76
77 this.test.assert(this.cell_element_exists(index,
77 // Continue with the tests.
78 this.then(function(){
79 this.test.assert(this.cell_element_exists(int_text2.index,
78 80 '.widget-area .widget-subarea'),
79 81 'Widget subarea exists.');
80 82
81 this.test.assert(this.cell_element_exists(index, slider_query),
83 this.test.assert(this.cell_element_exists(int_text2.index, slider_query),
82 84 'Widget slider exists.');
83 85
84 this.test.assert(this.cell_element_exists(index, int_text2.query),
86 this.test.assert(this.cell_element_exists(int_text2.index, int_text2.query),
85 87 'Widget int textbox exists.');
86 88 });
87 89
@@ -58,21 +58,30 b' casper.notebook_test(function () {'
58 58 this.execute_cell_then(selection_index, function(index){
59 59 this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
60 60 'Create selection cell executed with correct output.');
61 });
62
63 // Wait for the widgets to actually display.
64 this.wait_for_element(selection_index, combo_selector);
65 this.wait_for_element(selection_index, multibtn_selector);
66 this.wait_for_element(selection_index, radio_selector);
67 this.wait_for_element(selection_index, list_selector);
61 68
62 this.test.assert(this.cell_element_exists(index,
69 // Continue with the tests.
70 this.then(function() {
71 this.test.assert(this.cell_element_exists(selection_index,
63 72 '.widget-area .widget-subarea'),
64 73 'Widget subarea exists.');
65 74
66 this.test.assert(this.cell_element_exists(index, combo_selector),
75 this.test.assert(this.cell_element_exists(selection_index, combo_selector),
67 76 'Widget combobox exists.');
68 77
69 this.test.assert(this.cell_element_exists(index, multibtn_selector),
78 this.test.assert(this.cell_element_exists(selection_index, multibtn_selector),
70 79 'Widget multibutton exists.');
71 80
72 this.test.assert(this.cell_element_exists(index, radio_selector),
81 this.test.assert(this.cell_element_exists(selection_index, radio_selector),
73 82 'Widget radio buttons exists.');
74 83
75 this.test.assert(this.cell_element_exists(index, list_selector),
84 this.test.assert(this.cell_element_exists(selection_index, list_selector),
76 85 'Widget list exists.');
77 86
78 87 // Verify that no items are selected.
@@ -18,20 +18,22 b' casper.notebook_test(function () {'
18 18 'multicontainer.selected_index = 0\n' +
19 19 'print("Success")\n');
20 20 this.execute_cell_then(multicontainer1_index, function(index){
21
22 21 this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
23 22 'Create multicontainer cell executed with correct output. (1)');
23 });
24
25 // Wait for the widget to actually display.
26 this.wait_for_element(multicontainer1_index, multicontainer1_query);
24 27
25 this.test.assert(this.cell_element_exists(index,
28 // Continue with the tests.
29 this.then(function() {
30 this.test.assert(this.cell_element_exists(multicontainer1_index,
26 31 '.widget-area .widget-subarea'),
27 32 'Widget subarea exists.');
28 33
29 this.test.assert(this.cell_element_exists(index, multicontainer1_query),
34 this.test.assert(this.cell_element_exists(multicontainer1_index, multicontainer1_query),
30 35 'Widget tab list exists.');
31 36
32 this.test.assert(this.cell_element_exists(index, multicontainer1_query),
33 'First widget tab list exists.');
34
35 37 // JQuery selector is 1 based
36 38 this.click(multicontainer1_query + ' li:nth-child(2) a');
37 39 });
@@ -74,23 +76,28 b' casper.notebook_test(function () {'
74 76 'multicontainer.selected_index = 0\n' +
75 77 'print("Success")\n');
76 78 this.execute_cell_then(multicontainer2_index, function(index){
77
78 79 this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
79 80 'Create multicontainer cell executed with correct output. (2)');
81 });
82
83 // Wait for the widget to actually display.
84 this.wait_for_element(multicontainer2_index, multicontainer2_query);
80 85
81 this.test.assert(this.cell_element_exists(index,
86 // Continue with the tests.
87 this.then(function() {
88 this.test.assert(this.cell_element_exists(multicontainer2_index,
82 89 '.widget-area .widget-subarea'),
83 90 'Widget subarea exists.');
84 91
85 this.test.assert(this.cell_element_exists(index, multicontainer2_query),
92 this.test.assert(this.cell_element_exists(multicontainer2_index, multicontainer2_query),
86 93 'Widget accordion exists.');
87 94
88 this.test.assert(this.cell_element_exists(index, multicontainer2_query +
95 this.test.assert(this.cell_element_exists(multicontainer2_index, multicontainer2_query +
89 96 ' .panel:nth-child(1) .panel-collapse'),
90 97 'First accordion page exists.');
91 98
92 99 // JQuery selector is 1 based
93 this.test.assert(this.cell_element_function(index, multicontainer2_query +
100 this.test.assert(this.cell_element_function(multicontainer2_index, multicontainer2_query +
94 101 ' .panel.panel-default:nth-child(3) .panel-heading .accordion-toggle',
95 102 'html')=='good', 'Accordion page title set (before display).');
96 103
@@ -1,12 +1,8 b''
1 1 // Test widget string class
2 2 casper.notebook_test(function () {
3 index = this.append_cell(
3 var string_index = this.append_cell(
4 4 'from IPython.html import widgets\n' +
5 5 'from IPython.display import display, clear_output\n' +
6 'print("Success")');
7 this.execute_cell_then(index);
8
9 var string_index = this.append_cell(
10 6 'string_widget = [widgets.Text(value = "xyz", placeholder = "abc"),\n' +
11 7 ' widgets.Textarea(value = "xyz", placeholder = "def"),\n' +
12 8 ' widgets.HTML(value = "xyz"),\n' +
@@ -14,40 +10,50 b' casper.notebook_test(function () {'
14 10 '[display(widget) for widget in string_widget]\n'+
15 11 'print("Success")');
16 12 this.execute_cell_then(string_index, function(index){
17
18 13 this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
19 14 'Create string widget cell executed with correct output.');
15 });
16
17 // Wait for the widget to actually display.
18 var textbox_selector = '.widget-area .widget-subarea .widget-hbox input[type=text]';
19 var textarea_selector = '.widget-area .widget-subarea .widget-hbox textarea';
20 var latex_selector = '.widget-area .widget-subarea div span.MathJax_Preview';
21 this.wait_for_element(string_index, textbox_selector);
22 this.wait_for_element(string_index, textarea_selector);
23 this.wait_for_element(string_index, latex_selector);
20 24
21 this.test.assert(this.cell_element_exists(index,
25 // Continue with the tests.
26 this.then(function(){
27 this.test.assert(this.cell_element_exists(string_index,
22 28 '.widget-area .widget-subarea'),
23 29 'Widget subarea exists.');
24 30
25 this.test.assert(this.cell_element_exists(index,
26 '.widget-area .widget-subarea .widget-hbox input[type=text]'),
31 this.test.assert(this.cell_element_exists(string_index,
32 textbox_selector),
27 33 'Textbox exists.');
28 34
29 this.test.assert(this.cell_element_exists(index,
30 '.widget-area .widget-subarea .widget-hbox textarea'),
35 this.test.assert(this.cell_element_exists(string_index,
36 textarea_selector),
31 37 'Textarea exists.');
32 38
33 this.test.assert(this.cell_element_function(index,
34 '.widget-area .widget-subarea .widget-hbox textarea', 'val')=='xyz',
39 this.test.assert(this.cell_element_function(string_index,
40 textarea_selector, 'val')=='xyz',
35 41 'Python set textarea value.');
36 42
37 this.test.assert(this.cell_element_function(index,
38 '.widget-area .widget-subarea .widget-hbox input[type=text]', 'val')=='xyz',
43 this.test.assert(this.cell_element_function(string_index,
44 textbox_selector, 'val')=='xyz',
39 45 'Python set textbox value.');
40 46
41 47 this.test.assert(this.cell_element_exists(string_index,
42 '.widget-area .widget-subarea div span.MathJax_Preview'),
48 latex_selector),
43 49 'MathJax parsed the LaTeX successfully.');
44 50
45 this.test.assert(this.cell_element_function(index,
46 '.widget-area .widget-subarea .widget-hbox textarea', 'attr', ['placeholder'])=='def',
51 this.test.assert(this.cell_element_function(string_index,
52 textarea_selector, 'attr', ['placeholder'])=='def',
47 53 'Python set textarea placeholder.');
48 54
49 this.test.assert(this.cell_element_function(index,
50 '.widget-area .widget-subarea .widget-hbox input[type=text]', 'attr', ['placeholder'])=='abc',
55 this.test.assert(this.cell_element_function(string_index,
56 textbox_selector, 'attr', ['placeholder'])=='abc',
51 57 'Python set textbox placehoder.');
52 58 });
53 59 });
General Comments 0
You need to be logged in to leave comments. Login now