##// END OF EJS Templates
Print cell output
Jonathan Frederic -
Show More
@@ -1,80 +1,81 b''
1 1 // Test container class
2 2 casper.notebook_test(function () {
3 3 index = this.append_cell(
4 4 'from IPython.html import widgets\n' +
5 5 'from IPython.display import display, clear_output\n' +
6 6 'print("Success")');
7 7 this.execute_cell_then(index);
8 8
9 9 var container_index = this.append_cell(
10 10 'container = widgets.ContainerWidget()\n' +
11 11 'button = widgets.ButtonWidget()\n'+
12 12 'container.children = [button]\n'+
13 13 'display(container)\n'+
14 14 'container.add_class("my-test-class")\n'+
15 15 'print("Success")\n');
16 16 this.execute_cell_then(container_index, function(index){
17 17
18 print(this.get_output_cell(index).text);
18 19 this.test.assert(this.get_output_cell(index).text == 'Success\n',
19 20 'Create container cell executed with correct output.');
20 21
21 22 this.test.assert(this.cell_element_exists(index,
22 23 '.widget-area .widget-subarea'),
23 24 'Widget subarea exists.');
24 25
25 26 this.test.assert(this.cell_element_exists(index,
26 27 '.widget-area .widget-subarea .widget-container'),
27 28 'Widget container exists.');
28 29
29 30 this.test.assert(this.cell_element_exists(index,
30 31 '.widget-area .widget-subarea .my-test-class'),
31 32 'add_class works.');
32 33
33 34 this.test.assert(this.cell_element_exists(index,
34 35 '.widget-area .widget-subarea .my-test-class button'),
35 36 'Container parent/child relationship works.');
36 37 });
37 38
38 39 index = this.append_cell(
39 40 'container.set_css("float", "right")\n'+
40 41 'print("Success")\n');
41 42 this.execute_cell_then(index, function(index){
42 43
43 44 this.test.assert(this.get_output_cell(index).text == 'Success\n',
44 45 'Set container class CSS cell executed with correct output.');
45 46
46 47 this.test.assert(this.cell_element_function(container_index,
47 48 '.widget-area .widget-subarea .my-test-class', 'css', ['float'])=='right',
48 49 'set_css works.');
49 50 });
50 51
51 52 index = this.append_cell(
52 53 'container.remove_class("my-test-class")\n'+
53 54 'print("Success")\n');
54 55 this.execute_cell_then(index, function(index){
55 56
56 57 this.test.assert(this.get_output_cell(index).text == 'Success\n',
57 58 'Remove container class cell executed with correct output.');
58 59
59 60 this.test.assert(! this.cell_element_exists(container_index,
60 61 '.widget-area .widget-subarea .my-test-class'),
61 62 'remove_class works.');
62 63 });
63 64
64 65 index = this.append_cell(
65 66 'display(button)\n'+
66 67 'print("Success")\n');
67 68 this.execute_cell_then(index, function(index){
68 69
69 70 this.test.assert(this.get_output_cell(index).text == 'Success\n',
70 71 'Display container child executed with correct output.');
71 72
72 73 this.test.assert(! this.cell_element_exists(index,
73 74 '.widget-area .widget-subarea .widget-container'),
74 75 'Parent container not displayed.');
75 76
76 77 this.test.assert(this.cell_element_exists(index,
77 78 '.widget-area .widget-subarea button'),
78 79 'Child displayed.');
79 80 });
80 81 }); No newline at end of file
@@ -1,108 +1,108 b''
1 1 // Test multicontainer class
2 2 casper.notebook_test(function () {
3 3 index = this.append_cell(
4 4 'from IPython.html import widgets\n' +
5 5 'from IPython.display import display, clear_output\n' +
6 6 'print("Success")');
7 7 this.execute_cell_then(index);
8 8
9 9 // Test tab view
10 10 var multicontainer1_query = '.widget-area .widget-subarea div div.nav-tabs';
11 11 var multicontainer1_index = this.append_cell(
12 12 'multicontainer = widgets.MulticontainerWidget()\n' +
13 13 'page1 = widgets.StringWidget()\n' +
14 14 'page2 = widgets.StringWidget()\n' +
15 15 'page3 = widgets.StringWidget()\n' +
16 16 'multicontainer.children = [page1, page2, page3]\n' +
17 17 'display(multicontainer)\n' +
18 18 'multicontainer.selected_index = 0\n' +
19 19 'print("Success")\n');
20 20 this.execute_cell_then(multicontainer1_index, function(index){
21
21 print(this.get_output_cell(index).text);
22 22 this.test.assert(this.get_output_cell(index).text == 'Success\n',
23 23 'Create multicontainer cell executed with correct output. (1)');
24 24
25 25 this.test.assert(this.cell_element_exists(index,
26 26 '.widget-area .widget-subarea'),
27 27 'Widget subarea exists.');
28 28
29 29 this.test.assert(this.cell_element_exists(index, multicontainer1_query),
30 30 'Widget tab list exists.');
31 31
32 32 this.test.assert(this.cell_element_exists(index, multicontainer1_query),
33 33 'First widget tab list exists.');
34 34
35 35 // JQuery selector is 1 based
36 36 this.click(multicontainer1_query + ' li:nth-child(2) a')
37 37 });
38 38
39 39 this.wait(500); // Wait for change to execute in kernel
40 40
41 41 index = this.append_cell(
42 42 'print(multicontainer.selected_index)\n' +
43 43 'multicontainer.selected_index = 2'); // 0 based
44 44 this.execute_cell_then(index, function(index){
45 45 this.test.assert(this.get_output_cell(index).text == '1\n', // 0 based
46 46 'selected_index property updated with tab change.');
47 47
48 48 // JQuery selector is 1 based
49 49 this.test.assert(!this.cell_element_function(multicontainer1_index, multicontainer1_query + ' li:nth-child(1)', 'hasClass', ['active']),
50 50 "Tab 1 is not selected.")
51 51 this.test.assert(!this.cell_element_function(multicontainer1_index, multicontainer1_query + ' li:nth-child(2)', 'hasClass', ['active']),
52 52 "Tab 2 is not selected.")
53 53 this.test.assert(this.cell_element_function(multicontainer1_index, multicontainer1_query + ' li:nth-child(3)', 'hasClass', ['active']),
54 54 "Tab 3 is selected.")
55 55 });
56 56
57 57 index = this.append_cell('multicontainer.set_title(1, "hello")\nprint("Success")'); // 0 based
58 58 this.execute_cell_then(index, function(index){
59 59 this.test.assert(this.cell_element_function(multicontainer1_index, multicontainer1_query +
60 60 ' li:nth-child(2) a', 'html') == 'hello',
61 61 'Tab page title set (after display).');
62 62 });
63 63
64 64 // Test accordion view
65 65 var multicontainer2_query = '.widget-area .widget-subarea .accordion';
66 66 var multicontainer2_index = this.append_cell(
67 67 'multicontainer = widgets.MulticontainerWidget()\n' +
68 68 'page1 = widgets.StringWidget()\n' +
69 69 'page2 = widgets.StringWidget()\n' +
70 70 'page3 = widgets.StringWidget()\n' +
71 71 'multicontainer.children = [page1, page2, page3]\n' +
72 72 'multicontainer.set_title(2, "good")\n' +
73 73 'display(multicontainer, view_name="AccordionView")\n' +
74 74 'multicontainer.selected_index = 0\n' +
75 75 'print("Success")\n');
76 76 this.execute_cell_then(multicontainer2_index, function(index){
77 77
78 78 this.test.assert(this.get_output_cell(index).text == 'Success\n',
79 79 'Create multicontainer cell executed with correct output. (2)');
80 80
81 81 this.test.assert(this.cell_element_exists(index,
82 82 '.widget-area .widget-subarea'),
83 83 'Widget subarea exists.');
84 84
85 85 this.test.assert(this.cell_element_exists(index, multicontainer2_query),
86 86 'Widget accordion exists.');
87 87
88 88 this.test.assert(this.cell_element_exists(index, multicontainer2_query +
89 89 ' .accordion-group:nth-child(1) .accordion-body'),
90 90 'First accordion page exists.');
91 91
92 92 // JQuery selector is 1 based
93 93 this.test.assert(this.cell_element_function(index, multicontainer2_query +
94 94 ' .accordion-group:nth-child(3) .accordion-heading .accordion-toggle',
95 95 'html')=='good', 'Accordion page title set (before display).');
96 96
97 97 // JQuery selector is 1 based
98 98 this.click(multicontainer2_query + ' .accordion-group:nth-child(2) .accordion-heading .accordion-toggle');
99 99 });
100 100
101 101 this.wait(500); // Wait for change to execute in kernel
102 102
103 103 index = this.append_cell('print(multicontainer.selected_index)'); // 0 based
104 104 this.execute_cell_then(index, function(index){
105 105 this.test.assert(this.get_output_cell(index).text == '1\n', // 0 based
106 106 'selected_index property updated with tab change.');
107 107 });
108 108 }); No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now