@@ -233,6 +233,44 @@ test('can be filtered by accessible name', () => {
233
233
) . not . toBeNull ( )
234
234
} )
235
235
236
+ test ( 'when hidden can be filtered by accessible name' , ( ) => {
237
+ const { getByRole} = renderIntoDocument (
238
+ `
239
+ <div>
240
+ <h1>Order</h1>
241
+ <h2>Delivery Adress</h2>
242
+ <form aria-label="Delivery Adress" aria-hidden="true">
243
+ <label>
244
+ <div>Street</div>
245
+ <input type="text" />
246
+ </label>
247
+ <input type="submit" />
248
+ </form>
249
+ <h2>Invoice Adress</h2>
250
+ <form aria-label="Invoice Adress">
251
+ <label>
252
+ <div>Street</div>
253
+ <input type="text" />
254
+ </label>
255
+ <input type="submit" />
256
+ </form>
257
+ </div>` ,
258
+ )
259
+
260
+ const deliveryForm = getByRole ( 'form' , {
261
+ name : 'Delivery Adress' ,
262
+ hidden : true ,
263
+ } )
264
+ expect ( deliveryForm ) . not . toBeNull ( )
265
+
266
+ expect (
267
+ getQueriesForElement ( deliveryForm ) . getByRole ( 'button' , {
268
+ name : 'Submit' ,
269
+ hidden : true ,
270
+ } ) ,
271
+ ) . not . toBeNull ( )
272
+ } )
273
+
236
274
test ( 'accessible name comparison is case sensitive' , ( ) => {
237
275
const { getByRole} = render ( `<h1>Sign <em>up</em></h1>` )
238
276
@@ -609,6 +647,34 @@ test('can be filtered by accessible description', () => {
609
647
) . not . toBeNull ( )
610
648
} )
611
649
650
+ test ( 'when hidden can be filtered by accessible description' , ( ) => {
651
+ const targetedNotificationMessage = 'Your session is about to expire!'
652
+ const { getByRole} = renderIntoDocument (
653
+ `
654
+ <ul>
655
+ <li role="alertdialog" aria-hidden="true" aria-describedby="notification-id-2">
656
+ <div><button>Close</button></div>
657
+ <div id="notification-id-2">${ targetedNotificationMessage } </div>
658
+ </li>
659
+ </ul>` ,
660
+ )
661
+
662
+ const notification = getByRole ( 'alertdialog' , {
663
+ description : targetedNotificationMessage ,
664
+ hidden : true ,
665
+ } )
666
+
667
+ expect ( notification ) . not . toBeNull ( )
668
+ expect ( notification ) . toHaveTextContent ( targetedNotificationMessage )
669
+
670
+ expect (
671
+ getQueriesForElement ( notification ) . getByRole ( 'button' , {
672
+ name : 'Close' ,
673
+ hidden : true ,
674
+ } ) ,
675
+ ) . not . toBeNull ( )
676
+ } )
677
+
612
678
test ( 'error should include description when filtering and no results are found' , ( ) => {
613
679
const targetedNotificationMessage = 'Your session is about to expire!'
614
680
const { getByRole} = renderIntoDocument (
0 commit comments