@@ -29,7 +29,21 @@ vi.mock("../../visualBuilder.style", () => ({
2929} ) ) ;
3030
3131vi . mock ( "classnames" , ( ) => ( {
32- default : ( ...args : any [ ] ) => args . filter ( Boolean ) . join ( " " ) ,
32+ default : ( ...args : any [ ] ) => {
33+ const classes : string [ ] = [ ] ;
34+ args . forEach ( arg => {
35+ if ( typeof arg === 'string' ) {
36+ classes . push ( arg ) ;
37+ } else if ( typeof arg === 'object' && arg !== null ) {
38+ Object . entries ( arg ) . forEach ( ( [ className , condition ] ) => {
39+ if ( condition ) {
40+ classes . push ( className ) ;
41+ }
42+ } ) ;
43+ }
44+ } ) ;
45+ return classes . join ( ' ' ) ;
46+ } ,
3347} ) ) ;
3448
3549vi . mock ( "../icons/EmptyAppIcon" , ( ) => ( {
@@ -108,23 +122,23 @@ describe("FieldLocationAppList", () => {
108122 } ) ;
109123
110124 it ( "should render the app list with search input" , ( ) => {
111- render ( < FieldLocationAppList apps = { mockApps } position = "right" toolbarRef = { mockToolbarRef } /> ) ;
125+ render ( < FieldLocationAppList apps = { mockApps } position = "right" toolbarRef = { mockToolbarRef } domEditStack = { [ ] } setDisplayAllApps = { ( ) => { } } displayAllApps = { true } /> ) ;
112126
113127 expect ( screen . getByPlaceholderText ( "Search for Apps" ) ) . toBeInTheDocument ( ) ;
114128 expect ( screen . getByText ( "Second App" ) ) . toBeInTheDocument ( ) ;
115129 expect ( screen . getByText ( "Third App" ) ) . toBeInTheDocument ( ) ;
116130 } ) ;
117131
118132 it ( "should not render the first app (index 0)" , ( ) => {
119- render ( < FieldLocationAppList apps = { mockApps } position = "right" toolbarRef = { mockToolbarRef } /> ) ;
133+ render ( < FieldLocationAppList apps = { mockApps } position = "right" toolbarRef = { mockToolbarRef } domEditStack = { [ ] } setDisplayAllApps = { ( ) => { } } displayAllApps = { true } /> ) ;
120134
121135 expect ( screen . queryByText ( "First App" ) ) . not . toBeInTheDocument ( ) ;
122136 expect ( screen . getByText ( "Second App" ) ) . toBeInTheDocument ( ) ;
123137 expect ( screen . getByText ( "Third App" ) ) . toBeInTheDocument ( ) ;
124138 } ) ;
125139
126140 it ( "should filter apps when searching" , ( ) => {
127- render ( < FieldLocationAppList apps = { mockApps } position = "right" toolbarRef = { mockToolbarRef } /> ) ;
141+ render ( < FieldLocationAppList apps = { mockApps } position = "right" toolbarRef = { mockToolbarRef } domEditStack = { [ ] } setDisplayAllApps = { ( ) => { } } displayAllApps = { true } /> ) ;
128142
129143 const searchInput = screen . getByPlaceholderText ( "Search for Apps" ) ;
130144 fireEvent . input ( searchInput , { target : { value : "Second" } } ) ;
@@ -134,7 +148,7 @@ describe("FieldLocationAppList", () => {
134148 } ) ;
135149
136150 it ( "should show no results message when search has no matches" , ( ) => {
137- render ( < FieldLocationAppList apps = { mockApps } position = "right" toolbarRef = { mockToolbarRef } /> ) ;
151+ render ( < FieldLocationAppList apps = { mockApps } position = "right" toolbarRef = { mockToolbarRef } domEditStack = { [ ] } setDisplayAllApps = { ( ) => { } } displayAllApps = { true } /> ) ;
138152
139153 const searchInput = screen . getByPlaceholderText ( "Search for Apps" ) ;
140154 fireEvent . input ( searchInput , { target : { value : "NonExistent" } } ) ;
@@ -168,40 +182,54 @@ describe("FieldLocationAppList", () => {
168182 expect ( mockSetDisplayAllApps ) . toHaveBeenCalledWith ( false ) ;
169183 } ) ;
170184
171-
172-
173185
174186
175187 it ( "should apply correct CSS classes for right position" , ( ) => {
176- const { container } = render ( < FieldLocationAppList apps = { mockApps } position = "right" toolbarRef = { mockToolbarRef } /> ) ;
177-
188+ const { container } = render (
189+ < FieldLocationAppList
190+ apps = { mockApps }
191+ position = "right"
192+ toolbarRef = { mockToolbarRef }
193+ domEditStack = { [ ] }
194+ setDisplayAllApps = { ( ) => { } }
195+ displayAllApps = { true }
196+ />
197+ ) ;
178198 const appList = container . firstChild as HTMLElement ;
179- expect ( appList ) . toHaveClass ( "visual-builder__field-location-app-list" ) ;
199+ expect ( appList ) . toHaveClass ( "visual-builder__field-location-app-list--right " ) ;
180200 } ) ;
181201
182- it ( "should apply correct CSS classes for left position" , ( ) => {
183- const { container } = render ( < FieldLocationAppList apps = { mockApps } position = "left" toolbarRef = { mockToolbarRef } /> ) ;
184-
202+ it ( "should apply correct CSS classes and left position style for left position" , ( ) => {
203+ const { container } = render (
204+ < FieldLocationAppList
205+ apps = { mockApps }
206+ position = "left"
207+ toolbarRef = { mockToolbarRef }
208+ domEditStack = { [ ] }
209+ setDisplayAllApps = { ( ) => { } }
210+ displayAllApps = { true }
211+ />
212+ ) ;
185213 const appList = container . firstChild as HTMLElement ;
186- expect ( appList ) . toHaveClass ( "visual-builder__field-location-app-list" ) ;
214+ expect ( appList ) . toHaveClass ( "visual-builder__field-location-app-list--left " ) ;
187215 } ) ;
188216
189217 it ( "should handle empty apps array" , ( ) => {
190- render ( < FieldLocationAppList apps = { [ ] } position = "right" toolbarRef = { mockToolbarRef } /> ) ;
218+ render ( < FieldLocationAppList apps = { [ ] } position = "right" toolbarRef = { mockToolbarRef } domEditStack = { [ ] } setDisplayAllApps = { ( ) => { } } displayAllApps = { true } /> ) ;
191219
192220 expect ( screen . getByText ( "No matching results found!" ) ) . toBeInTheDocument ( ) ;
193221 } ) ;
194222
195223 it ( "should handle single app (which gets filtered out)" , ( ) => {
196224 const singleApp = [ mockApps [ 0 ] ] ;
197- render ( < FieldLocationAppList apps = { singleApp } position = "right" toolbarRef = { mockToolbarRef } /> ) ;
225+ render ( < FieldLocationAppList apps = { singleApp } position = "right" toolbarRef = { mockToolbarRef } domEditStack = { [ ] } setDisplayAllApps = { ( ) => { } } displayAllApps = { true } /> ) ;
198226
199227 expect ( screen . getByText ( "No matching results found!" ) ) . toBeInTheDocument ( ) ;
200228 expect ( screen . queryByText ( "First App" ) ) . not . toBeInTheDocument ( ) ;
201229 } ) ;
202230
203231 it ( "should handle case-insensitive search" , ( ) => {
204- render ( < FieldLocationAppList apps = { mockApps } position = "right" toolbarRef = { mockToolbarRef } /> ) ;
232+ render ( < FieldLocationAppList apps = { mockApps } position = "right" toolbarRef = { mockToolbarRef } domEditStack = { [ ] } setDisplayAllApps = { ( ) => { } } displayAllApps = { true } /> ) ;
205233
206234 const searchInput = screen . getByPlaceholderText ( "Search for Apps" ) ;
207235 fireEvent . input ( searchInput , { target : { value : "second" } } ) ;
@@ -211,7 +239,7 @@ describe("FieldLocationAppList", () => {
211239 } ) ;
212240
213241 it ( "should clear search results when search input is cleared" , ( ) => {
214- render ( < FieldLocationAppList apps = { mockApps } position = "right" toolbarRef = { mockToolbarRef } /> ) ;
242+ render ( < FieldLocationAppList apps = { mockApps } position = "right" toolbarRef = { mockToolbarRef } domEditStack = { [ ] } setDisplayAllApps = { ( ) => { } } displayAllApps = { true } /> ) ;
215243
216244 const searchInput = screen . getByPlaceholderText ( "Search for Apps" ) ;
217245
0 commit comments