Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
92502f3
WIP
yogevbd Apr 12, 2021
328f66f
WIP
yogevbd Apr 12, 2021
7dd463f
WIP
yogevbd Apr 13, 2021
ecc16e0
Suppoert overlays and modals
yogevbd Apr 13, 2021
50a9d64
Expose mocks
yogevbd Apr 13, 2021
775c5ab
Refactor tests
yogevbd Apr 13, 2021
64372d0
WIP
yogevbd Apr 14, 2021
f8338db
WIP
yogevbd Apr 18, 2021
745bfa7
Modals e2e passes!
yogevbd Apr 18, 2021
f4d302b
mergeOptions support
yogevbd Apr 19, 2021
e1c6ab1
WIP
yogevbd Apr 19, 2021
a831d18
WIP
yogevbd Apr 20, 2021
56a8559
Render topBar, bottomTabs and overlays inside ComponentScreen
yogevbd Apr 21, 2021
4396136
51 passing tests!
yogevbd Apr 28, 2021
fcab122
wip
yogevbd May 4, 2021
b7cc967
Improve imports
yogevbd May 5, 2021
acebc21
Support badge
yogevbd May 6, 2021
c17c512
Update wallaby.js
yogevbd May 20, 2021
652f3d2
fix wallaby and jest setup
Niryo May 20, 2021
7045e38
code clean + remove getApplication
Niryo May 23, 2021
2524c7a
allow using import instead of require
Niryo May 25, 2021
1045ee3
Migrated e2e to jest
yogevbd May 25, 2021
6dc22ef
Wait for first componentDidMount before dispatching componentDidAppear
yogevbd May 26, 2021
c170509
Fix buttons, move TopBar to a designated component
yogevbd May 26, 2021
bd89cc4
Fix buttons
yogevbd May 27, 2021
1bdc5b2
Fix ts build
yogevbd May 27, 2021
97cb773
f
yogevbd May 27, 2021
2c4a8fa
Connect topBar options to store
yogevbd May 27, 2021
6681a82
Fix tests, remove app.test.js
yogevbd May 27, 2021
d170850
Fix nativeEventsReceiver types
yogevbd May 27, 2021
fa721cd
fix mock location
yogevbd May 27, 2021
3cc274e
Clean code
yogevbd May 27, 2021
25b1294
Refactor mocks
yogevbd May 27, 2021
b5e84c0
Rename NavigationMock dir
yogevbd May 27, 2021
88d0571
Refactor mock hierarchy
yogevbd May 27, 2021
1f9b755
Fix index.ts
yogevbd May 27, 2021
5a9674c
Add Navigation delegate
yogevbd May 30, 2021
0abdd85
Fix detox tests
yogevbd May 30, 2021
8621384
Use detox-testing-library-rnn-adapter
yogevbd May 31, 2021
79104f5
clean
yogevbd May 31, 2021
b4c2070
Fix e2e tests
yogevbd May 31, 2021
aaff388
fix react is not defined
Niryo May 31, 2021
ec24932
Remove wrong default back button
yogevbd Jun 2, 2021
cac7ef0
Merge branch 'NavigationMock' of github.com:wix/react-native-navigati…
yogevbd Jun 2, 2021
ac0ad0b
Merge branch 'master' into NavigationMock
yogevbd Jun 2, 2021
791322a
Merge branch 'master' into NavigationMock
yogevbd Jun 2, 2021
fa684ce
Fix back button visibility
yogevbd Jun 7, 2021
4d67d4d
Merge branch 'master' into NavigationMock
yogevbd Jun 7, 2021
5c488c2
Exclude searchBar e2e test
yogevbd Jun 7, 2021
ddf8d55
Merge branch 'NavigationMock' of github.com:wix/react-native-navigati…
yogevbd Jun 7, 2021
ec4424a
exclude failing e2e
yogevbd Jun 7, 2021
5bff741
Merge branch 'master' into NavigationMock
yogevbd Jun 15, 2021
024d535
Merge branch 'master' into NavigationMock
yogevbd Jun 17, 2021
6208341
Merge branch 'master' into NavigationMock
yogevbd Jun 17, 2021
c95b874
Merge branch 'master' into NavigationMock
yogevbd Jun 21, 2021
7bf4818
Enable more e2e tests on jest
yogevbd Jun 23, 2021
9fa42d0
Merge branch 'master' into NavigationMock
yogevbd Jun 27, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion e2e/ApplicationLifecycleTest.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const { elementByLabel, elementById, sleep } = Utils;
const IS_RELEASE = includes(process.argv, '--release');
const KEY_CODE_R = 46;

describe('application lifecycle test', () => {
describe.e2e('application lifecycle test', () => {
beforeEach(async () => {
await device.launchApp({ newInstance: true });
});
Expand Down
8 changes: 4 additions & 4 deletions e2e/BackButton.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ describe('Back Button', () => {
await elementById(TestIDs.DISMISS_BTN).tap();
await elementById(TestIDs.BACK_BUTTON).tap();
await expect(elementById(TestIDs.NAVIGATION_TAB)).toBeVisible();
})
});

it(':android: hardware back button prevents pop and dispatch event', async () => {
it.e2e(':android: hardware back button prevents pop and dispatch event', async () => {
await elementById(TestIDs.PUSH_DISABLED_HARDWARE_BACK_BTN).tap();
await elementById(TestIDs.CLEAR_OVERLAY_EVENTS_BTN).tap();
Android.pressBack();
await expect(elementByLabel('navigationButtonPressed | RNN.hardwareBackButton')).toBeVisible();
await expect(elementById(testIDs.PUSHED_SCREEN_HEADER)).toBeVisible();
});

it(':android: hardware button pops and does not dispatch event', async () => {
it.e2e(':android: hardware button pops and does not dispatch event', async () => {
await elementById(TestIDs.PUSH_BTN).tap();
await elementById(TestIDs.CLEAR_OVERLAY_EVENTS_BTN).tap();
Android.pressBack();
Expand All @@ -54,7 +54,7 @@ describe('Back Button', () => {
await expect(elementById(testIDs.PUSHED_SCREEN_HEADER)).toBeNotVisible();
});

it(':android: hardware back should not dismiss modal and dispatch event', async () => {
it.e2e(':android: hardware back should not dismiss modal and dispatch event', async () => {
await elementById(TestIDs.MODAL_DISABLED_BACK_BTN).tap();
await expect(elementByLabel('Modal')).toBeVisible();
Android.pressBack();
Expand Down
2 changes: 1 addition & 1 deletion e2e/BottomTabs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('BottomTabs', () => {
await expect(element(by.text('NEW'))).toBeNotVisible();
});

it('merge options correctly in SideMenu inside BottomTabs layout', async () => {
it.e2e('merge options correctly in SideMenu inside BottomTabs layout', async () => {
await elementById(TestIDs.SWITCH_TAB_BY_INDEX_BTN).tap();
await elementById(TestIDs.SIDE_MENU_INSIDE_BOTTOM_TABS_BTN).tap();
await elementById(TestIDs.OPEN_LEFT_SIDE_MENU_BTN).tap();
Expand Down
4 changes: 2 additions & 2 deletions e2e/Buttons.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('Buttons', () => {
await elementById(TestIDs.GOTO_BUTTONS_SCREEN).tap();
});

it(':android: should not effect left buttons when hiding back button',async ()=>{
it(':android: should not effect left buttons when hiding back button', async () => {
await elementById(TestIDs.TOGGLE_BACK).tap();
await expect(elementById(TestIDs.LEFT_BUTTON)).toBeVisible();
await expect(elementById(TestIDs.TEXTUAL_LEFT_BUTTON)).toBeVisible();
Expand Down Expand Up @@ -65,7 +65,7 @@ describe('Buttons', () => {
it('resizes title component when a button is added with mergeOptions', async () => {
await elementById(TestIDs.RESET_BUTTONS).tap();
await elementById(TestIDs.SET_RIGHT_BUTTONS).tap();
await elementById(TestIDs.BUTTON_THREE).tap();
await elementById(TestIDs.BUTTON_THREE).tap();
});

it('Button component is not recreated if it has a predefined componentId', async () => {
Expand Down
2 changes: 1 addition & 1 deletion e2e/ExternalComponent.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import TestIDs from '../playground/src/testIDs';

const { elementByLabel, elementById } = Utils;

describe('External Component', () => {
describe.e2e('External Component', () => {
beforeEach(async () => {
await device.launchApp({ newInstance: true });
await elementById(TestIDs.NAVIGATION_TAB).tap();
Expand Down
2 changes: 1 addition & 1 deletion e2e/LazyRegsitration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import TestIDs from '../playground/src/testIDs';

const { elementById } = Utils;

describe('Lazy Registration', () => {
describe.e2e('Lazy Registration', () => {
beforeEach(async () => {
await device.relaunchApp();
await elementById(TestIDs.STACK_BTN).tap();
Expand Down
20 changes: 8 additions & 12 deletions e2e/Modals.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('modal', () => {
await expect(elementById(TestIDs.NAVIGATION_TAB)).toBeVisible();
});

it('unmount modal when dismissed', async () => {
it.e2e('unmount modal when dismissed', async () => {
await expect(elementById(TestIDs.MODAL_SCREEN_HEADER)).toBeVisible();
await elementById(TestIDs.MODAL_LIFECYCLE_BTN).tap();
await expect(elementByLabel('didAppear')).toBeVisible();
Expand Down Expand Up @@ -104,7 +104,7 @@ describe('modal', () => {
await expect(elementByLabel('Pushed Screen')).toBeVisible();
});

it(':android: push into modal and dismiss pushed screen with hardware back', async () => {
it.e2e(':android: push into modal and dismiss pushed screen with hardware back', async () => {
await elementById(TestIDs.PUSH_BTN).tap();
await elementById(TestIDs.PUSH_BTN).tap();
Android.pressBack();
Expand All @@ -123,7 +123,7 @@ describe('modal', () => {
await expect(elementById(TestIDs.PUSHED_SCREEN_HEADER)).toBeVisible();
});

it(':android: override hardware back button in modal with stack', async () => {
it.e2e(':android: override hardware back button in modal with stack', async () => {
await elementById(TestIDs.PUSH_BTN).tap();
await elementById(TestIDs.ADD_BACK_HANDLER).tap();

Expand All @@ -148,15 +148,11 @@ describe('modal', () => {
await elementById(TestIDs.MODAL_COMMANDS_BTN).tap();
await elementById(TestIDs.MODAL_BTN).tap();

await expect(element(by.id(TestIDs.SHOW_MODAL_PROMISE_RESULT))).toHaveText(
'showModal promise resolved with: UniqueStackId'
);
await expect(element(by.id(TestIDs.MODAL_DISMISSED_LISTENER_RESULT))).toHaveText(
'modalDismissed listener called with with: UniqueStackId'
);
await expect(element(by.id(TestIDs.DISMISS_MODAL_PROMISE_RESULT))).toHaveText(
'dismissModal promise resolved with: UniqueStackId'
);
await expect(elementByLabel('showModal promise resolved with: UniqueStackId')).toBeVisible();
await expect(
elementByLabel('modalDismissed listener called with with: UniqueStackId')
).toBeVisible();
await expect(elementByLabel('dismissModal promise resolved with: UniqueStackId')).toBeVisible();
});

it('dismiss previous react-native modal', async () => {
Expand Down
2 changes: 1 addition & 1 deletion e2e/Orientation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import TestIDs from '../playground/src/testIDs';

const { elementById } = Utils;

describe(':ios: orientation', () => {
describe.e2e(':ios: orientation', () => {
beforeEach(async () => {
await device.launchApp({ newInstance: true });
waitForDeviceToSettleAfterOrientationChangeAndroid = (ms) =>
Expand Down
12 changes: 6 additions & 6 deletions e2e/Overlay.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('Overlay', () => {
await expect(elementByLabel('Alert displayed')).toBeVisible();
});

it('overlay should redraw after orientation change', async () => {
it.e2e('overlay should redraw after orientation change', async () => {
await elementById(TestIDs.SHOW_OVERLAY_BTN).tap();
await device.setOrientation('landscape');
await expect(elementById(TestIDs.OVERLAY_ALERT_HEADER)).toBeVisible();
Expand All @@ -36,7 +36,7 @@ describe('Overlay', () => {
await expect(elementById(TestIDs.OVERLAY_ALERT_HEADER)).toBeVisible();
});

fit('nested touchables work as expected', async () => {
it('nested touchables work as expected', async () => {
await elementById(TestIDs.TOAST_BTN).tap();
await elementById(TestIDs.TOAST_OK_BTN_INNER).tap();
await expect(elementByLabel('Inner button clicked')).toBeVisible();
Expand All @@ -63,16 +63,16 @@ describe('Overlay Dismiss all', () => {
await elementById(TestIDs.OVERLAY_BTN).tap();
});

it('dismissAllOverlays should dismiss all opened overlays', async() => {
xit('dismissAllOverlays should dismiss all opened overlays', async () => {
await elementById(TestIDs.SHOW_FULLSCREEN_OVERLAY_BTN).tap();
await elementById(TestIDs.SHOW_OVERLAY_BTN).tap();
await elementById(TestIDs.DISMISS_ALL_OVERLAYS_BUTTON).tap();
await expect(elementById(TestIDs.OVERLAY_DISMISSED_COUNT)).toHaveText('2');
});

it('dismissAllOverlays should be able to dismiss only one overlay', async() => {
it.e2e('dismissAllOverlays should be able to dismiss only one overlay', async () => {
await elementById(TestIDs.SHOW_OVERLAY_BTN).tap();
await elementById(TestIDs.DISMISS_ALL_OVERLAYS_BUTTON).tap();
await expect(elementById(TestIDs.OVERLAY_DISMISSED_COUNT)).toHaveText('1');
})
})
});
});
4 changes: 2 additions & 2 deletions e2e/SearchBar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Utils from './Utils';

const { elementById, elementByTraits } = Utils;

describe(':ios: SearchBar', () => {
describe.e2e(':ios: SearchBar', () => {
beforeEach(async () => {
await device.launchApp({ newInstance: true });
await elementById(TestIDs.OPTIONS_TAB).tap();
Expand All @@ -18,7 +18,7 @@ describe(':ios: SearchBar', () => {
});
});

describe(':ios: SearchBar Modal', () => {
describe.e2e(':ios: SearchBar Modal', () => {
beforeAll(async () => {
await device.launchApp({ newInstance: true });
await elementById(TestIDs.OPTIONS_TAB).tap();
Expand Down
6 changes: 3 additions & 3 deletions e2e/SideMenu.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import Utils from './Utils';
import TestIDs from '../playground/src/testIDs';

const {elementByLabel, elementById} = Utils;
const { elementByLabel, elementById } = Utils;

describe('SideMenu', () => {
describe.e2e('SideMenu', () => {
beforeEach(async () => {
await device.launchApp({newInstance: true});
await device.launchApp({ newInstance: true });
await elementById(TestIDs.SIDE_MENU_BTN).tap();
});

Expand Down
2 changes: 1 addition & 1 deletion e2e/SplitView.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import TestIDs from '../playground/src/testIDs';
const cocktailsList = require('../playground/src/assets/cocktails').default;
const { elementByLabel, elementById } = Utils;

describe(':ios: SplitView', () => {
describe.e2e(':ios: SplitView', () => {
beforeEach(async () => {
await device.launchApp({ newInstance: true });
await elementById(TestIDs.SPLIT_VIEW_BUTTON).tap();
Expand Down
17 changes: 6 additions & 11 deletions e2e/Stack.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,21 +81,21 @@ describe('Stack', () => {
await expect(elementByLabel('didDisappear')).toBeVisible();
});

it('Screen popped event', async () => {
it.e2e('Screen popped event', async () => {
await elementById(TestIDs.PUSH_LIFECYCLE_BTN).tap();
await elementById(TestIDs.SCREEN_POPPED_BTN).tap();
await expect(elementByLabel('Screen popped event')).toBeVisible();
});

it('unmount is called on pop', async () => {
it.e2e('unmount is called on pop', async () => {
await elementById(TestIDs.PUSH_LIFECYCLE_BTN).tap();
await elementById(TestIDs.POP_BTN).tap();
await expect(elementByLabel('componentWillUnmount')).toBeVisible();
await elementByLabel('OK').atIndex(0).tap();
await expect(elementByLabel('didDisappear')).toBeVisible();
});

it(':android: override hardware back button', async () => {
it.e2e(':android: override hardware back button', async () => {
await elementById(TestIDs.PUSH_BTN).tap();
await elementById(TestIDs.ADD_BACK_HANDLER).tap();
Android.pressBack();
Expand All @@ -113,7 +113,7 @@ describe('Stack', () => {
await elementById(TestIDs.SET_STACK_ROOT_WITH_ID_BTN).tap();
});

it(':ios: set stack root component should be first in stack', async () => {
it.e2e(':ios: set stack root component should be first in stack', async () => {
await elementById(TestIDs.PUSH_BTN).tap();
await expect(elementByLabel('Stack Position: 1')).toBeVisible();
await elementById(TestIDs.SET_STACK_ROOT_BUTTON).tap();
Expand All @@ -135,12 +135,7 @@ describe('Stack', () => {
it('push promise is resolved with pushed ViewController id', async () => {
await elementById(TestIDs.STACK_COMMANDS_BTN).tap();
await elementById(TestIDs.PUSH_BTN).tap();

await expect(element(by.id(TestIDs.PUSH_PROMISE_RESULT))).toHaveText(
'push promise resolved with: ChildId'
);
await expect(element(by.id(TestIDs.POP_PROMISE_RESULT))).toHaveText(
'pop promise resolved with: ChildId'
);
await expect(elementByLabel('push promise resolved with: ChildId')).toBeVisible();
await expect(elementByLabel('pop promise resolved with: ChildId')).toBeVisible();
});
});
7 changes: 4 additions & 3 deletions e2e/StaticLifecycleEvents.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Utils from './Utils';
import TestIDs from '../playground/src/testIDs';
import Android from './AndroidUtils';

const { elementByLabel, elementById } = Utils;

Expand Down Expand Up @@ -75,7 +74,9 @@ describe('static lifecycle events', () => {
await elementById(TestIDs.PUSH_OPTIONS_BUTTON).tap();
await elementById(TestIDs.CLEAR_OVERLAY_EVENTS_BTN).tap();
await elementById(TestIDs.SET_REACT_TITLE_VIEW).tap();
await expect(elementByLabel('componentWillAppear | ReactTitleView | TopBarTitle')).toBeVisible();
await expect(
elementByLabel('componentWillAppear | ReactTitleView | TopBarTitle')
).toBeVisible();
await expect(elementByLabel('componentDidAppear | ReactTitleView | TopBarTitle')).toBeVisible();
await elementById(TestIDs.CLEAR_OVERLAY_EVENTS_BTN).tap();
await elementById(TestIDs.PUSH_BTN).tap();
Expand Down Expand Up @@ -103,5 +104,5 @@ describe('static lifecycle events', () => {
await expect(
elementByLabel('componentDidAppear | CustomRoundedButton | TopBarButton')
).toBeVisible();
})
});
});
1 change: 1 addition & 0 deletions e2e/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const detox = require('detox');
const config = require('../package.json').detox;
const exec = require('shell-utils').exec;
const adapter = require('detox/runners/jest/adapter');
require('detox-testing-library-rnn-adapter').extendDetox();

jest.setTimeout(300000);
jasmine.getEnv().addReporter(adapter);
Expand Down
2 changes: 1 addition & 1 deletion integration/redux/Redux.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const React = require('react');
require('react-native');
const renderer = require('react-test-renderer');
const { Provider } = require('react-redux');
const { Navigation } = require('../../lib/dist/index');
const { Navigation } = require('../../lib/src/index');

describe('redux support', () => {
let MyConnectedComponent;
Expand Down
3 changes: 2 additions & 1 deletion integration/remx/remx.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const React = require('react');
require('react-native');
const renderer = require('react-test-renderer');
const { Navigation } = require('../../lib/dist/index');
const { Navigation } = require('../../lib/src/index');

describe('remx support', () => {
let MyConnectedComponent;
Expand All @@ -14,6 +14,7 @@ describe('remx support', () => {

it('renders normally', () => {
const tree = renderer.create(<MyConnectedComponent />);
const tree2 = renderer.create(<MyConnectedComponent />);
expect(tree.toJSON().children).toEqual(['no name']);
});

Expand Down
20 changes: 20 additions & 0 deletions jest-setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const { mockDetox } = require('detox-testing-library-rnn-adapter');

mockDetox(() => require('./playground/index'));

beforeEach(() => {
const { Navigation } = require('react-native-navigation');
setTimeout = (func) => {
func();
};
Navigation.mockNativeComponents();
mockUILib();
});

const mockUILib = () => {
const NativeModules = require('react-native').NativeModules;
NativeModules.KeyboardTrackingViewTempManager = {};
NativeModules.StatusBarManager = {
getHeight: () => 40,
};
};
30 changes: 30 additions & 0 deletions lib/src/Mock/Application.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import * as React from 'react';
import { View } from 'react-native';
import { connect } from './connect';

interface ApplicationProps {
entryPoint: () => void;
}

export const Application = connect(
class extends React.Component<ApplicationProps> {
constructor(props: ApplicationProps) {
super(props);
props.entryPoint();
}

render() {
const { LayoutComponent } = require('./Components/LayoutComponent');
const { LayoutStore } = require('./Stores/LayoutStore');
const { Modals } = require('./Components/Modals');
const { Overlays } = require('./Components/Overlays');
return (
<View testID={'Application'}>
<LayoutComponent layoutNode={LayoutStore.getLayout()} />
<Modals />
<Overlays />
</View>
);
}
}
);
6 changes: 6 additions & 0 deletions lib/src/Mock/ComponentProps.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import ParentNode from './Layouts/ParentNode';

export interface ComponentProps {
layoutNode: ParentNode;
backButton?: boolean;
}
Loading