Skip to content

Commit 379486b

Browse files
committed
Add failing test for pull/206
1 parent b7fa236 commit 379486b

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

client/src/components/__tests__/Sidebar.test.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,31 @@ describe("Sidebar Environment Variables", () => {
161161
NEW_THIRD_KEY: "third_value",
162162
});
163163
});
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+
});
164189
});
165190

166191
describe("Multiple Operations", () => {

0 commit comments

Comments
 (0)