@@ -11,6 +11,7 @@ import * as eventBus from '@nextcloud/event-bus'
1111
1212import { action } from './deleteAction'
1313import logger from '../logger'
14+ import { shouldAskForConfirmation } from './deleteUtils'
1415
1516vi . mock ( '@nextcloud/auth' )
1617vi . mock ( '@nextcloud/axios' )
@@ -235,7 +236,6 @@ describe('Delete action execute tests', () => {
235236 vi . spyOn ( eventBus , 'emit' )
236237
237238 const confirmMock = vi . fn ( )
238- // @ts -expect-error We only mock what needed
239239 window . OC = { dialogs : { confirmDestructive : confirmMock } }
240240
241241 const file1 = new File ( {
@@ -275,7 +275,6 @@ describe('Delete action execute tests', () => {
275275
276276 // Emulate the confirmation dialog to always confirm
277277 const confirmMock = vi . fn ( ) . mockImplementation ( ( a , b , c , resolve ) => resolve ( true ) )
278- // @ts -expect-error We only mock what needed
279278 window . OC = { dialogs : { confirmDestructive : confirmMock } }
280279
281280 const file1 = new File ( {
@@ -339,7 +338,11 @@ describe('Delete action execute tests', () => {
339338 expect ( eventBus . emit ) . toHaveBeenNthCalledWith ( 5 , 'files:node:deleted' , file5 )
340339 } )
341340
342- test ( 'Delete action batch trashbin disabled' , async ( ) => {
341+ test ( 'Delete action batch dialog enabled' , async ( ) => {
342+ // Enable the confirmation dialog
343+ eventBus . emit ( 'files:config:updated' , { key : 'show_dialog_deletion' , value : true } )
344+ expect ( shouldAskForConfirmation ( ) ) . toBe ( true )
345+
343346 vi . spyOn ( axios , 'delete' )
344347 vi . spyOn ( eventBus , 'emit' )
345348 vi . spyOn ( capabilities , 'getCapabilities' ) . mockImplementation ( ( ) => {
@@ -350,7 +353,6 @@ describe('Delete action execute tests', () => {
350353
351354 // Emulate the confirmation dialog to always confirm
352355 const confirmMock = vi . fn ( ) . mockImplementation ( ( a , b , c , resolve ) => resolve ( true ) )
353- // @ts -expect-error We only mock what needed
354356 window . OC = { dialogs : { confirmDestructive : confirmMock } }
355357
356358 const file1 = new File ( {
@@ -382,6 +384,8 @@ describe('Delete action execute tests', () => {
382384 expect ( eventBus . emit ) . toBeCalledTimes ( 2 )
383385 expect ( eventBus . emit ) . toHaveBeenNthCalledWith ( 1 , 'files:node:deleted' , file1 )
384386 expect ( eventBus . emit ) . toHaveBeenNthCalledWith ( 2 , 'files:node:deleted' , file2 )
387+
388+ eventBus . emit ( 'files:config:updated' , { key : 'show_dialog_deletion' , value : false } )
385389 } )
386390
387391 test ( 'Delete fails' , async ( ) => {
@@ -407,7 +411,10 @@ describe('Delete action execute tests', () => {
407411 expect ( logger . error ) . toBeCalledTimes ( 1 )
408412 } )
409413
410- test ( 'Delete is cancelled' , async ( ) => {
414+ test ( 'Delete is cancelled with dialog enabled' , async ( ) => {
415+ // Enable the confirmation dialog
416+ eventBus . emit ( 'files:config:updated' , { key : 'show_dialog_deletion' , value : true } )
417+
411418 vi . spyOn ( axios , 'delete' )
412419 vi . spyOn ( eventBus , 'emit' )
413420 vi . spyOn ( capabilities , 'getCapabilities' ) . mockImplementation ( ( ) => {
@@ -418,7 +425,6 @@ describe('Delete action execute tests', () => {
418425
419426 // Emulate the confirmation dialog to always confirm
420427 const confirmMock = vi . fn ( ) . mockImplementation ( ( a , b , c , resolve ) => resolve ( false ) )
421- // @ts -expect-error We only mock what needed
422428 window . OC = { dialogs : { confirmDestructive : confirmMock } }
423429
424430 const file1 = new File ( {
@@ -437,5 +443,7 @@ describe('Delete action execute tests', () => {
437443 expect ( axios . delete ) . toBeCalledTimes ( 0 )
438444
439445 expect ( eventBus . emit ) . toBeCalledTimes ( 0 )
446+
447+ eventBus . emit ( 'files:config:updated' , { key : 'show_dialog_deletion' , value : false } )
440448 } )
441449} )
0 commit comments