diff --git a/IPython/html/static/widgets/js/manager.js b/IPython/html/static/widgets/js/manager.js index 4a2a59a..7cd73dc 100644 --- a/IPython/html/static/widgets/js/manager.js +++ b/IPython/html/static/widgets/js/manager.js @@ -96,11 +96,6 @@ define([ // Make sure the view creation is not out of order with // any state updates. model.state_change = model.state_change.then(function() { - try { - console.log('create_view ' + model.id); - console.log(' _view_name ' + model.get('_view_name')); - console.log(' _view_module ' + model.get('_view_module')); - } catch (e) { } return utils.load_class(model.get('_view_name'), model.get('_view_module'), WidgetManager._view_types).then(function(ViewType) { diff --git a/IPython/html/static/widgets/js/widget.js b/IPython/html/static/widgets/js/widget.js index 0814988..771dc35 100644 --- a/IPython/html/static/widgets/js/widget.js +++ b/IPython/html/static/widgets/js/widget.js @@ -69,7 +69,6 @@ define(["widgets/js/manager", _handle_comm_msg: function (msg) { // Handle incoming comm msg. var method = msg.content.data.method; - console.log(method); var that = this; switch (method) { case 'update': @@ -81,9 +80,7 @@ define(["widgets/js/manager", this.trigger('msg:custom', msg.content.data.content); break; case 'display': - this.state_change = this.state_change.then(function() { - return that.widget_manager.display_view(msg, that); - }).catch(utils.reject("Couldn't process display msg for model id '" + String(that.id) + "'", true)); + return that.widget_manager.display_view(msg, that); break; } }, @@ -94,8 +91,6 @@ define(["widgets/js/manager", return this._unpack_models(state).then(function(state) { that.state_lock = state; try { - console.log('set_state ' + that.id); - console.log(state); WidgetModel.__super__.set.call(that, state); } finally { that.state_lock = null; diff --git a/IPython/html/tests/util.js b/IPython/html/tests/util.js index 14f910b..6cd9981 100644 --- a/IPython/html/tests/util.js +++ b/IPython/html/tests/util.js @@ -314,6 +314,15 @@ casper.execute_cell_then = function(index, then_callback, expect_failure) { return return_val; }; +casper.waitfor_cell_element = function(index, selector){ + // Utility function that allows us to easily wait for an element + // within a cell. Uses JQuery selector to look for the element. + var that = this; + this.waitFor(function() { + return that.cell_element_exists(index, selector); + }, function() { console.log('FOUND!'); }); +}; + casper.cell_element_exists = function(index, selector){ // Utility function that allows us to easily check if an element exists // within a cell. Uses JQuery selector to look for the element. diff --git a/IPython/html/tests/widgets/widget_bool.js b/IPython/html/tests/widgets/widget_bool.js index 8b8cb05..fa818d7 100644 --- a/IPython/html/tests/widgets/widget_bool.js +++ b/IPython/html/tests/widgets/widget_bool.js @@ -1,12 +1,12 @@ // Test widget bool class casper.notebook_test(function () { - index = this.append_cell( - 'from IPython.html import widgets\n' + - 'from IPython.display import display, clear_output\n' + - 'print("Success")'); - this.execute_cell_then(index); + // index = this.append_cell( + // 'print("Success")'); + // this.execute_cell_then(index); var bool_index = this.append_cell( + 'from IPython.html import widgets\n' + + 'from IPython.display import display, clear_output\n' + 'bool_widgets = [widgets.Checkbox(description="Title", value=True),\n' + ' widgets.ToggleButton(description="Title", value=True)]\n' + 'display(bool_widgets[0])\n' + @@ -15,36 +15,41 @@ casper.notebook_test(function () { this.execute_cell_then(bool_index, function(index){ this.test.assertEquals(this.get_output_cell(index).text, 'Success\n', 'Create bool widget cell executed with correct output.'); + }); - this.test.assert(this.cell_element_exists(index, + this.waitfor_cell_element(bool_index, '.widget-area .widget-subarea .widget-hbox input'); + this.waitfor_cell_element(bool_index, '.widget-area .widget-subarea button'); + + this.then(function() { + this.test.assert(this.cell_element_exists(bool_index, '.widget-area .widget-subarea'), 'Widget subarea exists.'); - this.test.assert(this.cell_element_exists(index, + this.test.assert(this.cell_element_exists(bool_index, '.widget-area .widget-subarea .widget-hbox input'), 'Checkbox exists.'); - this.test.assert(this.cell_element_function(index, + this.test.assert(this.cell_element_function(bool_index, '.widget-area .widget-subarea .widget-hbox input', 'prop', ['checked']), 'Checkbox is checked.'); - this.test.assert(this.cell_element_exists(index, + this.test.assert(this.cell_element_exists(bool_index, '.widget-area .widget-subarea .widget-hbox .widget-label'), 'Checkbox label exists.'); - this.test.assert(this.cell_element_function(index, + this.test.assert(this.cell_element_function(bool_index, '.widget-area .widget-subarea .widget-hbox .widget-label', 'html')=="Title", 'Checkbox labeled correctly.'); - this.test.assert(this.cell_element_exists(index, + this.test.assert(this.cell_element_exists(bool_index, '.widget-area .widget-subarea button'), 'Toggle button exists.'); - this.test.assert(this.cell_element_function(index, + this.test.assert(this.cell_element_function(bool_index, '.widget-area .widget-subarea button', 'html')=="Title", 'Toggle button labeled correctly.'); - this.test.assert(this.cell_element_function(index, + this.test.assert(this.cell_element_function(bool_index, '.widget-area .widget-subarea button', 'hasClass', ['active']), 'Toggle button is toggled.'); }); @@ -54,9 +59,6 @@ casper.notebook_test(function () { 'bool_widgets[1].value = False\n' + 'print("Success")'); this.execute_cell_then(index, function(index){ - - this.interact(); - this.test.assertEquals(this.get_output_cell(index).text, 'Success\n', 'Change bool widget value cell executed with correct output.');