diff --git a/packages/block-editor/src/components/link-control/test/index.js b/packages/block-editor/src/components/link-control/test/index.js index 2f0ff4d0993091..ee48db15fd07f1 100644 --- a/packages/block-editor/src/components/link-control/test/index.js +++ b/packages/block-editor/src/components/link-control/test/index.js @@ -934,7 +934,9 @@ describe( 'Manual link entry', () => { } ); } ); +} ); +describe( 'Link submission', () => { it( 'should show a submit button when creating a link', async () => { const user = userEvent.setup(); @@ -961,6 +963,45 @@ describe( 'Manual link entry', () => { expect( submitButton ).toHaveAttribute( 'aria-disabled', 'false' ); } ); + + it( 'should show a submit button when editing a link', async () => { + const user = userEvent.setup(); + + const LinkControlConsumer = () => { + const [ link, setLink ] = useState( fauxEntitySuggestions[ 0 ] ); + + return ( + + ); + }; + + render( ); + + const searchInput = screen.getByRole( 'combobox', { + name: 'Link', + } ); + + const createSubmitButton = screen.queryByRole( 'button', { + name: 'Submit', + } ); + + expect( createSubmitButton ).not.toBeInTheDocument(); + + const editSubmitButton = screen.getByRole( 'button', { + name: 'Save', + } ); + + expect( editSubmitButton ).toBeVisible(); + expect( editSubmitButton ).toHaveAttribute( 'aria-disabled', 'true' ); + + await user.type( searchInput, '#appendtolinktext' ); + + expect( editSubmitButton ).toHaveAttribute( 'aria-disabled', 'false' ); + } ); } ); describe( 'Default search suggestions', () => {