Skip to content

Commit ae2b944

Browse files
committed
WIP debug state
1 parent 71a081d commit ae2b944

File tree

5 files changed

+63
-29
lines changed

5 files changed

+63
-29
lines changed

packages/vscode-extension/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@
337337
"clean": "rm -rf dist",
338338
"test:e2e": "npm run build:dev && npm run test:apiAndUnit && npm run test:webviews",
339339
"test:apiAndUnit": "npm run build:dev && rm -rf .vscode-test/user-data && node ./dist/tests/runApiAndUnitTests.js",
340-
"test:webviews": "wdio run ./dist/tests/runWebviewTests.js"
340+
"test:webviews": "npm run build:dev && wdio run ./dist/tests/runWebviewTests.js"
341341
},
342342
"dependencies": {
343343
"@neo4j-cypher/language-server": "2.0.0-next.17",

packages/vscode-extension/tests/specs/api/syntaxValidation.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export async function testSyntaxValidation({
6969
);
7070
}
7171

72-
suite.only('Syntax validation spec', () => {
72+
suite('Syntax validation spec', () => {
7373
afterEach(async () => {
7474
await toggleLinting(true);
7575
});

packages/vscode-extension/tests/specs/webviews/connection.spec.ts

+16-17
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ import * as os from 'os';
44
import { ViewSection, Workbench } from 'wdio-vscode-service';
55
import { CONSTANTS } from '../../../src/constants';
66
import {
7-
clickOnConnectionItem,
7+
clickOnContextMenuItem,
88
closeActiveTab,
99
getConnectionSection,
1010
openFixtureFile,
11-
selectConnectionItem,
1211
setText,
1312
waitUntilNotification,
1413
} from '../../webviewUtils';
@@ -26,40 +25,40 @@ suite('Connection testing', () => {
2625
if (os.platform() === 'darwin') {
2726
this.skip();
2827
}
29-
await clickOnConnectionItem(connectionSection, 'Disconnect', 1);
28+
await clickOnContextMenuItem(connectionSection, 'Disconnect', 1);
3029
await waitUntilNotification(browser, 'Disconnected from Neo4j.');
3130
});
3231

3332
test('should connect to neo4j gracefully', async function () {
3433
if (os.platform() === 'darwin') {
3534
this.skip();
3635
}
37-
await clickOnConnectionItem(connectionSection, 'Connect', 1);
36+
await clickOnContextMenuItem(connectionSection, 'Connect', 1);
3837
await waitUntilNotification(browser, 'Connected to Neo4j.');
3938
});
4039

41-
test('should connect when selecting new connection', async function () {
42-
await selectConnectionItem(connectionSection, 1);
43-
await waitUntilNotification(browser, 'Connected to Neo4j.');
44-
});
40+
// test('should connect when selecting new connection', async function () {
41+
// await selectConnectionItem(connectionSection, 1);
42+
// await waitUntilNotification(browser, 'Connected to Neo4j.');
43+
// });
4544

46-
test('should expand connectionItems when selecting connected connection', async function () {
47-
await selectConnectionItem(connectionSection, 1);
48-
await waitUntilNotification(browser, 'Connected to Neo4j.');
49-
await expect((await connectionSection.getVisibleItems()).length).toBe(2);
50-
await selectConnectionItem(connectionSection, 1);
51-
await expect((await connectionSection.getVisibleItems()).length).toBe(4);
52-
});
45+
// test('should expand connectionItems when selecting connected connection', async function () {
46+
// await selectConnectionItem(connectionSection, 1);
47+
// await waitUntilNotification(browser, 'Connected to Neo4j.');
48+
// await expect((await connectionSection.getVisibleItems()).length).toBe(2);
49+
// await selectConnectionItem(connectionSection, 1);
50+
// await expect((await connectionSection.getVisibleItems()).length).toBe(4);
51+
// });
5352

5453
test('should be able to connect to another instance', async function () {
5554
if (os.platform() === 'darwin') {
5655
this.skip();
5756
}
58-
await clickOnConnectionItem(connectionSection, 'Connect', 0);
57+
await clickOnContextMenuItem(connectionSection, 'Connect', 0);
5958
await waitUntilNotification(browser, 'Connected to Neo4j.');
6059

6160
// Reconnect to the original instance
62-
await clickOnConnectionItem(connectionSection, 'Connect', 1);
61+
await clickOnContextMenuItem(connectionSection, 'Connect', 1);
6362
await waitUntilNotification(browser, 'Connected to Neo4j.');
6463
});
6564

packages/vscode-extension/tests/specs/webviews/queryExecution.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as os from 'os';
44
import { ViewSection, Workbench } from 'wdio-vscode-service';
55
import { CONSTANTS } from '../../../src/constants';
66
import {
7-
clickOnConnectionItem,
7+
clickOnContextMenuItem,
88
getConnectionSection,
99
openFixtureFile,
1010
waitUntilNotification,
@@ -95,7 +95,7 @@ suite('Query results testing', () => {
9595

9696
// Disconnect from the current instance
9797
// Connect to an empty one, the results should be empty
98-
await clickOnConnectionItem(connectionSection, 'Connect', 0);
98+
await clickOnContextMenuItem(connectionSection, 'Connect', 0);
9999
await waitUntilNotification(browser, 'Connected to Neo4j.');
100100

101101
await executeFile('match-for-create.cypher');
@@ -105,7 +105,7 @@ suite('Query results testing', () => {
105105
});
106106

107107
// Reconnect to the original instance
108-
await clickOnConnectionItem(connectionSection, 'Connect', 1);
108+
await clickOnContextMenuItem(connectionSection, 'Connect', 1);
109109
await waitUntilNotification(browser, 'Connected to Neo4j.');
110110
});
111111
});

packages/vscode-extension/tests/webviewUtils.ts

+42-7
Original file line numberDiff line numberDiff line change
@@ -127,23 +127,58 @@ export async function selectConnectionItem(
127127
connectionSection: ViewSection,
128128
connectionIndex: integer,
129129
): Promise<void> {
130-
const items = (await connectionSection.getVisibleItems()).filter(
131-
async (i) => !(await i.parent),
132-
);
130+
const items = await connectionSection.getVisibleItems();
131+
const filteredItems = (
132+
await Promise.all(
133+
items.map(async (i) => ({ item: i, hasParent: await i.parent })),
134+
)
135+
)
136+
.filter(({ hasParent }) => !hasParent)
137+
.map(({ item }) => item);
138+
139+
await expect(filteredItems.length).toBeGreaterThan(connectionIndex);
140+
const connectionItem = filteredItems.at(connectionIndex) as TreeItem;
141+
await connectionItem.select();
142+
}
143+
144+
export async function clickOnContextMenuItem(
145+
connectionSection: ViewSection,
146+
item: string,
147+
connectionIndex: number,
148+
): Promise<void> {
149+
const items = await connectionSection.getVisibleItems();
133150

134151
await expect(items.length).toBeGreaterThan(connectionIndex);
135152
const connectionItem = items.at(connectionIndex) as TreeItem;
136-
await connectionItem.select();
153+
154+
// This context menu does not work in OSX because it's a native element rather
155+
// than a browser, so we get errors of the sort of
156+
// element (".monaco-menu-container") still not displayed after 5000ms
157+
//
158+
// https://github.com/webdriverio-community/wdio-vscode-service/issues/57
159+
const contextMenu = await connectionItem.openContextMenu();
160+
const menuItems = await contextMenu.getItems();
161+
const connect = menuItems.find(async (menuItem) => {
162+
const menuText = await menuItem.elem.getText();
163+
return menuText === item;
164+
});
165+
166+
if (connect) {
167+
const connectOption = await connect.elem;
168+
await connectOption.click();
169+
}
137170
}
138171

139172
export async function clickOnConnectionItem(
140173
connectionSection: ViewSection,
141174
item: string,
142175
connectionIndex: number,
143176
): Promise<void> {
144-
const items = (await connectionSection.getVisibleItems()).filter(
145-
async (i) => !(await i.parent),
146-
);
177+
// const items = await connectionSection.getVisibleItems();
178+
// const filteredItems = (await Promise.all(
179+
// items.map(async (i) => ({ item: i, hasParent: await i.parent }))
180+
// )).filter(({ hasParent }) => !hasParent).map(({ item }) => item);
181+
const items = await connectionSection.getVisibleItems();
147182

148183
await expect(items.length).toBeGreaterThan(connectionIndex);
149184
const connectionItem = items.at(connectionIndex) as TreeItem;

0 commit comments

Comments
 (0)