diff --git a/src/shared/modules/discovery/discoveryDuck.js b/src/shared/modules/discovery/discoveryDuck.js index 01684e6b2e4..2fe92f2d075 100644 --- a/src/shared/modules/discovery/discoveryDuck.js +++ b/src/shared/modules/discovery/discoveryDuck.js @@ -136,7 +136,9 @@ export const discoveryOnStartupEpic = (some$, store) => { // fake discovery response // Promise.resolve({ bolt: 'bolt+routing://localhost:7687' }) .then(result => { - const host = result && (result.bolt_direct || result.bolt) + const host = + result && + (result.bolt_routing || result.bolt_direct || result.bolt) // Try to get info from server if (!host) { throw new Error('No bolt address found') // No bolt info from server, throw diff --git a/src/shared/modules/discovery/discoveryDuck.test.js b/src/shared/modules/discovery/discoveryDuck.test.js index 40ff5560f9e..0fee8f13da0 100644 --- a/src/shared/modules/discovery/discoveryDuck.test.js +++ b/src/shared/modules/discovery/discoveryDuck.test.js @@ -146,6 +146,30 @@ describe('discoveryOnStartupEpic', () => { // When store.dispatch(action) }) + test('listens on APP_START and finds all of bolt_routing, bolt_direct and a bold host and dispatches an action with the found bolt_routing host', done => { + // Given + const action = { type: APP_START, env: WEB } + const expectedHost = 'neo4j://myhost:7777' + nock(getDiscoveryEndpoint()) + .get('/') + .reply(200, { + bolt_routing: expectedHost, + bolt_direct: 'bolt://myhost:666', + bolt: 'very://bad:1337' + }) + bus.take(discovery.DONE, currentAction => { + // Then + expect(store.getActions()).toEqual([ + action, + discovery.updateDiscoveryConnection({ host: expectedHost }), + { type: discovery.DONE } + ]) + done() + }) + + // When + store.dispatch(action) + }) test('listens on APP_START and reads bolt URL from location URL and dispatches an action with the found host', done => { // Given const action = {