@@ -30,6 +30,16 @@ const OverflowTestComponent = (props: PropTypes) => {
30
30
const { onOverflowChange } = props ;
31
31
const [ width , setWidth ] = useState ( undefined ) ;
32
32
const [ additionalChildren , setAdditionalChildren ] = useState ( [ ] ) ;
33
+ const [ eventProperties , setEventProperties ] = useState ( {
34
+ toolbarElements : [ ] ,
35
+ overflowElements : undefined ,
36
+ target : undefined
37
+ } ) ;
38
+
39
+ const handleOverflowChange = ( e ) => {
40
+ onOverflowChange ( e ) ;
41
+ setEventProperties ( e ) ;
42
+ } ;
33
43
return (
34
44
< >
35
45
< Input
@@ -62,7 +72,7 @@ const OverflowTestComponent = (props: PropTypes) => {
62
72
</ Button >
63
73
< Toolbar
64
74
data-testid = "toolbar"
65
- onOverflowChange = { onOverflowChange }
75
+ onOverflowChange = { handleOverflowChange }
66
76
style = { width ? { width : `${ width } px` , maxWidth : 'none' } : undefined }
67
77
>
68
78
< Text data-testid = "toolbar-item" style = { { width : '200px' } } >
@@ -79,6 +89,9 @@ const OverflowTestComponent = (props: PropTypes) => {
79
89
{ additionalChildren }
80
90
< ToolbarSeparator data-testid = "separator" />
81
91
</ Toolbar >
92
+ < br />
93
+ toolbarElements: < span data-testid = "toolbarElements" > { eventProperties . toolbarElements . length } </ span >
94
+ overflowElements: < span data-testid = "overflowElements" > { eventProperties . overflowElements ?. length } </ span >
82
95
</ >
83
96
) ;
84
97
} ;
@@ -128,6 +141,8 @@ describe('Toolbar', () => {
128
141
cy . viewport ( 300 , 500 ) ;
129
142
cy . mount ( < OverflowTestComponent onOverflowChange = { onOverflowChange } /> ) ;
130
143
cy . get ( '@overflowChangeSpy' ) . should ( 'have.been.calledOnce' ) ;
144
+ cy . findByTestId ( 'toolbarElements' ) . should ( 'have.text' , 2 ) ;
145
+ cy . findByTestId ( 'overflowElements' ) . should ( 'have.text' , 4 ) ;
131
146
cy . findByText ( 'Item1' ) . should ( 'be.visible' ) ;
132
147
cy . get ( '[data-testid="toolbar-item2"]' ) . should ( 'not.be.visible' ) ;
133
148
cy . get ( '[data-testid="toolbar-item3"]' ) . should ( 'not.be.visible' ) ;
@@ -146,12 +161,16 @@ describe('Toolbar', () => {
146
161
cy . get ( '[ui5-popover]' ) . should ( 'not.have.attr' , 'open' ) ;
147
162
148
163
cy . get ( '@overflowChangeSpy' ) . should ( 'have.callCount' , 2 ) ;
164
+ cy . findByTestId ( 'toolbarElements' ) . should ( 'have.text' , 3 ) ;
165
+ cy . findByTestId ( 'overflowElements' ) . should ( 'have.text' , 3 ) ;
149
166
150
167
cy . findByTestId ( 'input' ) . shadow ( ) . find ( 'input' ) . type ( '100' ) ;
151
168
cy . findByTestId ( 'input' ) . trigger ( 'change' ) ;
152
169
cy . findByTestId ( 'input' ) . shadow ( ) . find ( 'input' ) . clear ( { force : true } ) ;
153
170
154
171
cy . get ( '@overflowChangeSpy' ) . should ( 'have.callCount' , 3 ) ;
172
+ cy . findByTestId ( 'toolbarElements' ) . should ( 'have.text' , 0 ) ;
173
+ cy . findByTestId ( 'overflowElements' ) . should ( 'have.text' , 6 ) ;
155
174
156
175
cy . get ( '[data-testid="toolbar-item"]' ) . should ( 'not.be.visible' ) ;
157
176
cy . get ( '[data-testid="toolbar-item2"]' ) . should ( 'not.be.visible' ) ;
@@ -161,6 +180,8 @@ describe('Toolbar', () => {
161
180
cy . findByTestId ( 'input' ) . trigger ( 'change' ) ;
162
181
163
182
cy . get ( '@overflowChangeSpy' ) . should ( 'have.callCount' , 4 ) ;
183
+ cy . findByTestId ( 'toolbarElements' ) . should ( 'have.text' , 6 ) ;
184
+ cy . findByTestId ( 'overflowElements' ) . should ( 'not.have.text' ) ;
164
185
165
186
cy . get ( '[data-testid="toolbar-item"]' ) . should ( 'be.visible' ) ;
166
187
cy . get ( '[data-testid="toolbar-item2"]' ) . should ( 'be.visible' ) ;
@@ -170,10 +191,14 @@ describe('Toolbar', () => {
170
191
cy . findByTestId ( 'input' ) . trigger ( 'change' ) ;
171
192
172
193
cy . get ( '@overflowChangeSpy' ) . should ( 'have.callCount' , 5 ) ;
194
+ cy . findByTestId ( 'toolbarElements' ) . should ( 'have.text' , 3 ) ;
195
+ cy . findByTestId ( 'overflowElements' ) . should ( 'have.text' , 3 ) ;
173
196
174
197
cy . findByText ( 'Add' ) . click ( ) ;
175
198
176
199
cy . get ( '@overflowChangeSpy' ) . should ( 'have.callCount' , 6 ) ;
200
+ cy . findByTestId ( 'toolbarElements' ) . should ( 'have.text' , 3 ) ;
201
+ cy . findByTestId ( 'overflowElements' ) . should ( 'have.text' , 4 ) ;
177
202
178
203
cy . findByText ( 'Add' ) . click ( ) ;
179
204
cy . findByText ( 'Add' ) . click ( ) ;
@@ -182,10 +207,14 @@ describe('Toolbar', () => {
182
207
cy . findByText ( 'Add' ) . click ( ) ;
183
208
184
209
cy . get ( '@overflowChangeSpy' ) . should ( 'have.callCount' , 11 ) ;
210
+ cy . findByTestId ( 'toolbarElements' ) . should ( 'have.text' , 3 ) ;
211
+ cy . findByTestId ( 'overflowElements' ) . should ( 'have.text' , 9 ) ;
185
212
186
213
cy . findByText ( 'Remove' ) . click ( ) ;
187
214
188
215
cy . get ( '@overflowChangeSpy' ) . should ( 'have.callCount' , 12 ) ;
216
+ cy . findByTestId ( 'toolbarElements' ) . should ( 'have.text' , 3 ) ;
217
+ cy . findByTestId ( 'overflowElements' ) . should ( 'have.text' , 8 ) ;
189
218
190
219
cy . findByText ( 'Remove' ) . click ( ) ;
191
220
cy . findByText ( 'Remove' ) . click ( ) ;
@@ -194,6 +223,8 @@ describe('Toolbar', () => {
194
223
cy . findByText ( 'Remove' ) . click ( ) ;
195
224
196
225
cy . get ( '@overflowChangeSpy' ) . should ( 'have.callCount' , 17 ) ;
226
+ cy . findByTestId ( 'toolbarElements' ) . should ( 'have.text' , 3 ) ;
227
+ cy . findByTestId ( 'overflowElements' ) . should ( 'have.text' , 3 ) ;
197
228
198
229
cy . get ( `[ui5-toggle-button]` ) . click ( ) ;
199
230
0 commit comments