@@ -1441,6 +1441,48 @@ describe.concurrent('deploy command', () => {
14411441 } )
14421442 } )
14431443
1444+ test ( 'should use alias as the branch for both the deploy request and the build' , async ( t ) => {
1445+ await withMockDeploy ( async ( mockApi ) => {
1446+ await withSiteBuilder ( t , async ( builder ) => {
1447+ builder
1448+ . withContentFile ( {
1449+ path : 'public/index.html' ,
1450+ content : '<h1>test</h1>' ,
1451+ } )
1452+ . withNetlifyToml ( {
1453+ config : {
1454+ build : { publish : 'public' } ,
1455+ plugins : [ { package : './plugins/log-branch' } ] ,
1456+ } ,
1457+ } )
1458+ . withBuildPlugin ( {
1459+ name : 'log-branch' ,
1460+ plugin : {
1461+ async onPreBuild ( ) {
1462+ console . log ( `TEST_BRANCH: ${ require ( 'process' ) . env . BRANCH } ` )
1463+ } ,
1464+ } ,
1465+ } )
1466+
1467+ await builder . build ( )
1468+
1469+ const output : string = await callCli (
1470+ [ 'deploy' , '--alias' , 'custom-alias' , '--context' , 'deploy-preview' ] ,
1471+ getCLIOptions ( { apiUrl : mockApi . apiUrl , builder } ) ,
1472+ )
1473+
1474+ const [ , branch ] = output . match ( / T E S T _ B R A N C H : ( .+ ) / ) ?? [ ]
1475+ expect ( branch ) . toBe ( 'custom-alias' )
1476+
1477+ const createDeployRequest = mockApi . requests . find (
1478+ ( req ) => req . method === 'POST' && req . path === '/api/v1/sites/site_id/deploys' ,
1479+ )
1480+ expect ( createDeployRequest ) . toBeDefined ( )
1481+ expect ( ( createDeployRequest ! . body as Record < string , unknown > ) . branch ) . toBe ( 'custom-alias' )
1482+ } )
1483+ } )
1484+ } )
1485+
14441486 test ( 'should include build_version in deploy body' , async ( t ) => {
14451487 await withMockDeploy ( async ( mockApi , deployState ) => {
14461488 await withSiteBuilder ( t , async ( builder ) => {
0 commit comments