@@ -1186,6 +1186,98 @@ describe.skipIf(process.env.NETLIFY_TEST_DISABLE_LIVE === 'true').concurrent('co
11861186 } )
11871187 } )
11881188
1189+ test ( 'should deploy as draft when --draft flag is used' , async ( t ) => {
1190+ await withSiteBuilder ( t , async ( builder ) => {
1191+ const content = '<h1>Draft deploy test</h1>'
1192+ builder . withContentFile ( {
1193+ path : 'public/index.html' ,
1194+ content,
1195+ } )
1196+
1197+ await builder . build ( )
1198+
1199+ const deploy = await callCli ( [ 'deploy' , '--json' , '--no-build' , '--dir' , 'public' , '--draft' ] , {
1200+ cwd : builder . directory ,
1201+ env : { NETLIFY_SITE_ID : context . siteId } ,
1202+ } ) . then ( ( output : string ) => JSON . parse ( output ) )
1203+
1204+ await validateDeploy ( { deploy, siteName : SITE_NAME , content } )
1205+ expect ( deploy ) . toHaveProperty (
1206+ 'function_logs' ,
1207+ `https://app.netlify.com/projects/${ SITE_NAME } /logs/functions?scope=deploy:${ deploy . deploy_id } ` ,
1208+ )
1209+ expect ( deploy ) . toHaveProperty (
1210+ 'edge_function_logs' ,
1211+ `https://app.netlify.com/projects/${ SITE_NAME } /logs/edge-functions?scope=deployid:${ deploy . deploy_id } ` ,
1212+ )
1213+ } )
1214+ } )
1215+
1216+ test ( 'should not run deploy with --draft and --prod flags together' , async ( t ) => {
1217+ await withSiteBuilder ( t , async ( builder ) => {
1218+ await builder . build ( )
1219+ try {
1220+ await callCli ( [ 'deploy' , '--no-build' , '--draft' , '--prod' ] , {
1221+ cwd : builder . directory ,
1222+ env : { NETLIFY_SITE_ID : context . siteId } ,
1223+ } )
1224+ } catch ( error ) {
1225+ expect ( error ) . toHaveProperty (
1226+ 'stderr' ,
1227+ expect . stringContaining ( `Error: option '-p, --prod' cannot be used with option '--draft'` ) ,
1228+ )
1229+ }
1230+ } )
1231+ } )
1232+
1233+ test ( 'should not run deploy with --draft and --prod-if-unlocked flags together' , async ( t ) => {
1234+ await withSiteBuilder ( t , async ( builder ) => {
1235+ await builder . build ( )
1236+ try {
1237+ await callCli ( [ 'deploy' , '--no-build' , '--draft' , '--prod-if-unlocked' ] , {
1238+ cwd : builder . directory ,
1239+ env : { NETLIFY_SITE_ID : context . siteId } ,
1240+ } )
1241+ } catch ( error ) {
1242+ expect ( error ) . toHaveProperty (
1243+ 'stderr' ,
1244+ expect . stringContaining ( `Error: option '--prod-if-unlocked' cannot be used with option '--draft'` ) ,
1245+ )
1246+ }
1247+ } )
1248+ } )
1249+
1250+ test ( 'should deploy as draft when --draft flag is used with --alias and --no-build' , async ( t ) => {
1251+ await withSiteBuilder ( t , async ( builder ) => {
1252+ const content = '<h1>Draft deploy with alias test</h1>'
1253+ builder . withContentFile ( {
1254+ path : 'public/index.html' ,
1255+ content,
1256+ } )
1257+
1258+ await builder . build ( )
1259+
1260+ const deploy = await callCli (
1261+ [ 'deploy' , '--json' , '--no-build' , '--dir' , 'public' , '--draft' , '--alias' , 'test-branch' ] ,
1262+ {
1263+ cwd : builder . directory ,
1264+ env : { NETLIFY_SITE_ID : context . siteId } ,
1265+ } ,
1266+ ) . then ( ( output : string ) => JSON . parse ( output ) )
1267+
1268+ await validateDeploy ( { deploy, siteName : SITE_NAME , content } )
1269+ expect ( deploy ) . toHaveProperty (
1270+ 'function_logs' ,
1271+ `https://app.netlify.com/projects/${ SITE_NAME } /logs/functions?scope=deploy:${ deploy . deploy_id } ` ,
1272+ )
1273+ expect ( deploy ) . toHaveProperty (
1274+ 'edge_function_logs' ,
1275+ `https://app.netlify.com/projects/${ SITE_NAME } /logs/edge-functions?scope=deployid:${ deploy . deploy_id } ` ,
1276+ )
1277+ expect ( deploy . deploy_url ) . toContain ( 'test-branch--' )
1278+ } )
1279+ } )
1280+
11891281 test ( 'should include source_zip_filename in JSON output when --upload-source-zip flag is used' , async ( t ) => {
11901282 await withSiteBuilder ( t , async ( builder ) => {
11911283 const content = '<h1>Source zip test</h1>'
0 commit comments