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