@@ -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" ;
@@ -1470,13 +1471,22 @@ describe("r2", () => {
14701471 } ) ;
14711472 } ) ;
14721473 describe ( "domain" , ( ) => {
1474+ const { setIsTTY } = useMockIsTTY ( ) ;
14731475 mockAccountId ( ) ;
14741476 mockApiToken ( ) ;
14751477 describe ( "add" , ( ) => {
14761478 it ( "should add custom domain to the bucket as expected" , async ( ) => {
14771479 const bucketName = "my-bucket" ;
14781480 const domainName = "example.com" ;
14791481 const zoneId = "zone-id-123" ;
1482+
1483+ setIsTTY ( true ) ;
1484+ mockConfirm ( {
1485+ text :
1486+ `Are you sure you want to add the custom domain '${ domainName } ' to bucket '${ bucketName } '? ` +
1487+ `The contents of your bucket will be made publicly available at 'https://${ domainName } '` ,
1488+ result : true ,
1489+ } ) ;
14801490 msw . use (
14811491 http . post (
14821492 "*/accounts/:accountId/r2/buckets/:bucketName/domains/custom" ,
@@ -1497,7 +1507,7 @@ describe("r2", () => {
14971507 )
14981508 ) ;
14991509 await runWrangler (
1500- `r2 bucket domain add ${ bucketName } --domain ${ domainName } --zone-id ${ zoneId } --force `
1510+ `r2 bucket domain add ${ bucketName } --domain ${ domainName } --zone-id ${ zoneId } `
15011511 ) ;
15021512 expect ( std . out ) . toMatchInlineSnapshot ( `
15031513 "Connecting custom domain 'example.com' to bucket 'my-bucket'...
@@ -1508,7 +1518,7 @@ describe("r2", () => {
15081518 it ( "should error if domain and zone-id are not provided" , async ( ) => {
15091519 const bucketName = "my-bucket" ;
15101520 await expect (
1511- runWrangler ( `r2 bucket domain add ${ bucketName } --force ` )
1521+ runWrangler ( `r2 bucket domain add ${ bucketName } ` )
15121522 ) . rejects . toThrowErrorMatchingInlineSnapshot (
15131523 `[Error: Missing required arguments: domain, zone-id]`
15141524 ) ;
@@ -1587,6 +1597,13 @@ describe("r2", () => {
15871597 it ( "should remove a custom domain as expected" , async ( ) => {
15881598 const bucketName = "my-bucket" ;
15891599 const domainName = "example.com" ;
1600+ setIsTTY ( true ) ;
1601+ mockConfirm ( {
1602+ text :
1603+ `Are you sure you want to remove the custom domain '${ domainName } ' from bucket '${ bucketName } '? ` +
1604+ `Your bucket will no longer be available from 'https://${ domainName } '` ,
1605+ result : true ,
1606+ } ) ;
15901607 msw . use (
15911608 http . delete (
15921609 "*/accounts/:accountId/r2/buckets/:bucketName/domains/custom/:domainName" ,
@@ -1605,7 +1622,7 @@ describe("r2", () => {
16051622 )
16061623 ) ;
16071624 await runWrangler (
1608- `r2 bucket domain remove ${ bucketName } --domain ${ domainName } --force `
1625+ `r2 bucket domain remove ${ bucketName } --domain ${ domainName } `
16091626 ) ;
16101627 expect ( std . out ) . toMatchInlineSnapshot ( `
16111628 "Removing custom domain 'example.com' from bucket 'my-bucket'...
0 commit comments