Skip to content

Commit 56c6085

Browse files
authored
test(e2e, Fabric): add e2e test for issue/PR example 654 (#2898)
## Description Create e2e test for `Test654`. ### Test654 Test created, only on iOS. It checks that native back button is rendered correctly in RTL mode. ## Changes - add testID to RTL mode switch in Example screen - add e2e test for `Test654` - add comment in `apps/src/tests/index.ts` ## Test code and steps to reproduce CI ## Checklist - [x] Ensured that CI passes
1 parent d05c4c3 commit 56c6085

File tree

5 files changed

+32
-2
lines changed

5 files changed

+32
-2
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { device, expect, element, by } from 'detox';
2+
import { describeIfiOS } from '../e2e-utils';
3+
4+
// issue related to iOS native back button
5+
describeIfiOS('Test654', () => {
6+
beforeAll(async () => {
7+
await device.reloadReactNative();
8+
await element(by.id('root-screen-switch-rtl')).tap();
9+
});
10+
11+
it('Test654 should exist', async () => {
12+
await waitFor(element(by.id('root-screen-tests-Test654')))
13+
.toBeVisible()
14+
.whileElement(by.id('root-screen-examples-scrollview'))
15+
.scroll(600, 'down', NaN, 0.85);
16+
17+
await expect(element(by.id('root-screen-tests-Test654'))).toBeVisible();
18+
await element(by.id('root-screen-tests-Test654')).tap();
19+
});
20+
21+
it('back button should be visible on Second screen', async () => {
22+
await element(by.id('first-button-go-to-second')).tap();
23+
await expect(element(by.type('_UIButtonBarButton'))).toBeVisible(100);
24+
await expect(element(by.id('chevron.backward'))).toBeVisible(100);
25+
});
26+
});

apps/Example.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ const MainScreen = ({ navigation }: MainScreenProps): React.JSX.Element => {
197197
I18nManager.forceRTL(!I18nManager.isRTL);
198198
RNRestart.Restart();
199199
}}
200+
testID="root-screen-switch-rtl"
200201
/>
201202
<SettingsSwitch
202203
style={styles.switch}

apps/src/shared/SettingsSwitch.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,18 @@ type Props = {
77
value: boolean;
88
onValueChange: (value: boolean) => void;
99
style?: ViewStyle;
10+
testID?: string;
1011
};
1112

1213
export const SettingsSwitch = ({
1314
label,
1415
value,
1516
onValueChange,
1617
style = {},
18+
testID,
1719
}: Props): React.JSX.Element => {
1820
return (
19-
<TouchableOpacity onPress={() => onValueChange(!value)}>
21+
<TouchableOpacity onPress={() => onValueChange(!value)} testID={testID}>
2022
<ThemedView style={[styles.container, style]}>
2123
<ThemedText style={styles.label}>{`${label}: ${value}`}</ThemedText>
2224
</ThemedView>

apps/src/tests/Test654.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ function First({ navigation }) {
2929
<Button
3030
title="Tap me for second screen"
3131
onPress={() => navigation.navigate('Second')}
32+
testID="first-button-go-to-second"
3233
/>
3334
);
3435
}

apps/src/tests/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export { default as Test642 } from './Test642'; // [E2E skipped]: can't chec
1919
export { default as Test645 } from './Test645'; // [E2E created](iOS): headerLargeTitle is supported only on iOS
2020
export { default as Test648 } from './Test648'; // [E2E skipped]: can't check animation in a meaningful way
2121
export { default as Test649 } from './Test649'; // [E2E created](iOS): headerLargeTitle is supported only on iOS
22-
export { default as Test654 } from './Test654';
22+
export { default as Test654 } from './Test654'; // [E2E created](iOS): issue related to iOS native back button
2323
export { default as Test658 } from './Test658';
2424
export { default as Test662 } from './Test662';
2525
export { default as Test691 } from './Test691';

0 commit comments

Comments
 (0)