-
Notifications
You must be signed in to change notification settings - Fork 382
/
easyFormTest.js
144 lines (122 loc) · 5.61 KB
/
easyFormTest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*
* Copyright 2017 TWO SIGMA OPEN SOURCE, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var BeakerXPageObject = require('../beakerx.po.js');
var beakerxPO;
describe('Testing of EasyForm (groovy)', function () {
beforeAll(function () {
beakerxPO = new BeakerXPageObject();
beakerxPO.runNotebookByUrl('/notebooks/test/notebooks/groovy/EasyFormTest.ipynb');
}, 2);
afterAll(function () {
beakerxPO.closeAndHaltNotebook();
});
describe('EasyForm widget', function () {
it('Cell has EasyForm widget', function () {
var codeCell = beakerxPO.runCodeCellByIndex(0);
expect(codeCell.$('fieldset').isEnabled()).toBeTruthy();
expect(codeCell.$('legend').getText()).toBe('Legend name');
expect(codeCell.$('div.beaker-easyform-container').isEnabled()).toBeTruthy();
}, 2);
it('EasyForm has Text field', function () {
var easyForm = beakerxPO.runCellToGetEasyForm(1);
expect(easyForm.$('div.widget-text').isEnabled()).toBeTruthy();
expect(easyForm.$('label').getText()).toBe('field name2');
expect(easyForm.$('input[type="text"]').isEnabled()).toBeTruthy();
});
it('EasyForm has Textarea field', function () {
var easyForm = beakerxPO.runCellToGetEasyForm(2);
expect(easyForm.$('div.widget-textarea').isEnabled()).toBeTruthy();
expect(easyForm.$('label').getText()).toBe('field name3');
expect(easyForm.$('textarea').isEnabled()).toBeTruthy();
});
it('EasyForm has Checkbox field', function () {
var easyForm = beakerxPO.runCellToGetEasyForm(3);
expect(easyForm.$('div.widget-checkbox').isEnabled()).toBeTruthy();
expect(easyForm.$('span').getText()).toBe('field name4');
expect(easyForm.$('input[type="checkbox"]').isEnabled()).toBeTruthy();
});
it('EasyForm has Combobox field', function () {
var easyForm = beakerxPO.runCellToGetEasyForm(4);
expect(easyForm.$('div.widget-combobox').isEnabled()).toBeTruthy();
expect(easyForm.$('label').getText()).toBe('field name5');
expect(easyForm.$('select').getValue()).toBe('one');
expect(easyForm.$('span.easyform-combobox').isEnabled()).toBeTruthy();
});
it('EasyForm has List field', function () {
var easyForm = beakerxPO.runCellToGetEasyForm(5);
expect(easyForm.$('div.widget-select').isEnabled()).toBeTruthy();
expect(easyForm.$('label').getText()).toBe('field name6');
easyForm.$('select').selectByVisibleText('one');
expect(easyForm.$('select').getValue()).toBe('one');
});
it('EasyForm has CheckBoxes field', function () {
var easyForm = beakerxPO.runCellToGetEasyForm(6);
expect(easyForm.$$('div.widget-checkbox').length).toBe(3);
expect(easyForm.$$('input[type="checkbox"]').length).toBe(3);
expect(easyForm.$('div.widget-label').getText()).toBe('field name7');
});
it('EasyForm has RadioButtons field', function () {
var easyForm = beakerxPO.runCellToGetEasyForm(7);
expect(easyForm.$('div.widget-radio-box').isEnabled()).toBeTruthy();
expect(easyForm.$$('input[type="radio"]').length).toBe(3);
expect(easyForm.$('label.widget-label').getText()).toBe('field name8');
});
it('EasyForm has DatePicker field', function () {
var easyForm = beakerxPO.runCellToGetEasyForm(8);
expect(easyForm.$('div.datepicker-container').isEnabled()).toBeTruthy();
expect(easyForm.$('label.widget-label').getText()).toBe('field name9');
easyForm.$('a.date-picker-button').click();
browser.$('span.flatpickr-day=25').click();
expect(easyForm.$('input[type="text"]').getValue()).toMatch('25');
});
});
describe("EasyForm Actions", function(){
var inputs;
it('EasyForm has two buttons', function () {
var easyForm = beakerxPO.runCellToGetEasyForm(9);
easyForm.$('button=run tag').click();
beakerxPO.kernelIdleIcon.waitForEnabled();
easyForm.$('button=actionPerformed').click();
});
it('tag should create EasyForm', function () {
beakerxPO.kernelIdleIcon.waitForEnabled();
var codeCell_11 = beakerxPO.getCodeCellByIndex(11);
var easyForm = codeCell_11.$('div.beaker-easyform-container');
expect(easyForm.isEnabled()).toBeTruthy();
inputs = easyForm.$$('input[type="text"]');
});
it('onChange action should change text value', function () {
beakerxPO.runCallAndCheckOutputText(10, 'test text');
expect(inputs[1].getValue()).toBe('test text');
expect(inputs[2].getValue()).toBe('test text from onChange');
});
it('onInit action should change text value', function () {
expect(inputs[0].getValue()).toBe('from onInit');
});
it('actionPerformed should change text value', function () {
expect(inputs[3].getValue()).toBe('from actionPerformed');
});
});
describe('IntSlider widget in EasyForm', function(){
it('EasyForm has IntSlider widget', function(){
var easyForm = beakerxPO.runCellToGetEasyForm(12);
expect(easyForm.$('div.slider-container')).toBeTruthy();
});
it('IntSlider has value 50', function(){
beakerxPO.runCallAndCheckOutputText(13, '50');
});
});
});