Skip to content

Commit d2aaddc

Browse files
committed
test: update
1 parent 8ed62cb commit d2aaddc

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

test/e2e/tests/projectExplorer.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ test.describe("Project Explorer", () => {
2828
});
2929

3030
test("javaProjectExplorer.focus shows Java Projects section", async ({ page }) => {
31-
await VscodeOperator.executeCommand(page, "javaProjectExplorer.focus");
32-
// The section should be visible
31+
// beforeEach already focuses Java Projects; verify the tree is populated
3332
const found = await VscodeOperator.waitForTreeItem(page, "my-app", 15_000);
3433
expect(found).toBeTruthy();
3534
});

test/e2e/utils/javaOperator.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,23 @@ export default class JavaOperator {
4747

4848
/**
4949
* Focuses the Java Projects view and waits for it to render.
50+
*
51+
* Directly clicks the "Java Projects Section" button in the Explorer
52+
* sidebar rather than going through the command palette, which may
53+
* fail to find the view-focus command by its ID.
5054
*/
5155
static async focusJavaProjects(page: Page): Promise<void> {
52-
await VscodeOperator.executeCommand(page, "javaProjectExplorer.focus");
53-
// Wait a moment for the section to render
56+
const sectionButton = page.getByRole(VSCode.BUTTON_ROLE, { name: /Java Projects Section/i });
57+
if (await sectionButton.isVisible({ timeout: 5_000 }).catch(() => false)) {
58+
// Only click to expand if the section is currently collapsed
59+
const expanded = await sectionButton.getAttribute("aria-expanded");
60+
if (expanded !== "true") {
61+
await sectionButton.click();
62+
}
63+
} else {
64+
// Fallback: try via command palette
65+
await VscodeOperator.executeCommand(page, "Java Projects: Focus on Java Projects View");
66+
}
5467
await page.waitForTimeout(Timeout.TREE_EXPAND);
5568
}
5669

0 commit comments

Comments
 (0)