##// END OF EJS Templates
Merge pull request #7138 from quantopian/js-lint-errors...
Merge pull request #7138 from quantopian/js-lint-errors Minor cleanups in the contents API.

File last commit:

r18910:4100b1b7
r19368:429bbe5c merge
Show More
widget_selectioncontainer.js
119 lines | 5.3 KiB | application/javascript | JavascriptLexer
/ IPython / html / tests / widgets / widget_selectioncontainer.js
Jonathan Frederic
Organized tests.
r14464 // Test multicontainer 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);
// Test tab view
var multicontainer1_query = '.widget-area .widget-subarea div div.nav-tabs';
var multicontainer1_index = this.append_cell(
Jonathan Frederic
Renamed *Widget to *,...
r17598 'multicontainer = widgets.Tab()\n' +
'page1 = widgets.Text()\n' +
'page2 = widgets.Text()\n' +
'page3 = widgets.Text()\n' +
Jonathan Frederic
Fixed JS tests to reflect Jason's changes
r14509 'multicontainer.children = [page1, page2, page3]\n' +
Jonathan Frederic
Organized tests.
r14464 'display(multicontainer)\n' +
'multicontainer.selected_index = 0\n' +
'print("Success")\n');
this.execute_cell_then(multicontainer1_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 multicontainer cell executed with correct output. (1)');
Jonathan Frederic
Make all tests async display safe
r18910 });
// Wait for the widget to actually display.
this.wait_for_element(multicontainer1_index, multicontainer1_query);
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(multicontainer1_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(multicontainer1_index, multicontainer1_query),
Jonathan Frederic
Organized tests.
r14464 'Widget tab list exists.');
// JQuery selector is 1 based
MinRK
first review pass on widget tests
r14797 this.click(multicontainer1_query + ' li:nth-child(2) a');
Jonathan Frederic
Organized tests.
r14464 });
Jonathan Frederic
Remove sleep from the following,...
r14970 this.wait_for_idle();
Jonathan Frederic
Organized tests.
r14464
index = this.append_cell(
'print(multicontainer.selected_index)\n' +
'multicontainer.selected_index = 2'); // 0 based
this.execute_cell_then(index, function(index){
MinRK
first review pass on widget tests
r14797 this.test.assertEquals(this.get_output_cell(index).text, '1\n', // 0 based
Jonathan Frederic
Organized tests.
r14464 'selected_index property updated with tab change.');
// JQuery selector is 1 based
this.test.assert(!this.cell_element_function(multicontainer1_index, multicontainer1_query + ' li:nth-child(1)', 'hasClass', ['active']),
MinRK
first review pass on widget tests
r14797 "Tab 1 is not selected.");
Jonathan Frederic
Organized tests.
r14464 this.test.assert(!this.cell_element_function(multicontainer1_index, multicontainer1_query + ' li:nth-child(2)', 'hasClass', ['active']),
MinRK
first review pass on widget tests
r14797 "Tab 2 is not selected.");
Jonathan Frederic
Organized tests.
r14464 this.test.assert(this.cell_element_function(multicontainer1_index, multicontainer1_query + ' li:nth-child(3)', 'hasClass', ['active']),
MinRK
first review pass on widget tests
r14797 "Tab 3 is selected.");
Jonathan Frederic
Organized tests.
r14464 });
index = this.append_cell('multicontainer.set_title(1, "hello")\nprint("Success")'); // 0 based
this.execute_cell_then(index, function(index){
this.test.assert(this.cell_element_function(multicontainer1_index, multicontainer1_query +
' li:nth-child(2) a', 'html') == 'hello',
'Tab page title set (after display).');
});
// Test accordion view
Jonathan Frederic
Ran jdfreder/bootstrap2to3
r16913 var multicontainer2_query = '.widget-area .widget-subarea .panel-group';
Jonathan Frederic
Organized tests.
r14464 var multicontainer2_index = this.append_cell(
Jonathan Frederic
Renamed *Widget to *,...
r17598 'multicontainer = widgets.Accordion()\n' +
'page1 = widgets.Text()\n' +
'page2 = widgets.Text()\n' +
'page3 = widgets.Text()\n' +
Jonathan Frederic
Fixed JS tests to reflect Jason's changes
r14509 'multicontainer.children = [page1, page2, page3]\n' +
Jonathan Frederic
Organized tests.
r14464 'multicontainer.set_title(2, "good")\n' +
Jonathan Frederic
Fixed *almost* all of the test-detected bugs
r14596 'display(multicontainer)\n' +
Jonathan Frederic
Organized tests.
r14464 'multicontainer.selected_index = 0\n' +
'print("Success")\n');
this.execute_cell_then(multicontainer2_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 multicontainer cell executed with correct output. (2)');
Jonathan Frederic
Make all tests async display safe
r18910 });
// Wait for the widget to actually display.
this.wait_for_element(multicontainer2_index, multicontainer2_query);
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(multicontainer2_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(multicontainer2_index, multicontainer2_query),
Jonathan Frederic
Fix automation errors.
r16914 'Widget accordion exists.');
Jonathan Frederic
Organized tests.
r14464
Jonathan Frederic
Make all tests async display safe
r18910 this.test.assert(this.cell_element_exists(multicontainer2_index, multicontainer2_query +
Jonathan Frederic
Fix automation errors.
r16914 ' .panel:nth-child(1) .panel-collapse'),
'First accordion page exists.');
Jonathan Frederic
Organized tests.
r14464
// JQuery selector is 1 based
Jonathan Frederic
Make all tests async display safe
r18910 this.test.assert(this.cell_element_function(multicontainer2_index, multicontainer2_query +
Jonathan Frederic
Ran jdfreder/bootstrap2to3
r16913 ' .panel.panel-default:nth-child(3) .panel-heading .accordion-toggle',
Jonathan Frederic
Organized tests.
r14464 'html')=='good', 'Accordion page title set (before display).');
// JQuery selector is 1 based
Jonathan Frederic
Fix automation errors.
r16914 this.click(multicontainer2_query + ' .panel:nth-child(2) .panel-heading .accordion-toggle');
Jonathan Frederic
Organized tests.
r14464 });
Jonathan Frederic
Remove sleep from the following,...
r14970 this.wait_for_idle();
Jonathan Frederic
Organized tests.
r14464
index = this.append_cell('print(multicontainer.selected_index)'); // 0 based
this.execute_cell_then(index, function(index){
MinRK
first review pass on widget tests
r14797 this.test.assertEquals(this.get_output_cell(index).text, '1\n', // 0 based
Jonathan Frederic
Organized tests.
r14464 'selected_index property updated with tab change.');
Jonathan Frederic
Added a test
r15976
var is_collapsed = this.evaluate(function(s){
Jonathan Frederic
Fix automation errors.
r16914 return $(s + ' div.panel:nth-child(2) a').hasClass('collapsed'); // 1 based
Jonathan Frederic
Added a test
r15976 }, {s: multicontainer2_query});
this.test.assertEquals(is_collapsed, false, 'Was tab actually opened?');
Jonathan Frederic
Organized tests.
r14464 });
});