Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(store): add tests for runModeSlice

Steven Enamakelf285604521b2
diff --git a/app/src/store/runModeSlice.test.ts b/app/src/store/runModeSlice.test.ts
new file mode 100644
index 0000000000..83559e1d8b
--- /dev/null
+++ b/app/src/store/runModeSlice.test.ts
@@ -0,0 +1,25 @@
+import { describe, expect, it } from 'vitest';
+
+import reducer, { setRunMode, type RunModeState } from './runModeSlice';
+
+const initial: RunModeState = { byThread: {} };
+
+describe('runModeSlice', () => {
+ it('sets the mode for a thread', () => {
+ const next = reducer(initial, setRunMode({ threadId: 't1', mode: 'plan' }));
+ expect(next.byThread.t1).toBe('plan');
+ });
+
+ it('flips a thread from plan to build', () => {
+ const withPlan = reducer(initial, setRunMode({ threadId: 't1', mode: 'plan' }));
+ const withBuild = reducer(withPlan, setRunMode({ threadId: 't1', mode: 'build' }));
+ expect(withBuild.byThread.t1).toBe('build');
+ });
+
+ it('keeps other threads untouched', () => {
+ const withT1 = reducer(initial, setRunMode({ threadId: 't1', mode: 'plan' }));
+ const withT2 = reducer(withT1, setRunMode({ threadId: 't2', mode: 'build' }));
+ expect(withT2.byThread.t1).toBe('plan');
+ expect(withT2.byThread.t2).toBe('build');
+ });
+});