@@ -14,17 +14,17 @@ describe('Instagram Environment Configuration', () => {
14
14
INSTAGRAM_PASSWORD : 'test_password' ,
15
15
INSTAGRAM_APP_ID : 'test_app_id' ,
16
16
INSTAGRAM_APP_SECRET : 'test_app_secret' ,
17
- INSTAGRAM_POST_INTERVAL_MIN : 60 ,
18
- INSTAGRAM_POST_INTERVAL_MAX : 120 ,
17
+ INSTAGRAM_POST_INTERVAL_MIN : '60' ,
18
+ INSTAGRAM_POST_INTERVAL_MAX : ' 120' ,
19
19
INSTAGRAM_ENABLE_ACTION_PROCESSING : false ,
20
- INSTAGRAM_ACTION_INTERVAL : 5 ,
21
- INSTAGRAM_MAX_ACTIONS : 1 ,
20
+ INSTAGRAM_ACTION_INTERVAL : '5' ,
21
+ INSTAGRAM_MAX_ACTIONS : '1' ,
22
22
} ;
23
23
24
24
vi . mocked ( mockRuntime . getSetting ) . mockImplementation ( ( key : string ) => {
25
25
if ( key === 'INSTAGRAM_DRY_RUN' ) return 'false' ;
26
26
if ( key === 'INSTAGRAM_ENABLE_ACTION_PROCESSING' ) return 'false' ;
27
- return validConfig [ key as keyof typeof validConfig ] ;
27
+ return validConfig [ key as keyof typeof validConfig ] ?. toString ( ) || null ;
28
28
} ) ;
29
29
30
30
const config = await validateInstagramConfig ( mockRuntime ) ;
@@ -39,17 +39,80 @@ describe('Instagram Environment Configuration', () => {
39
39
INSTAGRAM_APP_ID : 'test_app_id' ,
40
40
INSTAGRAM_APP_SECRET : 'test_app_secret' ,
41
41
INSTAGRAM_BUSINESS_ACCOUNT_ID : 'business_123' ,
42
- INSTAGRAM_POST_INTERVAL_MIN : 60 ,
43
- INSTAGRAM_POST_INTERVAL_MAX : 120 ,
42
+ INSTAGRAM_POST_INTERVAL_MIN : '60' ,
43
+ INSTAGRAM_POST_INTERVAL_MAX : ' 120' ,
44
44
INSTAGRAM_ENABLE_ACTION_PROCESSING : false ,
45
- INSTAGRAM_ACTION_INTERVAL : 5 ,
46
- INSTAGRAM_MAX_ACTIONS : 1 ,
45
+ INSTAGRAM_ACTION_INTERVAL : '5' ,
46
+ INSTAGRAM_MAX_ACTIONS : '1' ,
47
47
} ;
48
48
49
49
vi . mocked ( mockRuntime . getSetting ) . mockImplementation ( ( key : string ) => {
50
50
if ( key === 'INSTAGRAM_DRY_RUN' ) return 'false' ;
51
51
if ( key === 'INSTAGRAM_ENABLE_ACTION_PROCESSING' ) return 'false' ;
52
- return validConfig [ key as keyof typeof validConfig ] ;
52
+ return validConfig [ key as keyof typeof validConfig ] ?. toString ( ) || null ;
53
+ } ) ;
54
+
55
+ const config = await validateInstagramConfig ( mockRuntime ) ;
56
+ expect ( config ) . toEqual ( validConfig ) ;
57
+ } ) ;
58
+
59
+ it ( 'validates configuration with enhanced image settings' , async ( ) => {
60
+ const validConfig = {
61
+ INSTAGRAM_DRY_RUN : false ,
62
+ INSTAGRAM_USERNAME : 'test_user' ,
63
+ INSTAGRAM_PASSWORD : 'test_password' ,
64
+ INSTAGRAM_APP_ID : 'test_app_id' ,
65
+ INSTAGRAM_APP_SECRET : 'test_app_secret' ,
66
+ INSTAGRAM_POST_INTERVAL_MIN : '60' ,
67
+ INSTAGRAM_POST_INTERVAL_MAX : '120' ,
68
+ INSTAGRAM_ENABLE_ACTION_PROCESSING : false ,
69
+ INSTAGRAM_ACTION_INTERVAL : '5' ,
70
+ INSTAGRAM_MAX_ACTIONS : '1' ,
71
+ INSTAGRAM_IMAGE_WIDTH : '1920' ,
72
+ INSTAGRAM_IMAGE_HEIGHT : '1080' ,
73
+ INSTAGRAM_IMAGE_NEGATIVE_PROMPT : 'blurry, low quality' ,
74
+ INSTAGRAM_IMAGE_ITERATIONS : '30' ,
75
+ INSTAGRAM_IMAGE_GUIDANCE_SCALE : '8.5' ,
76
+ INSTAGRAM_IMAGE_SEED : '12345' ,
77
+ INSTAGRAM_IMAGE_CFG_SCALE : '9' ,
78
+ INSTAGRAM_IMAGE_SAFE_MODE : true ,
79
+ INSTAGRAM_IMAGE_STYLE_PRESET : 'test-preset' ,
80
+ INSTAGRAM_IMAGE_HIDE_WATERMARK : true
81
+ } ;
82
+
83
+ vi . mocked ( mockRuntime . getSetting ) . mockImplementation ( ( key : string ) => {
84
+ if ( key === 'INSTAGRAM_DRY_RUN' ) return 'false' ;
85
+ if ( key === 'INSTAGRAM_ENABLE_ACTION_PROCESSING' ) return 'false' ;
86
+ if ( key === 'INSTAGRAM_IMAGE_SAFE_MODE' ) return 'true' ;
87
+ if ( key === 'INSTAGRAM_IMAGE_HIDE_WATERMARK' ) return 'true' ;
88
+ return validConfig [ key as keyof typeof validConfig ] ?. toString ( ) || null ;
89
+ } ) ;
90
+
91
+ const config = await validateInstagramConfig ( mockRuntime ) ;
92
+ expect ( config ) . toEqual ( validConfig ) ;
93
+ } ) ;
94
+
95
+ it ( 'validates configuration with partial image settings' , async ( ) => {
96
+ const validConfig = {
97
+ INSTAGRAM_DRY_RUN : false ,
98
+ INSTAGRAM_USERNAME : 'test_user' ,
99
+ INSTAGRAM_PASSWORD : 'test_password' ,
100
+ INSTAGRAM_APP_ID : 'test_app_id' ,
101
+ INSTAGRAM_APP_SECRET : 'test_app_secret' ,
102
+ INSTAGRAM_POST_INTERVAL_MIN : '60' ,
103
+ INSTAGRAM_POST_INTERVAL_MAX : '120' ,
104
+ INSTAGRAM_ENABLE_ACTION_PROCESSING : false ,
105
+ INSTAGRAM_ACTION_INTERVAL : '5' ,
106
+ INSTAGRAM_MAX_ACTIONS : '1' ,
107
+ INSTAGRAM_IMAGE_WIDTH : '1920' ,
108
+ INSTAGRAM_IMAGE_HEIGHT : '1080' ,
109
+ INSTAGRAM_IMAGE_NEGATIVE_PROMPT : 'blurry'
110
+ } ;
111
+
112
+ vi . mocked ( mockRuntime . getSetting ) . mockImplementation ( ( key : string ) => {
113
+ if ( key === 'INSTAGRAM_DRY_RUN' ) return 'false' ;
114
+ if ( key === 'INSTAGRAM_ENABLE_ACTION_PROCESSING' ) return 'false' ;
115
+ return validConfig [ key as keyof typeof validConfig ] ?. toString ( ) || null ;
53
116
} ) ;
54
117
55
118
const config = await validateInstagramConfig ( mockRuntime ) ;
@@ -67,7 +130,7 @@ describe('Instagram Environment Configuration', () => {
67
130
68
131
vi . mocked ( mockRuntime . getSetting ) . mockImplementation ( ( key : string ) => {
69
132
if ( key === 'INSTAGRAM_DRY_RUN' ) return 'false' ;
70
- return invalidConfig [ key as keyof typeof invalidConfig ] ;
133
+ return invalidConfig [ key as keyof typeof invalidConfig ] ?. toString ( ) || null ;
71
134
} ) ;
72
135
73
136
await expect ( validateInstagramConfig ( mockRuntime ) ) . rejects . toThrow ( ) ;
@@ -82,7 +145,46 @@ describe('Instagram Environment Configuration', () => {
82
145
83
146
vi . mocked ( mockRuntime . getSetting ) . mockImplementation ( ( key : string ) => {
84
147
if ( key === 'INSTAGRAM_DRY_RUN' ) return 'false' ;
85
- return invalidConfig [ key as keyof typeof invalidConfig ] ;
148
+ return invalidConfig [ key as keyof typeof invalidConfig ] ?. toString ( ) || null ;
149
+ } ) ;
150
+
151
+ await expect ( validateInstagramConfig ( mockRuntime ) ) . rejects . toThrow ( ) ;
152
+ } ) ;
153
+
154
+ it ( 'throws error for invalid image dimensions' , async ( ) => {
155
+ const invalidConfig = {
156
+ INSTAGRAM_DRY_RUN : false ,
157
+ INSTAGRAM_USERNAME : 'test_user' ,
158
+ INSTAGRAM_PASSWORD : 'test_password' ,
159
+ INSTAGRAM_APP_ID : 'test_app_id' ,
160
+ INSTAGRAM_APP_SECRET : 'test_app_secret' ,
161
+ INSTAGRAM_IMAGE_WIDTH : '-100' , // Invalid negative width
162
+ INSTAGRAM_IMAGE_HEIGHT : '0' , // Invalid zero height
163
+ } ;
164
+
165
+ vi . mocked ( mockRuntime . getSetting ) . mockImplementation ( ( key : string ) => {
166
+ if ( key === 'INSTAGRAM_DRY_RUN' ) return 'false' ;
167
+ return invalidConfig [ key as keyof typeof invalidConfig ] ?. toString ( ) || null ;
168
+ } ) ;
169
+
170
+ await expect ( validateInstagramConfig ( mockRuntime ) ) . rejects . toThrow ( ) ;
171
+ } ) ;
172
+
173
+ it ( 'throws error for invalid numeric image settings' , async ( ) => {
174
+ const invalidConfig = {
175
+ INSTAGRAM_DRY_RUN : false ,
176
+ INSTAGRAM_USERNAME : 'test_user' ,
177
+ INSTAGRAM_PASSWORD : 'test_password' ,
178
+ INSTAGRAM_APP_ID : 'test_app_id' ,
179
+ INSTAGRAM_APP_SECRET : 'test_app_secret' ,
180
+ INSTAGRAM_IMAGE_GUIDANCE_SCALE : '-1' , // Invalid negative guidance scale
181
+ INSTAGRAM_IMAGE_CFG_SCALE : '0' , // Invalid zero cfg scale
182
+ INSTAGRAM_IMAGE_ITERATIONS : '-5' // Invalid negative iterations
183
+ } ;
184
+
185
+ vi . mocked ( mockRuntime . getSetting ) . mockImplementation ( ( key : string ) => {
186
+ if ( key === 'INSTAGRAM_DRY_RUN' ) return 'false' ;
187
+ return invalidConfig [ key as keyof typeof invalidConfig ] ?. toString ( ) || null ;
86
188
} ) ;
87
189
88
190
await expect ( validateInstagramConfig ( mockRuntime ) ) . rejects . toThrow ( ) ;
0 commit comments