This repository was archived by the owner on Jul 26, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +41
-2
lines changed
Expand file tree Collapse file tree 2 files changed +41
-2
lines changed Original file line number Diff line number Diff line change @@ -109,6 +109,23 @@ class LSParamsBuilder {
109109 }
110110 return this ;
111111 }
112+
113+ eventListeners ( eventListeners ) {
114+ this . params . eventListeners = eventListeners ;
115+ return this ;
116+ }
117+
118+ withEventListener ( eventName , listener ) {
119+ if ( ! this . params . eventListeners ) this . params . eventListeners = { } ;
120+ this . params . eventListeners [ eventName ] = listener ;
121+ return this ;
122+ }
123+
124+ withParam ( paramName , paramValue ) {
125+ this . params [ paramName ] = paramValue ;
126+ return this ;
127+ }
128+
112129}
113130
114131export const LabelStudio = {
@@ -154,7 +171,13 @@ export const LabelStudio = {
154171 . visit ( '/' )
155172 . then ( win => {
156173 cy . log ( `Default feature flags set ${ JSON . stringify ( win . APP_SETTINGS . feature_flags , null , ' ' ) } ` ) ;
157- new win . LabelStudio ( 'label-studio' , win . LSF_CONFIG ) ;
174+ const labelStudio = new win . LabelStudio ( 'label-studio' , win . LSF_CONFIG ) ;
175+
176+ if ( win . LSF_CONFIG . eventListeners ) {
177+ for ( const [ event , listener ] of Object . entries ( win . LSF_CONFIG . eventListeners ) ) {
178+ labelStudio . on ( event , listener ) ;
179+ }
180+ }
158181 expect ( win . LabelStudio . instances . size ) . to . be . equal ( 1 ) ;
159182 cy . get ( '.lsf-editor' ) . should ( 'be.visible' ) ;
160183 cy . log ( 'Label Studio initialized' ) ;
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ class TextareaHelper {
55 return '.lsf-text-area' ;
66 }
77
8- private _rootSelector : string
8+ private _rootSelector : string ;
99
1010 constructor ( rootSelector ) {
1111 this . _rootSelector = rootSelector . replace ( / ^ \& / , this . _baseRootSelector ) ;
@@ -25,10 +25,26 @@ class TextareaHelper {
2525 . find ( '[class^="row--"]' ) ;
2626 }
2727
28+ row ( idx : number ) {
29+ return this . rows . eq ( idx - 1 ) ;
30+ }
31+
2832 type ( text : string ) {
2933 return this . input . type ( text ) ;
3034 }
3135
36+ clickRowEdit ( idx : number ) {
37+ this . row ( idx ) . find ( '[aria-label="Edit Region"]' ) . click ( ) ;
38+ }
39+
40+ rowInput ( idx : number ) {
41+ return this . row ( idx ) . find ( '.ant-input' ) ;
42+ }
43+
44+ rowType ( idx : number , text : string ) {
45+ return this . rowInput ( idx ) . type ( text ) ;
46+ }
47+
3248 hasValue ( text : string ) {
3349 this . rows . contains ( text ) ;
3450 }
You can’t perform that action at this time.
0 commit comments