From d86dd93bd247530140184b2e0ae0f8ce5721ce27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Cord=C3=B3n?= Date: Tue, 17 Oct 2023 11:13:02 +0200 Subject: [PATCH] Adds tests for VSCode and Codemirror --- .../e2e_tests/auto-completion.spec.ts | 32 +++++++++++++++++++ .../allShortestPaths-completion.cypher | 3 ++ .../e2e_tests/tests/auto-completion.spec.ts | 15 ++++++++- 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 packages/vscode-playground/e2e_tests/fixtures/allShortestPaths-completion.cypher diff --git a/packages/react-codemirror-experimental/e2e_tests/auto-completion.spec.ts b/packages/react-codemirror-experimental/e2e_tests/auto-completion.spec.ts index 69106f3de..7ff0273de 100644 --- a/packages/react-codemirror-experimental/e2e_tests/auto-completion.spec.ts +++ b/packages/react-codemirror-experimental/e2e_tests/auto-completion.spec.ts @@ -190,3 +190,35 @@ test('can complete parameters', async ({ page }) => { 'RETURN $parameter', ); }); + +test('completes allShortestPaths correctly', async ({ page }) => { + const editorPage = new CypherEditorPage(page); + + await editorPage.createEditor({ + value: '', + schema: { + labels: [], + relationshipTypes: [], + functionSignatures: {}, + procedureSignatures: {}, + aliasNames: [], + databaseNames: [], + parameters: { parameter: { type: 'string' } }, + propertyKeys: [], + }, + }); + + // The first query contains errors on purpose so the + // syntax errors get triggered before the auto-completion + await editorPage.getEditor().type('MATCH (n) REURN n; MATCH a'); + + await page + .locator('.cm-tooltip-autocomplete') + .getByText('allShortestPaths') + .click(); + await expect(page.locator('.cm-tooltip-autocomplete')).not.toBeVisible(); + + expect(await editorPage.getEditor().textContent()).toEqual( + 'MATCH (n) REURN n; RETURN allShortestPaths', + ); +}); diff --git a/packages/vscode-playground/e2e_tests/fixtures/allShortestPaths-completion.cypher b/packages/vscode-playground/e2e_tests/fixtures/allShortestPaths-completion.cypher new file mode 100644 index 000000000..081604fd2 --- /dev/null +++ b/packages/vscode-playground/e2e_tests/fixtures/allShortestPaths-completion.cypher @@ -0,0 +1,3 @@ +// The first query contains errors on purpose so the +// syntax errors get triggered before the auto-completion +MATCH (n) REURN n; MATCH a \ No newline at end of file diff --git a/packages/vscode-playground/e2e_tests/tests/auto-completion.spec.ts b/packages/vscode-playground/e2e_tests/tests/auto-completion.spec.ts index 7b9f9c490..983029aee 100644 --- a/packages/vscode-playground/e2e_tests/tests/auto-completion.spec.ts +++ b/packages/vscode-playground/e2e_tests/tests/auto-completion.spec.ts @@ -38,8 +38,21 @@ export async function testCompletionContains({ } suite('Auto completion spec', () => { + test('Completes allShortestPaths ', async () => { + const position = new vscode.Position(0, 28); + + const expected: vscode.CompletionItem[] = [ + { label: 'allShortestPaths', kind: vscode.CompletionItemKind.Keyword }, + ]; + await testCompletionContains({ + textFile: 'allShortestPaths-completion.cypher', + position: position, + expected: expected, + }); + }); + test('Completes MATCH clause with WHERE, CREATE, etc', async () => { - const position = new vscode.Position(0, 10); + const position = new vscode.Position(2, 10); const expected: vscode.CompletionItem[] = [ { label: 'WHERE', kind: vscode.CompletionItemKind.Keyword },