@@ -95,23 +95,23 @@ describe('VCombobox', () => {
95
95
await userEvent . click ( ( await screen . findAllByRole ( 'option' ) ) [ 0 ] )
96
96
expect ( model . value ) . toStrictEqual ( items [ 0 ] )
97
97
expect ( search . value ) . toBe ( items [ 0 ] . title )
98
- expect ( screen . getByRole ( 'textbox ') ) . toHaveValue ( items [ 0 ] . title )
98
+ expect ( screen . getByCSS ( 'input ') ) . toHaveValue ( items [ 0 ] . title )
99
99
expect ( screen . getByCSS ( '.v-combobox__selection' ) ) . toHaveTextContent ( items [ 0 ] . title )
100
100
101
101
await userEvent . click ( element )
102
- await userEvent . keyboard ( '{Control >}a{/Ctrl}{Backspace}' )
102
+ await userEvent . keyboard ( '{Ctrl >}a{/Ctrl}{Backspace}' )
103
103
await userEvent . keyboard ( 'Item 2' )
104
104
expect ( model . value ) . toBe ( 'Item 2' )
105
105
expect ( search . value ) . toBe ( 'Item 2' )
106
- expect ( screen . getByRole ( 'textbox ') ) . toHaveValue ( 'Item 2' )
106
+ expect ( screen . getByCSS ( 'input ') ) . toHaveValue ( 'Item 2' )
107
107
expect ( screen . getByCSS ( '.v-combobox__selection' ) ) . toHaveTextContent ( 'Item 2' )
108
108
109
109
await userEvent . click ( element )
110
- await userEvent . keyboard ( '{Control >}a{/Ctrl}{Backspace}' )
110
+ await userEvent . keyboard ( '{Ctrl >}a{/Ctrl}{Backspace}' )
111
111
await userEvent . keyboard ( 'item3' )
112
112
expect ( model . value ) . toBe ( 'item3' )
113
113
expect ( search . value ) . toBe ( 'item3' )
114
- expect ( screen . getByRole ( 'textbox ') ) . toHaveValue ( 'item3' )
114
+ expect ( screen . getByCSS ( 'input ') ) . toHaveValue ( 'item3' )
115
115
expect ( screen . getByCSS ( '.v-combobox__selection' ) ) . toHaveTextContent ( 'item3' )
116
116
} )
117
117
@@ -138,25 +138,27 @@ describe('VCombobox', () => {
138
138
/>
139
139
) )
140
140
141
+ const input = screen . getByCSS ( 'input' )
142
+
141
143
await userEvent . click ( element )
142
144
await userEvent . click ( screen . getAllByRole ( 'option' ) [ 0 ] )
143
145
expect ( model . value ) . toStrictEqual ( [ items [ 0 ] ] )
144
146
expect ( search . value ) . toBeUndefined ( )
145
- expect ( screen . getByRole ( 'textbox' ) ) . toHaveValue ( '' )
147
+ expect ( input ) . toHaveValue ( '' )
146
148
expect ( screen . getByCSS ( '.v-combobox__selection' ) ) . toHaveTextContent ( items [ 0 ] . title )
147
149
148
150
await userEvent . click ( element )
149
151
await userEvent . keyboard ( 'Item 2{tab}' )
150
152
expect ( model . value ) . toStrictEqual ( [ items [ 0 ] , 'Item 2' ] )
151
153
expect ( search . value ) . toBe ( '' )
152
- expect ( screen . getByRole ( 'textbox' ) ) . toHaveValue ( '' )
154
+ expect ( input ) . toHaveValue ( '' )
153
155
expect ( screen . getAllByCSS ( '.v-combobox__selection' ) . at ( - 1 ) ) . toHaveTextContent ( 'Item 2' )
154
156
155
157
await userEvent . click ( element )
156
158
await userEvent . keyboard ( 'item3{tab}' )
157
159
expect ( model . value ) . toStrictEqual ( [ items [ 0 ] , 'Item 2' , 'item3' ] )
158
160
expect ( search . value ) . toBe ( '' )
159
- expect ( screen . getByRole ( 'textbox' ) ) . toHaveValue ( '' )
161
+ expect ( input ) . toHaveValue ( '' )
160
162
expect ( screen . getAllByCSS ( '.v-combobox__selection' ) . at ( - 1 ) ) . toHaveTextContent ( 'item3' )
161
163
} )
162
164
} )
@@ -177,10 +179,10 @@ describe('VCombobox', () => {
177
179
await userEvent . click ( element )
178
180
await userEvent . keyboard ( 'Item' )
179
181
await expect ( screen . findAllByRole ( 'option' ) ) . resolves . toHaveLength ( 4 )
180
- await userEvent . keyboard ( '{Control >}a{/Ctrl}{Backspace}' )
182
+ await userEvent . keyboard ( '{Ctrl >}a{/Ctrl}{Backspace}' )
181
183
await userEvent . keyboard ( 'Item 1' )
182
184
await expect ( screen . findAllByRole ( 'option' ) ) . resolves . toHaveLength ( 2 )
183
- await userEvent . keyboard ( '{Control >}a{/Ctrl}{Backspace}' )
185
+ await userEvent . keyboard ( '{Ctrl >}a{/Ctrl}{Backspace}' )
184
186
await userEvent . keyboard ( 'Item 3' )
185
187
expect ( screen . queryAllByRole ( 'option' ) ) . toHaveLength ( 0 )
186
188
} )
@@ -200,10 +202,10 @@ describe('VCombobox', () => {
200
202
await userEvent . click ( element )
201
203
await userEvent . keyboard ( 'Item' )
202
204
await expect ( screen . findAllByRole ( 'option' ) ) . resolves . toHaveLength ( 4 )
203
- await userEvent . keyboard ( '{Control >}a{/Ctrl}{Backspace}' )
205
+ await userEvent . keyboard ( '{Ctrl >}a{/Ctrl}{Backspace}' )
204
206
await userEvent . keyboard ( 'Item 1' )
205
207
await expect ( screen . findAllByRole ( 'option' ) ) . resolves . toHaveLength ( 2 )
206
- await userEvent . keyboard ( '{Control >}a{/Ctrl}{Backspace}' )
208
+ await userEvent . keyboard ( '{Ctrl >}a{/Ctrl}{Backspace}' )
207
209
await userEvent . keyboard ( 'Item 3' )
208
210
expect ( screen . queryAllByRole ( 'option' ) ) . toHaveLength ( 0 )
209
211
} )
@@ -232,7 +234,7 @@ describe('VCombobox', () => {
232
234
await userEvent . keyboard ( 'test' )
233
235
await expect ( screen . findByRole ( 'option' ) ) . resolves . toHaveTextContent ( 'Test1' )
234
236
235
- await userEvent . keyboard ( '{Control >}a{/Ctrl}{Backspace}' )
237
+ await userEvent . keyboard ( '{Ctrl >}a{/Ctrl}{Backspace}' )
236
238
await userEvent . keyboard ( 'antonsen' )
237
239
await expect ( screen . findByRole ( 'option' ) ) . resolves . toHaveTextContent ( 'Antonsen PK' )
238
240
} )
@@ -254,13 +256,15 @@ describe('VCombobox', () => {
254
256
/>
255
257
) )
256
258
259
+ const input = screen . getByCSS ( 'input' )
260
+
257
261
await userEvent . click ( element )
258
262
259
263
await expect ( screen . findAllByRole ( 'option' , { selected : true } ) ) . resolves . toHaveLength ( 2 )
260
264
expect ( screen . getAllByCSS ( '.v-chip' ) ) . toHaveLength ( 2 )
261
265
262
266
await userEvent . click ( screen . getAllByTestId ( 'close-chip' ) [ 0 ] )
263
- await expect ( screen . findByRole ( 'textbox' ) ) . resolves . toBeVisible ( )
267
+ await expect ( input ) . toBeVisible ( )
264
268
expect ( screen . getAllByCSS ( '.v-chip' ) ) . toHaveLength ( 1 )
265
269
expect ( selectedItems . value ) . toStrictEqual ( [ 'Colorado' ] )
266
270
} )
@@ -305,13 +309,15 @@ describe('VCombobox', () => {
305
309
/>
306
310
) )
307
311
312
+ const input = screen . getByCSS ( 'input' )
313
+
308
314
await userEvent . click ( element )
309
315
310
316
await expect ( screen . findAllByRole ( 'option' , { selected : true } ) ) . resolves . toHaveLength ( 2 )
311
317
expect ( screen . getAllByCSS ( '.v-chip' ) ) . toHaveLength ( 2 )
312
318
313
319
await userEvent . click ( screen . getAllByTestId ( 'close-chip' ) [ 0 ] )
314
- await expect ( screen . findByRole ( 'textbox' ) ) . resolves . toBeVisible ( )
320
+ await expect ( input ) . toBeVisible ( )
315
321
expect ( screen . getAllByCSS ( '.v-chip' ) ) . toHaveLength ( 1 )
316
322
expect ( selectedItems . value ) . toStrictEqual ( [ {
317
323
title : 'Item 2' ,
@@ -363,9 +369,9 @@ describe('VCombobox', () => {
363
369
364
370
const options = await screen . findAllByRole ( 'option' , { selected : true } )
365
371
expect ( options ) . toHaveLength ( 2 )
366
- const input = await screen . findByRole ( 'combobox ')
367
- expect ( input ) . toHaveTextContent ( 'Item 1' )
368
- expect ( input ) . toHaveTextContent ( 'Item 2' )
372
+ const inputField = screen . getByCSS ( '.v-field ')
373
+ expect ( inputField ) . toHaveTextContent ( 'Item 1' )
374
+ expect ( inputField ) . toHaveTextContent ( 'Item 2' )
369
375
370
376
await userEvent . click ( options [ 0 ] )
371
377
@@ -453,7 +459,7 @@ describe('VCombobox', () => {
453
459
} )
454
460
} )
455
461
456
- // https://github.com/vuetifyjs/vuetify/issues/17120
462
+ // // https://github.com/vuetifyjs/vuetify/issues/17120
457
463
it ( 'should display 0 when selected' , async ( ) => {
458
464
const items = [ 0 , 1 , 2 , 3 , 4 ]
459
465
@@ -470,15 +476,15 @@ describe('VCombobox', () => {
470
476
471
477
await userEvent . click ( screen . getAllByRole ( 'option' ) [ 0 ] )
472
478
473
- expect ( screen . getByRole ( 'textbox ') ) . toHaveValue ( '0' )
479
+ expect ( screen . getByCSS ( 'input ') ) . toHaveValue ( '0' )
474
480
} )
475
481
476
482
it ( 'should conditionally show placeholder' , async ( ) => {
477
483
const { rerender } = render ( VCombobox , {
478
484
props : { placeholder : 'Placeholder' } ,
479
485
} )
480
486
481
- const input = screen . getByRole ( 'textbox ')
487
+ const input = screen . getByCSS ( 'input ')
482
488
await expect . element ( input ) . toHaveAttribute ( 'placeholder' , 'Placeholder' )
483
489
484
490
await rerender ( { label : 'Label' } )
0 commit comments