Skip to content

Commit d6891d7

Browse files
committed
corrects
1 parent 872dfc4 commit d6891d7

2 files changed

Lines changed: 77 additions & 48 deletions

File tree

apps/src/tests/single-feature-tests/tabs/test-tabs-events/index.tsx

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useCallback } from 'react';
1+
import React, { useCallback, useMemo } from 'react';
22
import { StyleSheet, Text } from 'react-native';
33
import type { ScenarioDescription } from '@apps/tests/shared/helpers';
44
import { createScenario } from '@apps/tests/shared/helpers';
@@ -16,7 +16,7 @@ const scenarioDescription: ScenarioDescription = {
1616
name: 'Tabs lifecycle events',
1717
key: 'test-tabs-events',
1818
details:
19-
'Verifies onWillAppear, onDidAppear, onWillDisappear, onDidDisappear fire in the correct order when switching tabs.',
19+
'Verify lifecycle events (onWillAppear, etc.) fire on tab switch',
2020
platforms: ['ios', 'android'],
2121
};
2222

@@ -62,35 +62,38 @@ function AppContents() {
6262
[toast],
6363
);
6464

65-
const TAB_CONFIGS: TabRouteConfig[] = [
66-
{
67-
name: 'TabA',
68-
Component: TabScreen,
69-
options: {
70-
...DEFAULT_TAB_ROUTE_OPTIONS,
71-
title: 'Tab A',
72-
...makeCallbacks('TabA'),
65+
const TAB_CONFIGS = useMemo<TabRouteConfig[]>(
66+
() => [
67+
{
68+
name: 'TabA',
69+
Component: TabScreen,
70+
options: {
71+
...DEFAULT_TAB_ROUTE_OPTIONS,
72+
title: 'Tab A',
73+
...makeCallbacks('TabA'),
74+
},
7375
},
74-
},
75-
{
76-
name: 'TabB',
77-
Component: TabScreen,
78-
options: {
79-
...DEFAULT_TAB_ROUTE_OPTIONS,
80-
title: 'Tab B',
81-
...makeCallbacks('TabB'),
76+
{
77+
name: 'TabB',
78+
Component: TabScreen,
79+
options: {
80+
...DEFAULT_TAB_ROUTE_OPTIONS,
81+
title: 'Tab B',
82+
...makeCallbacks('TabB'),
83+
},
8284
},
83-
},
84-
{
85-
name: 'TabC',
86-
Component: TabScreen,
87-
options: {
88-
...DEFAULT_TAB_ROUTE_OPTIONS,
89-
title: 'Tab C',
90-
...makeCallbacks('TabC'),
85+
{
86+
name: 'TabC',
87+
Component: TabScreen,
88+
options: {
89+
...DEFAULT_TAB_ROUTE_OPTIONS,
90+
title: 'Tab C',
91+
...makeCallbacks('TabC'),
92+
},
9193
},
92-
},
93-
];
94+
],
95+
[makeCallbacks],
96+
);
9497

9598
return <TabsContainer routeConfigs={TAB_CONFIGS} />;
9699
}

apps/src/tests/single-feature-tests/tabs/test-tabs-events/scenario.md

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ Other: ongoing research
3232
2. `TabX: onDidDisappear`
3333
3. `TabY: onWillAppear`
3434
4. `TabY: onDidAppear`
35-
- Toasts stack and dismiss automatically; observe each toast color and
36-
label as it appears. To dismiss a toast manually, tap it.
35+
- Toasts stack and dismiss automatically. To dismiss a toast manually,
36+
tap it. Toast background colors by event type:
37+
`onWillAppear` — green, `onWillDisappear` — light navy,
38+
`onDidAppear` — light blue, `onDidDisappear` — dark navy.
3739
- Re-tapping the currently active tab must not fire any lifecycle events.
3840

3941
## Steps
@@ -54,38 +56,62 @@ Other: ongoing research
5456

5557
2. Tap **Tab B** in the tab bar.
5658

57-
- [ ] Expected: The content area switches to show "TabB". Four toast
58-
notifications appear in a platform-specific order:
59-
- `TabB: onWillAppear` (green background)
60-
- `TabA: onWillDisappear` (light navy background)
61-
- `TabB: onDidAppear` (light blue background)
62-
- `TabA: onDidDisappear` (dark navy background)
59+
- [ ] Expected: The content area switches to show "TabB". Four toasts
60+
appear in the following platform-specific order:
61+
62+
**iOS:**
63+
1. `TabB: onWillAppear`
64+
2. `TabA: onWillDisappear`
65+
3. `TabB: onDidAppear`
66+
4. `TabA: onDidDisappear`
67+
68+
**Android:**
69+
1. `TabA: onWillDisappear`
70+
2. `TabA: onDidDisappear`
71+
3. `TabB: onWillAppear`
72+
4. `TabB: onDidAppear`
6373

6474
---
6575

6676
### Tab B → Tab C transition
6777

6878
3. Tap **Tab C** in the tab bar.
6979

70-
- [ ] Expected: The content area switches to show "TabC". Four toast
71-
notifications appear in a platform-specific order:
72-
- `TabC: onWillAppear` (green background)
73-
- `TabB: onWillDisappear` (light navy background)
74-
- `TabC: onDidAppear` (light blue background)
75-
- `TabB: onDidDisappear` (dark navy background)
80+
- [ ] Expected: The content area switches to show "TabC". Four toasts
81+
appear in the following platform-specific order:
82+
83+
**iOS:**
84+
1. `TabC: onWillAppear`
85+
2. `TabB: onWillDisappear`
86+
3. `TabC: onDidAppear`
87+
4. `TabB: onDidDisappear`
88+
89+
**Android:**
90+
1. `TabB: onWillDisappear`
91+
2. `TabB: onDidDisappear`
92+
3. `TabC: onWillAppear`
93+
4. `TabC: onDidAppear`
7694

7795
---
7896

7997
### Tab C → Tab A transition
8098

8199
4. Tap **Tab A** in the tab bar.
82100

83-
- [ ] Expected: The content area switches to show "TabA". Four toast
84-
notifications appear in a platform-specific order:
85-
- `TabA: onWillAppear` (green background)
86-
- `TabC: onWillDisappear` (light navy background)
87-
- `TabA: onDidAppear` (light blue background)
88-
- `TabC: onDidDisappear` (dark navy background)
101+
- [ ] Expected: The content area switches to show "TabA". Four toasts
102+
appear in the following platform-specific order:
103+
104+
**iOS:**
105+
1. `TabA: onWillAppear`
106+
2. `TabC: onWillDisappear`
107+
3. `TabA: onDidAppear`
108+
4. `TabC: onDidDisappear`
109+
110+
**Android:**
111+
1. `TabC: onWillDisappear`
112+
2. `TabC: onDidDisappear`
113+
3. `TabA: onWillAppear`
114+
4. `TabA: onDidAppear`
89115

90116
---
91117

0 commit comments

Comments
 (0)