@@ -15,65 +15,63 @@ 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 ) } "]` )
4033}
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 ) )
34+
35+ export const getInlineActionEntryForFile = ( file : string , actionId : string ) => {
36+ return getActionsForFile ( file )
37+ . find ( `[data-cy-files-list- row-action=" ${ CSS . escape ( actionId ) } "]` )
4538}
4639
4740export 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' )
41+ getActionButtonForFileId ( fileid )
42+ . as ( 'actionButton' )
5443 . scrollIntoView ( )
5544 cy . get ( '@actionButton' )
45+ . click ( { force : true } ) // force to avoid issues with overlaying file list header
46+ getActionEntryForFileId ( fileid , actionId )
47+ . find ( 'button' )
5648 . should ( 'be.visible' )
57- . click ( { force : true } )
49+ . click ( )
5850}
51+
5952export 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' )
53+ getActionButtonForFile ( filename )
54+ . as ( 'actionButton' )
6655 . scrollIntoView ( )
6756 cy . get ( '@actionButton' )
57+ . click ( { force : true } ) // force to avoid issues with overlaying file list header
58+ getActionEntryForFile ( filename , actionId )
59+ . find ( 'button' )
6860 . should ( 'be.visible' )
69- . click ( { force : true } )
61+ . click ( )
7062}
7163
7264export const triggerInlineActionForFileId = ( fileid : number , actionId : string ) => {
73- getActionsForFileId ( fileid ) . find ( `button[data-cy-files-list-row-action="${ CSS . escape ( actionId ) } "]` ) . should ( 'exist' ) . click ( )
65+ getActionsForFileId ( fileid )
66+ . find ( `button[data-cy-files-list-row-action="${ CSS . escape ( actionId ) } "]` )
67+ . should ( 'exist' )
68+ . click ( )
7469}
7570export const triggerInlineActionForFile = ( filename : string , actionId : string ) => {
76- getActionsForFile ( filename ) . find ( `button[data-cy-files-list-row-action="${ CSS . escape ( actionId ) } "]` ) . should ( 'exist' ) . click ( )
71+ getActionsForFile ( filename )
72+ . find ( `button[data-cy-files-list-row-action="${ CSS . escape ( actionId ) } "]` )
73+ . should ( 'exist' )
74+ . click ( )
7775}
7876
7977export const selectAllFiles = ( ) => {
@@ -176,12 +174,17 @@ export const copyFile = (fileName: string, dirPath: string) => {
176174
177175export const renameFile = ( fileName : string , newFileName : string ) => {
178176 getRowForFile ( fileName )
177+ . should ( 'exist' )
178+ . scrollIntoView ( )
179+
179180 triggerActionForFile ( fileName , 'rename' )
180181
181182 // intercept the move so we can wait for it
182183 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' )
183184
184- getRowForFile ( fileName ) . find ( '[data-cy-files-list-row-name] input' ) . type ( `{selectAll}${ newFileName } {enter}` )
185+ getRowForFile ( fileName )
186+ . find ( '[data-cy-files-list-row-name] input' )
187+ . type ( `{selectAll}${ newFileName } {enter}` )
185188
186189 cy . wait ( '@moveFile' )
187190}
0 commit comments