@neo4j-cypher/react-codemirror 2.0.0-next.23 → 2.0.0-next.25
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 +24 -0
- package/dist/{CypherEditor.d.ts → src/CypherEditor.d.ts} +0 -1
- package/dist/{CypherEditor.js → src/CypherEditor.js} +9 -6
- package/dist/src/CypherEditor.js.map +1 -0
- package/dist/{CypherEditor.test.js → src/CypherEditor.test.js} +3 -0
- package/dist/src/CypherEditor.test.js.map +1 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/{e2e_tests → src/e2e_tests}/autoCompletion.spec.js +15 -1
- package/dist/src/e2e_tests/autoCompletion.spec.js.map +1 -0
- package/dist/src/e2e_tests/configuration.spec.js.map +1 -0
- package/dist/src/e2e_tests/debounce.spec.js.map +1 -0
- package/dist/{e2e_tests → src/e2e_tests}/e2eUtils.d.ts +1 -0
- package/dist/{e2e_tests → src/e2e_tests}/e2eUtils.js +10 -2
- package/dist/src/e2e_tests/e2eUtils.js.map +1 -0
- package/dist/src/e2e_tests/extraKeybindings.spec.js.map +1 -0
- package/dist/src/e2e_tests/historyNavigation.spec.js.map +1 -0
- package/dist/{e2e_tests → src/e2e_tests}/performanceTest.spec.js +1 -1
- package/dist/src/e2e_tests/performanceTest.spec.js.map +1 -0
- package/dist/src/e2e_tests/sanityChecks.spec.js.map +1 -0
- package/dist/{e2e_tests → src/e2e_tests}/signatureHelp.spec.js +1 -1
- package/dist/src/e2e_tests/signatureHelp.spec.js.map +1 -0
- package/dist/src/e2e_tests/snippets.spec.js.map +1 -0
- package/dist/src/e2e_tests/syntaxHighlighting.spec.js.map +1 -0
- package/dist/{e2e_tests → src/e2e_tests}/syntaxValidation.spec.js +21 -10
- package/dist/src/e2e_tests/syntaxValidation.spec.js.map +1 -0
- package/dist/src/historyNavigation.js.map +1 -0
- package/dist/src/icons.js.map +1 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/lang-cypher/autocomplete.js.map +1 -0
- package/dist/src/lang-cypher/constants.js.map +1 -0
- package/dist/src/lang-cypher/contants.test.js.map +1 -0
- package/dist/{lang-cypher → src/lang-cypher}/createCypherTheme.js +1 -0
- package/dist/src/lang-cypher/createCypherTheme.js.map +1 -0
- package/dist/{lang-cypher → src/lang-cypher}/langCypher.d.ts +0 -1
- package/dist/src/lang-cypher/langCypher.js.map +1 -0
- package/dist/src/lang-cypher/lintWorker.mjs +2010 -0
- package/dist/src/lang-cypher/parser-adapter.js.map +1 -0
- package/dist/src/lang-cypher/signatureHelp.js.map +1 -0
- package/dist/{lang-cypher → src/lang-cypher}/syntaxValidation.js +9 -2
- package/dist/src/lang-cypher/syntaxValidation.js.map +1 -0
- package/dist/src/lang-cypher/themeIcons.js.map +1 -0
- package/dist/src/lang-cypher/utils.js.map +1 -0
- package/dist/src/ndlTokensCopy.js.map +1 -0
- package/dist/src/ndlTokensCopy.test.js.map +1 -0
- package/dist/src/neo4jSetup.js.map +1 -0
- package/dist/src/themes.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +10 -6
- package/src/CypherEditor.test.tsx +4 -0
- package/src/CypherEditor.tsx +29 -29
- package/src/e2e_tests/autoCompletion.spec.tsx +26 -1
- package/src/e2e_tests/e2eUtils.ts +18 -2
- package/src/e2e_tests/performanceTest.spec.tsx +1 -1
- package/src/e2e_tests/signatureHelp.spec.tsx +0 -1
- package/src/e2e_tests/syntaxValidation.spec.tsx +27 -10
- package/src/lang-cypher/createCypherTheme.ts +1 -0
- package/src/lang-cypher/langCypher.ts +0 -1
- package/src/lang-cypher/lintWorker.mjs +2010 -0
- package/src/lang-cypher/syntaxValidation.ts +12 -3
- package/dist/CypherEditor.js.map +0 -1
- package/dist/CypherEditor.test.js.map +0 -1
- package/dist/constants.js.map +0 -1
- package/dist/e2e_tests/autoCompletion.spec.js.map +0 -1
- package/dist/e2e_tests/configuration.spec.js.map +0 -1
- package/dist/e2e_tests/debounce.spec.js.map +0 -1
- package/dist/e2e_tests/e2eUtils.js.map +0 -1
- package/dist/e2e_tests/extraKeybindings.spec.js.map +0 -1
- package/dist/e2e_tests/historyNavigation.spec.js.map +0 -1
- package/dist/e2e_tests/performanceTest.spec.js.map +0 -1
- package/dist/e2e_tests/sanityChecks.spec.js.map +0 -1
- package/dist/e2e_tests/signatureHelp.spec.js.map +0 -1
- package/dist/e2e_tests/snippets.spec.js.map +0 -1
- package/dist/e2e_tests/syntaxHighlighting.spec.js.map +0 -1
- package/dist/e2e_tests/syntaxValidation.spec.js.map +0 -1
- package/dist/historyNavigation.js.map +0 -1
- package/dist/icons.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lang-cypher/autocomplete.js.map +0 -1
- package/dist/lang-cypher/constants.js.map +0 -1
- package/dist/lang-cypher/contants.test.js.map +0 -1
- package/dist/lang-cypher/createCypherTheme.js.map +0 -1
- package/dist/lang-cypher/langCypher.js.map +0 -1
- package/dist/lang-cypher/lintWorker.d.ts +0 -12
- package/dist/lang-cypher/lintWorker.js +0 -14
- package/dist/lang-cypher/lintWorker.js.map +0 -1
- package/dist/lang-cypher/parser-adapter.js.map +0 -1
- package/dist/lang-cypher/signatureHelp.js.map +0 -1
- package/dist/lang-cypher/syntaxValidation.js.map +0 -1
- package/dist/lang-cypher/themeIcons.js.map +0 -1
- package/dist/lang-cypher/utils.js.map +0 -1
- package/dist/ndlTokensCopy.js.map +0 -1
- package/dist/ndlTokensCopy.test.js.map +0 -1
- package/dist/neo4jSetup.js.map +0 -1
- package/dist/themes.js.map +0 -1
- package/src/lang-cypher/lintWorker.ts +0 -31
- /package/dist/{CypherEditor.test.d.ts → src/CypherEditor.test.d.ts} +0 -0
- /package/dist/{constants.d.ts → src/constants.d.ts} +0 -0
- /package/dist/{constants.js → src/constants.js} +0 -0
- /package/dist/{e2e_tests → src/e2e_tests}/autoCompletion.spec.d.ts +0 -0
- /package/dist/{e2e_tests → src/e2e_tests}/configuration.spec.d.ts +0 -0
- /package/dist/{e2e_tests → src/e2e_tests}/configuration.spec.js +0 -0
- /package/dist/{e2e_tests → src/e2e_tests}/debounce.spec.d.ts +0 -0
- /package/dist/{e2e_tests → src/e2e_tests}/debounce.spec.js +0 -0
- /package/dist/{e2e_tests → src/e2e_tests}/extraKeybindings.spec.d.ts +0 -0
- /package/dist/{e2e_tests → src/e2e_tests}/extraKeybindings.spec.js +0 -0
- /package/dist/{e2e_tests → src/e2e_tests}/historyNavigation.spec.d.ts +0 -0
- /package/dist/{e2e_tests → src/e2e_tests}/historyNavigation.spec.js +0 -0
- /package/dist/{e2e_tests → src/e2e_tests}/performanceTest.spec.d.ts +0 -0
- /package/dist/{e2e_tests → src/e2e_tests}/sanityChecks.spec.d.ts +0 -0
- /package/dist/{e2e_tests → src/e2e_tests}/sanityChecks.spec.js +0 -0
- /package/dist/{e2e_tests → src/e2e_tests}/signatureHelp.spec.d.ts +0 -0
- /package/dist/{e2e_tests → src/e2e_tests}/snippets.spec.d.ts +0 -0
- /package/dist/{e2e_tests → src/e2e_tests}/snippets.spec.js +0 -0
- /package/dist/{e2e_tests → src/e2e_tests}/syntaxHighlighting.spec.d.ts +0 -0
- /package/dist/{e2e_tests → src/e2e_tests}/syntaxHighlighting.spec.js +0 -0
- /package/dist/{e2e_tests → src/e2e_tests}/syntaxValidation.spec.d.ts +0 -0
- /package/dist/{historyNavigation.d.ts → src/historyNavigation.d.ts} +0 -0
- /package/dist/{historyNavigation.js → src/historyNavigation.js} +0 -0
- /package/dist/{icons.d.ts → src/icons.d.ts} +0 -0
- /package/dist/{icons.js → src/icons.js} +0 -0
- /package/dist/{index.d.ts → src/index.d.ts} +0 -0
- /package/dist/{index.js → src/index.js} +0 -0
- /package/dist/{lang-cypher → src/lang-cypher}/autocomplete.d.ts +0 -0
- /package/dist/{lang-cypher → src/lang-cypher}/autocomplete.js +0 -0
- /package/dist/{lang-cypher → src/lang-cypher}/constants.d.ts +0 -0
- /package/dist/{lang-cypher → src/lang-cypher}/constants.js +0 -0
- /package/dist/{lang-cypher → src/lang-cypher}/contants.test.d.ts +0 -0
- /package/dist/{lang-cypher → src/lang-cypher}/contants.test.js +0 -0
- /package/dist/{lang-cypher → src/lang-cypher}/createCypherTheme.d.ts +0 -0
- /package/dist/{lang-cypher → src/lang-cypher}/langCypher.js +0 -0
- /package/dist/{lang-cypher → src/lang-cypher}/parser-adapter.d.ts +0 -0
- /package/dist/{lang-cypher → src/lang-cypher}/parser-adapter.js +0 -0
- /package/dist/{lang-cypher → src/lang-cypher}/signatureHelp.d.ts +0 -0
- /package/dist/{lang-cypher → src/lang-cypher}/signatureHelp.js +0 -0
- /package/dist/{lang-cypher → src/lang-cypher}/syntaxValidation.d.ts +0 -0
- /package/dist/{lang-cypher → src/lang-cypher}/themeIcons.d.ts +0 -0
- /package/dist/{lang-cypher → src/lang-cypher}/themeIcons.js +0 -0
- /package/dist/{lang-cypher → src/lang-cypher}/utils.d.ts +0 -0
- /package/dist/{lang-cypher → src/lang-cypher}/utils.js +0 -0
- /package/dist/{ndlTokensCopy.d.ts → src/ndlTokensCopy.d.ts} +0 -0
- /package/dist/{ndlTokensCopy.js → src/ndlTokensCopy.js} +0 -0
- /package/dist/{ndlTokensCopy.test.d.ts → src/ndlTokensCopy.test.d.ts} +0 -0
- /package/dist/{ndlTokensCopy.test.js → src/ndlTokensCopy.test.js} +0 -0
- /package/dist/{neo4jSetup.d.ts → src/neo4jSetup.d.ts} +0 -0
- /package/dist/{neo4jSetup.js → src/neo4jSetup.js} +0 -0
- /package/dist/{themes.d.ts → src/themes.d.ts} +0 -0
- /package/dist/{themes.js → src/themes.js} +0 -0
package/src/CypherEditor.tsx
CHANGED
|
@@ -15,7 +15,6 @@ import {
|
|
|
15
15
|
} from '@codemirror/view';
|
|
16
16
|
import {
|
|
17
17
|
formatQuery,
|
|
18
|
-
_internalFeatureFlags,
|
|
19
18
|
type DbSchema,
|
|
20
19
|
} from '@neo4j-cypher/language-support';
|
|
21
20
|
import debounce from 'lodash.debounce';
|
|
@@ -103,7 +102,6 @@ export interface CypherEditorProps {
|
|
|
103
102
|
*/
|
|
104
103
|
featureFlags?: {
|
|
105
104
|
consoleCommands?: boolean;
|
|
106
|
-
cypher25?: boolean;
|
|
107
105
|
};
|
|
108
106
|
/**
|
|
109
107
|
* The schema to use for autocompletion and linting.
|
|
@@ -183,12 +181,12 @@ export interface CypherEditorProps {
|
|
|
183
181
|
const format = (view: EditorView): void => {
|
|
184
182
|
try {
|
|
185
183
|
const doc = view.state.doc.toString();
|
|
186
|
-
const {
|
|
184
|
+
const { formattedQuery, newCursorPos } = formatQuery(doc, { cursorPosition: view.state.selection.main.anchor });
|
|
187
185
|
view.dispatch({
|
|
188
186
|
changes: {
|
|
189
187
|
from: 0,
|
|
190
188
|
to: doc.length,
|
|
191
|
-
insert:
|
|
189
|
+
insert: formattedQuery,
|
|
192
190
|
},
|
|
193
191
|
selection: { anchor: newCursorPos },
|
|
194
192
|
});
|
|
@@ -325,13 +323,17 @@ export class CypherEditor extends Component<
|
|
|
325
323
|
*/
|
|
326
324
|
setValueAndFocus(value = '') {
|
|
327
325
|
const currentCmValue = this.editorView.current.state?.doc.toString() ?? '';
|
|
326
|
+
// Normalize line endings to LF that CM expects.
|
|
327
|
+
// Prevents issues with inserted values that contain CRLF line endings.
|
|
328
|
+
// https://codemirror.net/docs/ref/?utm_source=chatgpt.com#state.EditorState^lineSeparator
|
|
329
|
+
const normalizedValue = value.replace(/\r\n/g, '\n');
|
|
328
330
|
this.editorView.current.dispatch({
|
|
329
331
|
changes: {
|
|
330
332
|
from: 0,
|
|
331
333
|
to: currentCmValue.length,
|
|
332
|
-
insert:
|
|
334
|
+
insert: normalizedValue,
|
|
333
335
|
},
|
|
334
|
-
selection: { anchor:
|
|
336
|
+
selection: { anchor: normalizedValue.length, head: normalizedValue.length },
|
|
335
337
|
});
|
|
336
338
|
this.editorView.current?.focus();
|
|
337
339
|
}
|
|
@@ -352,11 +354,11 @@ export class CypherEditor extends Component<
|
|
|
352
354
|
|
|
353
355
|
private debouncedOnChange = this.props.onChange
|
|
354
356
|
? debounce(
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
357
|
+
((value, viewUpdate) => {
|
|
358
|
+
this.props.onChange(value, viewUpdate);
|
|
359
|
+
}) satisfies CypherEditorProps['onChange'],
|
|
360
|
+
DEBOUNCE_TIME,
|
|
361
|
+
)
|
|
360
362
|
: undefined;
|
|
361
363
|
|
|
362
364
|
componentDidMount(): void {
|
|
@@ -373,8 +375,6 @@ export class CypherEditor extends Component<
|
|
|
373
375
|
newLineOnEnter,
|
|
374
376
|
} = this.props;
|
|
375
377
|
|
|
376
|
-
_internalFeatureFlags.cypher25 = featureFlags?.cypher25 ?? false;
|
|
377
|
-
|
|
378
378
|
this.schemaRef.current = {
|
|
379
379
|
schema,
|
|
380
380
|
lint,
|
|
@@ -398,20 +398,20 @@ export class CypherEditor extends Component<
|
|
|
398
398
|
|
|
399
399
|
const changeListener = this.debouncedOnChange
|
|
400
400
|
? [
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
401
|
+
EditorView.updateListener.of((upt: ViewUpdate) => {
|
|
402
|
+
const wasUserEdit = !upt.transactions.some((tr) =>
|
|
403
|
+
tr.annotation(ExternalEdit),
|
|
404
|
+
);
|
|
405
|
+
|
|
406
|
+
if (upt.docChanged && wasUserEdit) {
|
|
407
|
+
const doc = upt.state.doc;
|
|
408
|
+
const value = doc.toString();
|
|
409
|
+
this.debouncedOnChange(value, upt);
|
|
410
|
+
}
|
|
411
|
+
}),
|
|
412
|
+
]
|
|
413
413
|
: [];
|
|
414
|
-
|
|
414
|
+
|
|
415
415
|
this.editorState.current = EditorState.create({
|
|
416
416
|
extensions: [
|
|
417
417
|
keyBindingCompartment.of(
|
|
@@ -445,8 +445,8 @@ export class CypherEditor extends Component<
|
|
|
445
445
|
),
|
|
446
446
|
this.props.ariaLabel
|
|
447
447
|
? EditorView.contentAttributes.of({
|
|
448
|
-
|
|
449
|
-
|
|
448
|
+
'aria-label': this.props.ariaLabel,
|
|
449
|
+
})
|
|
450
450
|
: [],
|
|
451
451
|
],
|
|
452
452
|
doc: this.props.value,
|
|
@@ -494,7 +494,7 @@ export class CypherEditor extends Component<
|
|
|
494
494
|
const didChangeTheme =
|
|
495
495
|
prevProps.theme !== this.props.theme ||
|
|
496
496
|
prevProps.overrideThemeBackgroundColor !==
|
|
497
|
-
|
|
497
|
+
this.props.overrideThemeBackgroundColor;
|
|
498
498
|
|
|
499
499
|
if (didChangeTheme) {
|
|
500
500
|
this.editorView.current.dispatch({
|
|
@@ -526,7 +526,6 @@ test('completions depend on the Cypher version', async ({ page, mount }) => {
|
|
|
526
526
|
},
|
|
527
527
|
},
|
|
528
528
|
}}
|
|
529
|
-
featureFlags={{ cypher25: true }}
|
|
530
529
|
/>,
|
|
531
530
|
);
|
|
532
531
|
|
|
@@ -544,3 +543,29 @@ test('completions depend on the Cypher version', async ({ page, mount }) => {
|
|
|
544
543
|
page.locator('.cm-tooltip-autocomplete').getByText('cypher25Function'),
|
|
545
544
|
).toBeVisible();
|
|
546
545
|
});
|
|
546
|
+
|
|
547
|
+
test('does not complete properties for non node / relationship variables', async ({ page, mount }) => {
|
|
548
|
+
await mount(
|
|
549
|
+
<CypherEditor
|
|
550
|
+
schema={{
|
|
551
|
+
propertyKeys: ["nodeProperty"]
|
|
552
|
+
}}
|
|
553
|
+
/>
|
|
554
|
+
);
|
|
555
|
+
|
|
556
|
+
const textField = page.getByRole('textbox');
|
|
557
|
+
await textField.fill('MATCH (n) RETURN n.');
|
|
558
|
+
|
|
559
|
+
await expect(
|
|
560
|
+
page.locator('.cm-tooltip-autocomplete').getByText('nodeProperty'),
|
|
561
|
+
).toBeVisible();
|
|
562
|
+
|
|
563
|
+
await textField.fill('WITH 1 AS x RETURN x.');
|
|
564
|
+
// This could be flaky if the semantic analysis takes too long
|
|
565
|
+
await page.waitForTimeout(500)
|
|
566
|
+
await textField.press('Escape');
|
|
567
|
+
await textField.press('Control+ ');
|
|
568
|
+
await expect(
|
|
569
|
+
page.locator('.cm-tooltip-autocomplete').getByText('nodeProperty')
|
|
570
|
+
).not.toBeVisible();
|
|
571
|
+
});
|
|
@@ -82,16 +82,32 @@ export class CypherEditorPage {
|
|
|
82
82
|
await expect(this.page.locator('.cm-tooltip-hover').last()).toBeVisible({
|
|
83
83
|
timeout: 10000,
|
|
84
84
|
});
|
|
85
|
-
await
|
|
85
|
+
await this.checkHoverMessage(expectedMsg, type);
|
|
86
86
|
/* Return the mouse to the beginning of the query and
|
|
87
87
|
This is because if for example we have an overlay with a
|
|
88
88
|
first interaction that covers the element we want to perform
|
|
89
89
|
the second interaction on, we won't be able to see that second element
|
|
90
90
|
*/
|
|
91
91
|
await this.page.mouse.move(0, 0);
|
|
92
|
-
// Make
|
|
92
|
+
// Make sure the tooltip closed
|
|
93
93
|
await expect(
|
|
94
94
|
this.page.locator('.cm-tooltip-hover').last(),
|
|
95
95
|
).not.toBeVisible();
|
|
96
96
|
}
|
|
97
|
+
|
|
98
|
+
private async checkHoverMessage(
|
|
99
|
+
expectedMsg: string,
|
|
100
|
+
type: 'error' | 'warning',
|
|
101
|
+
) {
|
|
102
|
+
const locator =
|
|
103
|
+
type === 'error'
|
|
104
|
+
? 'li.cm-diagnostic.cm-diagnostic-error'
|
|
105
|
+
: 'li.cm-diagnostic.cm-diagnostic-warning';
|
|
106
|
+
const tooltips = await this.page.locator(locator).all();
|
|
107
|
+
|
|
108
|
+
const tooltipTexts = await Promise.all(
|
|
109
|
+
tooltips.map((t) => t.textContent()),
|
|
110
|
+
);
|
|
111
|
+
expect(tooltipTexts).toContain(expectedMsg);
|
|
112
|
+
}
|
|
97
113
|
}
|
|
@@ -100,7 +100,7 @@ test('benchmarking & performance test session', async ({
|
|
|
100
100
|
|
|
101
101
|
await editorPage.checkErrorMessage(
|
|
102
102
|
'RETRN',
|
|
103
|
-
`Invalid input 'RETRN': expected a graph pattern, '
|
|
103
|
+
`Invalid input 'RETRN': expected a graph pattern, ',', 'ORDER BY', 'CALL', 'CREATE', 'LOAD CSV', 'DELETE', 'DETACH', 'FINISH', 'FOREACH', 'INSERT', 'LIMIT', 'MATCH', 'MERGE', 'NODETACH', 'OFFSET', 'OPTIONAL', 'REMOVE', 'RETURN', 'SET', 'SKIP', 'UNION', 'UNWIND', 'USE', 'USING', 'WHERE', 'WITH' or <EOF>`,
|
|
104
104
|
);
|
|
105
105
|
|
|
106
106
|
await editorPage
|
|
@@ -33,7 +33,7 @@ test('Can turn linting back on', async ({ page, mount }) => {
|
|
|
33
33
|
|
|
34
34
|
await editorPage.checkErrorMessage(
|
|
35
35
|
'METCH',
|
|
36
|
-
`Invalid input 'METCH': expected '
|
|
36
|
+
`Invalid input 'METCH': expected 'ALTER', 'ORDER BY', 'CALL', 'USING PERIODIC COMMIT', 'CREATE', 'LOAD CSV', 'START DATABASE', 'STOP DATABASE', 'DEALLOCATE', 'DELETE', 'DENY', 'DETACH', 'DROP', 'DRYRUN', 'FINISH', 'FOREACH', 'GRANT', 'INSERT', 'LIMIT', 'MATCH', 'MERGE', 'NODETACH', 'OFFSET', 'OPTIONAL', 'REALLOCATE', 'REMOVE', 'RENAME', 'RETURN', 'REVOKE', 'ENABLE SERVER', 'SET', 'SHOW', 'SKIP', 'TERMINATE', 'UNWIND', 'USE' or 'WITH'`,
|
|
37
37
|
);
|
|
38
38
|
});
|
|
39
39
|
|
|
@@ -45,7 +45,7 @@ test('Syntactic errors are surfaced', async ({ page, mount }) => {
|
|
|
45
45
|
|
|
46
46
|
await editorPage.checkErrorMessage(
|
|
47
47
|
'METCH',
|
|
48
|
-
`Invalid input 'METCH': expected '
|
|
48
|
+
`Invalid input 'METCH': expected 'ALTER', 'ORDER BY', 'CALL', 'USING PERIODIC COMMIT', 'CREATE', 'LOAD CSV', 'START DATABASE', 'STOP DATABASE', 'DEALLOCATE', 'DELETE', 'DENY', 'DETACH', 'DROP', 'DRYRUN', 'FINISH', 'FOREACH', 'GRANT', 'INSERT', 'LIMIT', 'MATCH', 'MERGE', 'NODETACH', 'OFFSET', 'OPTIONAL', 'REALLOCATE', 'REMOVE', 'RENAME', 'RETURN', 'REVOKE', 'ENABLE SERVER', 'SET', 'SHOW', 'SKIP', 'TERMINATE', 'UNWIND', 'USE' or 'WITH'`,
|
|
49
49
|
);
|
|
50
50
|
});
|
|
51
51
|
|
|
@@ -138,7 +138,7 @@ test('Semantic errors are correctly accumulated', async ({ page, mount }) => {
|
|
|
138
138
|
|
|
139
139
|
await editorPage.checkErrorMessage(
|
|
140
140
|
'-1',
|
|
141
|
-
"Invalid input. '-1' is not a valid value. Must be a positive integer",
|
|
141
|
+
"Invalid input. '-1' is not a valid value. Must be a positive integer.",
|
|
142
142
|
);
|
|
143
143
|
});
|
|
144
144
|
|
|
@@ -153,12 +153,12 @@ test('Multiline errors are correctly placed', async ({ page, mount }) => {
|
|
|
153
153
|
|
|
154
154
|
await editorPage.checkErrorMessage(
|
|
155
155
|
'MATCH (n)',
|
|
156
|
-
'Query cannot conclude with MATCH (must be a RETURN clause, a FINISH clause, an update clause, a unit subquery call, or a procedure call with no YIELD)',
|
|
156
|
+
'Query cannot conclude with MATCH (must be a RETURN clause, a FINISH clause, an update clause, a unit subquery call, or a procedure call with no YIELD).',
|
|
157
157
|
);
|
|
158
158
|
|
|
159
159
|
await editorPage.checkErrorMessage(
|
|
160
160
|
'-1',
|
|
161
|
-
"Invalid input. '-1' is not a valid value. Must be a positive integer",
|
|
161
|
+
"Invalid input. '-1' is not a valid value. Must be a positive integer.",
|
|
162
162
|
);
|
|
163
163
|
});
|
|
164
164
|
|
|
@@ -178,10 +178,27 @@ test('Validation errors are correctly overlapped', async ({ page, mount }) => {
|
|
|
178
178
|
|
|
179
179
|
await editorPage.checkErrorMessage(
|
|
180
180
|
'-1',
|
|
181
|
-
"Invalid input. '-1' is not a valid value. Must be a positive integer",
|
|
181
|
+
"Invalid input. '-1' is not a valid value. Must be a positive integer.",
|
|
182
182
|
);
|
|
183
183
|
});
|
|
184
184
|
|
|
185
|
+
test('Syntax highlighting works as expected with multiple separate linting messages', async ( {
|
|
186
|
+
page,
|
|
187
|
+
mount
|
|
188
|
+
}) => {
|
|
189
|
+
const editorPage = new CypherEditorPage(page);
|
|
190
|
+
const query = `MATCH (n)--(m) CALL (n) {RETURN id(n) AS b} RETURN apoc.create.uuid(), a`;
|
|
191
|
+
|
|
192
|
+
await mount(<CypherEditor value={query} schema={testData.mockSchema} />);
|
|
193
|
+
await expect(
|
|
194
|
+
editorPage.page.locator('.cm-deprecated-element').last(),
|
|
195
|
+
).toBeVisible({ timeout: 10000 });
|
|
196
|
+
await editorPage.checkWarningMessage('id', 'Function id is deprecated.');
|
|
197
|
+
await editorPage.checkWarningMessage('id', `The query used a deprecated function. ('id' has been replaced by 'elementId or consider using an application-generated id')`);
|
|
198
|
+
await editorPage.checkWarningMessage('apoc.create.uuid', 'Function apoc.create.uuid is deprecated. Alternative: Neo4j randomUUID() function');
|
|
199
|
+
await editorPage.checkErrorMessage('a', 'Variable `a` not defined');
|
|
200
|
+
})
|
|
201
|
+
|
|
185
202
|
test('Strikethroughs are shown for deprecated functions', async ({
|
|
186
203
|
page,
|
|
187
204
|
mount,
|
|
@@ -194,6 +211,7 @@ test('Strikethroughs are shown for deprecated functions', async ({
|
|
|
194
211
|
editorPage.page.locator('.cm-deprecated-element').last(),
|
|
195
212
|
).toBeVisible({ timeout: 10000 });
|
|
196
213
|
await editorPage.checkWarningMessage('id', 'Function id is deprecated.');
|
|
214
|
+
await editorPage.checkErrorMessage('id', `Insufficient parameters for function 'id'`);
|
|
197
215
|
});
|
|
198
216
|
|
|
199
217
|
test('Strikethroughs are shown for deprecated procedures', async ({
|
|
@@ -210,7 +228,7 @@ test('Strikethroughs are shown for deprecated procedures', async ({
|
|
|
210
228
|
|
|
211
229
|
await editorPage.checkWarningMessage(
|
|
212
230
|
'apoc.create.uuids',
|
|
213
|
-
|
|
231
|
+
"Procedure apoc.create.uuids is deprecated. Alternative: Neo4j's randomUUID() function can be used as a replacement, for example: `UNWIND range(0,$count) AS row RETURN row, randomUUID() AS uuid`",
|
|
214
232
|
);
|
|
215
233
|
});
|
|
216
234
|
|
|
@@ -221,7 +239,6 @@ test('Syntax validation depends on the Cypher version', async ({
|
|
|
221
239
|
await mount(
|
|
222
240
|
<CypherEditor
|
|
223
241
|
schema={testData.mockSchema}
|
|
224
|
-
featureFlags={{ cypher25: true }}
|
|
225
242
|
/>,
|
|
226
243
|
);
|
|
227
244
|
|
|
@@ -231,13 +248,13 @@ test('Syntax validation depends on the Cypher version', async ({
|
|
|
231
248
|
|
|
232
249
|
await editorPage.checkWarningMessage(
|
|
233
250
|
'apoc.create.uuids',
|
|
234
|
-
|
|
251
|
+
"Procedure apoc.create.uuids is deprecated. Alternative: Neo4j's randomUUID() function can be used as a replacement, for example: `UNWIND range(0,$count) AS row RETURN row, randomUUID() AS uuid`",
|
|
235
252
|
);
|
|
236
253
|
|
|
237
254
|
await textField.fill('CYPHER 25 CALL apoc.create.uuids(5)');
|
|
238
255
|
|
|
239
256
|
await editorPage.checkErrorMessage(
|
|
240
257
|
'apoc.create.uuids',
|
|
241
|
-
|
|
258
|
+
`Procedure apoc.create.uuids is not present in the database. Make sure you didn't misspell it or that it is available when you run this statement in your application`,
|
|
242
259
|
);
|
|
243
260
|
});
|
|
@@ -91,6 +91,7 @@ export const createCypherTheme = ({
|
|
|
91
91
|
'& .cm-panels': {
|
|
92
92
|
backgroundColor: settings.searchPanel.background,
|
|
93
93
|
fontFamily: 'Fira Code, Menlo, Monaco, Lucida Console, monospace',
|
|
94
|
+
zIndex: 0,
|
|
94
95
|
},
|
|
95
96
|
'& .cm-completionLabel': {
|
|
96
97
|
fontFamily: 'Fira Code, Menlo, Monaco, Lucida Console, monospace',
|