@@ -373,7 +373,9 @@ describe( 'Basic rendering', () => {
373373 />
374374 ) ;
375375
376- const linkPreview = screen . getByLabelText ( 'Currently selected' ) ;
376+ const linkPreview = screen . getByRole ( 'group' , {
377+ name : 'Manage link' ,
378+ } ) ;
377379
378380 const isPreviewError = linkPreview . classList . contains ( 'is-error' ) ;
379381 expect ( isPreviewError ) . toBe ( true ) ;
@@ -834,7 +836,9 @@ describe( 'Manual link entry', () => {
834836
835837 render ( < LinkControlConsumer /> ) ;
836838
837- let linkPreview = screen . getByLabelText ( 'Currently selected' ) ;
839+ let linkPreview = screen . getByRole ( 'group' , {
840+ name : 'Manage link' ,
841+ } ) ;
838842
839843 expect ( linkPreview ) . toBeInTheDocument ( ) ;
840844
@@ -868,7 +872,9 @@ describe( 'Manual link entry', () => {
868872 // Cancel the editing process.
869873 await user . click ( cancelButton ) ;
870874
871- linkPreview = screen . getByLabelText ( 'Currently selected' ) ;
875+ linkPreview = screen . getByRole ( 'group' , {
876+ name : 'Manage link' ,
877+ } ) ;
872878
873879 expect ( linkPreview ) . toBeInTheDocument ( ) ;
874880
@@ -1076,7 +1082,9 @@ describe( 'Default search suggestions', () => {
10761082
10771083 // Click the "Edit/Change" button and check initial suggestions are not
10781084 // shown.
1079- const currentLinkUI = screen . getByLabelText ( 'Currently selected' ) ;
1085+ const currentLinkUI = screen . getByRole ( 'group' , {
1086+ name : 'Manage link' ,
1087+ } ) ;
10801088 const currentLinkBtn = within ( currentLinkUI ) . getByRole ( 'button' , {
10811089 name : 'Edit link' ,
10821090 } ) ;
@@ -1230,8 +1238,9 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
12301238
12311239 // Check for loading indicator.
12321240 const loadingIndicator = screen . getByText ( 'Creating…' ) ;
1233- const currentLinkLabel =
1234- screen . queryByLabelText ( 'Currently selected' ) ;
1241+ const currentLinkLabel = screen . queryByRole ( 'group' , {
1242+ name : 'Manage link' ,
1243+ } ) ;
12351244
12361245 expect ( currentLinkLabel ) . not . toBeInTheDocument ( ) ;
12371246 expect ( loadingIndicator ) . toBeVisible ( ) ;
@@ -1242,8 +1251,9 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
12421251 // Resolve the `createSuggestion` promise.
12431252 resolver ( ) ;
12441253
1245- const currentLink =
1246- await screen . findByLabelText ( 'Currently selected' ) ;
1254+ const currentLink = await screen . findByRole ( 'group' , {
1255+ name : 'Manage link' ,
1256+ } ) ;
12471257
12481258 expect ( currentLink ) . toHaveTextContent ( entityNameText ) ;
12491259 expect ( currentLink ) . toHaveTextContent ( '/?p=123' ) ;
@@ -1291,7 +1301,9 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
12911301
12921302 await user . click ( createButton ) ;
12931303
1294- const currentLink = screen . getByLabelText ( 'Currently selected' ) ;
1304+ const currentLink = screen . getByRole ( 'group' , {
1305+ name : 'Manage link' ,
1306+ } ) ;
12951307
12961308 expect ( currentLink ) . toHaveTextContent ( 'Some new page to create' ) ;
12971309 expect ( currentLink ) . toHaveTextContent ( '/?p=123' ) ;
@@ -1350,7 +1362,9 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
13501362 triggerEnter ( searchInput ) ;
13511363
13521364 expect (
1353- await screen . findByLabelText ( 'Currently selected' )
1365+ await screen . findByRole ( 'group' , {
1366+ name : 'Manage link' ,
1367+ } )
13541368 ) . toHaveTextContent ( entityNameText ) ;
13551369 } ) ;
13561370
@@ -1529,7 +1543,9 @@ describe( 'Selecting links', () => {
15291543
15301544 render ( < LinkControlConsumer /> ) ;
15311545
1532- const currentLink = screen . getByLabelText ( 'Currently selected' ) ;
1546+ const currentLink = screen . getByRole ( 'group' , {
1547+ name : 'Manage link' ,
1548+ } ) ;
15331549 const currentLinkAnchor = screen . getByRole ( 'link' , {
15341550 name : `${ selectedLink . title } (opens in a new tab)` ,
15351551 } ) ;
@@ -1559,7 +1575,9 @@ describe( 'Selecting links', () => {
15591575 render ( < LinkControlConsumer /> ) ;
15601576
15611577 // Required in order to select the button below.
1562- let currentLinkUI = screen . getByLabelText ( 'Currently selected' ) ;
1578+ let currentLinkUI = screen . getByRole ( 'group' , {
1579+ name : 'Manage link' ,
1580+ } ) ;
15631581 const currentLinkBtn = within ( currentLinkUI ) . getByRole ( 'button' , {
15641582 name : 'Edit link' ,
15651583 } ) ;
@@ -1570,7 +1588,9 @@ describe( 'Selecting links', () => {
15701588 const searchInput = screen . getByRole ( 'combobox' , {
15711589 name : 'Search or type URL' ,
15721590 } ) ;
1573- currentLinkUI = screen . queryByLabelText ( 'Currently selected' ) ;
1591+ currentLinkUI = screen . queryByRole ( 'group' , {
1592+ name : 'Manage link' ,
1593+ } ) ;
15741594
15751595 // We should be back to showing the search input.
15761596 expect ( searchInput ) . toBeVisible ( ) ;
@@ -1733,8 +1753,9 @@ describe( 'Selecting links', () => {
17331753 triggerEnter ( searchInput ) ;
17341754
17351755 // Check that the suggestion selected via is now shown as selected.
1736- const currentLink =
1737- screen . getByLabelText ( 'Currently selected' ) ;
1756+ const currentLink = screen . getByRole ( 'group' , {
1757+ name : 'Manage link' ,
1758+ } ) ;
17381759 const currentLinkAnchor = screen . getByRole ( 'link' , {
17391760 name : `${ selectedLink . title } (opens in a new tab)` ,
17401761 } ) ;
@@ -2127,7 +2148,9 @@ describe( 'Rich link previews', () => {
21272148
21282149 render ( < LinkControl value = { selectedLink } /> ) ;
21292150
2130- const linkPreview = screen . getByLabelText ( 'Currently selected' ) ;
2151+ const linkPreview = screen . getByRole ( 'group' , {
2152+ name : 'Manage link' ,
2153+ } ) ;
21312154
21322155 const isRichLinkPreview = linkPreview . classList . contains ( 'is-rich' ) ;
21332156
@@ -2148,7 +2171,9 @@ describe( 'Rich link previews', () => {
21482171
21492172 render ( < LinkControl value = { selectedLink } hasRichPreviews /> ) ;
21502173
2151- const linkPreview = screen . getByLabelText ( 'Currently selected' ) ;
2174+ const linkPreview = screen . getByRole ( 'group' , {
2175+ name : 'Manage link' ,
2176+ } ) ;
21522177
21532178 await waitFor ( ( ) => expect ( linkPreview ) . toHaveClass ( 'is-rich' ) ) ;
21542179 } ) ;
@@ -2165,7 +2190,9 @@ describe( 'Rich link previews', () => {
21652190
21662191 render ( < LinkControl value = { selectedLink } hasRichPreviews /> ) ;
21672192
2168- const linkPreview = screen . getByLabelText ( 'Currently selected' ) ;
2193+ const linkPreview = screen . getByRole ( 'group' , {
2194+ name : 'Manage link' ,
2195+ } ) ;
21692196
21702197 await waitFor ( ( ) => expect ( linkPreview ) . toHaveClass ( 'is-rich' ) ) ;
21712198
@@ -2197,7 +2224,9 @@ describe( 'Rich link previews', () => {
21972224
21982225 render ( < LinkControl value = { selectedLink } hasRichPreviews /> ) ;
21992226
2200- const linkPreview = screen . getByLabelText ( 'Currently selected' ) ;
2227+ const linkPreview = screen . getByRole ( 'group' , {
2228+ name : 'Manage link' ,
2229+ } ) ;
22012230
22022231 await waitFor ( ( ) => expect ( linkPreview ) . toHaveClass ( 'is-rich' ) ) ;
22032232
@@ -2221,7 +2250,9 @@ describe( 'Rich link previews', () => {
22212250
22222251 render ( < LinkControl value = { selectedLink } hasRichPreviews /> ) ;
22232252
2224- const linkPreview = screen . getByLabelText ( 'Currently selected' ) ;
2253+ const linkPreview = screen . getByRole ( 'group' , {
2254+ name : 'Manage link' ,
2255+ } ) ;
22252256
22262257 await waitFor ( ( ) => expect ( linkPreview ) . toHaveClass ( 'is-rich' ) ) ;
22272258
@@ -2256,7 +2287,9 @@ describe( 'Rich link previews', () => {
22562287
22572288 render ( < LinkControl value = { selectedLink } hasRichPreviews /> ) ;
22582289
2259- const linkPreview = screen . getByLabelText ( 'Currently selected' ) ;
2290+ const linkPreview = screen . getByRole ( 'group' , {
2291+ name : 'Manage link' ,
2292+ } ) ;
22602293
22612294 await waitFor ( ( ) =>
22622295 expect ( linkPreview ) . toHaveClass ( 'is-rich' )
@@ -2281,7 +2314,9 @@ describe( 'Rich link previews', () => {
22812314
22822315 render ( < LinkControl value = { selectedLink } hasRichPreviews /> ) ;
22832316
2284- const linkPreview = screen . getByLabelText ( 'Currently selected' ) ;
2317+ const linkPreview = screen . getByRole ( 'group' , {
2318+ name : 'Manage link' ,
2319+ } ) ;
22852320
22862321 expect ( linkPreview ) . toHaveClass ( 'is-fetching' ) ;
22872322
@@ -2300,7 +2335,9 @@ describe( 'Rich link previews', () => {
23002335
23012336 render ( < LinkControl value = { selectedLink } hasRichPreviews /> ) ;
23022337
2303- const linkPreview = screen . getByLabelText ( 'Currently selected' ) ;
2338+ const linkPreview = screen . getByRole ( 'group' , {
2339+ name : 'Manage link' ,
2340+ } ) ;
23042341
23052342 expect ( linkPreview ) . toHaveClass ( 'is-fetching' ) ;
23062343 expect ( linkPreview ) . not . toHaveClass ( 'is-rich' ) ;
@@ -2313,7 +2350,9 @@ describe( 'Rich link previews', () => {
23132350
23142351 render ( < LinkControl value = { selectedLink } hasRichPreviews /> ) ;
23152352
2316- const linkPreview = screen . getByLabelText ( 'Currently selected' ) ;
2353+ const linkPreview = screen . getByRole ( 'group' , {
2354+ name : 'Manage link' ,
2355+ } ) ;
23172356
23182357 expect ( linkPreview ) . toHaveClass ( 'is-fetching' ) ;
23192358
0 commit comments