Skip to content

Commit 7292e7c

Browse files
test: add E2E tests for new session RPC features (mode, plan, workspace)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent de7d87c commit 7292e7c

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

nodejs/test/e2e/rpc.test.ts

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,80 @@ describe("Session RPC", async () => {
9494
const after = await session.rpc.model.getCurrent();
9595
expect(after.modelId).toBe("gpt-4.1");
9696
});
97+
98+
it("should get and set session mode", async () => {
99+
const session = await client.createSession();
100+
101+
// Get initial mode (default should be interactive)
102+
const initial = await session.rpc.mode.get();
103+
expect(initial.mode).toBe("interactive");
104+
105+
// Switch to plan mode
106+
const planResult = await session.rpc.mode.set({ mode: "plan" });
107+
expect(planResult.mode).toBe("plan");
108+
109+
// Verify mode persisted
110+
const afterPlan = await session.rpc.mode.get();
111+
expect(afterPlan.mode).toBe("plan");
112+
113+
// Switch back to interactive
114+
const interactiveResult = await session.rpc.mode.set({ mode: "interactive" });
115+
expect(interactiveResult.mode).toBe("interactive");
116+
});
117+
118+
it("should read, update, and delete plan", async () => {
119+
const session = await client.createSession();
120+
121+
// Initially plan should not exist
122+
const initial = await session.rpc.plan.read();
123+
expect(initial.exists).toBe(false);
124+
expect(initial.content).toBeNull();
125+
126+
// Create/update plan
127+
const planContent = "# Test Plan\n\n- Step 1\n- Step 2";
128+
await session.rpc.plan.update({ content: planContent });
129+
130+
// Verify plan exists and has correct content
131+
const afterUpdate = await session.rpc.plan.read();
132+
expect(afterUpdate.exists).toBe(true);
133+
expect(afterUpdate.content).toBe(planContent);
134+
135+
// Delete plan
136+
await session.rpc.plan.delete();
137+
138+
// Verify plan is deleted
139+
const afterDelete = await session.rpc.plan.read();
140+
expect(afterDelete.exists).toBe(false);
141+
expect(afterDelete.content).toBeNull();
142+
});
143+
144+
it("should create, list, and read workspace files", async () => {
145+
const session = await client.createSession();
146+
147+
// Initially no files
148+
const initialFiles = await session.rpc.workspace.listFiles();
149+
expect(initialFiles.files).toEqual([]);
150+
151+
// Create a file
152+
const fileContent = "Hello, workspace!";
153+
await session.rpc.workspace.createFile({ path: "test.txt", content: fileContent });
154+
155+
// List files
156+
const afterCreate = await session.rpc.workspace.listFiles();
157+
expect(afterCreate.files).toContain("test.txt");
158+
159+
// Read file
160+
const readResult = await session.rpc.workspace.readFile({ path: "test.txt" });
161+
expect(readResult.content).toBe(fileContent);
162+
163+
// Create nested file
164+
await session.rpc.workspace.createFile({
165+
path: "subdir/nested.txt",
166+
content: "Nested content",
167+
});
168+
169+
const afterNested = await session.rpc.workspace.listFiles();
170+
expect(afterNested.files).toContain("test.txt");
171+
expect(afterNested.files.some((f) => f.includes("nested.txt"))).toBe(true);
172+
});
97173
});

0 commit comments

Comments
 (0)