From 804bd3c06fa1c3e12a00ad5d27593cba0f4e73a2 Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Tue, 8 Aug 2023 13:13:53 +0100 Subject: [PATCH] Assert that premature submission is not possible via UI --- .../src/components/link-control/test/index.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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 ee48db15fd07f1..56aeac6b2ee08b 100644 --- a/packages/block-editor/src/components/link-control/test/index.js +++ b/packages/block-editor/src/components/link-control/test/index.js @@ -959,6 +959,12 @@ describe( 'Link submission', () => { expect( submitButton ).toBeVisible(); expect( submitButton ).toHaveAttribute( 'aria-disabled', 'true' ); + // Click the button and check it's not possible to prematurely submit the link. + await user.click( submitButton ); + + expect( searchInput ).toBeVisible(); + expect( submitButton ).toBeVisible(); + await user.type( searchInput, 'https://wordpress.org' ); expect( submitButton ).toHaveAttribute( 'aria-disabled', 'false' ); @@ -989,6 +995,7 @@ describe( 'Link submission', () => { name: 'Submit', } ); + // Check the submit button for "creation" of links is not displayed. expect( createSubmitButton ).not.toBeInTheDocument(); const editSubmitButton = screen.getByRole( 'button', { @@ -998,6 +1005,12 @@ describe( 'Link submission', () => { expect( editSubmitButton ).toBeVisible(); expect( editSubmitButton ).toHaveAttribute( 'aria-disabled', 'true' ); + // Click the button and check it's not possible to prematurely submit the link. + await user.click( editSubmitButton ); + + expect( searchInput ).toBeVisible(); + expect( editSubmitButton ).toBeVisible(); + await user.type( searchInput, '#appendtolinktext' ); expect( editSubmitButton ).toHaveAttribute( 'aria-disabled', 'false' );