Skip to content

Commit

Permalink
fix autocomplete (#1732)
Browse files Browse the repository at this point in the history
  • Loading branch information
OskarDamkjaer authored Apr 20, 2022
1 parent e4301be commit 3f36f39
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
50 changes: 50 additions & 0 deletions e2e_tests/integration/editor.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (c) Neo4j
* Neo4j Sweden AB [http://neo4j.com]
*
* This file is part of Neo4j.
*
* Neo4j is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import { selectAllAndDelete } from '../support/commands'

/* global Cypress, cy, before */

describe('Cypher Editor', () => {
before(function () {
cy.visit(Cypress.config('url'))
cy.get('input[data-testid="boltaddress"]', { timeout: 40000 })
cy.ensureConnection()
})

it('can autocomplete', () => {
cy.executeCommand('create (:AutocompeleteLabel)')
cy.getEditor().type(':')
cy.getEditor().contains(':play')
cy.getEditor().contains(':config')
cy.getEditor().contains(':guide')

cy.getEditor().type('{backspace}call dbms.listC')
cy.getEditor().contains('listConfig')

cy.getEditor().type(selectAllAndDelete)
cy.getEditor().type('MATCH (:')
cy.getEditor().contains(':AutocompeleteLabel')

cy.getEditor().type(selectAllAndDelete)
// cleanup
cy.executeCommand('match (n:AutocompeleteLabel) delete n;')
})
})
2 changes: 2 additions & 0 deletions e2e_tests/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ export const SubmitQueryButton = '[data-testid="editor-Run"]'
const EditorTextField = '[data-testid="activeEditor"] textarea'
const VisibleEditor = '#monaco-main-editor'
/* global Cypress, cy */
export const selectAllAndDelete =
Cypress.platform === 'darwin' ? '{cmd}a {backspace}' : '{ctrl}a {backspace}'

Cypress.Commands.add('getEditor', () => cy.get(VisibleEditor))
Cypress.Commands.add('getFrames', () => cy.get('[data-testid="frame"]'))
Expand Down
3 changes: 2 additions & 1 deletion src/shared/modules/editor/editorDuck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
import { DISABLE_IMPLICIT_INIT_COMMANDS } from 'shared/modules/settings/settingsDuck'
import { DB_META_DONE } from '../dbMeta/constants'
import { UPDATE_PARAMS } from '../params/paramsDuck'
import { isOfType } from 'shared/utils/typeSafeActions'

export const SET_CONTENT = 'editor/SET_CONTENT'
export const EDIT_CONTENT = 'editor/EDIT_CONTENT'
Expand Down Expand Up @@ -170,7 +171,7 @@ export const updateEditorSupportSchemaEpic: Epic<Action, GlobalState> = (
store
) =>
actions$
.ofType([DB_META_DONE, UPDATE_PARAMS])
.filter(isOfType([DB_META_DONE, UPDATE_PARAMS]))
.do(() => {
const { params, meta } = store.getState()

Expand Down

0 comments on commit 3f36f39

Please sign in to comment.