File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
client/src/components/__tests__ Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -161,6 +161,31 @@ describe("Sidebar Environment Variables", () => {
161
161
NEW_THIRD_KEY : "third_value" ,
162
162
} ) ;
163
163
} ) ;
164
+
165
+ it ( "should maintain order during key editing" , ( ) => {
166
+ const setEnv = jest . fn ( ) ;
167
+ const initialEnv = {
168
+ KEY1 : "value1" ,
169
+ KEY2 : "value2"
170
+ } ;
171
+ renderSidebar ( { env : initialEnv , setEnv } ) ;
172
+
173
+ openEnvVarsSection ( ) ;
174
+
175
+ // Type "NEW_" one character at a time
176
+ const key1Input = screen . getByDisplayValue ( "KEY1" ) ;
177
+ "NEW_" . split ( "" ) . forEach ( ( char ) => {
178
+ fireEvent . change ( key1Input , { target : { value : char + "KEY1" . slice ( 1 ) } } ) ;
179
+ } ) ;
180
+
181
+ // Verify the last setEnv call maintains the order
182
+ const lastCall = setEnv . mock . calls [ setEnv . mock . calls . length - 1 ] [ 0 ] as Record < string , string > ;
183
+ const entries = Object . entries ( lastCall ) ;
184
+
185
+ // The values should stay with their original keys
186
+ expect ( entries [ 0 ] [ 1 ] ) . toBe ( "value1" ) ; // First entry should still have value1
187
+ expect ( entries [ 1 ] [ 1 ] ) . toBe ( "value2" ) ; // Second entry should still have value2
188
+ } ) ;
164
189
} ) ;
165
190
166
191
describe ( "Multiple Operations" , ( ) => {
You can’t perform that action at this time.
0 commit comments