Skip to content

Commit f2688be

Browse files
authored
chore: Tests without scrolling (#903)
* Fixed tests by reducing spacing between elements in example App and changing iOS device to larger iPhone 15 Pro Max * Reverted a change done to an iOS test that caused it to fail sometimes * Changed CircleCI devices for Android and iOS
1 parent f30dce9 commit f2688be

File tree

5 files changed

+21
-30
lines changed

5 files changed

+21
-30
lines changed

.circleci/config.yml

+9-11
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ jobs:
4646
command: yarn detox:ios:build:release
4747
name: build app with new arch
4848

49-
5049
e2e_release_ios:
5150
executor:
5251
name: rn/macos
@@ -59,16 +58,16 @@ jobs:
5958
HOMEBREW_NO_INSTALL_CLEANUP=1 HOMEBREW_NO_AUTO_UPDATE=1 brew tap wix/brew >/dev/null
6059
HOMEBREW_NO_INSTALL_CLEANUP=1 HOMEBREW_NO_AUTO_UPDATE=1 brew install applesimutils >/dev/null
6160
- rn/ios_simulator_start:
62-
device: 'iPhone 14'
61+
device: 'iPhone 15 Pro Max'
6362
# - rn/yarn_install
6463
- run:
6564
command: yarn install --immutable
6665
name: yarn install
6766
- run:
6867
command: yarn bundle:ios
6968
name: bundle js
70-
# - rn/pod_install:
71-
# pod_install_directory: 'example/ios'
69+
# - rn/pod_install:
70+
# pod_install_directory: 'example/ios'
7271
- run:
7372
command: (cd example && npx pod-install)
7473
name: pod install
@@ -89,7 +88,7 @@ jobs:
8988
steps:
9089
- checkout
9190
- android/change-java-version:
92-
java-version: 17
91+
java-version: 17
9392
- run:
9493
command: avdmanager list
9594
name: list avds
@@ -99,7 +98,7 @@ jobs:
9998
- android/create-avd:
10099
avd-name: TestingAVD
101100
system-image: system-images;android-29;default;x86
102-
additional-args: --device pixel_3_xl
101+
additional-args: --device pixel_6_pro
103102
install: true
104103
background: false
105104
- android/start-emulator:
@@ -108,7 +107,7 @@ jobs:
108107
wait-for-emulator: true
109108
disable-animations: true
110109
restore-gradle-cache-post-emulator-launch: false
111-
post-emulator-launch-assemble-command: "pwd"
110+
post-emulator-launch-assemble-command: 'pwd'
112111
# - android/disable-animations
113112
- run:
114113
command: npm install --global yarn
@@ -128,7 +127,6 @@ jobs:
128127
- store_artifacts:
129128
path: ./artifacts
130129

131-
132130
new_arch_android_build_only:
133131
executor:
134132
name: android/android-machine
@@ -137,14 +135,14 @@ jobs:
137135
steps:
138136
- checkout
139137
- android/change-java-version:
140-
java-version: 17
138+
java-version: 17
141139
- run:
142140
command: avdmanager list
143141
name: list avds
144142
- android/create-avd:
145143
avd-name: TestingAVD
146144
system-image: system-images;android-29;default;x86
147-
additional-args: --device pixel_3_xl
145+
additional-args: --device pixel_6_pro
148146
install: true
149147
background: false
150148
- android/start-emulator:
@@ -153,7 +151,7 @@ jobs:
153151
wait-for-emulator: true
154152
disable-animations: true
155153
restore-gradle-cache-post-emulator-launch: false
156-
post-emulator-launch-assemble-command: "pwd"
154+
post-emulator-launch-assemble-command: 'pwd'
157155
- run:
158156
command: npm install --global yarn
159157
name: install yarn

.detoxrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module.exports = {
99
simulator: {
1010
type: 'ios.simulator',
1111
device: {
12-
type: 'iPhone 14',
12+
type: 'iPhone 15 Pro Max',
1313
},
1414
},
1515
emulator: {

example/App.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ export const App = () => {
336336
placeholder="accentColor"
337337
/>
338338
</View>
339-
<View style={{flex: 1, flexDirection: 'row'}}>
339+
<View style={styles.header}>
340340
<ThemedText style={styles.textLabel}>
341341
disabled (iOS only)
342342
</ThemedText>
@@ -360,15 +360,15 @@ export const App = () => {
360360
style={{
361361
flexDirection: 'column',
362362
flexWrap: 'wrap',
363-
paddingBottom: 10,
363+
paddingBottom: 0,
364364
}}>
365365
<ThemedText style={styles.textLabel}>
366366
firstDayOfWeek (android only)
367367
</ThemedText>
368368
<View style={styles.firstDayOfWeekContainer}>
369369
<FlatList
370370
testID="firstDayOfWeekSelector"
371-
style={{marginBottom: 10}}
371+
style={{marginBottom: 5}}
372372
horizontal={true}
373373
renderItem={renderDayOfWeekItem}
374374
data={Object.entries(DAY_OF_WEEK)}
@@ -647,7 +647,7 @@ const styles = StyleSheet.create({
647647
flexDirection: 'row',
648648
},
649649
textLabel: {
650-
margin: 10,
650+
marginHorizontal: 5,
651651
flex: 1,
652652
},
653653
textInput: {

example/e2e/detoxTest.spec.js

+2-14
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const {
1414
userTapsOkButtonAndroid,
1515
userSelectsDayInCalendar,
1616
userSwipesTimezoneListUntilDesiredIsVisible,
17+
userDismissesCompactDatePicker,
1718
} = require('./utils/actions');
1819
const {isIOS, isAndroid, wait, Platform} = require('./utils/utils');
1920
const {device} = require('detox');
@@ -65,15 +66,14 @@ describe('e2e tests', () => {
6566
await userOpensPicker({mode: 'date', display: 'default'});
6667

6768
if (isIOS()) {
68-
await elementById('DateTimePickerScrollView').scrollTo('bottom');
6969
await getDatePickerButtonIOS().tap();
7070

7171
// 'label' maps to 'description' in view hierarchy debugger
7272
const nextMonthArrow = element(by.label('Next Month'));
7373

7474
await nextMonthArrow.tap();
7575
await nextMonthArrow.tap();
76-
await getDatePickerButtonIOS().tap();
76+
await userDismissesCompactDatePicker();
7777
} else {
7878
const calendarHorizontalScrollView = element(
7979
by
@@ -121,11 +121,9 @@ describe('e2e tests', () => {
121121
ios: 'inline',
122122
android: 'default',
123123
});
124-
await elementById('DateTimePickerScrollView').scrollTo('top');
125124
await userOpensPicker({mode: 'time', display});
126125

127126
if (isIOS()) {
128-
await elementById('DateTimePickerScrollView').scrollTo('bottom');
129127
await expect(getInlineTimePickerIOS()).toBeVisible();
130128
} else {
131129
await expect(element(by.type('android.widget.TimePicker'))).toBeVisible();
@@ -169,8 +167,6 @@ describe('e2e tests', () => {
169167

170168
await expect(elementById('overriddenTzName')).toHaveText('Europe/Prague');
171169

172-
await elementById('DateTimePickerScrollView').scrollTo('bottom');
173-
174170
let timeZone = 'America/Vancouver';
175171
await waitFor(elementById('timezone')).toBeVisible().withTimeout(1000);
176172
await userSwipesTimezoneListUntilDesiredIsVisible(timeZone);
@@ -195,8 +191,6 @@ describe('e2e tests', () => {
195191
});
196192

197193
it('daylight saving should work properly', async () => {
198-
await elementById('DateTimePickerScrollView').scrollTo('bottom');
199-
200194
let timeZone = 'America/Vancouver';
201195
await waitFor(elementById('timezone')).toBeVisible().withTimeout(1000);
202196
await userSwipesTimezoneListUntilDesiredIsVisible(timeZone);
@@ -209,7 +203,6 @@ describe('e2e tests', () => {
209203

210204
await elementByText(timeZone).multiTap(2);
211205

212-
await elementById('DateTimePickerScrollView').scrollTo('top');
213206
await userOpensPicker({mode: 'date', display: getPickerDisplay()});
214207

215208
if (isIOS()) {
@@ -239,7 +232,6 @@ describe('e2e tests', () => {
239232
await uiDevice.pressEnter();
240233
await userTapsOkButtonAndroid();
241234

242-
await elementById('DateTimePickerScrollView').scrollTo('top');
243235
await userOpensPicker({mode: 'time', display: getPickerDisplay()});
244236
await userChangesTimeValue({hours: '2', minutes: '0'});
245237
await userTapsOkButtonAndroid();
@@ -287,8 +279,6 @@ describe('e2e tests', () => {
287279
tzOffsetPreset = tzOffsetPreset.toUpperCase();
288280
}
289281

290-
await elementById('DateTimePickerScrollView').scrollTo('top');
291-
292282
await userOpensPicker({
293283
mode: 'time',
294284
display: getPickerDisplay(),
@@ -324,9 +314,7 @@ describe('e2e tests', () => {
324314
await expect(elementById('utcTime')).toHaveText('2021-11-13T00:00:00Z');
325315

326316
// Ensure you can select tomorrow (iOS)
327-
await elementById('DateTimePickerScrollView').scrollTo('top');
328317
await userOpensPicker({mode: 'date', display: getPickerDisplay()});
329-
await elementById('DateTimePickerScrollView').scrollTo('bottom');
330318
await testElement.setDatePickerDate('2021-11-14T01:00:00Z', 'ISO8601');
331319
} else {
332320
const uiDevice = device.getUiDevice();

example/e2e/utils/actions.js

+5
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,16 @@ async function userSelectsDayInCalendar(uiDevice, {xPos, yPos}) {
9393
await uiDevice.pressEnter();
9494
}
9595

96+
async function userDismissesCompactDatePicker() {
97+
await element(by.type('_UIDatePickerContainerView')).tap();
98+
}
99+
96100
module.exports = {
97101
userOpensPicker,
98102
userTapsCancelButtonAndroid,
99103
userTapsOkButtonAndroid,
100104
userChangesTimeValue,
101105
userSelectsDayInCalendar,
102106
userSwipesTimezoneListUntilDesiredIsVisible,
107+
userDismissesCompactDatePicker,
103108
};

0 commit comments

Comments
 (0)