1- import { Selector } from 'testcafe' ;
1+ import { ClientFunction , Selector } from 'testcafe' ;
22import type { WidgetName } from '../types' ;
33import Widget from '../internal/widget' ;
44import Field from './field' ;
55
6- type FieldType = 'item' | 'groupOperation' | 'itemOperation' | 'itemAction' ;
6+ type FieldType = 'item' | 'groupOperation' | 'itemOperation' | 'itemAction' | 'itemValue' ;
77const CLASS = {
8+ root : 'dx-filterbuilder' ,
9+ group : 'dx-filterbuilder-group' ,
10+ groupItem : 'dx-filterbuilder-group-item' ,
11+ addButton : 'dx-icon-plus' ,
12+ removeButton : 'dx-icon-remove' ,
813 item : 'dx-filterbuilder-item-field' ,
914 popupContent : 'dx-popup-content' ,
1015 treeView : 'dx-treeview' ,
1116 treeViewLeaf : 'dx-treeview-node-is-leaf' ,
1217 groupOperation : 'dx-filterbuilder-group-operation' ,
1318 itemOperation : 'dx-filterbuilder-item-operation' ,
19+ itemValue : 'dx-filterbuilder-item-value-text' ,
1420 itemAction : 'dx-filterbuilder-action' ,
1521} ;
1622
@@ -31,4 +37,71 @@ export default class FilterBuilder extends Widget {
3137 const fields = this . element . find ( `.${ cssClass } ` ) ;
3238 return new Field ( fields . nth ( index ) ) ;
3339 }
40+
41+ getRootElement ( ) : Selector {
42+ return this . element . find ( `.${ CLASS . root } ` ) ;
43+ }
44+
45+ getGroupByLevel ( level ) : Selector {
46+ return this . element . find ( `.${ CLASS . group } ` ) . nth ( level - 1 ) ;
47+ }
48+
49+ getGroupItem ( level ?) : Selector {
50+ if ( level ) {
51+ return this . getGroupByLevel ( level ) . find ( `.${ CLASS . groupItem } ` ) ;
52+ }
53+ return this . element . find ( `.${ CLASS . groupItem } ` ) ;
54+ }
55+
56+ getOperationButton ( level ?) : Selector {
57+ if ( level ) {
58+ return this . getGroupByLevel ( level ) . find ( `.${ CLASS . groupOperation } ` ) ;
59+ }
60+ return this . element . find ( `.${ CLASS . groupOperation } ` ) ;
61+ }
62+
63+ getAddButton ( level ?) : Selector {
64+ if ( level ) {
65+ return this . getGroupByLevel ( level ) . find ( `.${ CLASS . addButton } ` ) ;
66+ }
67+ return this . element . find ( `.${ CLASS . addButton } ` ) ;
68+ }
69+
70+ getRemoveButton ( index ?) : Selector {
71+ if ( index ) {
72+ return this . element . find ( `.${ CLASS . removeButton } ` ) . nth ( index ) ;
73+ }
74+ return this . element . find ( `.${ CLASS . removeButton } ` ) ;
75+ }
76+
77+ getItem ( item , index ?) {
78+ var className ;
79+ switch ( item ) {
80+ case 'operation' :
81+ className = CLASS . itemOperation ;
82+ break ;
83+ case 'field' :
84+ className = CLASS . item ;
85+ break ;
86+ case 'value' :
87+ className = CLASS . itemValue ;
88+ break ;
89+ default :
90+ throw new Error ( `Unsupported class name: ${ className } ` ) ;
91+ }
92+
93+ if ( index ) {
94+ return this . element . find ( `.${ className } ` ) . nth ( index ) ;
95+ }
96+ return this . element . find ( `.${ className } ` ) ;
97+ }
98+
99+ isReady ( ) : Promise < boolean > {
100+ const { getInstance } = this ;
101+
102+ return ClientFunction (
103+ ( ) => ( getInstance ( ) as any ) . isReady ( ) ,
104+ { dependencies : { getInstance } } ,
105+ ) ( ) ;
106+ }
34107}
0 commit comments