-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add e2e tests, bug fixes for testIDs (#22537)
Summary: This PR adds e2e tests for the Picker and DatePicker components. While writing these tests, I also found and fixed two bugs where we wern't passing the `testID` down to the native components, so detox couldn't look them up. This confirms what was mentioned by rotemmiz [here](wix/Detox#798 (comment)) Pull Request resolved: #22537 Reviewed By: cpojer Differential Revision: D13371307 Pulled By: rickhanlonii fbshipit-source-id: a4dfcdb5913645bceca0c7353328eeb9ad0f6558
- Loading branch information
1 parent
1fdfed5
commit 00c7c5a
Showing
6 changed files
with
107 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** | ||
* 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 element, by, expect */ | ||
|
||
describe('DatePickerIOS', () => { | ||
beforeAll(async () => { | ||
await element(by.id('explorer_search')).replaceText('<DatePickerIOS>'); | ||
await element( | ||
by.label( | ||
'<DatePickerIOS> Select dates and times using the native UIDatePicker.', | ||
), | ||
).tap(); | ||
}); | ||
|
||
afterAll(async () => { | ||
await element(by.label('Back')).tap(); | ||
}); | ||
|
||
it('Should change indicator with datetime picker', async () => { | ||
const testID = 'date-and-time'; | ||
const indicatorID = 'date-and-time-indicator'; | ||
|
||
const testElement = await element( | ||
by.type('UIPickerView').withAncestor(by.id(testID)), | ||
); | ||
const indicator = await element(by.id(indicatorID)); | ||
|
||
await expect(testElement).toBeVisible(); | ||
await expect(indicator).toBeVisible(); | ||
|
||
await testElement.setColumnToValue(0, 'Dec 4'); | ||
await testElement.setColumnToValue(1, '4'); | ||
await testElement.setColumnToValue(2, '10'); | ||
await testElement.setColumnToValue(3, 'AM'); | ||
|
||
await expect(indicator).toHaveText('12/4/2005 4:10 AM'); | ||
}); | ||
|
||
it('Should change indicator with date-only picker', async () => { | ||
const testID = 'date-only'; | ||
const indicatorID = 'date-and-time-indicator'; | ||
|
||
const testElement = await element( | ||
by.type('UIPickerView').withAncestor(by.id(testID)), | ||
); | ||
const indicator = await element(by.id(indicatorID)); | ||
|
||
await expect(testElement).toBeVisible(); | ||
await expect(indicator).toBeVisible(); | ||
|
||
await testElement.setColumnToValue(0, 'November'); | ||
await testElement.setColumnToValue(1, '3'); | ||
await testElement.setColumnToValue(2, '2006'); | ||
|
||
await expect(indicator).toHaveText('11/3/2006 4:10 AM'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* 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 element, by, expect */ | ||
|
||
describe('Picker', () => { | ||
beforeAll(async () => { | ||
await element(by.id('explorer_search')).replaceText('<Picker>'); | ||
await element( | ||
by.label( | ||
'<Picker> Provides multiple options to choose from, using either a dropdown menu or a dialog.', | ||
), | ||
).tap(); | ||
}); | ||
|
||
afterAll(async () => { | ||
await element(by.label('Back')).tap(); | ||
}); | ||
|
||
it('should be selectable by ID', async () => { | ||
await expect(element(by.id('basic-picker'))).toBeVisible(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters