@@ -15,65 +15,65 @@ export const getActionsForFile = (filename: string) => getRowForFile(filename).f
1515export const getActionButtonForFileId = ( fileid : number ) => getActionsForFileId ( fileid ) . findByRole ( 'button' , { name : 'Actions' } )
1616export const getActionButtonForFile = ( filename : string ) => getActionsForFile ( filename ) . findByRole ( 'button' , { name : 'Actions' } )
1717
18- const searchForActionInRow = ( row : JQuery < HTMLElement > , actionId : string ) : Cypress . Chainable < JQuery < HTMLElement > > => {
19- const action = row . find ( `[data-cy-files-list-row-action="${ CSS . escape ( actionId ) } "]` )
20- if ( action . length > 0 ) {
21- cy . log ( 'Found action in row' )
22- return cy . wrap ( action )
23- }
24-
25- // Else look in the action menu
26- const menuButtonId = row . find ( 'button[aria-controls]' ) . attr ( 'aria-controls' )
27- if ( menuButtonId === undefined ) {
28- return cy . wrap ( Cypress . $ ( ) )
29- }
18+ export const getActionEntryForFileId = ( fileid : number , actionId : string ) => {
19+ return getActionButtonForFileId ( fileid )
20+ . should ( 'have.attr' , 'aria-controls' )
21+ . then ( ( menuId ) => cy . get ( `#${ menuId } ` ) . find ( `[data-cy-files-list-row-action="${ CSS . escape ( actionId ) } "]` ) )
22+ }
3023
31- // eslint-disable-next-line no-unused-expressions
32- expect ( menuButtonId ) . not . to . be . undefined
33- return cy . get ( `#${ menuButtonId } [data-cy-files-list-row-action="${ CSS . escape ( actionId ) } "]` )
24+ export const getActionEntryForFile = ( file : string , actionId : string ) => {
25+ return getActionButtonForFile ( file )
26+ . should ( 'have.attr' , 'aria-controls' )
27+ . then ( ( menuId ) => cy . get ( `#${ menuId } ` ) . find ( `[data-cy-files-list-row-action="${ CSS . escape ( actionId ) } "]` ) )
3428}
3529
36- export const getActionEntryForFileId = ( fileid : number , actionId : string ) : Cypress . Chainable < JQuery < HTMLElement > > => {
37- // If we cannot find the action in the row, it might be in the action menu
38- return getRowForFileId ( fileid ) . should ( 'be.visible' )
39- . then ( ( row ) => searchForActionInRow ( row , actionId ) )
30+ export const getInlineActionEntryForFileId = ( fileid : number , actionId : string ) => {
31+ return getActionsForFileId ( fileid )
32+ . find ( `[data-cy-files-list-row-action=" ${ CSS . escape ( actionId ) } "]` )
33+ . should ( 'be.visible' )
4034}
41- export const getActionEntryForFile = ( filename : string , actionId : string ) : Cypress . Chainable < JQuery < HTMLElement > > => {
42- // If we cannot find the action in the row, it might be in the action menu
43- return getRowForFile ( filename ) . should ( 'be.visible' )
44- . then ( ( row ) => searchForActionInRow ( row , actionId ) )
35+
36+ export const getInlineActionEntryForFile = ( file : string , actionId : string ) => {
37+ return getActionsForFile ( file )
38+ . find ( `[data-cy-files-list-row-action="${ CSS . escape ( actionId ) } "]` )
39+ . should ( 'be.visible' )
4540}
4641
4742export const triggerActionForFileId = ( fileid : number , actionId : string ) => {
48- // Even if it's inline, we open the action menu to get all actions visible
49- getActionButtonForFileId ( fileid ) . click ( { force : true } )
50- // wait for the actions menu to be visible
51- cy . findByRole ( 'menu' ) . findAllByRole ( 'menuitem' ) . first ( ) . should ( 'be.visible' )
52- getActionEntryForFileId ( fileid , actionId )
53- . find ( 'button' ) . last ( ) . as ( 'actionButton' )
43+ getActionButtonForFileId ( fileid )
5444 . scrollIntoView ( )
55- cy . get ( '@actionButton' )
45+ getActionButtonForFileId ( fileid )
5646 . should ( 'be.visible' )
57- . click ( { force : true } )
47+ . click ( )
48+ getActionEntryForFileId ( fileid , actionId )
49+ . find ( 'button' )
50+ . should ( 'be.visible' )
51+ . click ( )
5852}
53+
5954export const triggerActionForFile = ( filename : string , actionId : string ) => {
60- // Even if it's inline, we open the action menu to get all actions visible
61- getActionButtonForFile ( filename ) . click ( { force : true } )
62- // wait for the actions menu to be visible
63- cy . findByRole ( 'menu' ) . findAllByRole ( 'menuitem' ) . first ( ) . should ( 'be.visible' )
64- getActionEntryForFile ( filename , actionId )
65- . find ( 'button' ) . last ( ) . as ( 'actionButton' )
55+ getActionButtonForFile ( filename )
6656 . scrollIntoView ( )
67- cy . get ( '@actionButton' )
57+ getActionButtonForFile ( filename )
6858 . should ( 'be.visible' )
69- . click ( { force : true } )
59+ . click ( )
60+ getActionEntryForFile ( filename , actionId )
61+ . find ( 'button' )
62+ . should ( 'be.visible' )
63+ . click ( )
7064}
7165
7266export const triggerInlineActionForFileId = ( fileid : number , actionId : string ) => {
73- getActionsForFileId ( fileid ) . find ( `button[data-cy-files-list-row-action="${ CSS . escape ( actionId ) } "]` ) . should ( 'exist' ) . click ( )
67+ getActionsForFileId ( fileid )
68+ . find ( `button[data-cy-files-list-row-action="${ CSS . escape ( actionId ) } "]` )
69+ . should ( 'exist' )
70+ . click ( )
7471}
7572export const triggerInlineActionForFile = ( filename : string , actionId : string ) => {
76- getActionsForFile ( filename ) . find ( `button[data-cy-files-list-row-action="${ CSS . escape ( actionId ) } "]` ) . should ( 'exist' ) . click ( )
73+ getActionsForFile ( filename )
74+ . find ( `button[data-cy-files-list-row-action="${ CSS . escape ( actionId ) } "]` )
75+ . should ( 'exist' )
76+ . click ( )
7777}
7878
7979export const selectAllFiles = ( ) => {
@@ -176,12 +176,16 @@ export const copyFile = (fileName: string, dirPath: string) => {
176176
177177export const renameFile = ( fileName : string , newFileName : string ) => {
178178 getRowForFile ( fileName )
179+ . should ( 'be.visible' )
180+ . scrollIntoView ( )
179181 triggerActionForFile ( fileName , 'rename' )
180182
181183 // intercept the move so we can wait for it
182184 cy . intercept ( 'MOVE' , / \/ ( r e m o t e | p u b l i c ) \. p h p \/ d a v \/ f i l e s \/ / ) . as ( 'moveFile' )
183185
184- getRowForFile ( fileName ) . find ( '[data-cy-files-list-row-name] input' ) . type ( `{selectAll}${ newFileName } {enter}` )
186+ getRowForFile ( fileName )
187+ . find ( '[data-cy-files-list-row-name] input' )
188+ . type ( `{selectAll}${ newFileName } {enter}` )
185189
186190 cy . wait ( '@moveFile' )
187191}
0 commit comments