@@ -2351,6 +2351,67 @@ describe('OCA.Files.FileList tests', function() {
23512351 expect ( context . fileActions ) . toBeDefined ( ) ;
23522352 expect ( context . dir ) . toEqual ( '/subdir' ) ;
23532353 } ) ;
2354+ it ( 'clicking on a file name will render the app drawer context menu if more than one action applies for this mime type' , function ( ) {
2355+ var actionStub = sinon . stub ( ) ;
2356+ fileList . setFiles ( testFiles ) ;
2357+ fileList . fileActions . registerAction ( {
2358+ mime : 'text/plain' ,
2359+ name : 'View file' ,
2360+ type : OCA . Files . FileActions . TYPE_INLINE ,
2361+ permissions : OC . PERMISSION_ALL ,
2362+ icon : function ( ) {
2363+ return OC . imagePath ( 'core' , 'actions/history' ) ;
2364+ } ,
2365+ actionHandler : actionStub ,
2366+ } ) ;
2367+ fileList . fileActions . registerAction ( {
2368+ mime : 'text/plain' ,
2369+ name : 'Edit file' ,
2370+ type : OCA . Files . FileActions . TYPE_INLINE ,
2371+ permissions : OC . PERMISSION_ALL ,
2372+ icon : function ( ) {
2373+ return OC . imagePath ( 'core' , 'actions/history' ) ;
2374+ } ,
2375+ } ) ;
2376+
2377+ fileList . fileActions . setDefault ( 'text/plain' , 'View file' ) ;
2378+ var $tr = fileList . findFileEl ( 'One.txt' ) ;
2379+ $tr . find ( 'td.filename .nametext' ) . click ( ) ;
2380+ expect ( actionStub . calledOnce ) . toEqual ( false ) ;
2381+ expect ( $tr . find ( 'td.filename .fileActionsAppDrawer' ) . length ) . toEqual ( 1 ) ;
2382+ expect ( $tr . find ( 'td.filename .fileActionsAppDrawer a' ) . length ) . toEqual ( 2 ) ;
2383+ var firstAction = $tr . find ( 'td.filename .fileActionsAppDrawer a' ) [ 0 ] ;
2384+ firstAction . click ( ) ;
2385+ expect ( actionStub . calledOnce ) . toEqual ( true ) ;
2386+ } ) ;
2387+ it ( 'clicking on a directory name will never render the app drawer context menu' , function ( ) {
2388+ var actionStub = sinon . stub ( ) ;
2389+ fileList . setFiles ( testFiles ) ;
2390+ fileList . fileActions . registerAction ( {
2391+ mime : 'httpd/unix-directory' ,
2392+ name : 'View dir' ,
2393+ type : 'dir' ,
2394+ permissions : OC . PERMISSION_ALL ,
2395+ icon : function ( ) {
2396+ return OC . imagePath ( 'core' , 'actions/history' ) ;
2397+ } ,
2398+ actionHandler : actionStub ,
2399+ } ) ;
2400+ fileList . fileActions . registerAction ( {
2401+ mime : 'httpd/unix-directory' ,
2402+ name : 'Edit dir' ,
2403+ type : 'dir' ,
2404+ permissions : OC . PERMISSION_ALL ,
2405+ icon : function ( ) {
2406+ return OC . imagePath ( 'core' , 'actions/history' ) ;
2407+ } ,
2408+ } ) ;
2409+
2410+ fileList . fileActions . setDefault ( 'httpd/unix-directory' , 'View dir' ) ;
2411+ var $tr = fileList . findFileEl ( 'somedir' ) ;
2412+ $tr . find ( 'td.filename .nametext' ) . click ( ) ;
2413+ expect ( actionStub . calledOnce ) . toEqual ( true ) ;
2414+ } ) ;
23542415 it ( 'redisplays actions when new actions have been registered' , function ( ) {
23552416 var actionStub = sinon . stub ( ) ;
23562417 var readyHandler = sinon . stub ( ) ;
0 commit comments