@@ -5,6 +5,7 @@ import { actionsForEventCategories } from "../r2/helpers";
5
5
import { endEventLoop } from "./helpers/end-event-loop" ;
6
6
import { mockAccountId , mockApiToken } from "./helpers/mock-account-id" ;
7
7
import { mockConsoleMethods } from "./helpers/mock-console" ;
8
+ import { mockConfirm } from "./helpers/mock-dialogs" ;
8
9
import { useMockIsTTY } from "./helpers/mock-istty" ;
9
10
import { createFetchResult , msw , mswR2handlers } from "./helpers/msw" ;
10
11
import { runInTempDir } from "./helpers/run-in-tmp" ;
@@ -1470,13 +1471,22 @@ describe("r2", () => {
1470
1471
} ) ;
1471
1472
} ) ;
1472
1473
describe ( "domain" , ( ) => {
1474
+ const { setIsTTY } = useMockIsTTY ( ) ;
1473
1475
mockAccountId ( ) ;
1474
1476
mockApiToken ( ) ;
1475
1477
describe ( "add" , ( ) => {
1476
1478
it ( "should add custom domain to the bucket as expected" , async ( ) => {
1477
1479
const bucketName = "my-bucket" ;
1478
1480
const domainName = "example.com" ;
1479
1481
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
+ } ) ;
1480
1490
msw . use (
1481
1491
http . post (
1482
1492
"*/accounts/:accountId/r2/buckets/:bucketName/domains/custom" ,
@@ -1497,7 +1507,7 @@ describe("r2", () => {
1497
1507
)
1498
1508
) ;
1499
1509
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 } `
1501
1511
) ;
1502
1512
expect ( std . out ) . toMatchInlineSnapshot ( `
1503
1513
"Connecting custom domain 'example.com' to bucket 'my-bucket'...
@@ -1508,7 +1518,7 @@ describe("r2", () => {
1508
1518
it ( "should error if domain and zone-id are not provided" , async ( ) => {
1509
1519
const bucketName = "my-bucket" ;
1510
1520
await expect (
1511
- runWrangler ( `r2 bucket domain add ${ bucketName } --force ` )
1521
+ runWrangler ( `r2 bucket domain add ${ bucketName } ` )
1512
1522
) . rejects . toThrowErrorMatchingInlineSnapshot (
1513
1523
`[Error: Missing required arguments: domain, zone-id]`
1514
1524
) ;
@@ -1587,6 +1597,13 @@ describe("r2", () => {
1587
1597
it ( "should remove a custom domain as expected" , async ( ) => {
1588
1598
const bucketName = "my-bucket" ;
1589
1599
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
+ } ) ;
1590
1607
msw . use (
1591
1608
http . delete (
1592
1609
"*/accounts/:accountId/r2/buckets/:bucketName/domains/custom/:domainName" ,
@@ -1605,7 +1622,7 @@ describe("r2", () => {
1605
1622
)
1606
1623
) ;
1607
1624
await runWrangler (
1608
- `r2 bucket domain remove ${ bucketName } --domain ${ domainName } --force `
1625
+ `r2 bucket domain remove ${ bucketName } --domain ${ domainName } `
1609
1626
) ;
1610
1627
expect ( std . out ) . toMatchInlineSnapshot ( `
1611
1628
"Removing custom domain 'example.com' from bucket 'my-bucket'...
0 commit comments