Files
react-native/packages/rn-tester/e2e/__tests__/Button-test.js
T
chirag-singhal 43abf23bff New Button Component Use Cases (#29848)
Summary:
* New use cases for button component in rn-tester
 * E2E tests for the button component

## Changelog
[General] [Changed] - Changed use cases for button component in rn-tester

## Test Plan
![image](https://user-images.githubusercontent.com/42653703/92123053-ced6d400-ee19-11ea-8f10-c5e8529c85ca.png)
After -
![image](https://user-images.githubusercontent.com/42653703/92625569-70609880-f2e6-11ea-9fb9-f7327d842a34.png)
Before -
![image](https://user-images.githubusercontent.com/42653703/92625555-6a6ab780-f2e6-11ea-90d1-8c54ebc60062.png)

Pull Request resolved: https://github.com/facebook/react-native/pull/29848

Reviewed By: hramos

Differential Revision: D23649694

Pulled By: rickhanlonii

fbshipit-source-id: 3590eca08ea58c771596ad731f74eb233b1a40d8
2020-09-23 19:51:49 -07:00

98 lines
3.0 KiB
JavaScript

/**
* 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('Button', () => {
beforeAll(async () => {
await device.reloadReactNative();
await openComponentWithLabel(
'Button',
'Button Simple React Native button component.',
);
});
it('Default Styling button should be tappable', async () => {
await openExampleWithTitle('Default Styling');
await element(by.id('button_default_styling')).tap();
await expect(
element(by.text('Your application has been submitted!')),
).toBeVisible();
await element(by.text('OK')).tap();
});
it('Red color button should be tappable', async () => {
await openExampleWithTitle('Color');
await element(by.id('cancel_button')).tap();
await expect(
element(by.text('Your application has been cancelled!')),
).toBeVisible();
await element(by.text('OK')).tap();
});
it("Two buttons with JustifyContent:'space-between' should be tappable", async () => {
await openExampleWithTitle('Two Buttons');
await element(by.id('two_cancel_button')).tap();
await expect(
element(by.text('Your application has been cancelled!')),
).toBeVisible();
await element(by.text('OK')).tap();
await element(by.id('two_submit_button')).tap();
await expect(
element(by.text('Your application has been submitted!')),
).toBeVisible();
await element(by.text('OK')).tap();
});
it("Three buttons with JustifyContent:'space-between' should be tappable", async () => {
await openExampleWithTitle('Three Buttons');
await element(by.id('three_cancel_button')).tap();
await expect(
element(by.text('Your application has been cancelled!')),
).toBeVisible();
await element(by.text('OK')).tap();
await openExampleWithTitle('Three Buttons');
await element(by.id('three_save_button')).tap();
await expect(
element(by.text('Your application has been saved!')),
).toBeVisible();
await element(by.text('OK')).tap();
await element(by.id('three_submit_button')).tap();
await expect(
element(by.text('Your application has been submitted!')),
).toBeVisible();
await element(by.text('OK')).tap();
});
it('Disabled button should not interact', async () => {
await openExampleWithTitle('Disabled');
await element(by.id('disabled_button')).tap();
await expect(
element(by.text('Your application has been submitted!')),
).toBeNotVisible();
});
it('AccessibilityLabel button should be tappable', async () => {
await openExampleWithTitle('AccessibilityLabel');
await element(by.id('accessibilityLabel_button')).tap();
await expect(
element(by.text('Your application has been submitted!')),
).toBeVisible();
await element(by.text('OK')).tap();
});
});