From 3d1a852580c369889baa9ce5d15f3edc348d92cd Mon Sep 17 00:00:00 2001 From: jhen Date: Tue, 5 Feb 2019 08:43:34 +0800 Subject: [PATCH] Add test for Network Inspect enabled --- __e2e__/TestApp/__e2e__/app.spec.js | 29 ++++++++++++++++++- __e2e__/TestApp/js/App.js | 4 +-- __e2e__/TestApp/js/Home.js | 6 ++-- .../TestApp/js/containers/TestAsyncStorage.js | 20 ------------- .../TestApp/js/containers/TestContextMenu.js | 27 +++++++++++++++++ 5 files changed, 60 insertions(+), 26 deletions(-) delete mode 100644 __e2e__/TestApp/js/containers/TestAsyncStorage.js create mode 100644 __e2e__/TestApp/js/containers/TestContextMenu.js diff --git a/__e2e__/TestApp/__e2e__/app.spec.js b/__e2e__/TestApp/__e2e__/app.spec.js index 5fd58593..41d242b3 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(() => delay(300)); + 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 (