diff --git a/__e2e__/TestApp/__e2e__/app.spec.js b/__e2e__/TestApp/__e2e__/app.spec.js index 5fd58593..b0e9bebb 100644 --- a/__e2e__/TestApp/__e2e__/app.spec.js +++ b/__e2e__/TestApp/__e2e__/app.spec.js @@ -17,6 +17,7 @@ describe('Main', () => { describe('Context Menu', () => { const delay200 = () => delay(200); + const delay500 = () => delay(500); it('should show AsyncStorage content as expected', async () => { const { client } = rndebugger; await client.execute(() => window.invokeDevMethod('showAsyncStorage')).then(delay200); @@ -26,7 +27,7 @@ describe('Main', () => { logs.some(log => log.message.indexOf('[RNDebugger] No AsyncStorage content.') > -1) ).toBeTruthy(); - await element(by.id('navigate-async-storage')) + await element(by.id('navigate-context-menu')) .tap() .then(delay200); @@ -38,6 +39,10 @@ describe('Main', () => { it('should clear AsyncStorage as expected', async () => { const { client } = rndebugger; + await element(by.id('navigate-context-menu')) + .tap() + .then(delay500); + await client.execute(() => window.invokeDevMethod('clearAsyncStorage')).then(delay200); await client.execute(() => window.invokeDevMethod('showAsyncStorage')).then(delay200); const logs = await client.getRenderProcessLogs(); @@ -46,5 +51,27 @@ describe('Main', () => { logs.some(log => log.message.indexOf('[RNDebugger] No AsyncStorage content.') > -1) ).toBeTruthy(); }); + + it('should send Network request as expected if Network Inspsect enabled', async () => { + const { client } = rndebugger; + + await element(by.id('navigate-context-menu')) + .tap() + .then(delay500); + await element(by.id('send-request')) + .tap() + .then(delay200); + + await client.execute(() => window.invokeDevMethod('networkInspect')).then(delay200); + const logs = await client.getRenderProcessLogs(); + // Print renderer process logs + expect( + logs.some( + log => + // NOTE: https://github.com/electron/spectron/issues/282 + log.message.indexOf('[RNDebugger]') > -1 + ) + ).toBeTruthy(); + }); }); }); diff --git a/__e2e__/TestApp/js/App.js b/__e2e__/TestApp/js/App.js index 3b51c121..e3965735 100644 --- a/__e2e__/TestApp/js/App.js +++ b/__e2e__/TestApp/js/App.js @@ -1,11 +1,11 @@ import { createStackNavigator, createAppContainer } from 'react-navigation'; import Home from './Home'; -import TestAsyncStorage from './containers/TestAsyncStorage'; +import TestContextMenu from './containers/TestContextMenu'; const AppNavigator = createStackNavigator( { Home: { screen: Home }, - TestAsyncStorage: { screen: TestAsyncStorage }, + TestContextMenu: { screen: TestContextMenu }, }, { initialRouteName: 'Home', diff --git a/__e2e__/TestApp/js/Home.js b/__e2e__/TestApp/js/Home.js index 993bbd18..4910bebd 100644 --- a/__e2e__/TestApp/js/Home.js +++ b/__e2e__/TestApp/js/Home.js @@ -22,9 +22,9 @@ export default class Home extends React.Component { return ( <View testID="home" style={styles.container}> <Button - testID="navigate-async-storage" - title="Test Async Storage" - onPress={() => navigation.navigate('TestAsyncStorage')} + testID="navigate-context-menu" + title="Test Context Menu" + onPress={() => navigation.navigate('TestContextMenu')} /> </View> ); diff --git a/__e2e__/TestApp/js/containers/TestAsyncStorage.js b/__e2e__/TestApp/js/containers/TestAsyncStorage.js deleted file mode 100644 index c8f23165..00000000 --- a/__e2e__/TestApp/js/containers/TestAsyncStorage.js +++ /dev/null @@ -1,20 +0,0 @@ -import React from 'react'; -import { StyleSheet, View, AsyncStorage } from 'react-native'; - -const styles = StyleSheet.create({ - container: { - flex: 1, - backgroundColor: '#333', - justifyContent: 'center', - alignItems: 'center', - }, -}); - -export default class TestAsyncStorage extends React.Component { - componentDidMount() { - AsyncStorage.setItem('some', 'key'); - } - render() { - return <View style={styles.container} />; - } -} diff --git a/__e2e__/TestApp/js/containers/TestContextMenu.js b/__e2e__/TestApp/js/containers/TestContextMenu.js new file mode 100644 index 00000000..1a4e9979 --- /dev/null +++ b/__e2e__/TestApp/js/containers/TestContextMenu.js @@ -0,0 +1,27 @@ +import React from 'react'; +import { StyleSheet, View, AsyncStorage, Button } from 'react-native'; + +const styles = StyleSheet.create({ + container: { + flex: 1, + backgroundColor: '#333', + justifyContent: 'center', + alignItems: 'center', + }, +}); + +export default class TestContextMenu extends React.Component { + componentDidMount() { + AsyncStorage.setItem('some', 'key'); + } + sendRequest() { + fetch('http://localhost:8081'); + } + render() { + return ( + <View style={styles.container}> + <Button testID="send-request" title="Send request" /> + </View> + ); + } +}