@@ -283,6 +283,155 @@ describe("Select - Accessibility", () => {
283
283
. should ( "have.attr" , "aria-expanded" , "false" )
284
284
. should ( "have.attr" , "aria-roledescription" , EXPECTED_ARIA_ROLEDESCRIPTION ) ;
285
285
} ) ;
286
+
287
+ it ( "tests Select with valueState Positive and aria-describedby" , ( ) => {
288
+ cy . mount (
289
+ < Select valueState = "Positive" >
290
+ < Option value = "First" > First</ Option >
291
+ < Option value = "Second" > Second</ Option >
292
+ < Option value = "Third" selected > Third</ Option >
293
+ </ Select >
294
+ ) ;
295
+
296
+ // Test that valueState creates the correct aria-describedby reference
297
+ cy . get ( "[ui5-select]" )
298
+ . shadow ( )
299
+ . find ( ".ui5-select-label-root" )
300
+ . should ( "have.attr" , "aria-describedby" )
301
+ . and ( "contain" , "-valueStateDesc" ) ;
302
+
303
+ // Test that the value state description text contains "Success"
304
+ cy . get ( "[ui5-select]" )
305
+ . shadow ( )
306
+ . find ( "[id$='-valueStateDesc']" )
307
+ . should ( "contain.text" , "Success" ) ;
308
+ } ) ;
309
+
310
+ it ( "tests accessibleDescription and accessibleDescriptionRef" , ( ) => {
311
+ cy . mount (
312
+ < >
313
+ < span id = "descText" > Description text</ span >
314
+ < Select id = "selectWithAccessibleDescription" accessibleDescription = "Select description" >
315
+ < Option value = "First" > First</ Option >
316
+ < Option value = "Second" > Second</ Option >
317
+ < Option value = "Third" selected > Third</ Option >
318
+ </ Select >
319
+ < Select id = "selectWithAccessibleDescriptionRef" accessibleDescriptionRef = "descText" >
320
+ < Option value = "One" > One</ Option >
321
+ < Option value = "Two" > Two</ Option >
322
+ < Option value = "Three" selected > Three</ Option >
323
+ </ Select >
324
+ </ >
325
+ ) ;
326
+
327
+ const EXPECTED_DESCRIPTION = "Select description" ;
328
+ const EXPECTED_DESCRIPTION_REF = "Description text" ;
329
+
330
+ // Test first select with accessibleDescription
331
+ cy . get ( "#selectWithAccessibleDescription" )
332
+ . shadow ( )
333
+ . find ( "#accessibleDescription" )
334
+ . should ( "have.text" , EXPECTED_DESCRIPTION ) ;
335
+
336
+ cy . get ( "#selectWithAccessibleDescription" )
337
+ . shadow ( )
338
+ . find ( ".ui5-select-label-root" )
339
+ . should ( "have.attr" , "aria-describedby" )
340
+ . and ( "contain" , "accessibleDescription" ) ;
341
+
342
+ // Test second select with accessibleDescriptionRef
343
+ cy . get ( "#selectWithAccessibleDescriptionRef" )
344
+ . shadow ( )
345
+ . find ( "#accessibleDescription" )
346
+ . should ( "have.text" , EXPECTED_DESCRIPTION_REF ) ;
347
+
348
+ cy . get ( "#selectWithAccessibleDescriptionRef" )
349
+ . shadow ( )
350
+ . find ( ".ui5-select-label-root" )
351
+ . should ( "have.attr" , "aria-describedby" )
352
+ . and ( "contain" , "accessibleDescription" ) ;
353
+
354
+ // Test that changing the referenced element updates the description
355
+ cy . get ( "#descText" )
356
+ . invoke ( "text" , "Updated description text" ) ;
357
+
358
+ cy . get ( "#selectWithAccessibleDescriptionRef" )
359
+ . shadow ( )
360
+ . find ( "#accessibleDescription" )
361
+ . should ( "have.text" , "Updated description text" ) ;
362
+ } ) ;
363
+
364
+ it ( "tests Select with both valueState Positive and accessibleDescription" , ( ) => {
365
+ cy . mount (
366
+ < Select valueState = "Positive" accessibleDescription = "Additional description" >
367
+ < Option value = "First" > First</ Option >
368
+ < Option value = "Second" > Second</ Option >
369
+ < Option value = "Third" selected > Third</ Option >
370
+ </ Select >
371
+ ) ;
372
+
373
+ const EXPECTED_VALUE_STATE_TEXT = "Success" ;
374
+ const EXPECTED_DESCRIPTION = "Additional description" ;
375
+
376
+ // Test that both valueState and accessibleDescription are included in aria-describedby
377
+ cy . get ( "[ui5-select]" )
378
+ . shadow ( )
379
+ . find ( ".ui5-select-label-root" )
380
+ . should ( "have.attr" , "aria-describedby" )
381
+ . and ( "contain" , "-valueStateDesc" )
382
+ . and ( "contain" , "accessibleDescription" ) ;
383
+
384
+ // Test that the value state description text is correct
385
+ cy . get ( "[ui5-select]" )
386
+ . shadow ( )
387
+ . find ( "[id$='-valueStateDesc']" )
388
+ . should ( "contain.text" , EXPECTED_VALUE_STATE_TEXT ) ;
389
+
390
+ // Test that the accessible description text is correct
391
+ cy . get ( "[ui5-select]" )
392
+ . shadow ( )
393
+ . find ( "#accessibleDescription" )
394
+ . should ( "have.text" , EXPECTED_DESCRIPTION ) ;
395
+ } ) ;
396
+
397
+ it ( "tests Select with multiple accessibleDescriptionRef values" , ( ) => {
398
+ cy . mount (
399
+ < >
400
+ < span id = "desc1" > First description</ span >
401
+ < span id = "desc2" > Second description</ span >
402
+ < span id = "desc3" > Third description</ span >
403
+ < Select accessibleDescriptionRef = "desc1 desc2 desc3" >
404
+ < Option value = "First" > First</ Option >
405
+ < Option value = "Second" > Second</ Option >
406
+ < Option value = "Third" selected > Third</ Option >
407
+ </ Select >
408
+ </ >
409
+ ) ;
410
+
411
+ const EXPECTED_COMBINED_DESCRIPTION = "First description Second description Third description" ;
412
+
413
+ // Test that accessibleDescriptionRef with multiple IDs creates the correct aria-describedby reference
414
+ cy . get ( "[ui5-select]" )
415
+ . shadow ( )
416
+ . find ( ".ui5-select-label-root" )
417
+ . should ( "have.attr" , "aria-describedby" )
418
+ . and ( "contain" , "accessibleDescription" ) ;
419
+
420
+ // Test that the combined description text from multiple elements is correct
421
+ cy . get ( "[ui5-select]" )
422
+ . shadow ( )
423
+ . find ( "#accessibleDescription" )
424
+ . should ( "have.text" , EXPECTED_COMBINED_DESCRIPTION ) ;
425
+
426
+ // Test that changing one of the referenced elements updates the combined description
427
+ cy . get ( "#desc2" )
428
+ . invoke ( "text" , "Updated second description" ) ;
429
+
430
+ cy . get ( "[ui5-select]" )
431
+ . shadow ( )
432
+ . find ( "#accessibleDescription" )
433
+ . should ( "have.text" , "First description Updated second description Third description" ) ;
434
+ } ) ;
286
435
} ) ;
287
436
288
437
describe ( "Select - Popover" , ( ) => {
0 commit comments