From fbc8472571fb37c3c4b00829c6bb1a80281929fa Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Thu, 20 Jun 2024 16:34:22 +0200 Subject: [PATCH] Add missing capture events unit tests (skipped for now) --- .../legacy-component/test/index.tsx | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/packages/components/src/custom-select-control-v2/legacy-component/test/index.tsx b/packages/components/src/custom-select-control-v2/legacy-component/test/index.tsx index a053768aea596..af63bceab2fbe 100644 --- a/packages/components/src/custom-select-control-v2/legacy-component/test/index.tsx +++ b/packages/components/src/custom-select-control-v2/legacy-component/test/index.tsx @@ -282,6 +282,8 @@ describe.each( [ } ) ); + // NOTE: legacy CustomSelectControl doesn't fire onChange + // at this point in time. expect( mockOnChange ).toHaveBeenNthCalledWith( 1, expect.objectContaining( { @@ -351,6 +353,33 @@ describe.each( [ } ); describe( 'Keyboard behavior and accessibility', () => { + // skip reason: legacy v2 doesn't currently implement this behavior + it.skip( 'Captures the keypress event and does not let it propagate', async () => { + const onKeyDown = jest.fn(); + + render( +
+ +
+ ); + const currentSelectedItem = screen.getByRole( 'combobox', { + expanded: false, + } ); + await click( currentSelectedItem ); + + const customSelect = screen.getByRole( 'listbox', { + name: 'label!', + } ); + expect( customSelect ).toHaveFocus(); + await press.Enter(); + + expect( onKeyDown ).toHaveBeenCalledTimes( 0 ); + } ); + it( 'Should be able to change selection using keyboard', async () => { render( );