1
1
import { mount } from '@cypress/vue'
2
2
import { config } from '@vue/test-utils'
3
- import { SSelect , SSelectBase , SSelectButton , SSelectInput , SDropdown , SelectSize } from '@/lib'
3
+ import { SSelect , SSelectBase , SSelectButton , SSelectInput , SDropdown , SelectSize , STextField } from '@/lib'
4
4
5
5
const SIZES = [ SelectSize . Sm , SelectSize . Md , SelectSize . Lg , SelectSize . Xl ]
6
6
@@ -14,6 +14,8 @@ after(() => {
14
14
config . global . stubs = { }
15
15
} )
16
16
17
+ const findBtnLabel = ( ) => cy . get ( '.s-select-btn__label' )
18
+
17
19
it ( 'Gallery - Dropdown' , ( ) => {
18
20
mount ( {
19
21
setup ( ) {
@@ -276,3 +278,53 @@ it('SDropdown - show/hide by clicks', () => {
276
278
cy . contains ( 'Label' ) . click ( )
277
279
cy . contains ( 'OPTION' ) . should ( 'not.be.visible' )
278
280
} )
281
+
282
+ it ( `SDropdown - when value is selected and label is not provided, then label is not rendered` , ( ) => {
283
+ mount ( {
284
+ setup ( ) {
285
+ const showLabel = ref ( true )
286
+ const label = computed ( ( ) => ( showLabel . value ? 'Choice' : '' ) )
287
+ return {
288
+ options : [ { label : 'Pizza' , value : 'pizza' } ] ,
289
+ showLabel,
290
+ label,
291
+ }
292
+ } ,
293
+ template : `
294
+ <input v-model="showLabel" type="checkbox"> Show label
295
+
296
+ <SDropdown
297
+ v-bind="{ options, modelValue: 'pizza', label }"
298
+ />
299
+ ` ,
300
+ } )
301
+
302
+ findBtnLabel ( ) . should ( 'have.text' , 'Choice:' )
303
+ cy . get ( 'input' ) . click ( ) . should ( 'not.be.checked' )
304
+ findBtnLabel ( ) . should ( 'not.exist' )
305
+ } )
306
+
307
+ it ( 'SSelectDropdown overlaps STextField' , ( ) => {
308
+ mount ( {
309
+ components : { STextField } ,
310
+ setup ( ) {
311
+ return {
312
+ options : [
313
+ { label : 'one' , value : 1 } ,
314
+ { label : 'two' , value : 2 } ,
315
+ ] ,
316
+ }
317
+ } ,
318
+ template : `
319
+ <div class="m-4 space-y-4">
320
+ <SDropdown label="I am top" v-bind="{ options }" />
321
+ <STextField placeholder="I am bottom" />
322
+ </div>
323
+ ` ,
324
+ } )
325
+
326
+ cy . contains ( 'I am top' ) . click ( )
327
+ cy . contains ( 'two' )
328
+ // trying to click to ensure the element is not covered by anything
329
+ . click ( )
330
+ } )
0 commit comments