@@ -154,9 +154,87 @@ test.describe('Mouse Behavior', () => {
154
154
155
155
expect ( ( popoverBoundingBox ?. y ?? 0 ) - triggerBottomAbsolutePosition ) . toBe ( 24 ) ;
156
156
} ) ;
157
+
158
+ // test(`GIVEN a combobox with a flip configured
159
+ // WHEN scrolling the page
160
+ // THEN the popover flip to the opposite end once space runs out`, async ({ page }) => {
161
+ // const { driver: d } = await setup(page, 'flip');
162
+
163
+ // const popover = d.getPopover();
164
+ // const trigger = d.getTrigger();
165
+
166
+ // // Introduce artificial spacing
167
+ // await trigger.evaluate((element) => (element.style.top = '800px'));
168
+
169
+ // await trigger.click();
170
+
171
+ // await expect(popover).toBeVisible();
172
+
173
+ // const popoverBoundingBox = await popover.boundingBox();
174
+ // const triggerBoundingBox = await trigger.boundingBox();
175
+
176
+ // console.log(triggerBoundingBox, popoverBoundingBox);
177
+
178
+ // const triggerBottomAbsolutePosition =
179
+ // (triggerBoundingBox?.y ?? 0) + (triggerBoundingBox?.height ?? 0);
180
+
181
+ // expect((popoverBoundingBox?.y ?? 0) - triggerBottomAbsolutePosition).toBe(24);
182
+ // });
157
183
} ) ;
158
184
159
185
test . describe ( 'Keyboard Behavior' , ( ) => {
186
+ for ( const key of [ 'Enter' , 'Space' ] ) {
187
+ test ( `GIVEN a closed hero popover
188
+ WHEN focusing on the button and pressing the '${ key } ' key
189
+ THEN the popover should open` , async ( { page } ) => {
190
+ const { driver : d } = await setup ( page , 'hero' ) ;
191
+ await expect ( d . getPopover ( ) ) . toBeHidden ( ) ;
192
+
193
+ await d . getTrigger ( ) . focus ( ) ;
194
+ await d . getTrigger ( ) . press ( key ) ;
195
+
196
+ await expect ( d . getPopover ( ) ) . toBeVisible ( ) ;
197
+ } ) ;
198
+
199
+ test ( `GIVEN a open hero popover
200
+ WHEN focusing on the button and pressing the '${ key } ' key
201
+ THEN the popover should close` , async ( { page } ) => {
202
+ const { driver : d } = await setup ( page , 'hero' ) ;
203
+
204
+ // Open the popover
205
+ await d . getTrigger ( ) . focus ( ) ;
206
+ await d . getTrigger ( ) . press ( key ) ;
207
+
208
+ await expect ( d . getPopover ( ) ) . toBeVisible ( ) ;
209
+
210
+ await d . getTrigger ( ) . blur ( ) ;
211
+
212
+ // Close the popover
213
+ await d . getTrigger ( ) . focus ( ) ;
214
+ await d . getTrigger ( ) . press ( key ) ;
215
+
216
+ await expect ( d . getPopover ( ) ) . toBeHidden ( ) ;
217
+ } ) ;
218
+ }
219
+
220
+ test ( `GIVEN a open hero popover
221
+ WHEN focusing on the button and pressing the 'Escape' key
222
+ THEN the popover should close and the trigger be focused` , async ( { page } ) => {
223
+ const { driver : d } = await setup ( page , 'hero' ) ;
224
+
225
+ // Open the popover
226
+ await d . getTrigger ( ) . focus ( ) ;
227
+ await d . getTrigger ( ) . press ( 'Enter' ) ;
228
+
229
+ await expect ( d . getPopover ( ) ) . toBeVisible ( ) ;
230
+
231
+ // Close the popover
232
+ page . keyboard . press ( 'Escape' ) ;
233
+
234
+ await expect ( d . getPopover ( ) ) . toBeHidden ( ) ;
235
+ await expect ( d . getTrigger ( ) ) . toBeFocused ( ) ;
236
+ } ) ;
237
+
160
238
test ( `GIVEN a programmatic popover with a programmatic trigger
161
239
WHEN focusing on the button and pressing the 'o' key
162
240
THEN the popover should open` , async ( { page } ) => {
@@ -170,12 +248,11 @@ test.describe('Keyboard Behavior', () => {
170
248
171
249
await expect ( d . getPopover ( ) ) . toBeVisible ( ) ;
172
250
} ) ;
173
-
174
251
test ( `GIVEN an open auto popover
175
252
WHEN the first trigger open and the focus changes to the second popover
176
253
THEN the first popover should close and the second one appear` , async ( { page } ) => {
177
254
const { driver : d } = await setup ( page , 'auto' ) ;
178
- //ask shai: is it good to use nth here???
255
+
179
256
const [ firstPopOver , secondPopOver ] = await d . getAllPopovers ( ) ;
180
257
const [ firstPopoverTrigger , secondPopoverTrigger ] = await d . getAllTriggers ( ) ;
181
258
@@ -199,7 +276,6 @@ test.describe('Keyboard Behavior', () => {
199
276
THEN then both popovers should be opened` , async ( { page } ) => {
200
277
const { driver : d } = await setup ( page , 'manual' ) ;
201
278
202
- //ask shai: is it good to use nth here???
203
279
const [ firstPopOver , secondPopOver ] = await d . getAllPopovers ( ) ;
204
280
const [ firstPopoverTrigger , secondPopoverTrigger ] = await d . getAllTriggers ( ) ;
205
281
0 commit comments