@@ -86,6 +86,7 @@ export class FolderRenamePageUtil {
8686
8787 // Re-check for the renamed folder after reload
8888 const newFolderAfterReload = this . page . locator ( '.folder .name' , { hasText : newName } ) ;
89+
8990 await expect ( newFolderAfterReload ) . toBeVisible ( { timeout : 10000 } ) ;
9091 }
9192
@@ -104,117 +105,16 @@ export class FolderRenamePageUtil {
104105 await this . folderRenamePage . clickRenameMenuItem ( folderName ) ;
105106 await this . folderRenamePage . clearNewName ( ) ;
106107
107- await this . folderRenamePage . clickConfirm ( ) ;
108+ // NEW ASSERTION: The confirm button should be disabled when the input is empty.
109+ await expect ( this . folderRenamePage . confirmButton ) . toBeDisabled ( { timeout : 5000 } ) ;
110+
111+ // Clean up: Click cancel to close the modal after verifying validation.
112+ await this . folderRenamePage . clickCancel ( ) ;
113+ await expect ( this . folderRenamePage . renameModal ) . not . toBeVisible ( { timeout : 5000 } ) ;
108114
109- // Strategy 1: Wait for immediate client-side validation indicators
110- let clientValidationFound = false ;
111- const clientValidationChecks = [
112- // Check for validation error message
113- async ( ) =>
114- // Use isVisible() to check without asserting, and catch if element is not found
115- await this . folderRenamePage . validationError . isVisible ( { timeout : 1000 } ) . catch ( ( ) => false ) ,
116- // Check if input shows validation state
117- async ( ) => {
118- // Check attribute value, and catch if element is not found
119- const ariaInvalid = await this . folderRenamePage . renameInput
120- . getAttribute ( 'aria-invalid' , { timeout : 1000 } )
121- . catch ( ( ) => null ) ;
122- return ariaInvalid === 'true' ;
123- } ,
124- // Check if rename button is disabled
125- async ( ) =>
126- // Use isDisabled() to check without asserting, and catch if element is not found
127- await this . folderRenamePage . confirmButton . isDisabled ( { timeout : 1000 } ) . catch ( ( ) => false ) ,
128- // Check input validity via CSS classes
129- async ( ) =>
130- // Evaluate the class directly, and catch if element is not found
131- await this . folderRenamePage . renameInput
132- . evaluate ( el => el . classList . contains ( 'invalid' ) || el . classList . contains ( 'error' ) , { timeout : 1000 } )
133- . catch ( ( ) => false )
134- ] ;
135-
136- for ( const check of clientValidationChecks ) {
137- if ( await check ( ) ) {
138- clientValidationFound = true ;
139- // Client-side validation working - empty name prevented
140- break ;
141- }
142- }
143-
144- if ( clientValidationFound ) {
145- // Client-side validation is working, modal should stay open
146- await expect ( this . folderRenamePage . renameModal ) . toBeVisible ( ) ;
147- await this . folderRenamePage . clickCancel ( ) ;
148- return ;
149- }
150-
151- // Strategy 2: Wait for server-side processing and response
152- await this . page
153- . waitForFunction (
154- ( ) => {
155- // Wait for any network requests to complete and UI to stabilize
156- const modal = document . querySelector ( '.ant-modal-wrap' ) ;
157- const hasLoadingIndicators = document . querySelectorAll ( '.loading, .spinner, [aria-busy="true"]' ) . length > 0 ;
158-
159- // Consider stable when either modal is gone or no loading indicators
160- return ! modal || ! hasLoadingIndicators ;
161- } ,
162- { timeout : 5000 }
163- )
164- . catch ( ( ) => {
165- // Server response wait timeout, checking final state...
166- } ) ;
167-
168- // Check final state after server processing
169- const finalModalVisible = await this . folderRenamePage . isRenameModalVisible ( ) ;
170- const finalFolderVisible = await this . folderRenamePage . isFolderVisible ( folderName ) ;
171-
172- // Strategy 3: Analyze the validation behavior based on final state
173- if ( finalModalVisible && ! finalFolderVisible ) {
174- // Modal open, folder disappeared - server prevented rename but UI shows confusion
175- await expect ( this . folderRenamePage . renameModal ) . toBeVisible ( ) ;
176- await this . folderRenamePage . clickCancel ( ) ;
177- // Wait for folder to reappear after modal close
178- await expect (
179- this . page . locator ( '.node' ) . filter ( {
180- has : this . page . locator ( '.folder .name' , { hasText : folderName } )
181- } )
182- ) . toBeVisible ( { timeout : 3000 } ) ;
183- return ;
184- }
185-
186- if ( ! finalModalVisible && finalFolderVisible ) {
187- // Modal closed, folder visible - proper server-side validation (rejected empty name)
188- await expect ( this . folderRenamePage . renameModal ) . not . toBeVisible ( ) ;
189- await expect (
190- this . page . locator ( '.node' ) . filter ( {
191- has : this . page . locator ( '.folder .name' , { hasText : folderName } )
192- } )
193- ) . toBeVisible ( ) ;
194- return ;
195- }
196-
197- if ( finalModalVisible && finalFolderVisible ) {
198- // Modal still open, folder still visible - validation prevented submission
199- await expect ( this . folderRenamePage . renameModal ) . toBeVisible ( ) ;
200- await expect (
201- this . page . locator ( '.node' ) . filter ( {
202- has : this . page . locator ( '.folder .name' , { hasText : folderName } )
203- } )
204- ) . toBeVisible ( ) ;
205- await this . folderRenamePage . clickCancel ( ) ;
206- return ;
207- }
208-
209- if ( ! finalModalVisible && ! finalFolderVisible ) {
210- // Both gone - system handled the empty name by removing/hiding the folder
211- await expect ( this . folderRenamePage . renameModal ) . not . toBeVisible ( ) ;
212- // The folder being removed is acceptable behavior for empty names
213- return ;
214- }
215-
216- // Fallback: If we reach here, assume validation is working
217- // Validation behavior is unclear but folder appears protected
115+ // Verify the original folder still exists and was not renamed or deleted.
116+ const originalFolderLocator = this . page . locator ( '.folder .name' , { hasText : folderName } ) ;
117+ await expect ( originalFolderLocator ) . toBeVisible ( { timeout : 5000 } ) ;
218118 }
219119
220120 async verifyDeleteIconIsDisplayed ( folderName : string ) : Promise < void > {
0 commit comments