Skip to content

Commit 6b0fa71

Browse files
test(agents): add CLI-level pull tests with fixture and file assertions
- Add `with-agents-for-pull` fixture with a JSONC-commented agent file - Add tests verifying agent files are written to disk with correct content - Add test verifying unchanged agents are skipped (JSONC comment preserved) - Add test verifying changed agents are updated in-place at existing path Co-authored-by: paveltarno <Paveltarno@users.noreply.github.com>
1 parent fee405f commit 6b0fa71

File tree

4 files changed

+94
-1
lines changed

4 files changed

+94
-1
lines changed

tests/cli/agents_pull.spec.ts

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, it } from "vitest";
1+
import { describe, expect, it } from "vitest";
22
import { fixture, setupCLITests } from "./testkit/index.js";
33

44
describe("agents pull command", () => {
@@ -52,4 +52,85 @@ describe("agents pull command", () => {
5252

5353
t.expectResult(result).toFail();
5454
});
55+
56+
it("writes agent files to disk after pull", async () => {
57+
await t.givenLoggedInWithProject(fixture("basic"));
58+
t.api.mockAgentsFetch({
59+
items: [
60+
{
61+
name: "support_agent",
62+
description: "Helps users",
63+
instructions: "Be helpful",
64+
},
65+
],
66+
total: 1,
67+
});
68+
69+
const result = await t.run("agents", "pull");
70+
71+
t.expectResult(result).toSucceed();
72+
73+
expect(await t.fileExists("base44/agents/support_agent.jsonc")).toBe(true);
74+
75+
const fileContent = await t.readProjectFile(
76+
"base44/agents/support_agent.jsonc",
77+
);
78+
const parsed = JSON.parse(fileContent!);
79+
expect(parsed.name).toBe("support_agent");
80+
expect(parsed.description).toBe("Helps users");
81+
expect(parsed.instructions).toBe("Be helpful");
82+
});
83+
84+
it("skips unchanged agents and preserves file content", async () => {
85+
await t.givenLoggedInWithProject(fixture("with-agents-for-pull"));
86+
t.api.mockAgentsFetch({
87+
items: [
88+
{
89+
name: "support_agent",
90+
description: "Helps users",
91+
instructions: "Be helpful",
92+
},
93+
],
94+
total: 1,
95+
});
96+
97+
const result = await t.run("agents", "pull");
98+
99+
t.expectResult(result).toSucceed();
100+
t.expectResult(result).toContain("All agents are already up to date");
101+
102+
// The file should not have been rewritten — JSONC comment must still be present
103+
const fileContent = await t.readProjectFile(
104+
"base44/agents/support_agent.jsonc",
105+
);
106+
expect(fileContent).toContain("// My support agent");
107+
});
108+
109+
it("updates agent file in-place when remote data changes", async () => {
110+
await t.givenLoggedInWithProject(fixture("with-agents-for-pull"));
111+
t.api.mockAgentsFetch({
112+
items: [
113+
{
114+
name: "support_agent",
115+
description: "Updated description",
116+
instructions: "Updated instructions",
117+
},
118+
],
119+
total: 1,
120+
});
121+
122+
const result = await t.run("agents", "pull");
123+
124+
t.expectResult(result).toSucceed();
125+
126+
// File should be updated at the same path (in-place)
127+
expect(await t.fileExists("base44/agents/support_agent.jsonc")).toBe(true);
128+
129+
const fileContent = await t.readProjectFile(
130+
"base44/agents/support_agent.jsonc",
131+
);
132+
const parsed = JSON.parse(fileContent!);
133+
expect(parsed.description).toBe("Updated description");
134+
expect(parsed.instructions).toBe("Updated instructions");
135+
});
55136
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"id": "test-app-id"
3+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// My support agent
2+
{
3+
"name": "support_agent",
4+
"description": "Helps users",
5+
"instructions": "Be helpful"
6+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"name": "Agents Pull Test Project"
3+
}

0 commit comments

Comments
 (0)