diff --git a/e2e_tests/integration/index.spec.js b/e2e_tests/integration/index.spec.js index 6b00d66ee4e..0a0f61efb1d 100644 --- a/e2e_tests/integration/index.spec.js +++ b/e2e_tests/integration/index.spec.js @@ -129,13 +129,7 @@ describe('Neo4j Browser', () => { it('will add parameter using `:param` command', () => { // add cypher evalutated param function const command = ':param foo => 1 + 1' - cy.get(Editor).type(command, { force: true }) - cy.get(Editor).should('have.value', command) - cy.get(SubmitQueryButton).click() - cy - .get('[data-test-id="frameCommand"]') - .first() - .should('contain', command) + cy.executeCommand(command) cy .get('[data-test-id="rawParamData"]') .first() diff --git a/src/shared/modules/commands/commandsDuck.test.js b/src/shared/modules/commands/commandsDuck.test.js index bdf84ab1025..4208743d330 100644 --- a/src/shared/modules/commands/commandsDuck.test.js +++ b/src/shared/modules/commands/commandsDuck.test.js @@ -144,6 +144,37 @@ describe('commandsDuck', () => { const cmdString = cmd + ' x: 2' const id = 1 const action = commands.executeCommand(cmdString, id) + + bus.take('NOOP', currentAction => { + // Then + expect(store.getActions()).toEqual([ + action, + addHistory(cmdString, maxHistory), + { type: commands.KNOWN_COMMAND }, + updateParams({ x: 2 }), + frames.add({ + ...action, + success: true, + type: 'param', + params: { x: 2 } + }), + { type: 'NOOP' } + ]) + done() + }) + + // When + store.dispatch(action) + + // Then + // See above + }) + test('does the right thing for :param x => 2', done => { + // Given + const cmd = store.getState().settings.cmdchar + 'param' + const cmdString = cmd + ' x: 2' + const id = 1 + const action = commands.executeCommand(cmdString, id) bolt.routedWriteTransaction = jest.fn(() => Promise.resolve({ records: [{ get: () => 2 }] @@ -163,7 +194,6 @@ describe('commandsDuck', () => { type: 'param', params: { x: 2 } }), - { type: 'meta/FORCE_FETCH' }, { type: 'NOOP' } ]) done() @@ -189,7 +219,6 @@ describe('commandsDuck', () => { { type: commands.KNOWN_COMMAND }, replaceParams({ x: 2, y: 3 }), frames.add({ ...action, success: true, type: 'params', params: {} }), - { type: 'meta/FORCE_FETCH' }, { type: 'NOOP' } ]) done() diff --git a/src/shared/modules/commands/helpers/params.js b/src/shared/modules/commands/helpers/params.js index 4cb42b6fd21..e5a37c689f3 100644 --- a/src/shared/modules/commands/helpers/params.js +++ b/src/shared/modules/commands/helpers/params.js @@ -71,11 +71,11 @@ export const handleParamsCommand = (action, cmdchar, put) => { } } else { // Single param + const { key, value, isFn } = extractParams(param) + if (!isFn || !key || !value) { + return resolveAndStoreJsonValue(param, put, resolve, reject) + } try { - const { key, value, isFn } = extractParams(param) - if (!key || !value || !isFn) { - return resolveAndStoreJsonValue(param, put, resolve, reject) - } const cypherStatement = mapParamToCypherStatement(key, value) bolt .routedWriteTransaction( diff --git a/src/shared/modules/commands/helpers/params.test.js b/src/shared/modules/commands/helpers/params.test.js index d4ca512d2d2..5527799f528 100644 --- a/src/shared/modules/commands/helpers/params.test.js +++ b/src/shared/modules/commands/helpers/params.test.js @@ -50,8 +50,6 @@ describe('commandsDuck params helper', () => { }) test('handles :param "x": 2 and calls the update action creator', () => { // Given - // jest.spyOn(params, , accessType?) - const action = { cmd: ':param "x": 2' } const cmdchar = ':' const put = jest.fn() diff --git a/src/shared/services/commandInterpreterHelper.js b/src/shared/services/commandInterpreterHelper.js index 8d7fe9a31d9..59fdabf9e4f 100644 --- a/src/shared/services/commandInterpreterHelper.js +++ b/src/shared/services/commandInterpreterHelper.js @@ -31,7 +31,6 @@ import { import { getRemoteContentHostnameWhitelist } from 'shared/modules/dbMeta/dbMetaDuck' import { fetchRemoteGuide } from 'shared/modules/commands/helpers/play' import remote from 'services/remote' -import bolt from 'services/bolt/bolt' import { isLocalRequest, authHeaderFromCredentials } from 'services/remoteUtils' import { handleServerCommand } from 'shared/modules/commands/helpers/server' import { handleCypherCommand } from 'shared/modules/commands/helpers/cypher' @@ -91,7 +90,7 @@ const availableCommands = [ name: 'set-params', match: cmd => /^params?\s/.test(cmd), exec: function (action, cmdchar, put, store) { - return handleParamsCommand(action, cmdchar, put, bolt) + handleParamsCommand(action, cmdchar, put) .then(res => { const params = res.type === 'param' ? res.result : getParams(store.getState())