@@ -384,6 +384,99 @@ Are you sure you want to continue?`,
384384 }
385385 ` ) ;
386386 } ) ;
387+
388+ it ( "should prompt for extra confirmation when worker is used by a Pages function" , async ( ) => {
389+ mockConfirm ( {
390+ text : `Are you sure you want to delete test-name? This action cannot be undone.` ,
391+ result : true ,
392+ } ) ;
393+ mockConfirm ( {
394+ text : `test-name is currently in use by other Workers:
395+
396+ - A Pages project has a Service Binding to this Worker
397+
398+ You can still delete this Worker, but doing so WILL BREAK the Workers that depend on it. This will cause unexpected failures, and cannot be undone.
399+ Are you sure you want to continue?` ,
400+ result : true ,
401+ } ) ;
402+ writeWranglerConfig ( ) ;
403+ mockListKVNamespacesRequest ( ) ;
404+ mockListReferencesRequest ( "test-name" , {
405+ services : {
406+ incoming : [ ] ,
407+ outgoing : [ ] ,
408+ pages_function : true ,
409+ } ,
410+ } ) ;
411+ mockListTailsByConsumerRequest ( "test-name" ) ;
412+ mockDeleteWorkerRequest ( { force : true } ) ;
413+ await runWrangler ( "delete" ) ;
414+
415+ expect ( std ) . toMatchInlineSnapshot ( `
416+ Object {
417+ "debug": "",
418+ "err": "",
419+ "info": "",
420+ "out": "Successfully deleted test-name",
421+ "warn": "",
422+ }
423+ ` ) ;
424+ } ) ;
425+
426+ it ( "should include Pages function in confirmation when combined with other dependencies" , async ( ) => {
427+ mockConfirm ( {
428+ text : `Are you sure you want to delete test-name? This action cannot be undone.` ,
429+ result : true ,
430+ } ) ;
431+ mockConfirm ( {
432+ text : `test-name is currently in use by other Workers:
433+
434+ - Worker existing-worker (production) uses this Worker as a Service Binding
435+ - A Pages project has a Service Binding to this Worker
436+ - Worker do-binder (production) has a binding to the Durable Object Namespace "actor_ns" implemented by this Worker
437+
438+ You can still delete this Worker, but doing so WILL BREAK the Workers that depend on it. This will cause unexpected failures, and cannot be undone.
439+ Are you sure you want to continue?` ,
440+ result : true ,
441+ } ) ;
442+ writeWranglerConfig ( ) ;
443+ mockListKVNamespacesRequest ( ) ;
444+ mockListReferencesRequest ( "test-name" , {
445+ services : {
446+ incoming : [
447+ {
448+ service : "existing-worker" ,
449+ environment : "production" ,
450+ name : "BINDING" ,
451+ } ,
452+ ] ,
453+ outgoing : [ ] ,
454+ pages_function : true ,
455+ } ,
456+ durable_objects : [
457+ {
458+ service : "do-binder" ,
459+ environment : "production" ,
460+ name : "ACTOR" ,
461+ durable_object_namespace_id : "123" ,
462+ durable_object_namespace_name : "actor_ns" ,
463+ } ,
464+ ] ,
465+ } ) ;
466+ mockListTailsByConsumerRequest ( "test-name" ) ;
467+ mockDeleteWorkerRequest ( { force : true } ) ;
468+ await runWrangler ( "delete" ) ;
469+
470+ expect ( std ) . toMatchInlineSnapshot ( `
471+ Object {
472+ "debug": "",
473+ "err": "",
474+ "info": "",
475+ "out": "Successfully deleted test-name",
476+ "warn": "",
477+ }
478+ ` ) ;
479+ } ) ;
387480 } ) ;
388481} ) ;
389482
0 commit comments