Skip to content

Commit 033152c

Browse files
authored
test(e2e, Fabric): add e2e tests for issue/PR examples 761..791 (#2957)
## Description Check which example screens from issues/PRs can be used in e2e testing for tests `Test761, ..., Test791` and implement them if possible for Fabric. ### Test761 Skipped because we can't check animation. ### Test779 Skipped because we can't check animation. ### Test780 Skipped because we can't use native swipe back gesture with Detox. ### Test791 Test created, only on iOS (original issue was about crashes on iOS). It tests if the app crashes when you push multiple screens quickly behind modal. ## Changes - add `Test791` e2e test - modify`Test791` test screen (add explicit `presentation: 'card'` for push screen, add testIDs) - add comments for every test screen from this PR in `apps/src/tests/index.ts` with the reason for (not) implementing e2e test for it ## Test code and steps to reproduce CI ## Checklist - [ ] Ensured that CI passes
1 parent ab82c8b commit 033152c

File tree

3 files changed

+42
-6
lines changed

3 files changed

+42
-6
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { device, expect, element, by } from 'detox';
2+
import { describeIfiOS, selectTestScreen } from '../e2e-utils';
3+
4+
// issue related to iOS
5+
describeIfiOS('Test791', () => {
6+
beforeAll(async () => {
7+
await device.reloadReactNative();
8+
});
9+
10+
it('Test791 should exist', async () => {
11+
await selectTestScreen('Test791');
12+
});
13+
14+
it('the app should not crash after quickly pushing multiple card screens behind the modal', async () => {
15+
await element(by.id('main-button-push-modal')).tap();
16+
await element(by.id('push-button-push-multiple')).tap();
17+
});
18+
19+
it('pushed screens should be visible after closing modal', async () => {
20+
await element(by.text('Modal')).swipe('down', 'fast');
21+
22+
for (let i = 0; i < 5; ++i) {
23+
await expect(element(by.id('push-text'))).toBeVisible();
24+
await element(by.type('_UIButtonBarButton')).atIndex(0).tap();
25+
}
26+
27+
await expect(element(by.id('main-text'))).toBeVisible();
28+
});
29+
});

apps/src/tests/Test791.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,21 @@ const MainScreen = ({ navigation }: NativeStackScreenProps<ParamListBase>) => {
2020
title="Click this button to see the crash if native changes not applied"
2121
/>
2222
<Button
23+
testID="main-button-push-modal"
2324
onPress={() => {
2425
navigation.push('Modal');
2526
}}
2627
title="Push modal"
2728
/>
28-
<Text>Issue 791</Text>
29+
<Text testID="main-text">Issue 791</Text>
2930
</View>
3031
);
3132
};
3233

3334
const PushScreen = ({ navigation }: NativeStackScreenProps<ParamListBase>) => (
3435
<View style={styles.screen}>
3536
<Button
37+
testID="push-button-push-multiple"
3638
onPress={() => {
3739
navigation.push('Push');
3840
setTimeout(() => navigation.push('Push'), 10);
@@ -50,6 +52,7 @@ const PushScreen = ({ navigation }: NativeStackScreenProps<ParamListBase>) => (
5052
}}
5153
title="Click this button to pop"
5254
/>
55+
<Text testID="push-text">Push screen</Text>
5356
</View>
5457
);
5558

@@ -59,7 +62,11 @@ const App = () => (
5962
<NavigationContainer>
6063
<Stack.Navigator>
6164
<Stack.Screen name="Main" component={MainScreen} />
62-
<Stack.Screen name="Push" component={PushScreen} />
65+
<Stack.Screen
66+
name="Push"
67+
component={PushScreen}
68+
options={{ presentation: 'card' }}
69+
/>
6370
<Stack.Screen
6471
name="Modal"
6572
component={PushScreen}

apps/src/tests/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ export { default as Test726 } from './Test726'; // [E2E created](iOS): issue
3030
export { default as Test748 } from './Test748';
3131
export { default as Test750 } from './Test750';
3232
export { default as Test758 } from './Test758';
33-
export { default as Test761 } from './Test761';
34-
export { default as Test779 } from './Test779';
35-
export { default as Test780 } from './Test780';
36-
export { default as Test791 } from './Test791';
33+
export { default as Test761 } from './Test761'; // [E2E skipped]: can't check animation in a meaningful way
34+
export { default as Test779 } from './Test779'; // [E2E skipped]: can't check animation in a meaningful way
35+
export { default as Test780 } from './Test780'; // [E2E skipped]: can't use native swipe back gesture
36+
export { default as Test791 } from './Test791'; // [E2E created](iOS): issue related to iOS
3737
export { default as Test800 } from './Test800';
3838
export { default as Test817 } from './Test817';
3939
export { default as Test830 } from './Test830';

0 commit comments

Comments
 (0)