Skip to content

Commit 7e7e97b

Browse files
committed
Merge remote-tracking branch 'origin/7.x.x' into support-drawer-menu-open-mode
2 parents 8a591c3 + d3d6961 commit 7e7e97b

73 files changed

Lines changed: 655 additions & 540 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@ module.exports = {
55
plugins: ['@typescript-eslint'],
66
env: {
77
jest: true,
8-
'jest/globals': true,
98
},
109
};

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,4 +244,3 @@ Mock.js
244244
Mock.d.ts
245245

246246
Gemfile.lock
247-
/playground/ios/.xcode.env.local

babel.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = function (api) {
22
api && api.cache(false);
33
return {
4-
presets: ['module:@react-native/babel-preset'],
4+
presets: ['module:metro-react-native-babel-preset'],
55
plugins: [
66
'@babel/plugin-proposal-export-namespace-from',
77
'@babel/plugin-proposal-export-default-from',

e2e/SideMenu.test.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import TestIDs from '../playground/src/testIDs';
33

44
const { elementByLabel, elementById } = Utils;
55

6-
describe.e2e('SideMenu', () => {
6+
describe('SideMenu', () => {
77
beforeEach(async () => {
88
await device.launchApp({ newInstance: true });
99
await elementById(TestIDs.SIDE_MENU_BTN).tap();
@@ -38,13 +38,13 @@ describe.e2e('SideMenu', () => {
3838
await expect(elementById(TestIDs.CLOSE_RIGHT_SIDE_MENU_BTN)).toBeNotVisible();
3939
});
4040

41-
it('should rotate', async () => {
41+
it.e2e('should rotate', async () => {
4242
await elementById(TestIDs.OPEN_LEFT_SIDE_MENU_BTN).tap();
4343
await device.setOrientation('landscape');
4444
await expect(elementById(TestIDs.LEFT_SIDE_MENU_PUSH_BTN)).toBeVisible();
4545
});
4646

47-
it(':ios: rotation should update drawer height', async () => {
47+
it.e2e(':ios: rotation should update drawer height', async () => {
4848
await elementById(TestIDs.OPEN_LEFT_SIDE_MENU_BTN).tap();
4949
await expect(elementByLabel('left drawer height: 869')).toBeVisible();
5050
await device.setOrientation('landscape');
@@ -53,23 +53,24 @@ describe.e2e('SideMenu', () => {
5353
await expect(elementByLabel('left drawer height: 869')).toBeVisible();
5454
});
5555

56-
it('should set left drawer width', async () => {
56+
it.e2e('should set left drawer width', async () => {
5757
await elementById(TestIDs.OPEN_LEFT_SIDE_MENU_BTN).tap();
58+
await expect(elementById(TestIDs.SIDE_MENU_LEFT_DRAWER_HEIGHT_TEXT)).toBeVisible();
5859
await expect(elementByLabel('left drawer width: 250')).toBeVisible();
5960
});
6061

61-
it('should change left drawer width', async () => {
62+
it.e2e('should change left drawer width', async () => {
6263
await elementById(TestIDs.CHANGE_LEFT_SIDE_MENU_WIDTH_BTN).tap();
6364
await elementById(TestIDs.OPEN_LEFT_SIDE_MENU_BTN).tap();
6465
await expect(elementByLabel('left drawer width: 50')).toBeVisible();
6566
});
6667

67-
it('should set right drawer width', async () => {
68+
it.e2e('should set right drawer width', async () => {
6869
await elementById(TestIDs.OPEN_RIGHT_SIDE_MENU_BTN).tap();
6970
await expect(elementByLabel('right drawer width: 250')).toBeVisible();
7071
});
7172

72-
it('should change right drawer width', async () => {
73+
it.e2e('should change right drawer width', async () => {
7374
await elementById(TestIDs.CHANGE_RIGHT_SIDE_MENU_WIDTH_BTN).tap();
7475
await elementById(TestIDs.OPEN_RIGHT_SIDE_MENU_BTN).tap();
7576
await expect(elementByLabel('right drawer width: 50')).toBeVisible();

e2e/StaticLifecycleEvents.test.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Utils from './Utils';
22
import TestIDs from '../playground/src/testIDs';
33

4-
const { elementByLabel, elementById, sleep } = Utils;
4+
const { elementByLabel, elementById } = Utils;
55

66
describe('static lifecycle events', () => {
77
beforeEach(async () => {
@@ -93,9 +93,6 @@ describe('static lifecycle events', () => {
9393
await elementById(TestIDs.SET_ROOT_BTN).tap();
9494
await elementById(TestIDs.CLEAR_OVERLAY_EVENTS_BTN).tap();
9595
await elementById(TestIDs.SET_ROOT_BTN).tap();
96-
// This sleep is needed in order to synchronize the test rendered with state changes. We can remove it after moving
97-
// our mock to work with act(()=>{}) from react-test-renderer
98-
await sleep(10);
9996
await expect(elementByLabel('setRoot complete - previous root is unmounted')).toBeVisible();
10097
});
10198

31.1 KB
Loading

lib/Mock/Components/ComponentScreen.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ export const ComponentScreen = connect(
2525
}
2626

2727
isVisible(): boolean {
28-
return LayoutStore.isVisibleLayout(this.props.layoutNode);
28+
const isVisible = LayoutStore.isVisibleLayout(this.props.layoutNode);
29+
return isVisible;
2930
}
3031

3132
renderTabBar() {

lib/Mock/Components/LayoutComponent.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { BottomTabs } from './BottomTabs';
44
import { ComponentProps } from '../ComponentProps';
55
import { ComponentScreen } from './ComponentScreen';
66
import { Stack } from './Stack';
7+
import { SideMenuRoot, SideMenuCenter, SideMenuLeft, SideMenuRight } from './SideMenu';
78

89
export const LayoutComponent = class extends Component<ComponentProps> {
910
render() {
@@ -14,6 +15,14 @@ export const LayoutComponent = class extends Component<ComponentProps> {
1415
return <Stack layoutNode={this.props.layoutNode} />;
1516
case 'Component':
1617
return <ComponentScreen layoutNode={this.props.layoutNode} />;
18+
case 'SideMenuRoot':
19+
return <SideMenuRoot layoutNode={this.props.layoutNode} />;
20+
case 'SideMenuLeft':
21+
return <SideMenuLeft layoutNode={this.props.layoutNode} />;
22+
case 'SideMenuCenter':
23+
return <SideMenuCenter layoutNode={this.props.layoutNode} />;
24+
case 'SideMenuRight':
25+
return <SideMenuRight layoutNode={this.props.layoutNode} />;
1726
}
1827

1928
return <View />;

lib/Mock/Components/SideMenu.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React, { Component } from 'react';
2+
import { connect } from '../connect';
3+
import { ComponentProps } from '../ComponentProps';
4+
import { LayoutComponent } from './LayoutComponent';
5+
import ParentNode from '../Layouts/ParentNode';
6+
7+
export const SideMenuRoot = connect(
8+
class extends Component<ComponentProps> {
9+
render() {
10+
const children = this.props.layoutNode.children;
11+
return children.map((child: ParentNode) => {
12+
return <LayoutComponent key={child.nodeId} layoutNode={child} />;
13+
});
14+
}
15+
}
16+
);
17+
18+
class SideMenuComponent extends Component<ComponentProps> {
19+
render() {
20+
const children = this.props.layoutNode.children;
21+
const component = children[0];
22+
return <LayoutComponent key={component.nodeId} layoutNode={component} />;
23+
}
24+
}
25+
export const SideMenuLeft = connect(SideMenuComponent);
26+
export const SideMenuCenter = connect(SideMenuComponent);
27+
export const SideMenuRight = connect(SideMenuComponent);

lib/Mock/Layouts/BottomTabsNode.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ export default class BottomTabsNode extends ParentNode {
1010
this.selectedIndex = layout.data?.options?.bottomTabs?.currentTabIndex || 0;
1111
}
1212

13-
mergeOptions(options: Options) {
14-
super.mergeOptions(options);
13+
mergeOptions(_options: Options) {
14+
super.mergeOptions(_options);
15+
16+
const { options } = this.data;
1517
if (options.bottomTabs?.currentTabIndex) {
1618
this.selectedIndex = options.bottomTabs?.currentTabIndex;
1719
switchTabByIndex(this, this.selectedIndex);

0 commit comments

Comments
 (0)