From 0800158a5998faf2f5d747714d9dea28458c6c50 Mon Sep 17 00:00:00 2001 From: David Calhoun <438664+dcalhoun@users.noreply.github.com> Date: Tue, 21 Dec 2021 11:02:06 -0600 Subject: [PATCH] Further clarify link picker test intent The assertions of these tests do not tell the full story of the test expectation. Namely, due to bugs within react-native-testing-library and its dependencies, the tests do not assert navigation events that should occur _after_ the keyboard dismisses. Combining async renders and mocked timers is currently quite difficult. https://github.com/callstack/react-native-testing-library/issues/379#issuecomment-952031783 To clarify the intent of the test, the test description was expanded to describe the expectation that the keyboard is dismissed prior to the navigation event occurring. Simultaneously dismissing the keyboard and navigating has caused performance issues in our bottom sheet before. https://github.com/WordPress/gutenberg/issues/37559 --- .../link-settings/test/link-settings-navigation.native.js | 8 ++++---- packages/format-library/src/link/test/index.native.js | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/components/src/mobile/link-settings/test/link-settings-navigation.native.js b/packages/components/src/mobile/link-settings/test/link-settings-navigation.native.js index c1af29a177cdc4..7c98462207cf8a 100644 --- a/packages/components/src/mobile/link-settings/test/link-settings-navigation.native.js +++ b/packages/components/src/mobile/link-settings/test/link-settings-navigation.native.js @@ -31,7 +31,7 @@ const subject = ( ); describe( 'Android', () => { - it( 'ensures smooth back animation', async () => { + it( 'improves back animation performance by dismissing keyboard beforehand', async () => { const screen = render( subject ); fireEvent.press( screen.getByText( 'Link to' ) ); fireEvent.press( @@ -47,7 +47,7 @@ describe( 'Android', () => { expect( Keyboard.dismiss ).toHaveBeenCalledTimes( 1 ); } ); - it( 'ensures smooth apply animation', async () => { + it( 'improves apply animation performance by dismissing keyboard beforehand', async () => { const screen = render( subject ); fireEvent.press( screen.getByText( 'Link to' ) ); // Await back button to allow async state updates to complete @@ -71,7 +71,7 @@ describe( 'iOS', () => { Platform.OS = originalPlatform; } ); - it( 'ensures smooth back animation', async () => { + it( 'improves back animation performance by dismissing keyboard beforehand', async () => { const screen = render( subject ); fireEvent.press( screen.getByText( 'Link to' ) ); // Await back button to allow async state updates to complete @@ -84,7 +84,7 @@ describe( 'iOS', () => { expect( Keyboard.dismiss ).toHaveBeenCalledTimes( 1 ); } ); - it( 'ensures smooth apply animation', async () => { + it( 'improves apply animation performance by dismissing keyboard beforehand', async () => { const screen = render( subject ); fireEvent.press( screen.getByText( 'Link to' ) ); // Await back button to allow async state updates to complete diff --git a/packages/format-library/src/link/test/index.native.js b/packages/format-library/src/link/test/index.native.js index 97caf01702d000..58b270e14d75d1 100644 --- a/packages/format-library/src/link/test/index.native.js +++ b/packages/format-library/src/link/test/index.native.js @@ -30,7 +30,7 @@ beforeAll( () => { } ); describe( 'Android', () => { - it( 'ensures smooth back animation', async () => { + it( 'improves back animation performance by dismissing keyboard beforehand', async () => { const screen = render( { expect( Keyboard.dismiss ).toHaveBeenCalledTimes( 1 ); } ); - it( 'ensures smooth apply animation', async () => { + it( 'improves apply animation performance by dismissing keyboard beforehand', async () => { const { getByA11yLabel } = render( { Platform.OS = originalPlatform; } ); - it( 'ensures smooth back animation', async () => { + it( 'improves back animation performance by dismissing keyboard beforehand', async () => { const screen = render( { expect( Keyboard.dismiss ).toHaveBeenCalledTimes( 1 ); } ); - it( 'ensures smooth apply animation', async () => { + it( 'improves apply animation performance by dismissing keyboard beforehand', async () => { const { getByA11yLabel } = render(