Skip to content

Commit

Permalink
Further clarify link picker test intent
Browse files Browse the repository at this point in the history
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.

callstack/react-native-testing-library#379 (comment)

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.

#37559
  • Loading branch information
dcalhoun committed Dec 21, 2021
1 parent 553f1fd commit 0800158
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions packages/format-library/src/link/test/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
<LinkEditSlot
activeAttributes={ {} }
Expand All @@ -56,7 +56,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 { getByA11yLabel } = render(
<LinkEditSlot
activeAttributes={ {} }
Expand Down Expand Up @@ -89,7 +89,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(
<LinkEditSlot
activeAttributes={ {} }
Expand All @@ -115,7 +115,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 { getByA11yLabel } = render(
<LinkEditSlot
activeAttributes={ {} }
Expand Down

0 comments on commit 0800158

Please sign in to comment.