@neo4j-cypher/react-codemirror 2.0.0-next.4 → 2.0.0-next.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/{types/CypherEditor.d.ts → CypherEditor.d.ts} +10 -1
- package/dist/CypherEditor.js +206 -0
- package/dist/CypherEditor.js.map +1 -0
- package/dist/e2e_tests/auto-completion.spec.js +129 -0
- package/dist/e2e_tests/auto-completion.spec.js.map +1 -0
- package/dist/e2e_tests/e2e-utils.js +52 -0
- package/dist/e2e_tests/e2e-utils.js.map +1 -0
- package/dist/e2e_tests/extra-keybindings.spec.js +44 -0
- package/dist/e2e_tests/extra-keybindings.spec.js.map +1 -0
- package/dist/e2e_tests/history-navigation.spec.js +136 -0
- package/dist/e2e_tests/history-navigation.spec.js.map +1 -0
- package/dist/e2e_tests/performance-test.spec.d.ts +6 -0
- package/dist/e2e_tests/performance-test.spec.js +96 -0
- package/dist/e2e_tests/performance-test.spec.js.map +1 -0
- package/dist/e2e_tests/sanity-checks.spec.js +65 -0
- package/dist/e2e_tests/sanity-checks.spec.js.map +1 -0
- package/dist/e2e_tests/signature-help.spec.js +151 -0
- package/dist/e2e_tests/signature-help.spec.js.map +1 -0
- package/dist/e2e_tests/syntax-highlighting.spec.js +91 -0
- package/dist/e2e_tests/syntax-highlighting.spec.js.map +1 -0
- package/dist/e2e_tests/syntax-validation.spec.js +79 -0
- package/dist/e2e_tests/syntax-validation.spec.js.map +1 -0
- package/dist/history-navigation.js +163 -0
- package/dist/history-navigation.js.map +1 -0
- package/dist/{types/icons.d.ts → icons.d.ts} +1 -1
- package/dist/icons.js +62 -0
- package/dist/icons.js.map +1 -0
- package/dist/{types/index.d.ts → index.d.ts} +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/lang-cypher/autocomplete.js +56 -0
- package/dist/lang-cypher/autocomplete.js.map +1 -0
- package/dist/{types/lang-cypher → lang-cypher}/constants.d.ts +9 -0
- package/dist/lang-cypher/constants.js +65 -0
- package/dist/lang-cypher/constants.js.map +1 -0
- package/dist/lang-cypher/contants.test.js +102 -0
- package/dist/lang-cypher/contants.test.js.map +1 -0
- package/dist/lang-cypher/create-cypher-theme.js +144 -0
- package/dist/lang-cypher/create-cypher-theme.js.map +1 -0
- package/dist/{types/lang-cypher → lang-cypher}/lang-cypher.d.ts +3 -1
- package/dist/lang-cypher/lang-cypher.js +24 -0
- package/dist/lang-cypher/lang-cypher.js.map +1 -0
- package/dist/lang-cypher/lint-worker.d.ts +8 -0
- package/dist/lang-cypher/lint-worker.js +4 -0
- package/dist/lang-cypher/lint-worker.js.map +1 -0
- package/dist/lang-cypher/parser-adapter.d.ts +19 -0
- package/dist/lang-cypher/parser-adapter.js +113 -0
- package/dist/lang-cypher/parser-adapter.js.map +1 -0
- package/dist/lang-cypher/signature-help.d.ts +4 -0
- package/dist/lang-cypher/signature-help.js +77 -0
- package/dist/lang-cypher/signature-help.js.map +1 -0
- package/dist/{types/lang-cypher → lang-cypher}/syntax-validation.d.ts +2 -0
- package/dist/lang-cypher/syntax-validation.js +68 -0
- package/dist/lang-cypher/syntax-validation.js.map +1 -0
- package/dist/lang-cypher/theme-icons.js +22 -0
- package/dist/lang-cypher/theme-icons.js.map +1 -0
- package/dist/ndl-tokens-copy.js +380 -0
- package/dist/ndl-tokens-copy.js.map +1 -0
- package/dist/ndl-tokens-copy.test.js +11 -0
- package/dist/ndl-tokens-copy.test.js.map +1 -0
- package/dist/neo4j-setup.js +86 -0
- package/dist/neo4j-setup.js.map +1 -0
- package/dist/themes.js +114 -0
- package/dist/themes.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +15 -18
- package/src/CypherEditor.tsx +31 -5
- package/src/e2e_tests/performance-test.spec.tsx +100 -13
- package/src/e2e_tests/sanity-checks.spec.tsx +8 -3
- package/src/e2e_tests/signature-help.spec.tsx +312 -0
- package/src/icons.ts +3 -0
- package/src/index.ts +1 -1
- package/src/lang-cypher/autocomplete.ts +6 -1
- package/src/lang-cypher/constants.ts +23 -0
- package/src/lang-cypher/create-cypher-theme.ts +4 -0
- package/src/lang-cypher/lang-cypher.ts +16 -7
- package/src/lang-cypher/lint-worker.ts +14 -0
- package/src/lang-cypher/parser-adapter.ts +145 -0
- package/src/lang-cypher/signature-help.ts +102 -0
- package/src/lang-cypher/syntax-validation.ts +70 -4
- package/src/themes.ts +2 -0
- package/dist/cjs/index.cjs +0 -1441
- package/dist/cjs/index.cjs.map +0 -7
- package/dist/esm/index.mjs +0 -1464
- package/dist/esm/index.mjs.map +0 -7
- package/dist/types/e2e_tests/mock-data.d.ts +0 -3779
- package/dist/types/lang-cypher/ParserAdapter.d.ts +0 -14
- package/dist/types/tsconfig.tsbuildinfo +0 -1
- package/src/e2e_tests/mock-data.ts +0 -4310
- package/src/lang-cypher/ParserAdapter.ts +0 -92
- /package/dist/{types/e2e_tests → e2e_tests}/auto-completion.spec.d.ts +0 -0
- /package/dist/{types/e2e_tests → e2e_tests}/e2e-utils.d.ts +0 -0
- /package/dist/{types/e2e_tests → e2e_tests}/extra-keybindings.spec.d.ts +0 -0
- /package/dist/{types/e2e_tests → e2e_tests}/history-navigation.spec.d.ts +0 -0
- /package/dist/{types/e2e_tests → e2e_tests}/sanity-checks.spec.d.ts +0 -0
- /package/dist/{types/e2e_tests/performance-test.spec.d.ts → e2e_tests/signature-help.spec.d.ts} +0 -0
- /package/dist/{types/e2e_tests → e2e_tests}/syntax-highlighting.spec.d.ts +0 -0
- /package/dist/{types/e2e_tests → e2e_tests}/syntax-validation.spec.d.ts +0 -0
- /package/dist/{types/history-navigation.d.ts → history-navigation.d.ts} +0 -0
- /package/dist/{types/lang-cypher → lang-cypher}/autocomplete.d.ts +0 -0
- /package/dist/{types/lang-cypher → lang-cypher}/contants.test.d.ts +0 -0
- /package/dist/{types/lang-cypher → lang-cypher}/create-cypher-theme.d.ts +0 -0
- /package/dist/{types/lang-cypher → lang-cypher}/theme-icons.d.ts +0 -0
- /package/dist/{types/ndl-tokens-copy.d.ts → ndl-tokens-copy.d.ts} +0 -0
- /package/dist/{types/ndl-tokens-copy.test.d.ts → ndl-tokens-copy.test.d.ts} +0 -0
- /package/dist/{types/neo4j-setup.d.ts → neo4j-setup.d.ts} +0 -0
- /package/dist/{types/themes.d.ts → themes.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @neo4j-cypher/react-codemirror
|
|
2
2
|
|
|
3
|
+
## 2.0.0-next.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8cc77c6: Add support for console commands
|
|
8
|
+
- 1e210cb: Moves semantic analysis to a separate worker file
|
|
9
|
+
- Updated dependencies [8cc77c6]
|
|
10
|
+
- Updated dependencies [1e210cb]
|
|
11
|
+
- Updated dependencies [f6d20b2]
|
|
12
|
+
- @neo4j-cypher/language-support@2.0.0-next.3
|
|
13
|
+
|
|
3
14
|
## 2.0.0-next.4
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -38,6 +38,10 @@ export interface CypherEditorProps {
|
|
|
38
38
|
* @default false
|
|
39
39
|
*/
|
|
40
40
|
autofocus?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Where to place the cursor in the query. Cannot be enabled at the same time than autofocus
|
|
43
|
+
*/
|
|
44
|
+
offset?: number;
|
|
41
45
|
/**
|
|
42
46
|
* Whether the editor should wrap lines.
|
|
43
47
|
*
|
|
@@ -78,7 +82,10 @@ export interface CypherEditorProps {
|
|
|
78
82
|
*/
|
|
79
83
|
onChange?(value: string, viewUpdate: ViewUpdate): void;
|
|
80
84
|
}
|
|
81
|
-
|
|
85
|
+
type CypherEditorState = {
|
|
86
|
+
cypherSupportEnabled: boolean;
|
|
87
|
+
};
|
|
88
|
+
export declare class CypherEditor extends Component<CypherEditorProps, CypherEditorState> {
|
|
82
89
|
/**
|
|
83
90
|
* The codemirror editor container.
|
|
84
91
|
*/
|
|
@@ -106,8 +113,10 @@ export declare class CypherEditor extends Component<CypherEditorProps> {
|
|
|
106
113
|
*/
|
|
107
114
|
setValueAndFocus(value?: string): void;
|
|
108
115
|
static defaultProps: CypherEditorProps;
|
|
116
|
+
private debouncedOnChange;
|
|
109
117
|
componentDidMount(): void;
|
|
110
118
|
componentDidUpdate(prevProps: CypherEditorProps): void;
|
|
111
119
|
componentWillUnmount(): void;
|
|
112
120
|
render(): React.ReactNode;
|
|
113
121
|
}
|
|
122
|
+
export {};
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Annotation, Compartment, EditorState, } from '@codemirror/state';
|
|
3
|
+
import { EditorView, keymap, lineNumbers, } from '@codemirror/view';
|
|
4
|
+
import debounce from 'lodash.debounce';
|
|
5
|
+
import { Component, createRef } from 'react';
|
|
6
|
+
import { replaceHistory, replMode as historyNavigation, } from './history-navigation';
|
|
7
|
+
import { cypher } from './lang-cypher/lang-cypher';
|
|
8
|
+
import { cleanupWorkers } from './lang-cypher/syntax-validation';
|
|
9
|
+
import { basicNeo4jSetup } from './neo4j-setup';
|
|
10
|
+
import { getThemeExtension } from './themes';
|
|
11
|
+
const executeKeybinding = (onExecute) => onExecute
|
|
12
|
+
? [
|
|
13
|
+
{
|
|
14
|
+
key: 'Ctrl-Enter',
|
|
15
|
+
mac: 'Mod-Enter',
|
|
16
|
+
preventDefault: true,
|
|
17
|
+
run: (view) => {
|
|
18
|
+
const doc = view.state.doc.toString();
|
|
19
|
+
if (doc.trim() !== '') {
|
|
20
|
+
onExecute(doc);
|
|
21
|
+
}
|
|
22
|
+
return true;
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
]
|
|
26
|
+
: [];
|
|
27
|
+
const themeCompartment = new Compartment();
|
|
28
|
+
const keyBindingCompartment = new Compartment();
|
|
29
|
+
const ExternalEdit = Annotation.define();
|
|
30
|
+
export class CypherEditor extends Component {
|
|
31
|
+
/**
|
|
32
|
+
* The codemirror editor container.
|
|
33
|
+
*/
|
|
34
|
+
editorContainer = createRef();
|
|
35
|
+
/**
|
|
36
|
+
* The codemirror editor state.
|
|
37
|
+
*/
|
|
38
|
+
editorState = createRef();
|
|
39
|
+
/**
|
|
40
|
+
* The codemirror editor view.
|
|
41
|
+
*/
|
|
42
|
+
editorView = createRef();
|
|
43
|
+
schemaRef = createRef();
|
|
44
|
+
/**
|
|
45
|
+
* Focus the editor
|
|
46
|
+
*/
|
|
47
|
+
focus() {
|
|
48
|
+
this.editorView.current?.focus();
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Move the cursor to the supplied position.
|
|
52
|
+
* For example, to move the cursor to the end of the editor, use `value.length`
|
|
53
|
+
*/
|
|
54
|
+
updateCursorPosition(position) {
|
|
55
|
+
this.editorView.current?.dispatch({
|
|
56
|
+
selection: { anchor: position, head: position },
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Externally set the editor value and focus the editor.
|
|
61
|
+
*/
|
|
62
|
+
setValueAndFocus(value = '') {
|
|
63
|
+
const currentCmValue = this.editorView.current.state?.doc.toString() ?? '';
|
|
64
|
+
this.editorView.current.dispatch({
|
|
65
|
+
changes: {
|
|
66
|
+
from: 0,
|
|
67
|
+
to: currentCmValue.length,
|
|
68
|
+
insert: value,
|
|
69
|
+
},
|
|
70
|
+
selection: { anchor: value.length, head: value.length },
|
|
71
|
+
});
|
|
72
|
+
this.editorView.current?.focus();
|
|
73
|
+
}
|
|
74
|
+
static defaultProps = {
|
|
75
|
+
lint: true,
|
|
76
|
+
schema: {},
|
|
77
|
+
overrideThemeBackgroundColor: false,
|
|
78
|
+
lineWrap: false,
|
|
79
|
+
extraKeybindings: [],
|
|
80
|
+
history: [],
|
|
81
|
+
theme: 'light',
|
|
82
|
+
};
|
|
83
|
+
debouncedOnChange = this.props.onChange
|
|
84
|
+
? debounce(this.props.onChange, 200)
|
|
85
|
+
: undefined;
|
|
86
|
+
componentDidMount() {
|
|
87
|
+
const { theme, extraKeybindings, lineWrap, overrideThemeBackgroundColor, schema, lint, onExecute, } = this.props;
|
|
88
|
+
this.schemaRef.current = {
|
|
89
|
+
schema,
|
|
90
|
+
lint,
|
|
91
|
+
useLightVersion: false,
|
|
92
|
+
setUseLightVersion: (newVal) => {
|
|
93
|
+
if (this.schemaRef.current !== undefined) {
|
|
94
|
+
this.schemaRef.current.useLightVersion = newVal;
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
const themeExtension = getThemeExtension(theme, overrideThemeBackgroundColor);
|
|
99
|
+
const changeListener = this.debouncedOnChange
|
|
100
|
+
? [
|
|
101
|
+
EditorView.updateListener.of((upt) => {
|
|
102
|
+
const wasUserEdit = !upt.transactions.some((tr) => tr.annotation(ExternalEdit));
|
|
103
|
+
if (upt.docChanged && wasUserEdit) {
|
|
104
|
+
const doc = upt.state.doc;
|
|
105
|
+
const value = doc.toString();
|
|
106
|
+
this.debouncedOnChange(value, upt);
|
|
107
|
+
}
|
|
108
|
+
}),
|
|
109
|
+
]
|
|
110
|
+
: [];
|
|
111
|
+
this.editorState.current = EditorState.create({
|
|
112
|
+
extensions: [
|
|
113
|
+
keyBindingCompartment.of(keymap.of([...executeKeybinding(onExecute), ...extraKeybindings])),
|
|
114
|
+
historyNavigation(this.props),
|
|
115
|
+
basicNeo4jSetup(),
|
|
116
|
+
themeCompartment.of(themeExtension),
|
|
117
|
+
changeListener,
|
|
118
|
+
cypher(this.schemaRef.current),
|
|
119
|
+
lineWrap ? EditorView.lineWrapping : [],
|
|
120
|
+
lineNumbers({
|
|
121
|
+
formatNumber: (a, state) => {
|
|
122
|
+
if (state.doc.lines === 1 && this.props.prompt !== undefined) {
|
|
123
|
+
return this.props.prompt;
|
|
124
|
+
}
|
|
125
|
+
return a.toString();
|
|
126
|
+
},
|
|
127
|
+
}),
|
|
128
|
+
],
|
|
129
|
+
doc: this.props.value,
|
|
130
|
+
});
|
|
131
|
+
this.editorView.current = new EditorView({
|
|
132
|
+
state: this.editorState.current,
|
|
133
|
+
parent: this.editorContainer.current,
|
|
134
|
+
});
|
|
135
|
+
if (this.props.autofocus) {
|
|
136
|
+
this.focus();
|
|
137
|
+
if (this.props.value) {
|
|
138
|
+
this.updateCursorPosition(this.props.value.length);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
else if (this.props.offset) {
|
|
142
|
+
this.updateCursorPosition(this.props.offset);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
componentDidUpdate(prevProps) {
|
|
146
|
+
if (!this.editorView.current) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
// Handle externally set value
|
|
150
|
+
const currentCmValue = this.editorView.current.state?.doc.toString() ?? '';
|
|
151
|
+
if (this.props.value !== undefined && currentCmValue !== this.props.value) {
|
|
152
|
+
this.editorView.current.dispatch({
|
|
153
|
+
changes: {
|
|
154
|
+
from: 0,
|
|
155
|
+
to: currentCmValue.length,
|
|
156
|
+
insert: this.props.value ?? '',
|
|
157
|
+
},
|
|
158
|
+
annotations: [ExternalEdit.of(true)],
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
// Handle theme change
|
|
162
|
+
const didChangeTheme = prevProps.theme !== this.props.theme ||
|
|
163
|
+
prevProps.overrideThemeBackgroundColor !==
|
|
164
|
+
this.props.overrideThemeBackgroundColor;
|
|
165
|
+
if (didChangeTheme) {
|
|
166
|
+
this.editorView.current.dispatch({
|
|
167
|
+
effects: themeCompartment.reconfigure(getThemeExtension(this.props.theme, this.props.overrideThemeBackgroundColor)),
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
if (prevProps.extraKeybindings !== this.props.extraKeybindings ||
|
|
171
|
+
prevProps.onExecute !== this.props.onExecute) {
|
|
172
|
+
this.editorView.current.dispatch({
|
|
173
|
+
effects: keyBindingCompartment.reconfigure(keymap.of([
|
|
174
|
+
...executeKeybinding(this.props.onExecute),
|
|
175
|
+
...this.props.extraKeybindings,
|
|
176
|
+
])),
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
// This component rerenders on every keystroke and comparing the
|
|
180
|
+
// full lists of editor strings on every render could be expensive.
|
|
181
|
+
const didChangeHistoryEstimate = prevProps.history?.length !== this.props.history?.length ||
|
|
182
|
+
prevProps.history?.[0] !== this.props.history?.[0];
|
|
183
|
+
if (didChangeHistoryEstimate) {
|
|
184
|
+
this.editorView.current.dispatch({
|
|
185
|
+
effects: replaceHistory.of(this.props.history ?? []),
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
/*
|
|
189
|
+
The cypher configuration is a mutable object that is passed to the cypher language extension.
|
|
190
|
+
Much like how the schema based completions work in the official sql language extension.
|
|
191
|
+
https://github.com/codemirror/lang-sql/blob/4b7b2564dff7cdb1a15f8ccd08142f2cc8a0006f/src/sql.ts#L178C17-L178C18
|
|
192
|
+
*/
|
|
193
|
+
this.schemaRef.current.schema = this.props.schema;
|
|
194
|
+
this.schemaRef.current.lint = this.props.lint;
|
|
195
|
+
}
|
|
196
|
+
componentWillUnmount() {
|
|
197
|
+
this.editorView.current?.destroy();
|
|
198
|
+
cleanupWorkers();
|
|
199
|
+
}
|
|
200
|
+
render() {
|
|
201
|
+
const { className, theme } = this.props;
|
|
202
|
+
const themeClass = typeof theme === 'string' ? `cm-theme-${theme}` : 'cm-theme';
|
|
203
|
+
return (_jsx("div", { ref: this.editorContainer, className: `${themeClass}${className ? ` ${className}` : ''}` }));
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
//# sourceMappingURL=CypherEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CypherEditor.js","sourceRoot":"","sources":["../src/CypherEditor.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EACV,WAAW,EACX,WAAW,GAEZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,UAAU,EAEV,MAAM,EACN,WAAW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AAS,EAAE,GAAG,UAAU,GAAG,SAAS,CAAC,CAAC,CAAC,IAAI,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,GAC7D,CACH,CAAC;IACJ,CAAC"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { expect, test } from '@playwright/experimental-ct-react';
|
|
3
|
+
import { CypherEditor } from '../CypherEditor';
|
|
4
|
+
test.use({ viewport: { width: 500, height: 500 } });
|
|
5
|
+
test('hello world end 2 end test', async ({ mount }) => {
|
|
6
|
+
const component = await mount(_jsx(CypherEditor, { value: "hello world" }));
|
|
7
|
+
await expect(component).toContainText('hello world');
|
|
8
|
+
await component.update(_jsx(CypherEditor, { value: "RETURN 123" }));
|
|
9
|
+
await expect(component).toContainText('RETURN 123');
|
|
10
|
+
});
|
|
11
|
+
test('can complete in the middle of statement', async ({ mount, page }) => {
|
|
12
|
+
const component = await mount(_jsx(CypherEditor, { value: `MATCH ()
|
|
13
|
+
WHER true
|
|
14
|
+
RETURN n;` }));
|
|
15
|
+
// Move into the statement and trigger autocompletion
|
|
16
|
+
const textField = page.getByRole('textbox');
|
|
17
|
+
await textField.focus();
|
|
18
|
+
await textField.press('ArrowDown');
|
|
19
|
+
await textField.press('ArrowRight');
|
|
20
|
+
await textField.press('ArrowRight');
|
|
21
|
+
await textField.press('ArrowRight');
|
|
22
|
+
await textField.press('ArrowRight');
|
|
23
|
+
await textField.press('Control+ ');
|
|
24
|
+
await expect(page.locator('.cm-tooltip-autocomplete')).toBeVisible();
|
|
25
|
+
await page.locator('.cm-tooltip-autocomplete').getByText('WHERE').click();
|
|
26
|
+
await expect(page.locator('.cm-tooltip-autocomplete')).not.toBeVisible();
|
|
27
|
+
await expect(component).toContainText('WHERE true');
|
|
28
|
+
});
|
|
29
|
+
test('get completions when typing and can accept completions with tab', async ({ mount, page, }) => {
|
|
30
|
+
const component = await mount(_jsx(CypherEditor, {}));
|
|
31
|
+
const textField = page.getByRole('textbox');
|
|
32
|
+
await textField.fill('RETU');
|
|
33
|
+
await expect(page.locator('.cm-tooltip-autocomplete').getByText('RETURN')).toBeVisible();
|
|
34
|
+
// We need to wait for the editor to realise there is a completion open
|
|
35
|
+
// so that it does not just indent with tab key
|
|
36
|
+
await page.waitForTimeout(500);
|
|
37
|
+
await textField.press('Tab');
|
|
38
|
+
await expect(page.locator('.cm-tooltip-autocomplete')).not.toBeVisible();
|
|
39
|
+
await expect(component).toContainText('RETURN');
|
|
40
|
+
});
|
|
41
|
+
test('can complete labels', async ({ mount, page }) => {
|
|
42
|
+
const component = await mount(_jsx(CypherEditor, { schema: {
|
|
43
|
+
labels: ['Pokemon'],
|
|
44
|
+
} }));
|
|
45
|
+
const textField = page.getByRole('textbox');
|
|
46
|
+
await textField.fill('MATCH (n :P');
|
|
47
|
+
await page.locator('.cm-tooltip-autocomplete').getByText('Pokemon').click();
|
|
48
|
+
await expect(page.locator('.cm-tooltip-autocomplete')).not.toBeVisible();
|
|
49
|
+
await expect(component).toContainText('MATCH (n :Pokemon');
|
|
50
|
+
});
|
|
51
|
+
test('can update dbschema', async ({ mount, page }) => {
|
|
52
|
+
const component = await mount(_jsx(CypherEditor, { schema: {
|
|
53
|
+
labels: ['Pokemon'],
|
|
54
|
+
} }));
|
|
55
|
+
const textField = page.getByRole('textbox');
|
|
56
|
+
await textField.fill('MATCH (n :');
|
|
57
|
+
await expect(page.locator('.cm-tooltip-autocomplete').getByText('Pokemon')).toBeVisible();
|
|
58
|
+
await textField.press('Escape');
|
|
59
|
+
await expect(page.locator('.cm-tooltip-autocomplete')).not.toBeVisible();
|
|
60
|
+
await component.update(_jsx(CypherEditor, { schema: {
|
|
61
|
+
labels: ['Pokemon', 'Digimon'],
|
|
62
|
+
} }));
|
|
63
|
+
await textField.press('Control+ ');
|
|
64
|
+
await expect(page.locator('.cm-tooltip-autocomplete').getByText('Pokemon')).toBeVisible();
|
|
65
|
+
await expect(page.locator('.cm-tooltip-autocomplete').getByText('Digimon')).toBeVisible();
|
|
66
|
+
});
|
|
67
|
+
test('can complete rel types', async ({ page, mount }) => {
|
|
68
|
+
const component = await mount(_jsx(CypherEditor, { schema: {
|
|
69
|
+
relationshipTypes: ['KNOWS'],
|
|
70
|
+
} }));
|
|
71
|
+
const textField = page.getByRole('textbox');
|
|
72
|
+
await textField.fill('MATCH (n)-[:');
|
|
73
|
+
await page.locator('.cm-tooltip-autocomplete').getByText('KNOWS').click();
|
|
74
|
+
await expect(page.locator('.cm-tooltip-autocomplete')).not.toBeVisible();
|
|
75
|
+
await expect(component).toContainText('MATCH (n)-[:KNOWS');
|
|
76
|
+
});
|
|
77
|
+
test('can complete functions', async ({ page, mount }) => {
|
|
78
|
+
const component = await mount(_jsx(CypherEditor, { schema: {
|
|
79
|
+
functionSignatures: {
|
|
80
|
+
function123: { label: 'function123', documentation: 'no docs' },
|
|
81
|
+
},
|
|
82
|
+
} }));
|
|
83
|
+
const textField = page.getByRole('textbox');
|
|
84
|
+
await textField.fill('RETURN func');
|
|
85
|
+
await page
|
|
86
|
+
.locator('.cm-tooltip-autocomplete')
|
|
87
|
+
.getByText('function123')
|
|
88
|
+
.click();
|
|
89
|
+
await expect(page.locator('.cm-tooltip-autocomplete')).not.toBeVisible();
|
|
90
|
+
await expect(component).toContainText('RETURN function123');
|
|
91
|
+
});
|
|
92
|
+
test('can complete procedures', async ({ page, mount }) => {
|
|
93
|
+
const component = await mount(_jsx(CypherEditor, { schema: {
|
|
94
|
+
procedureSignatures: {
|
|
95
|
+
'db.ping': { label: 'db.ping', documentation: 'no docs' },
|
|
96
|
+
},
|
|
97
|
+
} }));
|
|
98
|
+
const textField = page.getByRole('textbox');
|
|
99
|
+
await textField.fill('CALL d');
|
|
100
|
+
await page.locator('.cm-tooltip-autocomplete').getByText('db.ping').click();
|
|
101
|
+
await expect(page.locator('.cm-tooltip-autocomplete')).not.toBeVisible();
|
|
102
|
+
await expect(component).toContainText('CALL db.ping');
|
|
103
|
+
});
|
|
104
|
+
test('can complete parameters', async ({ page, mount }) => {
|
|
105
|
+
const component = await mount(_jsx(CypherEditor, { schema: {
|
|
106
|
+
parameters: { parameter: { type: 'string' } },
|
|
107
|
+
} }));
|
|
108
|
+
const textField = page.getByRole('textbox');
|
|
109
|
+
await textField.fill('RETURN $p');
|
|
110
|
+
await page.locator('.cm-tooltip-autocomplete').getByText('parameter').click();
|
|
111
|
+
await expect(page.locator('.cm-tooltip-autocomplete')).not.toBeVisible();
|
|
112
|
+
await expect(component).toContainText('RETURN $parameter');
|
|
113
|
+
});
|
|
114
|
+
test('completes allShortestPaths correctly', async ({ page, mount }) => {
|
|
115
|
+
await mount(_jsx(CypherEditor, { schema: {
|
|
116
|
+
parameters: { parameter: { type: 'string' } },
|
|
117
|
+
} }));
|
|
118
|
+
const textField = page.getByRole('textbox');
|
|
119
|
+
// The first query contains errors on purpose so the
|
|
120
|
+
// syntax errors get triggered before the auto-completion
|
|
121
|
+
await textField.fill('MATCH (n) REURN n; MATCH a');
|
|
122
|
+
await page
|
|
123
|
+
.locator('.cm-tooltip-autocomplete')
|
|
124
|
+
.getByText('allShortestPaths')
|
|
125
|
+
.click();
|
|
126
|
+
await expect(page.locator('.cm-tooltip-autocomplete')).not.toBeVisible();
|
|
127
|
+
expect(await textField.textContent()).toEqual('MATCH (n) REURN n; MATCH allShortestPaths');
|
|
128
|
+
});
|
|
129
|
+
//# sourceMappingURL=auto-completion.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-completion.spec.js","sourceRoot":"","sources":["../../src/e2e_tests/auto-completion.spec.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,IAAI,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,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,CAC3C,2CAA2C,CAC5C,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { expect } from '@playwright/experimental-ct-react';
|
|
2
|
+
export class CypherEditorPage {
|
|
3
|
+
page;
|
|
4
|
+
constructor(page) {
|
|
5
|
+
this.page = page;
|
|
6
|
+
}
|
|
7
|
+
getEditor() {
|
|
8
|
+
return this.page.getByRole('textbox');
|
|
9
|
+
}
|
|
10
|
+
async focusEditor() {
|
|
11
|
+
await this.getEditor().focus();
|
|
12
|
+
}
|
|
13
|
+
editorBackgroundIsUnset() {
|
|
14
|
+
return this.page.locator('.cm-editor').evaluate((e) => {
|
|
15
|
+
const browserDefaultBackgroundColor = 'rgba(0, 0, 0, 0)';
|
|
16
|
+
return (window.getComputedStyle(e).getPropertyValue('background-color') ===
|
|
17
|
+
browserDefaultBackgroundColor);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
getHexColorOfLocator(locator) {
|
|
21
|
+
return locator.evaluate((e) => {
|
|
22
|
+
// https://stackoverflow.com/questions/49974145/how-to-convert-rgba-to-hex-color-code-using-javascript
|
|
23
|
+
function RGBAToHexA(rgba, forceRemoveAlpha = false) {
|
|
24
|
+
return ('#' +
|
|
25
|
+
rgba
|
|
26
|
+
.replace(/^rgba?\(|\s+|\)$/g, '')
|
|
27
|
+
.split(',')
|
|
28
|
+
.filter((string, index) => !forceRemoveAlpha || index !== 3)
|
|
29
|
+
.map((string) => parseFloat(string))
|
|
30
|
+
.map((number, index) => index === 3 ? Math.round(number * 255) : number)
|
|
31
|
+
.map((number) => number.toString(16))
|
|
32
|
+
.map((string) => (string.length === 1 ? '0' + string : string))
|
|
33
|
+
.join(''));
|
|
34
|
+
}
|
|
35
|
+
const color = window.getComputedStyle(e).getPropertyValue('color');
|
|
36
|
+
return RGBAToHexA(color);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
async checkErrorMessage(queryChunk, expectedMsg) {
|
|
40
|
+
return this.checkNotificationMessage('error', queryChunk, expectedMsg);
|
|
41
|
+
}
|
|
42
|
+
async checkWarningMessage(queryChunk, expectedMsg) {
|
|
43
|
+
return this.checkNotificationMessage('warning', queryChunk, expectedMsg);
|
|
44
|
+
}
|
|
45
|
+
async checkNotificationMessage(type, queryChunk, expectedMsg) {
|
|
46
|
+
await expect(this.page.locator('.cm-lintRange-' + type).last()).toBeVisible({ timeout: 2000 });
|
|
47
|
+
await this.page.getByText(queryChunk, { exact: true }).hover();
|
|
48
|
+
await expect(this.page.locator('.cm-tooltip-hover').last()).toBeVisible();
|
|
49
|
+
await expect(this.page.getByText(expectedMsg)).toBeVisible();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=e2e-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"e2e-utils.js","sourceRoot":"","sources":["../../src/e2e_tests/e2e-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAG3D,MAAM,OAAO,gBAAgB;IAClB,IAAI,CAAO;IAEpB,YAAY,IAAU;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,WAAW;QACf,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC;IACjC,CAAC;IAED,uBAAuB;QACrB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAU,EAAE,EAAE;YAC7D,MAAM,6BAA6B,GAAG,kBAAkB,CAAC;YACzD,OAAO,CACL,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,kBAAkB,CAAC;gBAC/D,6BAA6B,CAC9B,CAAC;QACJ,CAA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OAAO,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;IACzE,CAAC;IAED,KAAK,CAAC,mBAAmB,CAAC,UAAkB,EAAE,WAAmB;QAC/D,OAAO,IAAI,CAAC,wBAAwB,CAAC,SAAS,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;IAC3E,CAAC;IAEO,KAAK,CAAC,wBAAwB,CACpC,IAAyB,EACzB,UAAkB,EAClB,WAAmB;QAEnB,MAAM,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,WAAW,CACzE,EAAE,OAAO,EAAE,IAAI,EAAE,CAClB,CAAC;QAEF,MAAM,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;QAC/D,MAAM,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;QAC1E,MAAM,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IAC/D,CAAC;CACF"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { expect, test } from '@playwright/experimental-ct-react';
|
|
3
|
+
import { CypherEditor } from '../CypherEditor';
|
|
4
|
+
import { CypherEditorPage } from './e2e-utils';
|
|
5
|
+
test.use({ viewport: { width: 500, height: 500 } });
|
|
6
|
+
test('can add extra keybinding statically', async ({ mount, page }) => {
|
|
7
|
+
const editorPage = new CypherEditorPage(page);
|
|
8
|
+
let hasRun = false;
|
|
9
|
+
const component = await mount(_jsx(CypherEditor, { extraKeybindings: [
|
|
10
|
+
{
|
|
11
|
+
key: 'a',
|
|
12
|
+
preventDefault: true,
|
|
13
|
+
run: () => {
|
|
14
|
+
hasRun = true;
|
|
15
|
+
return true;
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
] }));
|
|
19
|
+
await editorPage.getEditor().press('a');
|
|
20
|
+
await expect(component).not.toHaveText('a');
|
|
21
|
+
expect(hasRun).toBe(true);
|
|
22
|
+
});
|
|
23
|
+
test('can add extra keybinding dymanically', async ({ mount, page }) => {
|
|
24
|
+
const editorPage = new CypherEditorPage(page);
|
|
25
|
+
let hasRun = false;
|
|
26
|
+
const component = await mount(_jsx(CypherEditor, {}));
|
|
27
|
+
await editorPage.getEditor().press('a');
|
|
28
|
+
await editorPage.getEditor().press('Escape');
|
|
29
|
+
await expect(component).toContainText('a');
|
|
30
|
+
await component.update(_jsx(CypherEditor, { extraKeybindings: [
|
|
31
|
+
{
|
|
32
|
+
key: 'a',
|
|
33
|
+
preventDefault: true,
|
|
34
|
+
run: () => {
|
|
35
|
+
hasRun = true;
|
|
36
|
+
return true;
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
] }));
|
|
40
|
+
await editorPage.getEditor().press('a');
|
|
41
|
+
await expect(component).not.toContainText('aa');
|
|
42
|
+
expect(hasRun).toBe(true);
|
|
43
|
+
});
|
|
44
|
+
//# sourceMappingURL=extra-keybindings.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extra-keybindings.spec.js","sourceRoot":"","sources":["../../src/e2e_tests/extra-keybindings.spec.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,IAAI,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;AAEpD,I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gBACE,GAAG,EAAE,GAAG;gBACR,cAAc,EAAE,IAAI;gBACpB,GAAG,EAAE,GAAG,EAAE;oBACR,MAAM,GAAG,IAAI,CAAC;oBACd,OAAO,IAAI,CAAC;gBACd,CAAC;aACF;SACF,GACD,CACH,CAAC;IAEF,MAAM,UAAU,CAAC,SAAS,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACxC,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAChD,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { expect, test } from '@playwright/experimental-ct-react';
|
|
3
|
+
import { CypherEditor } from '../CypherEditor';
|
|
4
|
+
import { CypherEditorPage } from './e2e-utils';
|
|
5
|
+
test.use({ viewport: { width: 500, height: 500 } });
|
|
6
|
+
test('respects preloaded history', async ({ page, mount }) => {
|
|
7
|
+
const editorPage = new CypherEditorPage(page);
|
|
8
|
+
const initialValue = 'MATCH (n) RETURN n;';
|
|
9
|
+
await mount(_jsx(CypherEditor, { value: initialValue, history: ['first', 'second'], onExecute: () => {
|
|
10
|
+
/* needed to turn on history movements */
|
|
11
|
+
} }));
|
|
12
|
+
await editorPage.getEditor().press('ArrowUp');
|
|
13
|
+
await expect(page.getByText('first')).toBeVisible();
|
|
14
|
+
// First arrow up is to get to start of line
|
|
15
|
+
await editorPage.getEditor().press('ArrowUp');
|
|
16
|
+
await editorPage.getEditor().press('ArrowUp');
|
|
17
|
+
await expect(page.getByText('second')).toBeVisible();
|
|
18
|
+
await editorPage.getEditor().press('ArrowDown');
|
|
19
|
+
await expect(page.getByText('first')).toBeVisible();
|
|
20
|
+
await editorPage.getEditor().press('ArrowDown');
|
|
21
|
+
await expect(page.getByText(initialValue)).toBeVisible();
|
|
22
|
+
});
|
|
23
|
+
test('can execute queries and see them in history', async ({ page, mount }) => {
|
|
24
|
+
const editorPage = new CypherEditorPage(page);
|
|
25
|
+
const initialValue = `MATCH (n)
|
|
26
|
+
RETURN n;`;
|
|
27
|
+
const history = [];
|
|
28
|
+
const onExecute = (cmd) => {
|
|
29
|
+
history.unshift(cmd);
|
|
30
|
+
};
|
|
31
|
+
const editor = await mount(_jsx(CypherEditor, { value: initialValue, history: history, onExecute: onExecute }));
|
|
32
|
+
// Execute initial query
|
|
33
|
+
await editorPage.getEditor().press('Control+Enter');
|
|
34
|
+
await editorPage.getEditor().press('Meta+Enter');
|
|
35
|
+
expect(history.length).toBe(1);
|
|
36
|
+
// Ensure query execution doesn't fire if the query is only whitespace
|
|
37
|
+
await editorPage.getEditor().fill(' ');
|
|
38
|
+
await editorPage.getEditor().press('Control+Enter');
|
|
39
|
+
await editorPage.getEditor().press('Meta+Enter');
|
|
40
|
+
expect(history.length).toBe(1);
|
|
41
|
+
// Ensure only enter doesn't execute query
|
|
42
|
+
await editorPage.getEditor().fill('multiline');
|
|
43
|
+
await editorPage.getEditor().press('Enter');
|
|
44
|
+
await editorPage.getEditor().press('Enter');
|
|
45
|
+
await editorPage.getEditor().press('Enter');
|
|
46
|
+
await editorPage.getEditor().press('Enter');
|
|
47
|
+
await page.keyboard.type('entry');
|
|
48
|
+
expect(history.length).toBe(1);
|
|
49
|
+
await editorPage.getEditor().press('Control+Enter');
|
|
50
|
+
await editorPage.getEditor().press('Meta+Enter');
|
|
51
|
+
expect(history.length).toBe(2);
|
|
52
|
+
// rerender with new history
|
|
53
|
+
await editor.update(_jsx(CypherEditor, { value: initialValue, history: history, onExecute: onExecute }));
|
|
54
|
+
// type a new query and make sure it's not lost when navigating history
|
|
55
|
+
await editorPage.getEditor().fill('draft');
|
|
56
|
+
await expect(page.getByText('draft')).toBeVisible();
|
|
57
|
+
expect(history.length).toBe(2);
|
|
58
|
+
// Navigate to the top of the editor before navigating history
|
|
59
|
+
await editorPage.getEditor().press('ArrowLeft');
|
|
60
|
+
await editorPage.getEditor().press('ArrowLeft');
|
|
61
|
+
await editorPage.getEditor().press('ArrowLeft');
|
|
62
|
+
await editorPage.getEditor().press('ArrowLeft');
|
|
63
|
+
await editorPage.getEditor().press('ArrowLeft');
|
|
64
|
+
await editorPage.getEditor().press('ArrowUp');
|
|
65
|
+
// Ensure moving down in the editor doesn't navigate history
|
|
66
|
+
await expect(page.getByText('multiline')).toBeVisible();
|
|
67
|
+
// arrow movements don't matter until bottom is hit
|
|
68
|
+
await editorPage.getEditor().press('ArrowUp');
|
|
69
|
+
await editorPage.getEditor().press('ArrowUp');
|
|
70
|
+
await editorPage.getEditor().press('ArrowDown');
|
|
71
|
+
await editorPage.getEditor().press('ArrowDown');
|
|
72
|
+
// editor still multiline
|
|
73
|
+
await expect(page.getByText('multiline')).toBeVisible();
|
|
74
|
+
// until you hit the end where have the draft we created earlier
|
|
75
|
+
await editorPage.getEditor().press('ArrowDown');
|
|
76
|
+
await expect(page.getByText('draft')).toBeVisible();
|
|
77
|
+
});
|
|
78
|
+
test('can navigate with cmd+up as well', async ({ page, mount }) => {
|
|
79
|
+
const editorPage = new CypherEditorPage(page);
|
|
80
|
+
const isMac = process.platform === 'darwin';
|
|
81
|
+
const metaUp = isMac ? 'Meta+ArrowUp' : 'Control+ArrowUp';
|
|
82
|
+
const metaDown = isMac ? 'Meta+ArrowDown' : 'Control+ArrowDown';
|
|
83
|
+
const initialValue = 'MATCH (n) RETURN n;';
|
|
84
|
+
await mount(_jsx(CypherEditor, { value: initialValue, history: [
|
|
85
|
+
`one
|
|
86
|
+
multiline
|
|
87
|
+
entry
|
|
88
|
+
.`,
|
|
89
|
+
'second',
|
|
90
|
+
], onExecute: () => {
|
|
91
|
+
/* needed to turn on history movements */
|
|
92
|
+
} }));
|
|
93
|
+
await editorPage.getEditor().press(metaUp);
|
|
94
|
+
await expect(page.getByText('multiline')).toBeVisible();
|
|
95
|
+
// Single meta up moves all the way to top of editor on mac
|
|
96
|
+
if (isMac) {
|
|
97
|
+
await editorPage.getEditor().press(metaUp);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
await editorPage.getEditor().press('ArrowUp');
|
|
101
|
+
await editorPage.getEditor().press('ArrowUp');
|
|
102
|
+
await editorPage.getEditor().press('ArrowUp');
|
|
103
|
+
await editorPage.getEditor().press('ArrowUp');
|
|
104
|
+
}
|
|
105
|
+
// move in history
|
|
106
|
+
await editorPage.getEditor().press(metaUp);
|
|
107
|
+
await expect(page.getByText('second')).toBeVisible();
|
|
108
|
+
await editorPage.getEditor().press(metaDown);
|
|
109
|
+
await expect(page.getByText('multiline')).toBeVisible();
|
|
110
|
+
});
|
|
111
|
+
test('test onExecute', async ({ page, mount }) => {
|
|
112
|
+
const editorPage = new CypherEditorPage(page);
|
|
113
|
+
const isMac = process.platform === 'darwin';
|
|
114
|
+
const execButton = isMac ? 'Meta+Enter' : 'Control+Enter';
|
|
115
|
+
const initialValue = 'MATCH (n) RETURN n;';
|
|
116
|
+
const history = [];
|
|
117
|
+
const onExecute = (cmd) => {
|
|
118
|
+
history.unshift(cmd);
|
|
119
|
+
};
|
|
120
|
+
const cypherEditor = await mount(_jsx(CypherEditor, { value: initialValue, onExecute: onExecute }));
|
|
121
|
+
await editorPage.getEditor().press(execButton);
|
|
122
|
+
expect(history).toEqual([initialValue]);
|
|
123
|
+
await editorPage.getEditor().press(execButton);
|
|
124
|
+
expect(history).toEqual([initialValue, initialValue]);
|
|
125
|
+
// can update onExecute
|
|
126
|
+
let newExecRan = false;
|
|
127
|
+
const newOnExecute = () => {
|
|
128
|
+
newExecRan = true;
|
|
129
|
+
};
|
|
130
|
+
await cypherEditor.update(_jsx(CypherEditor, { value: initialValue, onExecute: newOnExecute }));
|
|
131
|
+
await editorPage.getEditor().press(execButton);
|
|
132
|
+
expect(newExecRan).toEqual(true);
|
|
133
|
+
// old value should still be only 2
|
|
134
|
+
expect(history).toEqual([initialValue, initialValue]);
|
|
135
|
+
});
|
|
136
|
+
//# sourceMappingURL=history-navigation.spec.js.map
|