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