@@ -90,43 +90,16 @@ describe('banner.ts', () => {
9090 expect ( bannerOutput ) . toContain ( '\x1b[0m' ) ; // Reset color
9191 } ) ;
9292
93- it ( 'should use DEPLOYSTACK_BACKEND_VERSION when available' , ( ) => {
94- process . env . DEPLOYSTACK_BACKEND_VERSION = '1.2.3' ;
93+ it ( 'should use version from config' , ( ) => {
9594 const testPort = 3000 ;
9695
9796 displayStartupBanner ( testPort , mockLogger ) ;
9897
9998 const logCall = ( mockLogger . info as any ) . mock . calls [ 0 ] ;
10099 const bannerOutput = logCall [ 1 ] as string ;
101- expect ( bannerOutput ) . toContain ( 'v1.2.3' ) ;
102- expect ( bannerOutput ) . toContain ( 'DeployStack CI/CD Backend' ) ;
103- expect ( logCall [ 0 ] . version ) . toBe ( '1.2.3' ) ;
104- } ) ;
105-
106- it ( 'should fallback to npm_package_version when DEPLOYSTACK_BACKEND_VERSION is not set' , ( ) => {
107- delete process . env . DEPLOYSTACK_BACKEND_VERSION ;
108- process . env . npm_package_version = '2.1.0' ;
109- const testPort = 3000 ;
110-
111- displayStartupBanner ( testPort , mockLogger ) ;
112-
113- const logCall = ( mockLogger . info as any ) . mock . calls [ 0 ] ;
114- const bannerOutput = logCall [ 1 ] as string ;
115- expect ( bannerOutput ) . toContain ( 'v2.1.0' ) ;
116- expect ( logCall [ 0 ] . version ) . toBe ( '2.1.0' ) ;
117- } ) ;
118-
119- it ( 'should use default version when no version environment variables are set' , ( ) => {
120- delete process . env . DEPLOYSTACK_BACKEND_VERSION ;
121- delete process . env . npm_package_version ;
122- const testPort = 3000 ;
123-
124- displayStartupBanner ( testPort , mockLogger ) ;
125-
126- const logCall = ( mockLogger . info as any ) . mock . calls [ 0 ] ;
127- const bannerOutput = logCall [ 1 ] as string ;
128- expect ( bannerOutput ) . toContain ( 'v0.1.0' ) ;
129- expect ( logCall [ 0 ] . version ) . toBe ( '0.1.0' ) ;
100+ // Should use the version from version.ts (which reads from package.json in development)
101+ expect ( bannerOutput ) . toContain ( 'v0.20.9' ) ;
102+ expect ( logCall [ 0 ] . version ) . toBe ( '0.20.9' ) ;
130103 } ) ;
131104
132105 it ( 'should display current NODE_ENV' , ( ) => {
@@ -249,11 +222,7 @@ describe('banner.ts', () => {
249222
250223 it ( 'should handle empty string environment variables gracefully' , ( ) => {
251224 const originalNodeEnv = process . env . NODE_ENV ;
252- const originalBackendVersion = process . env . DEPLOYSTACK_BACKEND_VERSION ;
253- const originalNpmVersion = process . env . npm_package_version ;
254225
255- process . env . DEPLOYSTACK_BACKEND_VERSION = '' ;
256- process . env . npm_package_version = '' ;
257226 process . env . NODE_ENV = '' ;
258227 const testPort = 3000 ;
259228
@@ -262,35 +231,15 @@ describe('banner.ts', () => {
262231 const logCall = ( mockLogger . info as any ) . mock . calls [ 0 ] ;
263232 const bannerOutput = logCall [ 1 ] as string ;
264233 const cleanOutput = stripAnsiCodes ( bannerOutput ) ;
265- expect ( cleanOutput ) . toContain ( 'v0.1.0 ' ) ; // Should fallback to default
234+ expect ( cleanOutput ) . toContain ( 'v0.20.9 ' ) ; // Should use version.ts data
266235 expect ( cleanOutput ) . toContain ( 'Environment: development' ) ; // Should fallback to default
267- expect ( logCall [ 0 ] . version ) . toBe ( '0.1.0 ' ) ;
236+ expect ( logCall [ 0 ] . version ) . toBe ( '0.20.9 ' ) ;
268237 expect ( logCall [ 0 ] . environment ) . toBe ( 'development' ) ;
269238
270239 // Restore original environment variables
271240 if ( originalNodeEnv !== undefined ) {
272241 process . env . NODE_ENV = originalNodeEnv ;
273242 }
274- if ( originalBackendVersion !== undefined ) {
275- process . env . DEPLOYSTACK_BACKEND_VERSION = originalBackendVersion ;
276- }
277- if ( originalNpmVersion !== undefined ) {
278- process . env . npm_package_version = originalNpmVersion ;
279- }
280- } ) ;
281-
282- it ( 'should prioritize DEPLOYSTACK_BACKEND_VERSION over npm_package_version' , ( ) => {
283- process . env . DEPLOYSTACK_BACKEND_VERSION = '5.0.0' ;
284- process . env . npm_package_version = '4.0.0' ;
285- const testPort = 3000 ;
286-
287- displayStartupBanner ( testPort , mockLogger ) ;
288-
289- const logCall = ( mockLogger . info as any ) . mock . calls [ 0 ] ;
290- const bannerOutput = logCall [ 1 ] as string ;
291- expect ( bannerOutput ) . toContain ( 'v5.0.0' ) ;
292- expect ( bannerOutput ) . not . toContain ( 'v4.0.0' ) ;
293- expect ( logCall [ 0 ] . version ) . toBe ( '5.0.0' ) ;
294243 } ) ;
295244 } ) ;
296245} ) ;
0 commit comments