Skip to content

Commit ef9da54

Browse files
committed
test: update
1 parent 1b98c6d commit ef9da54

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

test/e2e/utils/javaOperator.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,22 @@ export default class JavaOperator {
104104
}
105105

106106
/**
107-
* Opens a file in the editor via VS Code command.
107+
* Opens a file in the editor via Quick Open (Ctrl+P).
108108
*/
109109
static async openFile(page: Page, filePath: string): Promise<void> {
110-
await VscodeOperator.executeCommand(page, "workbench.action.quickOpen");
111-
const input = await VscodeOperator.getQuickInput(page);
110+
// Use Ctrl+P directly instead of going through command palette
111+
await page.keyboard.press("Control+P");
112+
const input = page.locator(".quick-input-widget input.input");
113+
await input.waitFor({ state: "visible", timeout: 10_000 });
112114
await input.fill(filePath);
113115
await page.waitForTimeout(Timeout.CLICK);
114-
await input.press(VSCode.ENTER);
116+
// Wait for file matches to appear, then select the first one
117+
const firstMatch = page.locator(".quick-input-widget .quick-input-list .monaco-list-row").first();
118+
if (await firstMatch.isVisible({ timeout: 3_000 }).catch(() => false)) {
119+
await firstMatch.click();
120+
} else {
121+
await input.press(VSCode.ENTER);
122+
}
115123
await page.waitForTimeout(Timeout.TREE_EXPAND);
116124
}
117125

test/e2e/utils/vscodeOperator.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,38 @@ export default class VscodeOperator {
2222
*/
2323
static async executeCommand(page: Page, command: string): Promise<void> {
2424
await page.keyboard.press(VSCode.CMD_PALETTE_KEY);
25-
await page.waitForTimeout(Timeout.CLICK);
26-
const input = page.getByRole(VSCode.CMD_PALETTE_ROLE, { name: VSCode.CMD_PALETTE_INPUT_NAME });
25+
// Wait for the quick-input widget to appear
26+
const input = page.locator(".quick-input-widget input.input");
27+
await input.waitFor({ state: "visible", timeout: 10_000 });
2728
await input.fill(command);
2829
await page.waitForTimeout(Timeout.CLICK);
29-
// Press Enter on the first matching option
30-
await page.getByRole(VSCode.LISTBOX_ROLE).first().press(VSCode.ENTER);
30+
// Press Enter on the first matching option in the list
31+
const firstOption = page.locator(".quick-input-widget .quick-input-list .monaco-list-row").first();
32+
if (await firstOption.isVisible({ timeout: 3_000 }).catch(() => false)) {
33+
await firstOption.click();
34+
} else {
35+
await input.press(VSCode.ENTER);
36+
}
3137
await page.waitForTimeout(Timeout.CLICK);
3238
}
3339

3440
/**
3541
* Select a quick-pick option by its visible label text.
3642
*/
3743
static async selectQuickPickItem(page: Page, label: string): Promise<void> {
38-
await page.getByRole(VSCode.OPTION_ROLE, { name: label }).locator(VSCode.LINK).click();
44+
const option = page.locator(".quick-input-widget .quick-input-list .monaco-list-row", { hasText: label });
45+
await option.first().waitFor({ state: "visible", timeout: 10_000 });
46+
await option.first().click();
3947
await page.waitForTimeout(Timeout.CLICK);
4048
}
4149

4250
/**
4351
* Select a quick-pick option by its zero-based index.
4452
*/
4553
static async selectQuickPickIndex(page: Page, index: number): Promise<void> {
46-
await page.getByRole(VSCode.OPTION_ROLE).nth(index).locator(VSCode.LINK).click();
54+
const option = page.locator(".quick-input-widget .quick-input-list .monaco-list-row").nth(index);
55+
await option.waitFor({ state: "visible", timeout: 10_000 });
56+
await option.click();
4757
await page.waitForTimeout(Timeout.CLICK);
4858
}
4959

0 commit comments

Comments
 (0)