Skip to content

Commit

Permalink
Add test for submit button in link creation
Browse files Browse the repository at this point in the history
  • Loading branch information
getdave committed Sep 5, 2023
1 parent 2dccffc commit 028cd30
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions packages/block-editor/src/components/link-control/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,33 @@ describe( 'Manual link entry', () => {
}
);
} );

it( 'should show a submit button when creating a link', async () => {
const user = userEvent.setup();

const LinkControlConsumer = () => {
const [ link, setLink ] = useState( {} );

return <LinkControl value={ link } onChange={ setLink } />;
};

render( <LinkControlConsumer /> );

const searchInput = screen.getByRole( 'combobox', {
name: 'Link',
} );

const submitButton = screen.getByRole( 'button', {
name: 'Submit',
} );

expect( submitButton ).toBeVisible();
expect( submitButton ).toHaveAttribute( 'aria-disabled', 'true' );

await user.type( searchInput, 'https://wordpress.org' );

expect( submitButton ).toHaveAttribute( 'aria-disabled', 'false' );
} );
} );

describe( 'Default search suggestions', () => {
Expand Down

0 comments on commit 028cd30

Please sign in to comment.