fix(pet): a member's pet chat starts in <their folder>/sagi
POST /api/lanes/ensure without a cwd defaulted to the dashboard's own home, outside a member's folder, so every member's pet chat failed with "a workspace must be inside your own folder" (EFOLDER). A member now gets <their folder>/sagi, made as them (write-as mkdir) on first use.
This commit is contained in:
@@ -192,3 +192,31 @@ describe("a member's new project folder", () => {
|
||||
assert.equal(fs.existsSync(path.join(TMP, "host-new")), false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("the pet chat's workspace for a member", () => {
|
||||
it("is <their folder>/sagi, made as them — never the host's home (EFOLDER)", async () => {
|
||||
const { fakeSudo } = require("./fixtures/fake-sudo");
|
||||
const sudo = fakeSudo();
|
||||
runAs.__setExecImpl(sudo.exec);
|
||||
const login = await fetch(`${BASE}/api/auth/login`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ username: "mia", password: "member-pass-1" }),
|
||||
});
|
||||
const cm = login.headers.get("set-cookie").split(";")[0];
|
||||
const ensure = () =>
|
||||
fetch(`${BASE}/api/lanes/ensure`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json", cookie: cm },
|
||||
body: JSON.stringify({ title: "Sagi" }),
|
||||
}).then(async (r) => ({ status: r.status, body: await r.json() }));
|
||||
const first = await ensure();
|
||||
assert.equal(first.status, 201, JSON.stringify(first.body));
|
||||
const want = fs.realpathSync(path.join(USERS, "mia", "sagi"));
|
||||
assert.equal(first.body.lane.cwd, want);
|
||||
const mk = sudo.calls.find((c) => c.includes("/opt/agenthub/libexec/write-as"));
|
||||
assert.ok(mk && mk.includes("ah-mia") && mk.includes("mkdir"));
|
||||
const again = await ensure();
|
||||
assert.equal(again.body.lane.id, first.body.lane.id, "the same workspace next time");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user