Skip to content

Commit

Permalink
label -> text nearly everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
simonracz committed Sep 27, 2017
1 parent ad42950 commit 37b5c40
Show file tree
Hide file tree
Showing 33 changed files with 128 additions and 126 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('Login flow', () => {

await element(by.id('email')).typeText('[email protected]');
await element(by.id('password')).typeText('123456');
await element(by.label('Login')).tap();
await element(by.text('Login')).tap();

await expect(element(by.text('Welcome'))).toBeVisible();
await expect(element(by.id('email'))).toNotExist();
Expand Down
12 changes: 6 additions & 6 deletions detox/test/e2e/a-sanity.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ describe('Sanity', () => {
});

beforeEach(async () => {
await element(by.label('Sanity')).tap();
await element(by.text('Sanity')).tap();
});

it('should have welcome screen', async () => {
await expect(element(by.label('Welcome'))).toBeVisible();
await expect(element(by.label('Say Hello'))).toBeVisible();
await expect(element(by.label('Say World'))).toBeVisible();
await expect(element(by.text('Welcome'))).toBeVisible();
await expect(element(by.text('Say Hello'))).toBeVisible();
await expect(element(by.text('Say World'))).toBeVisible();
});

it('should show hello screen after tap', async () => {
await element(by.label('Say Hello')).tap();
await element(by.text('Say Hello')).tap();
await expect(element(by.text('Hello!!!'))).toBeVisible();
});

it('should show world screen after tap', async () => {
await element(by.label('Say World')).tap();
await element(by.text('Say World')).tap();
await expect(element(by.text('World!!!'))).toBeVisible();
});
});
10 changes: 5 additions & 5 deletions detox/test/e2e/b-matchers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
describe('Matchers', () => {
beforeEach(async () => {
await device.reloadReactNative();
await element(by.label('Matchers')).tap();
await element(by.text('Matchers')).tap();
});

it('should match elements by (accesibility) label', async () => {
Expand All @@ -26,7 +26,7 @@ describe('Matchers', () => {
// Accessibility Inspector in the simulator can help investigate traits
it(':ios: should match elements by accesibility trait', async () => {
await element(by.traits(['button', 'text'])).tap();
await expect(element(by.label('Traits Working!!!'))).toBeVisible();
await expect(element(by.text('Traits Working!!!'))).toBeVisible();
});

it('should match elements with ancenstor (parent)', async () => {
Expand All @@ -48,13 +48,13 @@ describe('Matchers', () => {
});

it('should match elements by using two matchers together with and', async () => {
await expect(element(by.id('UniqueId345').and(by.label('ID')))).toExist();
await expect(element(by.id('UniqueId345').and(by.label('RandomJunk')))).toNotExist();
await expect(element(by.id('UniqueId345').and(by.text('ID')))).toExist();
await expect(element(by.id('UniqueId345').and(by.text('RandomJunk')))).toNotExist();
});

// waiting to upgrade EarlGrey version in order to test this (not supported in our current one)
it.skip('should choose from multiple elements matching the same matcher using index', async () => {
await expect(element(by.label('Product')).atIndex(2)).toHaveId('ProductId002');
await expect(element(by.text('Product')).atIndex(2)).toHaveId('ProductId002');
});

});
28 changes: 14 additions & 14 deletions detox/test/e2e/c-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ describe('Actions', () => {
});

beforeEach(async () => {
await element(by.label('Actions')).tap();
await element(by.text('Actions')).tap();
});

it('should tap on an element', async () => {
await element(by.label('Tap Me')).tap();
await element(by.text('Tap Me')).tap();
await expect(element(by.text('Tap Working!!!'))).toBeVisible();
});

it('should long press on an element', async () => {
await element(by.label('Tap Me')).longPress();
await element(by.text('Tap Me')).longPress();
await expect(element(by.text('Long Press Working!!!'))).toBeVisible();
});

Expand Down Expand Up @@ -48,30 +48,30 @@ describe('Actions', () => {

// directions: 'up'/'down'/'left'/'right'
it('should scroll for a small amount in direction', async () => {
await expect(element(by.label('Text1'))).toBeVisible();
await expect(element(by.label('Text4'))).toBeNotVisible();
await expect(element(by.text('Text1'))).toBeVisible();
await expect(element(by.text('Text4'))).toBeNotVisible();
await expect(element(by.id('ScrollView161'))).toBeVisible();
await element(by.id('ScrollView161')).scroll(100, 'down');
await expect(element(by.label('Text1'))).toBeNotVisible();
await expect(element(by.label('Text4'))).toBeVisible();
await expect(element(by.text('Text1'))).toBeNotVisible();
await expect(element(by.text('Text4'))).toBeVisible();
await element(by.id('ScrollView161')).scroll(100, 'up');
await expect(element(by.label('Text1'))).toBeVisible();
await expect(element(by.label('Text4'))).toBeNotVisible();
await expect(element(by.text('Text1'))).toBeVisible();
await expect(element(by.text('Text4'))).toBeNotVisible();
});

it('should scroll for a large amount in direction', async () => {
await expect(element(by.label('Text6'))).toBeNotVisible();
await expect(element(by.text('Text6'))).toBeNotVisible();
await element(by.id('ScrollView161')).scroll(200, 'down');
await expect(element(by.label('Text6'))).toBeVisible();
await expect(element(by.text('Text6'))).toBeVisible();
});

// edges: 'top'/'bottom'/'left'/'right'
it('should scroll to edge', async () => {
await expect(element(by.label('Text8'))).toBeNotVisible();
await expect(element(by.text('Text8'))).toBeNotVisible();
await element(by.id('ScrollView161')).scrollTo('bottom');
await expect(element(by.label('Text8'))).toBeVisible();
await expect(element(by.text('Text8'))).toBeVisible();
await element(by.id('ScrollView161')).scrollTo('top');
await expect(element(by.label('Text1'))).toBeVisible();
await expect(element(by.text('Text1'))).toBeVisible();
});

// TODO - swipe is not good enough for triggering pull to refresh. need to come up with something better
Expand Down
4 changes: 2 additions & 2 deletions detox/test/e2e/d-assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ describe('Assertions', () => {
});

beforeEach(async () => {
await element(by.label('Assertions')).tap();
await element(by.text('Assertions')).tap();
});

it('should assert an element is visible', async () => {
Expand Down Expand Up @@ -35,7 +35,7 @@ describe('Assertions', () => {
});

it('should assert an element has (accessibility) id', async () => {
await expect(element(by.label('I contain some text'))).toHaveId('UniqueId204');
await expect(element(by.text('I contain some text'))).toHaveId('UniqueId204');
});

// for example, the value of a UISwitch in the "on" state is "1"
Expand Down
8 changes: 4 additions & 4 deletions detox/test/e2e/e-waitfor.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
describe('WaitFor', () => {
beforeEach(async() => {
await device.reloadReactNative();
await element(by.label('WaitFor')).tap();
await element(by.text('WaitFor')).tap();
});

it('should wait until an element is created and exists in layout', async () => {
Expand All @@ -23,9 +23,9 @@ describe('WaitFor', () => {
});

it('should find element by scrolling until it is visible', async() => {
await expect(element(by.label('Text5'))).toBeNotVisible();
await waitFor(element(by.label('Text5'))).toBeVisible().whileElement(by.id('ScrollView630')).scroll(50, 'down');
await expect(element(by.label('Text5'))).toBeVisible();
await expect(element(by.text('Text5'))).toBeNotVisible();
await waitFor(element(by.text('Text5'))).toBeVisible().whileElement(by.id('ScrollView630')).scroll(50, 'down');
await expect(element(by.text('Text5'))).toBeVisible();
});

});
26 changes: 13 additions & 13 deletions detox/test/e2e/f-device.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
describe('Device', () => {
it('reloadReactNative - should tap successfully', async () => {
await device.reloadReactNative();
await element(by.label('Sanity')).tap();
await element(by.label('Say Hello')).tap();
await element(by.text('Sanity')).tap();
await element(by.text('Say Hello')).tap();
await expect(element(by.text('Hello!!!'))).toBeVisible();
});

it('relaunchApp - should tap successfully', async () => {
await device.relaunchApp();
await element(by.label('Sanity')).tap();
await element(by.label('Say Hello')).tap();
await element(by.text('Sanity')).tap();
await element(by.text('Say Hello')).tap();
await expect(element(by.text('Hello!!!'))).toBeVisible();
});

it('relaunchApp({delete: true}) - should tap successfully', async () => {
await device.relaunchApp({delete: true});
await element(by.label('Sanity')).tap();
await element(by.label('Say Hello')).tap();
await element(by.text('Sanity')).tap();
await element(by.text('Say Hello')).tap();
await expect(element(by.text('Hello!!!'))).toBeVisible();
});

it('uninstall() + install() + relaunch() - should tap successfully', async () => {
await device.uninstallApp();
await device.installApp();
await device.relaunchApp();
await element(by.label('Sanity')).tap();
await element(by.label('Say Hello')).tap();
await element(by.text('Sanity')).tap();
await element(by.text('Say Hello')).tap();
await expect(element(by.text('Hello!!!'))).toBeVisible();
});

it('launchApp({newInstance: true}) + sendToHome() + launchApp() - should bring up previous instance', async () => {
await device.launchApp({newInstance: true});
await element(by.label('Sanity')).tap();
await element(by.label('Say Hello')).tap();
await element(by.text('Sanity')).tap();
await element(by.text('Say Hello')).tap();
await device.sendToHome();
await device.launchApp();

Expand All @@ -43,15 +43,15 @@ describe('Device', () => {
await device.resetContentAndSettings();
await device.installApp();
await device.launchApp({ newInstance: true });
await element(by.label('Sanity')).tap();
await element(by.label('Say Hello')).tap();
await element(by.text('Sanity')).tap();
await element(by.text('Say Hello')).tap();
await expect(element(by.text('Hello!!!'))).toBeVisible();
});

describe('device orientation', () => {
beforeEach(async() => {
await device.reloadReactNative();
await element(by.label('Orientation')).tap();
await element(by.text('Orientation')).tap();

// Check if the element which input we will test actually exists
await expect(element(by.id('currentOrientation'))).toExist();
Expand Down
18 changes: 9 additions & 9 deletions detox/test/e2e/g-stress-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,30 @@ describe('StressTests', () => {
});

beforeEach(async () => {
await element(by.label('Stress')).tap();
await element(by.text('Stress')).tap();
});

it('should handle tap during busy bridge (one way)', async () => {
await element(by.label('Bridge OneWay Stress')).tap();
await element(by.label('Next')).tap();
await element(by.text('Bridge OneWay Stress')).tap();
await element(by.text('Next')).tap();
await expect(element(by.text('BridgeOneWay'))).toBeVisible();
});

it('should handle tap during busy bridge (two way)', async () => {
await element(by.label('Bridge TwoWay Stress')).tap();
await element(by.label('Next')).tap();
await element(by.text('Bridge TwoWay Stress')).tap();
await element(by.text('Next')).tap();
await expect(element(by.text('BridgeTwoWay'))).toBeVisible();
});

it('should handle tap during busy bridge (setState)', async () => {
await element(by.label('Bridge setState Stress')).tap();
await element(by.label('Next')).tap();
await element(by.text('Bridge setState Stress')).tap();
await element(by.text('Next')).tap();
await expect(element(by.text('BridgeSetState'))).toBeVisible();
});

it('should handle tap during busy JS event loop', async () => {
await element(by.label('EventLoop Stress')).tap();
await element(by.label('Next')).tap();
await element(by.text('EventLoop Stress')).tap();
await element(by.text('Next')).tap();
await expect(element(by.text('EventLoop'))).toBeVisible();
});

Expand Down
6 changes: 3 additions & 3 deletions detox/test/e2e/h-stress-root.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ describe('StressRoot', () => {
});

beforeEach(async () => {
await element(by.label('Switch Root')).tap();
await element(by.text('Switch Root')).tap();
});

after(async () => {
await device.relaunchApp();
});

it('should switch root view controller from RN to native', async () => {
await element(by.label('Switch to a new native root')).tap();
await element(by.text('Switch to a new native root')).tap();
await expect(element(by.text('this is a new native root'))).toBeVisible();
});

it(':ios: should switch root view controller from RN to RN', async () => {
await element(by.label('Switch to multiple react roots')).tap();
await element(by.text('Switch to multiple react roots')).tap();
await expect(element(by.text('Choose a test'))).toBeVisible();
});
});
2 changes: 1 addition & 1 deletion detox/test/e2e/i-stress-timeouts.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ describe('StressTimeouts', () => {
});

beforeEach(async () => {
await element(by.label('Timeouts')).tap();
await element(by.text('Timeouts')).tap();
});

it(':ios: should handle a short timeout', async () => {
Expand Down
6 changes: 3 additions & 3 deletions detox/test/e2e/j-async-and-callbacks.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
describe('Async and Callbacks', () => {
beforeEach(async () => {
await device.reloadReactNative();
await element(by.label('Sanity')).tap();
await element(by.text('Sanity')).tap();
});

it('should handle done() callback', (done) => {
expect(element(by.label('Welcome'))).toBeVisible().then(() => {
expect(element(by.text('Welcome'))).toBeVisible().then(() => {
setTimeout(() => {
done();
}, 1000);
Expand All @@ -14,7 +14,7 @@ describe('Async and Callbacks', () => {

it('should handle async await', async () => {
await timeout(1);
await expect(element(by.label('Welcome'))).toBeVisible();
await expect(element(by.text('Welcome'))).toBeVisible();
});
});

Expand Down
2 changes: 1 addition & 1 deletion detox/test/e2e/l-animations.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ let _ = require('lodash');
describe('Animations', () => {
beforeEach(async () => {
await device.reloadReactNative();
await element(by.label('Animations')).tap();
await element(by.text('Animations')).tap();
});

async function _startTest(driver, options = {}) {
Expand Down
4 changes: 2 additions & 2 deletions detox/test/e2e/l-permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ describe('Permissions', () => {

it('Permissions is granted', async () => {
await device.launchApp({permissions: {calendar: 'YES'}});
await element(by.label('Permissions')).tap();
await element(by.text('Permissions')).tap();
await expect(element(by.text('granted'))).toBeVisible();
});

it('Permissions denied', async () => {
await device.launchApp({permissions: {calendar: 'NO'}});
await element(by.label('Permissions')).tap();
await element(by.text('Permissions')).tap();
await expect(element(by.text('denied'))).toBeVisible();
});
});
2 changes: 1 addition & 1 deletion detox/test/e2e/m-network.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('Network Synchronization', () => {

beforeEach(async () => {
await device.reloadReactNative();
await element(by.label('Network')).tap();
await element(by.text('Network')).tap();
});

it('Sync with short network requests - 100ms', async () => {
Expand Down
4 changes: 2 additions & 2 deletions detox/test/e2e/o-location.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('location', () => {
return;
}
await device.relaunchApp({ permissions: { location: 'never' } });
await element(by.label('Location')).tap();
await element(by.text('Location')).tap();
await element(by.id('getLocationButton')).tap();
await expect(element(by.id('error'))).toBeVisible();
});
Expand All @@ -30,7 +30,7 @@ describe('location', () => {
}
await device.relaunchApp({ permissions: { location: 'always' } });
await device.setLocation(20, 20);
await element(by.label('Location')).tap();
await element(by.text('Location')).tap();
await element(by.id('getLocationButton')).tap();
await waitFor(element(by.text('Latitude: 20'))).toBeVisible().withTimeout(3000);

Expand Down
Loading

0 comments on commit 37b5c40

Please sign in to comment.