@@ -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" ;
@@ -1446,13 +1447,22 @@ describe("r2", () => {
1446
1447
} ) ;
1447
1448
} ) ;
1448
1449
describe ( "domain" , ( ) => {
1450
+ const { setIsTTY } = useMockIsTTY ( ) ;
1449
1451
mockAccountId ( ) ;
1450
1452
mockApiToken ( ) ;
1451
1453
describe ( "add" , ( ) => {
1452
1454
it ( "should add custom domain to the bucket as expected" , async ( ) => {
1453
1455
const bucketName = "my-bucket" ;
1454
1456
const domainName = "example.com" ;
1455
1457
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
+ } ) ;
1456
1466
msw . use (
1457
1467
http . post (
1458
1468
"*/accounts/:accountId/r2/buckets/:bucketName/domains/custom" ,
@@ -1473,7 +1483,7 @@ describe("r2", () => {
1473
1483
)
1474
1484
) ;
1475
1485
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 } `
1477
1487
) ;
1478
1488
expect ( std . out ) . toMatchInlineSnapshot ( `
1479
1489
"Connecting custom domain 'example.com' to bucket 'my-bucket'...
@@ -1484,7 +1494,7 @@ describe("r2", () => {
1484
1494
it ( "should error if domain and zone-id are not provided" , async ( ) => {
1485
1495
const bucketName = "my-bucket" ;
1486
1496
await expect (
1487
- runWrangler ( `r2 bucket domain add ${ bucketName } --force ` )
1497
+ runWrangler ( `r2 bucket domain add ${ bucketName } ` )
1488
1498
) . rejects . toThrowErrorMatchingInlineSnapshot (
1489
1499
`[Error: Missing required arguments: domain, zone-id]`
1490
1500
) ;
@@ -1563,6 +1573,13 @@ describe("r2", () => {
1563
1573
it ( "should remove a custom domain as expected" , async ( ) => {
1564
1574
const bucketName = "my-bucket" ;
1565
1575
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
+ } ) ;
1566
1583
msw . use (
1567
1584
http . delete (
1568
1585
"*/accounts/:accountId/r2/buckets/:bucketName/domains/custom/:domainName" ,
@@ -1581,7 +1598,7 @@ describe("r2", () => {
1581
1598
)
1582
1599
) ;
1583
1600
await runWrangler (
1584
- `r2 bucket domain remove ${ bucketName } --domain ${ domainName } --force `
1601
+ `r2 bucket domain remove ${ bucketName } --domain ${ domainName } `
1585
1602
) ;
1586
1603
expect ( std . out ) . toMatchInlineSnapshot ( `
1587
1604
"Removing custom domain 'example.com' from bucket 'my-bucket'...
0 commit comments