Skip to content

Commit

Permalink
Adjust test.
Browse files Browse the repository at this point in the history
  • Loading branch information
afercia committed Oct 24, 2024
1 parent 8b838e9 commit adb94ad
Showing 1 changed file with 21 additions and 24 deletions.
45 changes: 21 additions & 24 deletions packages/block-editor/src/components/link-control/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ describe( 'Basic rendering', () => {
/>
);

const linkPreview = screen.getByLabelText( 'Currently selected' );
const linkPreview = screen.getByLabelText( 'Manage link' );

const isPreviewError = linkPreview.classList.contains( 'is-error' );
expect( isPreviewError ).toBe( true );
Expand Down Expand Up @@ -834,7 +834,7 @@ describe( 'Manual link entry', () => {

render( <LinkControlConsumer /> );

let linkPreview = screen.getByLabelText( 'Currently selected' );
let linkPreview = screen.getByLabelText( 'Manage link' );

expect( linkPreview ).toBeInTheDocument();

Expand Down Expand Up @@ -868,7 +868,7 @@ describe( 'Manual link entry', () => {
// Cancel the editing process.
await user.click( cancelButton );

linkPreview = screen.getByLabelText( 'Currently selected' );
linkPreview = screen.getByLabelText( 'Manage link' );

expect( linkPreview ).toBeInTheDocument();

Expand Down Expand Up @@ -1076,7 +1076,7 @@ describe( 'Default search suggestions', () => {

// Click the "Edit/Change" button and check initial suggestions are not
// shown.
const currentLinkUI = screen.getByLabelText( 'Currently selected' );
const currentLinkUI = screen.getByLabelText( 'Manage link' );
const currentLinkBtn = within( currentLinkUI ).getByRole( 'button', {
name: 'Edit link',
} );
Expand Down Expand Up @@ -1230,8 +1230,7 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {

// Check for loading indicator.
const loadingIndicator = screen.getByText( 'Creating…' );
const currentLinkLabel =
screen.queryByLabelText( 'Currently selected' );
const currentLinkLabel = screen.queryByLabelText( 'Manage link' );

expect( currentLinkLabel ).not.toBeInTheDocument();
expect( loadingIndicator ).toBeVisible();
Expand All @@ -1242,8 +1241,7 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
// Resolve the `createSuggestion` promise.
resolver();

const currentLink =
await screen.findByLabelText( 'Currently selected' );
const currentLink = await screen.findByLabelText( 'Manage link' );

expect( currentLink ).toHaveTextContent( entityNameText );
expect( currentLink ).toHaveTextContent( '/?p=123' );
Expand Down Expand Up @@ -1291,7 +1289,7 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {

await user.click( createButton );

const currentLink = screen.getByLabelText( 'Currently selected' );
const currentLink = screen.getByLabelText( 'Manage link' );

expect( currentLink ).toHaveTextContent( 'Some new page to create' );
expect( currentLink ).toHaveTextContent( '/?p=123' );
Expand Down Expand Up @@ -1350,7 +1348,7 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
triggerEnter( searchInput );

expect(
await screen.findByLabelText( 'Currently selected' )
await screen.findByLabelText( 'Manage link' )
).toHaveTextContent( entityNameText );
} );

Expand Down Expand Up @@ -1529,7 +1527,7 @@ describe( 'Selecting links', () => {

render( <LinkControlConsumer /> );

const currentLink = screen.getByLabelText( 'Currently selected' );
const currentLink = screen.getByLabelText( 'Manage link' );
const currentLinkAnchor = screen.getByRole( 'link', {
name: `${ selectedLink.title } (opens in a new tab)`,
} );
Expand Down Expand Up @@ -1559,7 +1557,7 @@ describe( 'Selecting links', () => {
render( <LinkControlConsumer /> );

// Required in order to select the button below.
let currentLinkUI = screen.getByLabelText( 'Currently selected' );
let currentLinkUI = screen.getByLabelText( 'Manage link' );
const currentLinkBtn = within( currentLinkUI ).getByRole( 'button', {
name: 'Edit link',
} );
Expand All @@ -1570,7 +1568,7 @@ describe( 'Selecting links', () => {
const searchInput = screen.getByRole( 'combobox', {
name: 'Search or type URL',
} );
currentLinkUI = screen.queryByLabelText( 'Currently selected' );
currentLinkUI = screen.queryByLabelText( 'Manage link' );

// We should be back to showing the search input.
expect( searchInput ).toBeVisible();
Expand Down Expand Up @@ -1733,8 +1731,7 @@ describe( 'Selecting links', () => {
triggerEnter( searchInput );

// Check that the suggestion selected via is now shown as selected.
const currentLink =
screen.getByLabelText( 'Currently selected' );
const currentLink = screen.getByLabelText( 'Manage link' );
const currentLinkAnchor = screen.getByRole( 'link', {
name: `${ selectedLink.title } (opens in a new tab)`,
} );
Expand Down Expand Up @@ -2127,7 +2124,7 @@ describe( 'Rich link previews', () => {

render( <LinkControl value={ selectedLink } /> );

const linkPreview = screen.getByLabelText( 'Currently selected' );
const linkPreview = screen.getByLabelText( 'Manage link' );

const isRichLinkPreview = linkPreview.classList.contains( 'is-rich' );

Expand All @@ -2148,7 +2145,7 @@ describe( 'Rich link previews', () => {

render( <LinkControl value={ selectedLink } hasRichPreviews /> );

const linkPreview = screen.getByLabelText( 'Currently selected' );
const linkPreview = screen.getByLabelText( 'Manage link' );

await waitFor( () => expect( linkPreview ).toHaveClass( 'is-rich' ) );
} );
Expand All @@ -2165,7 +2162,7 @@ describe( 'Rich link previews', () => {

render( <LinkControl value={ selectedLink } hasRichPreviews /> );

const linkPreview = screen.getByLabelText( 'Currently selected' );
const linkPreview = screen.getByLabelText( 'Manage link' );

await waitFor( () => expect( linkPreview ).toHaveClass( 'is-rich' ) );

Expand Down Expand Up @@ -2197,7 +2194,7 @@ describe( 'Rich link previews', () => {

render( <LinkControl value={ selectedLink } hasRichPreviews /> );

const linkPreview = screen.getByLabelText( 'Currently selected' );
const linkPreview = screen.getByLabelText( 'Manage link' );

await waitFor( () => expect( linkPreview ).toHaveClass( 'is-rich' ) );

Expand All @@ -2221,7 +2218,7 @@ describe( 'Rich link previews', () => {

render( <LinkControl value={ selectedLink } hasRichPreviews /> );

const linkPreview = screen.getByLabelText( 'Currently selected' );
const linkPreview = screen.getByLabelText( 'Manage link' );

await waitFor( () => expect( linkPreview ).toHaveClass( 'is-rich' ) );

Expand Down Expand Up @@ -2256,7 +2253,7 @@ describe( 'Rich link previews', () => {

render( <LinkControl value={ selectedLink } hasRichPreviews /> );

const linkPreview = screen.getByLabelText( 'Currently selected' );
const linkPreview = screen.getByLabelText( 'Manage link' );

await waitFor( () =>
expect( linkPreview ).toHaveClass( 'is-rich' )
Expand All @@ -2281,7 +2278,7 @@ describe( 'Rich link previews', () => {

render( <LinkControl value={ selectedLink } hasRichPreviews /> );

const linkPreview = screen.getByLabelText( 'Currently selected' );
const linkPreview = screen.getByLabelText( 'Manage link' );

expect( linkPreview ).toHaveClass( 'is-fetching' );

Expand All @@ -2300,7 +2297,7 @@ describe( 'Rich link previews', () => {

render( <LinkControl value={ selectedLink } hasRichPreviews /> );

const linkPreview = screen.getByLabelText( 'Currently selected' );
const linkPreview = screen.getByLabelText( 'Manage link' );

expect( linkPreview ).toHaveClass( 'is-fetching' );
expect( linkPreview ).not.toHaveClass( 'is-rich' );
Expand All @@ -2313,7 +2310,7 @@ describe( 'Rich link previews', () => {

render( <LinkControl value={ selectedLink } hasRichPreviews /> );

const linkPreview = screen.getByLabelText( 'Currently selected' );
const linkPreview = screen.getByLabelText( 'Manage link' );

expect( linkPreview ).toHaveClass( 'is-fetching' );

Expand Down

0 comments on commit adb94ad

Please sign in to comment.