@@ -34,13 +34,22 @@ describe('isCanary', () => {
3434 expect ( isCanary ) . toBe ( true )
3535 } )
3636
37+ it ( 'returns true when VERCEL_ENV is "production" and branch is "main"' , async ( ) => {
38+ vi . stubEnv ( 'VERCEL_ENV' , 'production' )
39+ vi . stubEnv ( 'VERCEL_GIT_COMMIT_REF' , 'main' )
40+ const { isCanary } = await import ( '../../../config/env' )
41+
42+ expect ( isCanary ) . toBe ( true )
43+ } )
44+
3745 it . each ( [
38- [ 'production' , 'production' ] ,
39- [ 'preview' , 'preview' ] ,
40- [ 'development' , 'development' ] ,
41- [ 'unset' , undefined ] ,
42- ] ) ( 'returns false when VERCEL_ENV is %s' , async ( _label , value ) => {
46+ [ 'production (non-main branch) ' , 'production' , 'v1.0.0 '] ,
47+ [ 'preview' , 'preview' , undefined ] ,
48+ [ 'development' , 'development' , undefined ] ,
49+ [ 'unset' , undefined , undefined ] ,
50+ ] ) ( 'returns false when VERCEL_ENV is %s' , async ( _label , value , branch ) => {
4351 if ( value !== undefined ) vi . stubEnv ( 'VERCEL_ENV' , value )
52+ if ( branch !== undefined ) vi . stubEnv ( 'VERCEL_GIT_COMMIT_REF' , branch )
4453 const { isCanary } = await import ( '../../../config/env' )
4554
4655 expect ( isCanary ) . toBe ( false )
@@ -98,7 +107,16 @@ describe('getEnv', () => {
98107 expect ( result . env ) . toBe ( 'preview' )
99108 } )
100109
101- it ( 'returns "release" for Vercel production deploys' , async ( ) => {
110+ it ( 'returns "canary" for Vercel production deploys from main branch' , async ( ) => {
111+ vi . stubEnv ( 'VERCEL_ENV' , 'production' )
112+ vi . stubEnv ( 'VERCEL_GIT_COMMIT_REF' , 'main' )
113+ const { getEnv } = await import ( '../../../config/env' )
114+ const result = await getEnv ( false )
115+
116+ expect ( result . env ) . toBe ( 'canary' )
117+ } )
118+
119+ it ( 'returns "release" for Vercel production deploys from non-main branch' , async ( ) => {
102120 vi . stubEnv ( 'VERCEL_ENV' , 'production' )
103121 vi . stubEnv ( 'VERCEL_GIT_COMMIT_REF' , 'v1.0.0' )
104122 const { getEnv } = await import ( '../../../config/env' )
0 commit comments