@@ -5,6 +5,7 @@ import { actionsForEventCategories } from "../r2/helpers";
55import { endEventLoop } from "./helpers/end-event-loop" ;
66import { mockAccountId , mockApiToken } from "./helpers/mock-account-id" ;
77import { mockConsoleMethods } from "./helpers/mock-console" ;
8+ import { mockConfirm } from "./helpers/mock-dialogs" ;
89import { useMockIsTTY } from "./helpers/mock-istty" ;
910import { createFetchResult , msw , mswR2handlers } from "./helpers/msw" ;
1011import { runInTempDir } from "./helpers/run-in-tmp" ;
@@ -1446,13 +1447,22 @@ describe("r2", () => {
14461447 } ) ;
14471448 } ) ;
14481449 describe ( "domain" , ( ) => {
1450+ const { setIsTTY } = useMockIsTTY ( ) ;
14491451 mockAccountId ( ) ;
14501452 mockApiToken ( ) ;
14511453 describe ( "add" , ( ) => {
14521454 it ( "should add custom domain to the bucket as expected" , async ( ) => {
14531455 const bucketName = "my-bucket" ;
14541456 const domainName = "example.com" ;
14551457 const zoneId = "zone-id-123" ;
1458+
1459+ setIsTTY ( true ) ;
1460+ mockConfirm ( {
1461+ text :
1462+ `Are you sure you want to add the custom domain '${ domainName } ' to bucket '${ bucketName } '? ` +
1463+ `The contents of your bucket will be made publicly available at 'https://${ domainName } '` ,
1464+ result : true ,
1465+ } ) ;
14561466 msw . use (
14571467 http . post (
14581468 "*/accounts/:accountId/r2/buckets/:bucketName/domains/custom" ,
@@ -1473,7 +1483,7 @@ describe("r2", () => {
14731483 )
14741484 ) ;
14751485 await runWrangler (
1476- `r2 bucket domain add ${ bucketName } --domain ${ domainName } --zone-id ${ zoneId } --force `
1486+ `r2 bucket domain add ${ bucketName } --domain ${ domainName } --zone-id ${ zoneId } `
14771487 ) ;
14781488 expect ( std . out ) . toMatchInlineSnapshot ( `
14791489 "Connecting custom domain 'example.com' to bucket 'my-bucket'...
@@ -1484,7 +1494,7 @@ describe("r2", () => {
14841494 it ( "should error if domain and zone-id are not provided" , async ( ) => {
14851495 const bucketName = "my-bucket" ;
14861496 await expect (
1487- runWrangler ( `r2 bucket domain add ${ bucketName } --force ` )
1497+ runWrangler ( `r2 bucket domain add ${ bucketName } ` )
14881498 ) . rejects . toThrowErrorMatchingInlineSnapshot (
14891499 `[Error: Missing required arguments: domain, zone-id]`
14901500 ) ;
@@ -1563,6 +1573,13 @@ describe("r2", () => {
15631573 it ( "should remove a custom domain as expected" , async ( ) => {
15641574 const bucketName = "my-bucket" ;
15651575 const domainName = "example.com" ;
1576+ setIsTTY ( true ) ;
1577+ mockConfirm ( {
1578+ text :
1579+ `Are you sure you want to remove the custom domain '${ domainName } ' from bucket '${ bucketName } '? ` +
1580+ `Your bucket will no longer be available from 'https://${ domainName } '` ,
1581+ result : true ,
1582+ } ) ;
15661583 msw . use (
15671584 http . delete (
15681585 "*/accounts/:accountId/r2/buckets/:bucketName/domains/custom/:domainName" ,
@@ -1581,7 +1598,7 @@ describe("r2", () => {
15811598 )
15821599 ) ;
15831600 await runWrangler (
1584- `r2 bucket domain remove ${ bucketName } --domain ${ domainName } --force `
1601+ `r2 bucket domain remove ${ bucketName } --domain ${ domainName } `
15851602 ) ;
15861603 expect ( std . out ) . toMatchInlineSnapshot ( `
15871604 "Removing custom domain 'example.com' from bucket 'my-bucket'...
0 commit comments