11import { expect } from '@vaadin/chai-plugins' ;
22import { sendKeys } from '@vaadin/test-runner-commands' ;
3- import {
4- esc ,
5- fixtureSync ,
6- focusout ,
7- nextRender ,
8- nextUpdate ,
9- oneEvent ,
10- outsideClick ,
11- tab ,
12- } from '@vaadin/testing-helpers' ;
3+ import { fixtureSync , focusout , nextRender , nextUpdate , oneEvent , outsideClick , tab } from '@vaadin/testing-helpers' ;
134import sinon from 'sinon' ;
145import './not-animated-styles.js' ;
156import { getDeepActiveElement } from '@vaadin/a11y-base/src/focus-utils.js' ;
@@ -226,16 +217,16 @@ describe('a11y', () => {
226217 let spy ;
227218
228219 beforeEach ( ( ) => {
229- spy = sinon . spy ( overlay . $ . overlay , 'focus' ) ;
220+ spy = sinon . spy ( popover , 'focus' ) ;
230221 } ) ;
231222
232- it ( 'should not move focus to the overlay content when opened by default' , async ( ) => {
223+ it ( 'should not focus the popover when opened by default' , async ( ) => {
233224 target . click ( ) ;
234225 await oneEvent ( overlay , 'vaadin-overlay-open' ) ;
235226 expect ( spy ) . to . not . be . called ;
236227 } ) ;
237228
238- it ( 'should move focus to the overlay content when opened if autofocus is true' , async ( ) => {
229+ it ( 'should focus the popover when opened if autofocus is true' , async ( ) => {
239230 popover . autofocus = true ;
240231 target . click ( ) ;
241232 await oneEvent ( overlay , 'vaadin-overlay-open' ) ;
@@ -255,31 +246,31 @@ describe('a11y', () => {
255246
256247 it ( 'should restore focus on Esc with trigger set to focus' , async ( ) => {
257248 const focusSpy = sinon . spy ( target , 'focus' ) ;
258- overlay . $ . overlay . focus ( ) ;
259- esc ( overlay . $ . overlay ) ;
249+ popover . focus ( ) ;
250+ await sendKeys ( { press : 'Escape' } ) ;
260251 await nextRender ( ) ;
261252
262253 expect ( focusSpy ) . to . be . calledOnce ;
263254 } ) ;
264255
265256 it ( 'should not re-open when restoring focus on Esc with trigger set to focus' , async ( ) => {
266- overlay . $ . overlay . focus ( ) ;
267- esc ( overlay . $ . overlay ) ;
257+ popover . focus ( ) ;
258+ await sendKeys ( { press : 'Escape' } ) ;
268259 await nextRender ( ) ;
269260
270261 expect ( popover . opened ) . to . be . false ;
271262 } ) ;
272263
273264 it ( 'should not re-open when restoring focus on outside click with trigger set to focus' , async ( ) => {
274- overlay . $ . overlay . focus ( ) ;
265+ popover . focus ( ) ;
275266 outsideClick ( ) ;
276267 await nextRender ( ) ;
277268
278269 expect ( popover . opened ) . to . be . false ;
279270 } ) ;
280271
281272 it ( 'should re-open when re-focusing after closing on outside click with trigger set to focus' , async ( ) => {
282- overlay . $ . overlay . focus ( ) ;
273+ popover . focus ( ) ;
283274 outsideClick ( ) ;
284275 await nextRender ( ) ;
285276
@@ -302,8 +293,8 @@ describe('a11y', () => {
302293
303294 it ( 'should restore focus on Esc with trigger set to click' , async ( ) => {
304295 const focusSpy = sinon . spy ( target , 'focus' ) ;
305- overlay . $ . overlay . focus ( ) ;
306- esc ( overlay . $ . overlay ) ;
296+ popover . focus ( ) ;
297+ await sendKeys ( { press : 'Escape' } ) ;
307298 await nextRender ( ) ;
308299
309300 expect ( focusSpy ) . to . be . calledOnce ;
@@ -321,8 +312,8 @@ describe('a11y', () => {
321312 const focusSpy = sinon . spy ( target , 'focus' ) ;
322313 tab ( target ) ;
323314 focusout ( target , overlay ) ;
324- overlay . $ . overlay . focus ( ) ;
325- esc ( overlay . $ . overlay ) ;
315+ popover . focus ( ) ;
316+ await sendKeys ( { press : 'Escape' } ) ;
326317 await nextRender ( ) ;
327318
328319 expect ( focusSpy ) . to . be . calledOnce ;
@@ -340,8 +331,8 @@ describe('a11y', () => {
340331 await oneEvent ( overlay , 'vaadin-overlay-open' ) ;
341332
342333 const focusSpy = sinon . spy ( target , 'focus' ) ;
343- overlay . $ . overlay . focus ( ) ;
344- esc ( overlay . $ . overlay ) ;
334+ popover . focus ( ) ;
335+ await sendKeys ( { press : 'Escape' } ) ;
345336 await nextRender ( ) ;
346337
347338 expect ( focusSpy ) . to . not . be . called ;
@@ -389,8 +380,8 @@ describe('a11y', () => {
389380 await nextRender ( ) ;
390381
391382 const focusSpy = sinon . spy ( target , 'focus' ) ;
392- overlay . $ . overlay . focus ( ) ;
393- esc ( overlay . $ . overlay ) ;
383+ popover . focus ( ) ;
384+ await sendKeys ( { press : 'Escape' } ) ;
394385 await nextRender ( ) ;
395386
396387 expect ( focusSpy ) . to . not . be . called ;
@@ -400,8 +391,8 @@ describe('a11y', () => {
400391 mouseenter ( target ) ;
401392
402393 const focusSpy = sinon . spy ( target , 'focus' ) ;
403- overlay . $ . overlay . focus ( ) ;
404- esc ( overlay . $ . overlay ) ;
394+ popover . focus ( ) ;
395+ await sendKeys ( { press : 'Escape' } ) ;
405396 await nextRender ( ) ;
406397
407398 expect ( focusSpy ) . to . be . calledOnce ;
@@ -432,10 +423,10 @@ describe('a11y', () => {
432423 await oneEvent ( overlay , 'vaadin-overlay-open' ) ;
433424 } ) ;
434425
435- it ( 'should focus the overlay content part on target Tab' , async ( ) => {
426+ it ( 'should focus the popover on target Tab' , async ( ) => {
436427 target . focus ( ) ;
437428
438- const spy = sinon . spy ( overlay . $ . overlay , 'focus' ) ;
429+ const spy = sinon . spy ( popover , 'focus' ) ;
439430 await sendKeys ( { press : 'Tab' } ) ;
440431
441432 expect ( spy ) . to . be . calledOnce ;
@@ -483,13 +474,13 @@ describe('a11y', () => {
483474 expect ( spy ) . to . be . calledOnce ;
484475 } ) ;
485476
486- it ( 'should not focus the overlay part on the next element Tab' , async ( ) => {
477+ it ( 'should not focus the popover on the next element Tab' , async ( ) => {
487478 input . focus ( ) ;
488479
489480 await sendKeys ( { press : 'Tab' } ) ;
490481
491482 const activeElement = getDeepActiveElement ( ) ;
492- expect ( activeElement ) . to . not . equal ( overlay . $ . overlay ) ;
483+ expect ( activeElement ) . to . not . equal ( popover ) ;
493484 } ) ;
494485
495486 it ( 'should focus previous element on target Shift Tab while opened' , async ( ) => {
@@ -543,18 +534,18 @@ describe('a11y', () => {
543534 expect ( activeElement ) . to . equal ( input ) ;
544535 } ) ;
545536
546- it ( 'should focus the overlay content part on focusable content Shift Tab' , async ( ) => {
537+ it ( 'should focus the popover on focusable content Shift Tab' , async ( ) => {
547538 // Move focus to the overlay
548539 await sendKeys ( { press : 'Tab' } ) ;
549540
550541 // Move focus to the input inside the overlay
551542 await sendKeys ( { press : 'Tab' } ) ;
552543
553- // Move focus back to the overlay part
544+ // Move focus back to the popover
554545 await sendKeys ( { press : 'Shift+Tab' } ) ;
555546
556547 const activeElement = getDeepActiveElement ( ) ;
557- expect ( activeElement ) . to . equal ( overlay . $ . overlay ) ;
548+ expect ( activeElement ) . to . equal ( popover ) ;
558549 } ) ;
559550 } ) ;
560551 } ) ;
0 commit comments