##// END OF EJS Templates
#7548: A bang, "!", followed by an equal sign, "=", is not a shell escape.
#7548: A bang, "!", followed by an equal sign, "=", is not a shell escape.

File last commit:

r19169:81a29071
r20146:cfc41c06
Show More
widget_selection.js
147 lines | 6.6 KiB | application/javascript | JavascriptLexer
Jonathan Frederic
Organized tests.
r14464 // Test selection 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);
Jonathan Frederic
Cleaned up hbox and vbox widget div styles,...
r17929 var combo_selector = '.widget-area .widget-subarea .widget-hbox .btn-group .widget-combo-btn';
var multibtn_selector = '.widget-area .widget-subarea .widget-hbox .btn-group[data-toggle="buttons-radio"]';
Jonathan Frederic
Fixed .. typo
r15371 var radio_selector = '.widget-area .widget-subarea .widget-hbox .widget-radio-box';
MinRK
first review pass on widget tests
r14797 var list_selector = '.widget-area .widget-subarea .widget-hbox .widget-listbox';
Jonathan Frederic
Organized tests.
r14464
var selection_index;
var selection_values = 'abcd';
var check_state = function(context, index, state){
if (0 <= index && index < selection_values.length) {
var multibtn_state = context.cell_element_function(selection_index, multibtn_selector + ' .btn:nth-child(' + (index + 1) + ')', 'hasClass', ['active']);
var radio_state = context.cell_element_function(selection_index, radio_selector + ' .radio:nth-child(' + (index + 1) + ') input', 'prop', ['checked']);
var list_val = context.cell_element_function(selection_index, list_selector, 'val');
var combo_val = context.cell_element_function(selection_index, combo_selector, 'html');
var val = selection_values.charAt(index);
var list_state = (val == list_val);
var combo_state = (val == combo_val);
return multibtn_state == state &&
radio_state == state &&
list_state == state &&
combo_state == state;
}
return true;
MinRK
first review pass on widget tests
r14797 };
Jonathan Frederic
Organized tests.
r14464
var verify_selection = function(context, index){
for (var i = 0; i < selection_values.length; i++) {
if (!check_state(context, i, i==index)) {
return false;
}
}
return true;
MinRK
first review pass on widget tests
r14797 };
Jonathan Frederic
Organized tests.
r14464
Jonathan Frederic
Fixed *almost* all of the test-detected bugs
r14596 //values=["' + selection_values + '"[i] for i in range(4)]
Jonathan Frederic
Organized tests.
r14464 selection_index = this.append_cell(
Jonathan Frederic
Fixed *almost* all of the test-detected bugs
r14596 'values=["' + selection_values + '"[i] for i in range(4)]\n' +
Jonathan Frederic
Renamed *Widget to *,...
r17598 'selection = [widgets.Dropdown(values=values),\n' +
' widgets.ToggleButtons(values=values),\n' +
' widgets.RadioButtons(values=values),\n' +
' widgets.Select(values=values)]\n' +
Jonathan Frederic
Many checks off the todo list, test fixes
r14583 '[display(selection[i]) for i in range(4)]\n' +
'for widget in selection:\n' +
' def handle_change(name,old,new):\n' +
' for other_widget in selection:\n' +
' other_widget.value = new\n' +
' widget.on_trait_change(handle_change, "value")\n' +
Jonathan Frederic
Organized tests.
r14464 'print("Success")\n');
this.execute_cell_then(selection_index, function(index){
MinRK
first review pass on widget tests
r14797 this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
Jonathan Frederic
Organized tests.
r14464 'Create selection cell executed with correct output.');
Jonathan Frederic
Make all tests async display safe
r18910 });
// Wait for the widgets to actually display.
this.wait_for_element(selection_index, combo_selector);
this.wait_for_element(selection_index, multibtn_selector);
this.wait_for_element(selection_index, radio_selector);
this.wait_for_element(selection_index, list_selector);
Jonathan Frederic
Organized tests.
r14464
Jonathan Frederic
Make all tests async display safe
r18910 // Continue with the tests.
this.then(function() {
this.test.assert(this.cell_element_exists(selection_index,
Jonathan Frederic
Organized tests.
r14464 '.widget-area .widget-subarea'),
'Widget subarea exists.');
Jonathan Frederic
Make all tests async display safe
r18910 this.test.assert(this.cell_element_exists(selection_index, combo_selector),
Jonathan Frederic
Organized tests.
r14464 'Widget combobox exists.');
Jonathan Frederic
Make all tests async display safe
r18910 this.test.assert(this.cell_element_exists(selection_index, multibtn_selector),
Jonathan Frederic
Organized tests.
r14464 'Widget multibutton exists.');
Jonathan Frederic
Make all tests async display safe
r18910 this.test.assert(this.cell_element_exists(selection_index, radio_selector),
Jonathan Frederic
Organized tests.
r14464 'Widget radio buttons exists.');
Jonathan Frederic
Make all tests async display safe
r18910 this.test.assert(this.cell_element_exists(selection_index, list_selector),
Jonathan Frederic
Organized tests.
r14464 'Widget list exists.');
// Verify that no items are selected.
MinRK
update selection test with null selection being invalid
r15058 this.test.assert(verify_selection(this, 0), 'Default first item selected.');
Jonathan Frederic
Organized tests.
r14464 });
index = this.append_cell(
Jonathan Frederic
Many checks off the todo list, test fixes
r14583 'for widget in selection:\n' +
' widget.value = "a"\n' +
Jonathan Frederic
Organized tests.
r14464 'print("Success")\n');
this.execute_cell_then(index, function(index){
MinRK
first review pass on widget tests
r14797 this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
Jonathan Frederic
Organized tests.
r14464 'Python select item executed with correct output.');
// Verify that the first item is selected.
this.test.assert(verify_selection(this, 0), 'Python selected');
// Verify that selecting a radio button updates all of the others.
this.cell_element_function(selection_index, radio_selector + ' .radio:nth-child(2) input', 'click');
Jonathan Frederic
Fixed *almost* all of the test-detected bugs
r14596 });
Jonathan Frederic
Remove sleep from the following,...
r14970 this.wait_for_idle();
Jonathan Frederic
Fixed *almost* all of the test-detected bugs
r14596 this.then(function () {
Jonathan Frederic
Organized tests.
r14464 this.test.assert(verify_selection(this, 1), 'Radio button selection updated view states correctly.');
// Verify that selecting a list option updates all of the others.
this.cell_element_function(selection_index, list_selector + ' option:nth-child(3)', 'click');
Jonathan Frederic
Fixed *almost* all of the test-detected bugs
r14596 });
Jonathan Frederic
Remove sleep from the following,...
r14970 this.wait_for_idle();
Jonathan Frederic
Fixed *almost* all of the test-detected bugs
r14596 this.then(function () {
Jonathan Frederic
Organized tests.
r14464 this.test.assert(verify_selection(this, 2), 'List selection updated view states correctly.');
// Verify that selecting a multibutton option updates all of the others.
Jonathan Frederic
Fixed test to reflect new Bootstrap3 toggle button behavior.
r16990 // Bootstrap3 has changed the toggle button group behavior. Two clicks
// are required to actually select an item.
this.cell_element_function(selection_index, multibtn_selector + ' .btn:nth-child(4)', 'click');
Jonathan Frederic
Organized tests.
r14464 this.cell_element_function(selection_index, multibtn_selector + ' .btn:nth-child(4)', 'click');
Jonathan Frederic
Fixed *almost* all of the test-detected bugs
r14596 });
Jonathan Frederic
Remove sleep from the following,...
r14970 this.wait_for_idle();
Jonathan Frederic
Fixed *almost* all of the test-detected bugs
r14596 this.then(function () {
Jonathan Frederic
Organized tests.
r14464 this.test.assert(verify_selection(this, 3), 'Multibutton selection updated view states correctly.');
// Verify that selecting a combobox option updates all of the others.
Jonathan Frederic
Cleaned up hbox and vbox widget div styles,...
r17929 this.cell_element_function(selection_index, '.widget-area .widget-subarea .widget-hbox .btn-group ul.dropdown-menu li:nth-child(3) a', 'click');
Jonathan Frederic
Fixed *almost* all of the test-detected bugs
r14596 });
Jonathan Frederic
Remove sleep from the following,...
r14970 this.wait_for_idle();
Jonathan Frederic
Fixed *almost* all of the test-detected bugs
r14596 this.then(function () {
Jonathan Frederic
Organized tests.
r14464 this.test.assert(verify_selection(this, 2), 'Combobox selection updated view states correctly.');
});
Jonathan Frederic
Remove sleep from the following,...
r14970 this.wait_for_idle();
Jonathan Frederic
Organized tests.
r14464
index = this.append_cell(
Jonathan Frederic
Selection test fix
r19169 'from copy import copy\n' +
Jonathan Frederic
Fixed *almost* all of the test-detected bugs
r14596 'for widget in selection:\n' +
Jonathan Frederic
Selection test fix
r19169 ' d = copy(widget.values)\n' +
' d.append("z")\n' +
MinRK
Make `SelectionWidget.values` a dict...
r15024 ' widget.values = d\n' +
Jonathan Frederic
Fixed bug in selection widget tests.
r14723 'selection[0].value = "z"');
Jonathan Frederic
Organized tests.
r14464 this.execute_cell_then(index, function(index){
// Verify that selecting a combobox option updates all of the others.
this.test.assert(verify_selection(this, 4), 'Item added to selection widget.');
});
});