@@ -69,28 +69,20 @@ test.describe("File Operations", () => {
6969 // Expand to AppToRename
7070 await JavaOperator . expandTreePath ( page , "my-app" , "src/main/java" , "com.mycompany.app" ) ;
7171
72- // Select AppToRename and trigger rename via F2
72+ // Select AppToRename in the tree (clicking opens the file in editor,
73+ // which steals keyboard focus, so we use command palette for rename).
7374 const appToRename = page . getByRole ( VSCode . TREE_ITEM_ROLE , { name : "AppToRename" } ) . first ( ) ;
7475 await appToRename . click ( ) ;
7576 await page . waitForTimeout ( Timeout . CLICK ) ;
76- await page . keyboard . press ( "F2" ) ;
77- await page . waitForTimeout ( Timeout . CLICK ) ;
78-
79- // VS Code may show either a quick-input dialog or an inline rename editor.
80- // Try the inline rename input first (common in modern VS Code).
81- const inlineInput = page . locator ( ".monaco-inputbox input.rename-input" ) ;
82- const quickInput = page . locator ( ".quick-input-widget input.input" ) ;
83-
84- if ( await inlineInput . isVisible ( { timeout : 3_000 } ) . catch ( ( ) => false ) ) {
85- await inlineInput . fill ( "AppRenamed" ) ;
86- await inlineInput . press ( VSCode . ENTER ) ;
87- } else if ( await quickInput . isVisible ( { timeout : 3_000 } ) . catch ( ( ) => false ) ) {
88- await quickInput . fill ( "AppRenamed" ) ;
89- await quickInput . press ( VSCode . ENTER ) ;
90- }
9177
78+ // Invoke rename via command palette (keyboard F2 requires tree focus
79+ // but clicking the tree item shifts focus to the editor).
80+ await VscodeOperator . executeCommand ( page , "Java: Rename" ) ;
9281 await page . waitForTimeout ( Timeout . CLICK ) ;
9382
83+ // The extension shows a showInputBox (quick-input) for the new name
84+ await VscodeOperator . fillQuickInput ( page , "AppRenamed" ) ;
85+
9486 // Handle confirmation dialog if it appears
9587 try {
9688 await VscodeOperator . clickDialogButton ( page , "OK" , 5_000 ) ;
@@ -107,11 +99,13 @@ test.describe("File Operations", () => {
10799 await JavaOperator . collapseFileExplorer ( page ) ;
108100 await JavaOperator . expandTreePath ( page , "my-app" , "src/main/java" , "com.mycompany.app" ) ;
109101
110- // Select AppToDelete and press Delete key
102+ // Select AppToDelete (clicking opens the file, shifting focus to editor)
111103 const appToDelete = page . getByRole ( VSCode . TREE_ITEM_ROLE , { name : "AppToDelete" } ) . first ( ) ;
112104 await appToDelete . click ( ) ;
113105 await page . waitForTimeout ( Timeout . CLICK ) ;
114- await page . keyboard . press ( "Delete" ) ;
106+
107+ // Invoke delete via command palette (Delete key requires tree focus)
108+ await VscodeOperator . executeCommand ( page , "Java: Delete" ) ;
115109 await page . waitForTimeout ( Timeout . CLICK ) ;
116110
117111 // Confirm deletion in dialog
0 commit comments