Skip to content

Commit

Permalink
Adds tests for VSCode and Codemirror
Browse files Browse the repository at this point in the history
  • Loading branch information
ncordon committed Oct 17, 2023
1 parent 8927807 commit d86dd93
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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',
);
});
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down

0 comments on commit d86dd93

Please sign in to comment.