Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

#5681: test that the grant waits for the team setup write that made the department

milind-soniad1e492b2e79
diff --git a/server/store.test.ts b/server/store.test.ts
index 8e1ffeba93..83494ce83e 100644
--- a/server/store.test.ts
+++ b/server/store.test.ts
@@ -1265,6 +1265,25 @@ describe("Store", () => {
}
});
+ it("gives a new department to a Chief in charge of every department once the write that made it is saved", async () => {
+ const store = new Store(selection);
+ const lead = store.createBot({ name: "Lead", section: "Ops" });
+ store.patchBot(lead.id, { chiefOfStaff: true, managedSections: [""] });
+ const planner = store.createBot({ name: "Planner" });
+ store.setChiefOfStaff(planner.id);
+ store.applyTeamSetup({ version: 1, requestId: "setup-new-team", botId: planner.id, threadId: planner.threadId,
+ reason: "Requested", createdAt: 1, requesterRevision: "fixture", newTeams: ["Research"], operations: [
+ { action: "create", botId: "researcher", threadId: "researcher-thread", fields: { name: "Researcher", section: "Research", modelSelection: selection() } },
+ ] });
+ await new Promise((resolve) => setImmediate(resolve));
+ expect(store.bot(lead.id)?.managedSections).toEqual(["", "Research"]);
+ // Planner was in charge of General alone; the setup's own grant is the only one it has.
+ expect(store.bot(planner.id)?.managedSections).toEqual(["Research"]);
+ const restored = new Store(selection);
+ expect(restored.bot("researcher")?.section).toBe("Research");
+ expect(restored.bot(lead.id)?.managedSections).toEqual(["", "Research"]);
+ });
+
it("lands a created specialist in its proposed working folder, keeping the private workspace clean", () => {
const store = new Store(selection);
const chief = store.createBot({ name: "Chief", section: "Ops" });