@@ -75,9 +75,10 @@ const COMBO_BOX_KEYS_TO_CLOSE: KeyToPress[] = [
7575
7676const COMBO_BOX_KEYS_TO_CLOSE_AND_RETURN_FOCUS : KeyToPress [ ] = [
7777 // TODO: Fix these tests
78- // "Enter",
79- // "Escape"
80- // "NumpadEnter",
78+ "Enter" ,
79+ "Escape" ,
80+ "Tab"
81+ // "NumpadEnter"
8182] ;
8283
8384const STRICT_FILTERS : ComboBoxSuggestOptions = { strict : true } ;
@@ -87,7 +88,8 @@ const testOpeningClosing = (suggest: boolean, strict?: true) => {
8788 suggest ? "suggest" : "combo-box"
8889 } ]${ strict ? "[strict]" : "" } `;
8990
90- const focusableElementTagName = suggest ? "input" : "div" ;
91+ // TODO: Fix this. The focusable element should not change
92+ // const focusableElementTagName = suggest ? "input" : "div";
9193
9294 describe ( testDescription , ( ) => {
9395 let page : E2EPage ;
@@ -103,8 +105,6 @@ const testOpeningClosing = (suggest: boolean, strict?: true) => {
103105
104106 // TODO: Add Mouse click in the test
105107 const keysToClose : KeyToPress [ ] = COMBO_BOX_KEYS_TO_CLOSE ;
106- const keysToCloseAndReturnFocus : KeyToPress [ ] =
107- COMBO_BOX_KEYS_TO_CLOSE_AND_RETURN_FOCUS ;
108108
109109 const checkPopoverDefined = async ( shouldBeDefined : boolean ) => {
110110 const popoverRef = await page . find ( "ch-combo-box-render >>> ch-popover" ) ;
@@ -204,23 +204,21 @@ const testOpeningClosing = (suggest: boolean, strict?: true) => {
204204 } ) ;
205205 } ) ;
206206
207- keysToCloseAndReturnFocus . forEach ( key => {
207+ COMBO_BOX_KEYS_TO_CLOSE_AND_RETURN_FOCUS . forEach ( key => {
208208 it ( `should close the popover when pressing KEY = "${ key } " and return the focus to the combo-box` , async ( ) => {
209209 await page . click ( "ch-combo-box-render" ) ;
210210 await page . waitForChanges ( ) ;
211211 await pressKey ( key ) ;
212212 await checkPopoverDefined ( false ) ;
213213
214214 const focusedElementTagName = await page . evaluate ( ( ) =>
215- document
216- . querySelector ( "ch-combo-box-render" )
217- . shadowRoot . activeElement ?. tagName . toLowerCase ( )
215+ document . activeElement . tagName . toLowerCase ( )
218216 ) ;
219- expect ( focusedElementTagName ) . toBe ( focusableElementTagName ) ;
217+ expect ( focusedElementTagName ) . toBe ( "ch-combo-box-render" ) ;
220218 } ) ;
221219 } ) ;
222220
223- keysToCloseAndReturnFocus . forEach ( key => {
221+ COMBO_BOX_KEYS_TO_CLOSE_AND_RETURN_FOCUS . forEach ( key => {
224222 it ( `should close the popover when pressing KEY = "${ key } " and return the focus to the combo-box even if the selection is updated` , async ( ) => {
225223 await page . click ( "ch-combo-box-render" ) ;
226224 await page . waitForChanges ( ) ;
@@ -229,11 +227,9 @@ const testOpeningClosing = (suggest: boolean, strict?: true) => {
229227 await checkPopoverDefined ( false ) ;
230228
231229 const focusedElementTagName = await page . evaluate ( ( ) =>
232- document
233- . querySelector ( "ch-combo-box-render" )
234- . shadowRoot . activeElement ?. tagName . toLowerCase ( )
230+ document . activeElement . tagName . toLowerCase ( )
235231 ) ;
236- expect ( focusedElementTagName ) . toBe ( focusableElementTagName ) ;
232+ expect ( focusedElementTagName ) . toBe ( "ch-combo-box-render" ) ;
237233 } ) ;
238234 } ) ;
239235
0 commit comments