##// END OF EJS Templates
Use wait_for_widget in widgets and string widget tests
Jonathan Frederic -
Show More
@@ -23,6 +23,7 b' casper.notebook_test(function () {'
23 }), 'Notebook widget manager instantiated');
23 }), 'Notebook widget manager instantiated');
24 });
24 });
25
25
26 var textbox = {};
26 throttle_index = this.append_cell(
27 throttle_index = this.append_cell(
27 'import time\n' +
28 'import time\n' +
28 'textbox = widgets.TextWidget()\n' +
29 'textbox = widgets.TextWidget()\n' +
@@ -32,10 +33,9 b' casper.notebook_test(function () {'
32 ' print(len(new))\n' +
33 ' print(len(new))\n' +
33 ' time.sleep(0.5)\n' +
34 ' time.sleep(0.5)\n' +
34 'textbox.on_trait_change(handle_change, "value")\n' +
35 'textbox.on_trait_change(handle_change, "value")\n' +
35 'print("Success")');
36 'print(textbox.model_id)');
36 this.execute_cell_then(throttle_index, function(index){
37 this.execute_cell_then(throttle_index, function(index){
37 this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
38 textbox.model_id = this.get_output_cell(index).text.trim();
38 'Test throttling cell executed with correct output');
39
39
40 this.test.assert(this.cell_element_exists(index,
40 this.test.assert(this.cell_element_exists(index,
41 '.widget-area .widget-subarea'),
41 '.widget-area .widget-subarea'),
@@ -48,14 +48,9 b' casper.notebook_test(function () {'
48 this.sendKeys('.my-throttle-textbox', '....................');
48 this.sendKeys('.my-throttle-textbox', '....................');
49 });
49 });
50
50
51 this.waitFor(function check() {
51 this.wait_for_widget(textbox);
52 var outputs = this.evaluate(function(i) {
52
53 return IPython.notebook.get_cell(i).output_area.outputs;
53 this.then(function () {
54 }, {i : throttle_index});
55 var output = outputs[outputs.length-1].text.trim();
56 return (output == '20');
57
58 }, function then() {
59 var outputs = this.evaluate(function(i) {
54 var outputs = this.evaluate(function(i) {
60 return IPython.notebook.get_cell(i).output_area.outputs;
55 return IPython.notebook.get_cell(i).output_area.outputs;
61 }, {i : throttle_index});
56 }, {i : throttle_index});
@@ -38,13 +38,6 b' casper.notebook_test(function () {'
38 '.widget-area .widget-subarea .widget-hbox-single input[type=text]', 'val')=='xyz',
38 '.widget-area .widget-subarea .widget-hbox-single input[type=text]', 'val')=='xyz',
39 'Python set textbox value.');
39 'Python set textbox value.');
40
40
41 });
42
43 this.wait(500); // Wait for change to execute in kernel
44
45 index = this.append_cell('print(string_widget.value)');
46 this.execute_cell_then(index, function(index){
47
48 this.test.assert(this.cell_element_exists(string_index,
41 this.test.assert(this.cell_element_exists(string_index,
49 '.widget-area .widget-subarea div span.MathJax_Preview'),
42 '.widget-area .widget-subarea div span.MathJax_Preview'),
50 'MathJax parsed the LaTeX successfully.');
43 'MathJax parsed the LaTeX successfully.');
General Comments 0
You need to be logged in to leave comments. Login now