Skip to content

Commit 3f36f39

Browse files
fix autocomplete (#1732)
1 parent e4301be commit 3f36f39

File tree

3 files changed

+54
-1
lines changed

3 files changed

+54
-1
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright (c) Neo4j
3+
* Neo4j Sweden AB [http://neo4j.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Neo4j is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
import { selectAllAndDelete } from '../support/commands'
22+
23+
/* global Cypress, cy, before */
24+
25+
describe('Cypher Editor', () => {
26+
before(function () {
27+
cy.visit(Cypress.config('url'))
28+
cy.get('input[data-testid="boltaddress"]', { timeout: 40000 })
29+
cy.ensureConnection()
30+
})
31+
32+
it('can autocomplete', () => {
33+
cy.executeCommand('create (:AutocompeleteLabel)')
34+
cy.getEditor().type(':')
35+
cy.getEditor().contains(':play')
36+
cy.getEditor().contains(':config')
37+
cy.getEditor().contains(':guide')
38+
39+
cy.getEditor().type('{backspace}call dbms.listC')
40+
cy.getEditor().contains('listConfig')
41+
42+
cy.getEditor().type(selectAllAndDelete)
43+
cy.getEditor().type('MATCH (:')
44+
cy.getEditor().contains(':AutocompeleteLabel')
45+
46+
cy.getEditor().type(selectAllAndDelete)
47+
// cleanup
48+
cy.executeCommand('match (n:AutocompeleteLabel) delete n;')
49+
})
50+
})

e2e_tests/support/commands.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ export const SubmitQueryButton = '[data-testid="editor-Run"]'
22
const EditorTextField = '[data-testid="activeEditor"] textarea'
33
const VisibleEditor = '#monaco-main-editor'
44
/* global Cypress, cy */
5+
export const selectAllAndDelete =
6+
Cypress.platform === 'darwin' ? '{cmd}a {backspace}' : '{ctrl}a {backspace}'
57

68
Cypress.Commands.add('getEditor', () => cy.get(VisibleEditor))
79
Cypress.Commands.add('getFrames', () => cy.get('[data-testid="frame"]'))

src/shared/modules/editor/editorDuck.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import {
4141
import { DISABLE_IMPLICIT_INIT_COMMANDS } from 'shared/modules/settings/settingsDuck'
4242
import { DB_META_DONE } from '../dbMeta/constants'
4343
import { UPDATE_PARAMS } from '../params/paramsDuck'
44+
import { isOfType } from 'shared/utils/typeSafeActions'
4445

4546
export const SET_CONTENT = 'editor/SET_CONTENT'
4647
export const EDIT_CONTENT = 'editor/EDIT_CONTENT'
@@ -170,7 +171,7 @@ export const updateEditorSupportSchemaEpic: Epic<Action, GlobalState> = (
170171
store
171172
) =>
172173
actions$
173-
.ofType([DB_META_DONE, UPDATE_PARAMS])
174+
.filter(isOfType([DB_META_DONE, UPDATE_PARAMS]))
174175
.do(() => {
175176
const { params, meta } = store.getState()
176177

0 commit comments

Comments
 (0)