Skip to content

Conversation

@sansyrox
Copy link
Member

Summary

Fixes #7
Added E2E tests for the InputAccessoryView component.

Changelog

[IOS] [Added] - Integration test for the pressable component

Test Plan

On running the following commands

detox build -c ios.sim.debug
detox test -c ios.sim.debug

The output is as shown below:

=== BUILD TARGET Flipper-RSocket OF PROJECT Pods WITH CONFIGURATION Debug ===
warning: no rule to process file '/Users/sakshijethi/Desktop/mlh-fellowship-react-native/react-native/RNTester/Pods/Flipper-RSocket/rsocket/benchmarks/CMakeLists.txt' of type text for architecture x86_64
warning: no rule to process file '/Users/sakshijethi/Desktop/mlh-fellowship-react-native/react-native/RNTester/Pods/Flipper-RSocket/rsocket/benchmarks/README.md' of type net.daringfireball.markdown for architecture x86_64
warning: no rule to process file '/Users/sakshijethi/Desktop/mlh-fellowship-react-native/react-native/RNTester/Pods/Flipper-RSocket/rsocket/README.md' of type net.daringfireball.markdown for architecture x86_64
detox[49276] INFO:  [test.js] configuration="ios.sim.debug" reportSpecs=true useCustomLogger=true DETOX_START_TIMESTAMP=1591901151922 node_modules/.bin/jest --config RNTester/e2e/config.json '--testNamePattern=^((?!:android:).)*$' --maxWorkers 1 "e2e"
detox[49277] INFO:  [DetoxServer.js] server listening on localhost:59406...
detox[49277] INFO:  [AppleSimUtils.js] com.facebook.react.uiapp launched. To watch simulator logs, run:
        /usr/bin/xcrun simctl spawn 822F3487-EBAD-4652-A225-6EE20D894605 log stream --level debug --style compact --predicate 'process == "RNTester"'
 PASS  RNTester/e2e/__tests__/Touchable-test.js (14.348 s)
  Touchable
    ✓ Touchable Highlight should be tappable (1553 ms)
    ✓ Touchable Without Feedback should be tappable (1038 ms)
    ✓ Text should be tappable (1031 ms)

detox[49277] INFO:  [DetoxServer.js] server listening on localhost:59443...
detox[49277] INFO:  [AppleSimUtils.js] com.facebook.react.uiapp launched. To watch simulator logs, run:
        /usr/bin/xcrun simctl spawn 822F3487-EBAD-4652-A225-6EE20D894605 log stream --level debug --style compact --predicate 'process == "RNTester"'
 PASS  RNTester/e2e/__tests__/TextInput-test.js (21.3 s)
  TextInput
    ✓ Live rewrite with spaces should replace spaces and enforce max length (2966 ms)
    ✓ Live rewrite with no spaces should remove spaces (3062 ms)
    ✓ Live rewrite with clear should remove spaces and clear (3506 ms)

detox[49277] INFO:  [DetoxServer.js] server listening on localhost:59496...
detox[49277] INFO:  [AppleSimUtils.js] com.facebook.react.uiapp launched. To watch simulator logs, run:
        /usr/bin/xcrun simctl spawn 822F3487-EBAD-4652-A225-6EE20D894605 log stream --level debug --style compact --predicate 'process == "RNTester"'
 PASS  RNTester/e2e/__tests__/DatePickerIOS-test.js (19.887 s)
  DatePickerIOS
    ✓ Should change indicator with datetime picker (3706 ms)
    ✓ Should change indicator with date-only picker (5734 ms)

detox[49277] INFO:  [DetoxServer.js] server listening on localhost:59541...
detox[49277] INFO:  [AppleSimUtils.js] com.facebook.react.uiapp launched. To watch simulator logs, run:
        /usr/bin/xcrun simctl spawn 822F3487-EBAD-4652-A225-6EE20D894605 log stream --level debug --style compact --predicate 'process == "RNTester"'
 PASS  RNTester/e2e/__tests__/Button-test.js (16.616 s)
  Button
    ✓ Simple button should be tappable (1726 ms)
    ✓ Adjusted color button should be tappable (1489 ms)
    ✓ Two buttons with JustifyContent:'space-between' should be tappable (2902 ms)
    ✓ Disabled button should not interact (542 ms)

detox[49277] INFO:  [DetoxServer.js] server listening on localhost:59584...
detox[49277] INFO:  [AppleSimUtils.js] com.facebook.react.uiapp launched. To watch simulator logs, run:
        /usr/bin/xcrun simctl spawn 822F3487-EBAD-4652-A225-6EE20D894605 log stream --level debug --style compact --predicate 'process == "RNTester"'
 PASS  RNTester/e2e/__tests__/Picker-test.js (10.008 s)
  Picker
    ✓ should be selectable by ID (159 ms)

detox[49277] INFO:  [DetoxServer.js] server listening on localhost:59617...
detox[49277] INFO:  [AppleSimUtils.js] com.facebook.react.uiapp launched. To watch simulator logs, run:
        /usr/bin/xcrun simctl spawn 822F3487-EBAD-4652-A225-6EE20D894605 log stream --level debug --style compact --predicate 'process == "RNTester"'
 PASS  RNTester/e2e/__tests__/InputAccessoryView-test.js (11.277 s)
  InputAccessoryView
    ✓ Send button should show alert on press (931 ms)

Test Suites: 6 passed, 6 total
Tests:       14 passed, 14 total
Snapshots:   0 total
Time:        93.543 s, estimated 124 s
Ran all test suites matching /e2e/i with tests matching "^((?!:android:).)*$"

@sansyrox sansyrox requested review from AnshG714 and jevakallio June 11, 2020 19:41
Copy link

@AnshG714 AnshG714 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me!

);
});

it('Send button should show alert on press', async () => {
Copy link

@jevakallio jevakallio Jun 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, the test title should read like a sentence: "it should show alert on press", which in the test runner expands to InputAccessoryView should show alert on press.

However, that is not an appropriate description of our test case, because the InputAccessoryView only handles the positioning of the element, and not the click of a button.

Ideally, a test for InputAccessoryView would check that the component moves as keyboard is moved, but as discussed, that's currently not supported by Detox. So instead, maybe a better test case here is to say, InputAccessoryView should be visible (where we test that the element is visible on screen), and InputAccessoryView should be interactable, where we test that the button is pressed as tested below?

An additional good test would be to bring up the keyboard by focusing on a TextInput, and ensuring the element is still visible and tappable before and after the keyboard is focused, and dismissed.

There's many ways to do this, none ideal, but that's what I would do.

Copy link

@jevakallio jevakallio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation is looking good! The test case description could be improved somewhat (see line comments)

@sansyrox
Copy link
Member Author

Thank you @jevakallio for the comments. I've updated the tests accordingly.

@sansyrox sansyrox requested a review from jevakallio June 17, 2020 14:50
Copy link

@jevakallio jevakallio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I'm going to hold off merging this, I think we're going to start a new long lived branch and merge these changes into it.

@jevakallio jevakallio added the pending merge This PR is ready to merge, but requires Mentor/PO action to merge upstream label Jun 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending merge This PR is ready to merge, but requires Mentor/PO action to merge upstream

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Write E2E tests for InputAccessoryView

4 participants