Skip to content

Commit d8528ec

Browse files
LKuchnokkafar
andauthored
chore(test): new test-tabs-controller-mode-ios with scenario (#3848)
## Description New screen for tabBarControllerMode prop (iOS only) with corresponding manual scenario. Closes: software-mansion/react-native-screens-labs#1114 ## Changes Adding new screen in new directory to cover tabBarControllerMode props. Screen added to tabs/index.ts to be displayed under SFT category. --------- Co-authored-by: Kacper Kafara <kacper.kafara@swmansion.com>
1 parent bb49824 commit d8528ec

3 files changed

Lines changed: 203 additions & 0 deletions

File tree

apps/src/tests/single-feature-tests/tabs/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import TestTabsSimpleNav from './test-tabs-simple-nav';
1212
import TestTabsMoreNavigationController from './test-tabs-more-navigation-controller';
1313
import TestTabsStaleStateUpdateRejection from './test-tabs-stale-update-rejection';
1414
import TestTabsTabBarMinimizeBehavior from './test-tabs-tab-bar-minimize-behavior-ios';
15+
import TestTabsTabBarControllerMode from './test-tabs-tab-bar-controller-mode-ios';
1516

1617
const scenarios = {
1718
BottomAccessoryScenario,
@@ -26,6 +27,7 @@ const scenarios = {
2627
TestTabsMoreNavigationController,
2728
TestTabsStaleStateUpdateRejection,
2829
TestTabsTabBarMinimizeBehavior,
30+
TestTabsTabBarControllerMode,
2931
};
3032

3133
const TabsScenarioGroup: ScenarioGroup<keyof typeof scenarios> = {
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
import {
2+
TabsContainerWithHostConfigContext,
3+
type TabRouteConfig,
4+
useTabsHostConfig,
5+
DEFAULT_TAB_ROUTE_OPTIONS,
6+
} from '@apps/shared/gamma/containers/tabs';
7+
import React from 'react';
8+
import { View, Text, ScrollView, StyleSheet } from 'react-native';
9+
import { Scenario } from '@apps/tests/shared/helpers';
10+
import { SettingsPicker } from '@apps/shared';
11+
import {TabBarControllerMode } from 'react-native-screens';
12+
13+
const SCENARIO: Scenario = {
14+
name: 'Tab Bar Controller Mode',
15+
key: 'test-tabs-tab-bar-controller-mode-ios',
16+
details: 'Test different tab bar modes.',
17+
platforms: ['ios'],
18+
AppComponent: App,
19+
};
20+
21+
export default SCENARIO;
22+
23+
function ConfigScreen() {
24+
const { hostConfig, updateHostConfig } = useTabsHostConfig();
25+
return (
26+
<ScrollView style={{ padding: 40 }}>
27+
<View>
28+
<Text style={styles.description}>
29+
Controls whether the tab bar is displayed as a bar or
30+
sidebar.{'\n'}Test tabSidebar on iPad — on iPhone it collapses
31+
back to a tab bar automatically.
32+
</Text>
33+
<SettingsPicker<TabBarControllerMode>
34+
label="tabBarControllerMode"
35+
value={hostConfig.ios?.tabBarControllerMode ?? 'automatic'}
36+
onValueChange={value =>
37+
updateHostConfig({ ios: { tabBarControllerMode: value } })
38+
}
39+
items={['automatic', 'tabBar', 'tabSidebar']}
40+
/>
41+
</View>
42+
</ScrollView >
43+
);
44+
}
45+
46+
function TestScreen() {
47+
return (
48+
<ScrollView
49+
style={{ flex: 1 }}
50+
contentInsetAdjustmentBehavior="automatic"
51+
testID="test-screen-scroll">
52+
{Array.from({ length: 40 }, (_, i) => (
53+
<View key={i} style={styles.scrollItem}>
54+
<Text>Row {i + 1} — scroll to test tabBarMinimizeBehavior</Text>
55+
</View>
56+
))}
57+
</ScrollView>
58+
);
59+
};
60+
61+
const ROUTE_CONFIGS: TabRouteConfig[] = [
62+
{
63+
name: 'Tab1',
64+
Component: ConfigScreen,
65+
options: {
66+
...DEFAULT_TAB_ROUTE_OPTIONS,
67+
title: 'Tab1',
68+
},
69+
},
70+
{
71+
name: 'Tab2',
72+
Component: TestScreen,
73+
options: {
74+
...DEFAULT_TAB_ROUTE_OPTIONS,
75+
title: 'Tab2',
76+
77+
},
78+
},
79+
];
80+
81+
export function App() {
82+
return <TabsContainerWithHostConfigContext routeConfigs={ROUTE_CONFIGS} />;
83+
};
84+
85+
const styles = {
86+
sectionHeader: {
87+
fontSize: 13,
88+
fontWeight: '600' as const,
89+
textTransform: 'uppercase' as const,
90+
color: '#888',
91+
letterSpacing: 0.5,
92+
marginTop: 24,
93+
marginBottom: 4,
94+
},
95+
description: {
96+
fontSize: 13,
97+
color: '#555',
98+
marginBottom: 6,
99+
marginTop: 12,
100+
textAlign: 'center' as const,
101+
},
102+
scrollItem: {
103+
padding: 16,
104+
borderBottomWidth: StyleSheet.hairlineWidth,
105+
borderBottomColor: '#e0e0e0',
106+
},
107+
centeredScreen: {
108+
flex: 1,
109+
justifyContent: 'center',
110+
alignItems: 'center',
111+
padding: 24,
112+
gap: 12,
113+
},
114+
screenLabel: {
115+
fontSize: 17,
116+
fontWeight: '600',
117+
textAlign: 'center',
118+
},
119+
screenHint: {
120+
fontSize: 14,
121+
color: '#555',
122+
textAlign: 'center',
123+
lineHeight: 20,
124+
},
125+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Test Scenario: tabBarControllerMode
2+
3+
**E2E:** Not automated - test will be added at least for iPad to check sidebar visibility.
4+
5+
## Prerequisites
6+
7+
- iPhone simulator or device
8+
- iPad simulator or device (required for `tabSidebar` mode)
9+
- iOS 18+
10+
11+
## Steps
12+
13+
### iPad
14+
15+
1. Launch the app and navigate to the **Tab Bar Controller Mode** screen.
16+
17+
- [ ] Expected: Tab bar displayed at the top with Tab1 and Tab2. Picker defaults to `automatic`
18+
19+
2. Ensure that tabBarControllerMode = `automatic`
20+
21+
- [ ] Expected: Tab bar displayed according to iPadOS default behavior for current orientation
22+
23+
3. Change app window size to correspond to iPhone view.
24+
25+
- [ ] Expected: Tab bar displayed at the **bottom**
26+
27+
4. Resize app to full screen.
28+
Set tabBarControllerMode = `tabBar`
29+
30+
- [ ] Expected: Tab bar displayed without sidebar option - even if iPadOS would default do it
31+
32+
5. Change app window size to correspond to iPhone view.
33+
34+
- [ ] Expected: Tab bar displayed at the **bottom**
35+
36+
6. Resize app to full screen.
37+
Set tabBarControllerMode = `tabSidebar`, test on **iPad landscape** orientation
38+
39+
- [ ] Expected: Navigation displayed as a **sidebar** on the leading edge
40+
41+
7. Keep tabBarControllerMode = `tabSidebar`, test on **iPad portrait**
42+
43+
- [ ] Expected: Sidebar adapts or collapses — tab items still accessible
44+
45+
8. Change app window size to correspond to iPhone view.
46+
47+
- [ ] Expected: Tab bar displayed at the **bottom** without sidebar option.
48+
49+
9. Resize app to full screen.
50+
Cycle through `automatic``tabBar``tabSidebar``automatic`
51+
52+
- [ ] Expected: UI transitions immediately with each change, no crash or layout freeze
53+
54+
10. Switch tabs (Tab1 ↔ Tab2) while cycling through all modes.
55+
56+
- [ ] Expected: Tab switching works correctly in all three modes.
57+
58+
---
59+
60+
### Simple check on iPhone
61+
62+
11. Launch the app and navigate to the **Tab Bar Controller Mode** screen.
63+
64+
- [ ] Expected: Tab bar displayed at the bottom with Tab1 and Tab2. Picker defaults to `automatic`
65+
66+
12. Set tabBarControllerMode = `automatic`
67+
68+
- [ ] Expected: Tab bar displayed at the **bottom**
69+
70+
13. Set tabBarControllerMode = `tabBar`
71+
72+
- [ ] Expected: Tab bar displayed at the **bottom**
73+
74+
14. Set tabBarControllerMode = `tabSidebar`
75+
76+
- [ ] Expected: Tab bar displayed at the **bottom**

0 commit comments

Comments
 (0)