14
14
* limitations under the License.
15
15
*/
16
16
17
- import propertyUtils from "../../_utils_/property-utils " ;
18
- import tableUtils from "./../../_utils_/table-utils " ;
17
+ import propertyUtilsRTL from "../../_utils_/property-utilsRTL " ;
18
+ import tableUtilsRTL from "./../../_utils_/table-utilsRTL " ;
19
19
import { expect } from "chai" ;
20
20
import sharedFieldsParamDef from "../../test_resources/paramDefs/sharedFields_paramDef.json" ;
21
+ import { fireEvent } from "@testing-library/react" ;
21
22
22
23
23
24
describe ( "Condition dmSharedFields test cases" , ( ) => {
24
25
let wrapper ;
25
26
beforeEach ( ( ) => {
26
- const renderedObject = propertyUtils . flyoutEditorForm ( sharedFieldsParamDef ) ;
27
+ const renderedObject = propertyUtilsRTL . flyoutEditorForm ( sharedFieldsParamDef ) ;
27
28
wrapper = renderedObject . wrapper ;
28
29
} ) ;
29
30
afterEach ( ( ) => {
@@ -32,86 +33,94 @@ describe("Condition dmSharedFields test cases", () => {
32
33
33
34
34
35
it ( "Test the available fields." , ( ) => {
36
+ const { container } = wrapper ;
35
37
// Validate the available fields in the selectColumns control
36
- let fieldPicker = tableUtils . openFieldPicker ( wrapper , "properties-ft-input_fields" ) ;
37
- tableUtils . fieldPicker ( fieldPicker , [ ] , [ "Age" , "BP" , "Cholesterol" ] ) ;
38
+ let fieldPicker = tableUtilsRTL . openFieldPicker ( container , "properties-ft-input_fields" ) ;
39
+ tableUtilsRTL . fieldPicker ( fieldPicker , [ ] , [ "Age" , "BP" , "Cholesterol" ] ) ;
38
40
39
41
// Validate the available fields in the table control
40
- const summaryPanel = propertyUtils . openSummaryPanel ( wrapper , "structuretable_filter-summary-panel" ) ;
41
- fieldPicker = tableUtils . openFieldPicker ( wrapper , "properties-ft-structuretable_filter" ) ;
42
- const tableRows = tableUtils . getTableRows ( fieldPicker ) ;
42
+ const summaryPanel = propertyUtilsRTL . openSummaryPanel ( wrapper , "structuretable_filter-summary-panel" ) ;
43
+ fieldPicker = tableUtilsRTL . openFieldPicker ( container , "properties-ft-structuretable_filter" ) ;
44
+ const tableRows = tableUtilsRTL . getTableRows ( fieldPicker ) ;
43
45
expect ( tableRows ) . to . have . length ( 3 ) ; // Other fields should be filtered out
44
46
// close summary panel
45
- summaryPanel . find ( "button.properties-apply-button" ) . simulate ( "click" ) ;
47
+ fireEvent . click ( summaryPanel . querySelector ( "button.properties-apply-button" ) ) ;
46
48
47
49
// Check the available fields in the weight dropdown
48
- const weightDropDown = wrapper . find ( "div[data-id='properties-regression_weight_field'] Dropdown" ) ;
49
- let options = weightDropDown . prop ( "items" ) ; // by Type
50
- let expectedOptions = [
51
- { label : "..." , value : "" } ,
52
- { label : "K" , value : "K" } ,
53
- { label : "BP" , value : "BP" }
54
- ] ;
50
+ const weightDropDown = container . querySelector ( "div[data-id='properties-regression_weight_field']" ) ;
51
+ const weightDropDownButton = weightDropDown . querySelector ( "button.cds--list-box__field" ) ;
52
+ fireEvent . click ( weightDropDownButton ) ;
53
+ const weightDropDownItems = container . querySelectorAll ( ".cds--list-box__menu-item__option" ) ;
54
+ let options = [ ] ;
55
+ weightDropDownItems . forEach ( ( element ) => {
56
+ options . push ( element . textContent ) ;
57
+ } ) ;
58
+ let expectedOptions = [ "..." , "K" , "BP" ] ;
55
59
expect ( options ) . to . eql ( expectedOptions ) ;
56
60
57
61
// Check the available fields in the offset dropdown
58
- const offsetDropDown = wrapper . find ( "div[data-id='properties-offset_field'] Dropdown" ) ;
59
- options = offsetDropDown . prop ( "items" ) ; // by Type
60
- expectedOptions = [
61
- { label : "..." , value : "" } ,
62
- { label : "Na" , value : "Na" }
63
- ] ;
62
+ const offsetDropDown = container . querySelector ( "div[data-id='properties-offset_field']" ) ;
63
+ const offSetDropDownButton = offsetDropDown . querySelector ( "button.cds--list-box__field" ) ;
64
+ fireEvent . click ( offSetDropDownButton ) ;
65
+ const offsetDropDownItems = offsetDropDown . querySelectorAll ( ".cds--list-box__menu-item__option" ) ;
66
+ options = [ ] ;
67
+ offsetDropDownItems . forEach ( ( element ) => {
68
+ options . push ( element . textContent ) ;
69
+ } ) ;
70
+ expectedOptions = [ "..." , "Na" ] ;
64
71
expect ( options ) . to . eql ( expectedOptions ) ;
65
72
} ) ;
66
73
67
74
it ( "Test allow a change to a field to filter another field's choices." , ( ) => {
68
- let selectedFields = tableUtils . getTableRows ( wrapper . find ( "div[data-id='properties-input_fields']" ) ) ;
75
+ const { container } = wrapper ;
76
+ let selectedFields = tableUtilsRTL . getTableRows ( container . querySelector ( "div[data-id='properties-input_fields']" ) ) ;
69
77
expect ( selectedFields ) . to . have . length ( 2 ) ; // Age and Cholesterol already selected
70
78
// Select another field `BP` in the selectColumns control
71
- const fieldPicker = tableUtils . openFieldPicker ( wrapper , "properties-ft-input_fields" ) ;
72
- tableUtils . fieldPicker ( fieldPicker , [ "BP" ] , [ "Age" , "BP" , "Cholesterol" ] ) ;
73
- selectedFields = tableUtils . getTableRows ( wrapper . find ( "div[data-id='properties-input_fields']" ) ) ;
79
+ const fieldPicker = tableUtilsRTL . openFieldPicker ( container , "properties-ft-input_fields" ) ;
80
+ tableUtilsRTL . fieldPicker ( fieldPicker , [ "BP" ] , [ "Age" , "BP" , "Cholesterol" ] ) ;
81
+ selectedFields = tableUtilsRTL . getTableRows ( container . querySelector ( "div[data-id='properties-input_fields']" ) ) ;
74
82
expect ( selectedFields ) . to . have . length ( 3 ) ; // Age, BP, and Cholesterol selected
75
83
76
- const weightDropDown = wrapper . find ( "div[data-id='properties-regression_weight_field'] Dropdown" ) ;
77
- const options = weightDropDown . prop ( "items" ) ; // by Type
78
- const expectedOptions = [
79
- { label : "..." , value : "" } ,
80
- { label : "K" , value : "K" }
81
- ] ;
84
+ const weightDropDown = container . querySelector ( "div[data-id='properties-regression_weight_field']" ) ;
85
+ const weightDropDownButton = weightDropDown . querySelector ( "button.cds--list-box__field" ) ;
86
+ fireEvent . click ( weightDropDownButton ) ;
87
+ const weightDropDownItems = container . querySelectorAll ( ".cds--list-box__menu-item__option" ) ;
88
+ const options = [ ] ;
89
+ weightDropDownItems . forEach ( ( element ) => {
90
+ options . push ( element . textContent ) ;
91
+ } ) ;
92
+ const expectedOptions = [ "..." , "K" ] ;
82
93
expect ( options ) . to . eql ( expectedOptions ) ;
83
94
} ) ;
84
95
85
96
it ( "Shares fields between dmSharedFields and columnSelection panel" , ( ) => {
97
+ const { container } = wrapper ;
86
98
// Validate the available fields in the selectColumns control
87
- const fieldPicker = tableUtils . openFieldPicker ( wrapper , "properties-column_selection_fields" ) ;
88
- tableUtils . fieldPicker ( fieldPicker , [ ] , [ "Age" , "Sex" , "BP" , "Na" , "K" , "Drug" ] ) ;
99
+ const fieldPicker = tableUtilsRTL . openFieldPicker ( container , "properties-column_selection_fields" ) ;
100
+ tableUtilsRTL . fieldPicker ( fieldPicker , [ ] , [ "Age" , "Sex" , "BP" , "Na" , "K" , "Drug" ] ) ;
89
101
90
102
// Check the available fields in the single chooser dropdown
91
- const weightDropDown = wrapper . find ( "div[data-id='properties-column_selection_chooser'] Dropdown" ) ;
92
- let options = weightDropDown . prop ( "items" ) ; // by Type
93
- let expectedOptions = [
94
- { label : "..." , value : "" } ,
95
- { label : "Sex" , value : "Sex" } ,
96
- { label : "Cholesterol" , value : "Cholesterol" } ,
97
- { label : "Na" , value : "Na" } ,
98
- { label : "K" , value : "K" } ,
99
- { label : "Drug" , value : "Drug" }
100
- ] ;
103
+ const weightDropDown = container . querySelector ( "div[data-id='properties-column_selection_chooser']" ) ;
104
+ const weightDropDownButton = weightDropDown . querySelector ( "button.cds--list-box__field" ) ;
105
+ fireEvent . click ( weightDropDownButton ) ;
106
+ const weightDropDownItems = container . querySelectorAll ( ".cds--list-box__menu-item__option" ) ;
107
+ let options = [ ] ;
108
+ weightDropDownItems . forEach ( ( element ) => {
109
+ options . push ( element . textContent ) ;
110
+ } ) ;
111
+ let expectedOptions = [ "..." , "Sex" , "Cholesterol" , "Na" , "K" , "Drug" ] ;
101
112
expect ( options ) . to . eql ( expectedOptions ) ;
102
113
103
114
// Check the available fields in the offset dropdown
104
- const offsetDropDown = wrapper . find ( "div[data-id='properties-dmSharedFields_chooser'] Dropdown" ) ;
105
- options = offsetDropDown . prop ( "items" ) ; // by Type
106
- expectedOptions = [
107
- { label : "..." , value : "" } ,
108
- { label : "Age" , value : "Age" } ,
109
- { label : "Sex" , value : "Sex" } ,
110
- { label : "BP" , value : "BP" } ,
111
- { label : "Na" , value : "Na" } ,
112
- { label : "K" , value : "K" } ,
113
- { label : "Drug" , value : "Drug" }
114
- ] ;
115
+ const offsetDropDown = container . querySelector ( "div[data-id='properties-dmSharedFields_chooser']" ) ;
116
+ const offSetDropDownButton = offsetDropDown . querySelector ( "button.cds--list-box__field" ) ;
117
+ fireEvent . click ( offSetDropDownButton ) ;
118
+ const offsetDropDownItems = offsetDropDown . querySelectorAll ( ".cds--list-box__menu-item__option" ) ;
119
+ options = [ ] ;
120
+ offsetDropDownItems . forEach ( ( element ) => {
121
+ options . push ( element . textContent ) ;
122
+ } ) ;
123
+ expectedOptions = [ "..." , "Age" , "Sex" , "BP" , "Na" , "K" , "Drug" ] ;
115
124
expect ( options ) . to . eql ( expectedOptions ) ;
116
125
} ) ;
117
126
} ) ;
0 commit comments