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