diff --git a/e2e_tests/integration/editor.spec.ts b/e2e_tests/integration/editor.spec.ts new file mode 100644 index 00000000000..e635b449054 --- /dev/null +++ b/e2e_tests/integration/editor.spec.ts @@ -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 . + */ + +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;') + }) +}) diff --git a/e2e_tests/support/commands.ts b/e2e_tests/support/commands.ts index bd188eb2fde..71736fd5355 100644 --- a/e2e_tests/support/commands.ts +++ b/e2e_tests/support/commands.ts @@ -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"]')) diff --git a/src/shared/modules/editor/editorDuck.ts b/src/shared/modules/editor/editorDuck.ts index 040b7eac50f..312d8c35e00 100644 --- a/src/shared/modules/editor/editorDuck.ts +++ b/src/shared/modules/editor/editorDuck.ts @@ -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' @@ -170,7 +171,7 @@ export const updateEditorSupportSchemaEpic: Epic = ( store ) => actions$ - .ofType([DB_META_DONE, UPDATE_PARAMS]) + .filter(isOfType([DB_META_DONE, UPDATE_PARAMS])) .do(() => { const { params, meta } = store.getState()