From 7e78629023667064a12488fafdde8a8f00aa1f65 Mon Sep 17 00:00:00 2001 From: stealthanthrax Date: Wed, 10 Jun 2020 18:47:13 +0530 Subject: [PATCH 1/3] Add E2E tests for Pressable component --- RNTester/e2e/__tests__/Pressable-test.js | 66 +++++++++++++++++++ .../js/examples/Pressable/PressableExample.js | 6 +- 2 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 RNTester/e2e/__tests__/Pressable-test.js diff --git a/RNTester/e2e/__tests__/Pressable-test.js b/RNTester/e2e/__tests__/Pressable-test.js new file mode 100644 index 00000000000000..c7f1ee3bb49e86 --- /dev/null +++ b/RNTester/e2e/__tests__/Pressable-test.js @@ -0,0 +1,66 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @emails oncall+react_native + * @format + */ + +/* global device, element, by, expect */ +const { + openComponentWithLabel, + openExampleWithTitle, +} = require('../e2e-helpers'); + +describe('Pressable', () => { + beforeAll(async () => { + await device.reloadReactNative(); + await openComponentWithLabel( + '', + ' Component for making views pressable.', + ); + }); + + it('Console content should change on Press', async () => { + await openExampleWithTitle('Change content based on Press'); + + const consoleID = 'pressable_press_console'; + + await element(by.text('Press Me')).tap(); + await expect(element(by.id(consoleID))).toHaveText('onPress'); + + await element(by.text('Press Me')).tap(); + await expect(element(by.id(consoleID))).toHaveText('2x onPress'); + + await element(by.text('Press Me')).tap(); + await expect(element(by.id(consoleID))).toHaveText('3x onPress'); + }); + + it('Highlighted text should be pressable', async () => { + await openExampleWithTitle(' with highlight'); + + const buttonID = 'tappable_text'; + const consoleID = 'tappable_text_console'; + + await element(by.id(buttonID)).tap(); + await expect(element(by.id(consoleID))).toHaveText('text onPress'); + + await element(by.id(buttonID)).tap(); + await expect(element(by.id(consoleID))).toHaveText('2x text onPress'); + }); + + it('Components with hitSlop prop extends touch area', async () => { + await openExampleWithTitle('Pressable Hit Slop'); + + const buttonID = 'pressable_hit_slop_extended_touch'; + const consoleID = 'pressable_hit_slop_console'; + + await element(by.id(buttonID)).tap(); + await expect(element(by.id(consoleID))).toHaveText('onPress'); + + await element(by.id(buttonID)).tap(); + await expect(element(by.id(consoleID))).toHaveText('2x onPress'); + }); +}); diff --git a/RNTester/js/examples/Pressable/PressableExample.js b/RNTester/js/examples/Pressable/PressableExample.js index 9a67af10f6c4ed..7e53ed3b0d87dd 100644 --- a/RNTester/js/examples/Pressable/PressableExample.js +++ b/RNTester/js/examples/Pressable/PressableExample.js @@ -188,7 +188,9 @@ function PressableHitSlop() { return ( - + setTimesPressed(num => num + 1)} style={styles.hitSlopWrapper} @@ -198,7 +200,7 @@ function PressableHitSlop() { - {log} + {log} ); From 686fb6392d82ef9341bcc30a4492b1ca6813dc73 Mon Sep 17 00:00:00 2001 From: stealthanthrax Date: Wed, 17 Jun 2020 03:45:34 +0530 Subject: [PATCH 2/3] Added more meaningful commit messages --- RNTester/e2e/__tests__/Pressable-test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/RNTester/e2e/__tests__/Pressable-test.js b/RNTester/e2e/__tests__/Pressable-test.js index c7f1ee3bb49e86..eeacedd1a90839 100644 --- a/RNTester/e2e/__tests__/Pressable-test.js +++ b/RNTester/e2e/__tests__/Pressable-test.js @@ -23,7 +23,7 @@ describe('Pressable', () => { ); }); - it('Console content should change on Press', async () => { + it('should change console content should on press', async () => { await openExampleWithTitle('Change content based on Press'); const consoleID = 'pressable_press_console'; @@ -38,7 +38,7 @@ describe('Pressable', () => { await expect(element(by.id(consoleID))).toHaveText('3x onPress'); }); - it('Highlighted text should be pressable', async () => { + it('should show different text on highlight button press', async () => { await openExampleWithTitle(' with highlight'); const buttonID = 'tappable_text'; @@ -51,7 +51,7 @@ describe('Pressable', () => { await expect(element(by.id(consoleID))).toHaveText('2x text onPress'); }); - it('Components with hitSlop prop extends touch area', async () => { + it('should change text when hitSlop prop extends touch area', async () => { await openExampleWithTitle('Pressable Hit Slop'); const buttonID = 'pressable_hit_slop_extended_touch'; From fd228a9f09e085d62ca96cc88c2d8c8b865f633b Mon Sep 17 00:00:00 2001 From: Sanskar Jethi Date: Wed, 17 Jun 2020 20:19:09 +0530 Subject: [PATCH 3/3] Fix typo in Pressable-test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jani Eväkallio --- RNTester/e2e/__tests__/Pressable-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RNTester/e2e/__tests__/Pressable-test.js b/RNTester/e2e/__tests__/Pressable-test.js index eeacedd1a90839..a6e82d070774fb 100644 --- a/RNTester/e2e/__tests__/Pressable-test.js +++ b/RNTester/e2e/__tests__/Pressable-test.js @@ -23,7 +23,7 @@ describe('Pressable', () => { ); }); - it('should change console content should on press', async () => { + it('should change console content on press', async () => { await openExampleWithTitle('Change content based on Press'); const consoleID = 'pressable_press_console';