Versions 32 to 318
new file, 239 lines
1+// abso orgs and abso org: reads as the person who approved the box's sign-in, and the changes say where the
2+// website makes them. The server here is a stand-in that answers the org routes' documented shapes.
3+
13+
16+
31+
48+
50+
52+ it("lists yours with your role, and invitations waiting, reading with the box's sign-in", async () => {
62+ invitations: [{ id: "inv_1", org: "gamma", role: "member", expiresAt: "2026-10-16T10:00:00.000Z" }],
78+ assert.deepEqual(s.asked, [{ url: `${SERVER}/orgs`, method: "GET", auth: `Box ${CREDENTIAL}` }]);
80+
81+ it("says so when the box isn't signed in, the sign-in isn't taken, or orgs aren't on", async () => {
83+ await assert.rejects(runOrgs(SERVER, { home: empty, fetch: server({}).fetcher }), /abso login signs it in/);
85+ const expired = server({ "/orgs": { status: 401, body: { error: "missing or wrong token" } } });
86+ await assert.rejects(runOrgs(SERVER, { home, fetch: expired.fetcher }), /abso login renews it/);
87+ const off = server({ "/orgs": { status: 404, body: { error: "organizations aren't on here yet" } } });
88+ await assert.rejects(runOrgs(SERVER, { home, fetch: off.fetcher }), /api\.example\.dev: organizations aren't on/);
90+
94+ await assert.rejects(runOrgs(SERVER, { home, fetch: s.fetcher }), (e: Error) => !e.message.includes(CREDENTIAL));
97+
111+ invites: [{ id: "inv_2", role: "member", kind: "link", for: null, expiresAt: "2026-10-16T10:00:00.000Z" }],
113+
114+ it("shows its projects, people, settings and open invites to a member, never a person's id", async () => {
134+
138+ "/orgs/acme-labs": { status: 200, body: { name: "acme-labs", displayName: "Acme Labs", description: null } },
141+ assert.equal(out.text, "acme-labs (Acme Labs)\nYou aren't a member, so its people and settings aren't shown.");
143+
146+ await assert.rejects(runOrg(args(["nope"]), SERVER, { home, fetch: server({}).fetcher }), /^.*nope: no such route/);
148+
149+ it("sends no change: each says where on the website it is made, and nothing reaches the server", async () => {
153+ [["acme-labs", "--invite", "sam"], /--invite is on acme-labs's People tab: https:\/\/example\.dev\/acme-labs\./],
162+ await assert.rejects(runOrg(args(line), SERVER, { home, fetch: s.fetcher }), said, line.join(" "));
170+
185+
189+ assert.equal(siteOf("https://staging.example.workers.dev/"), "https://staging.example.workers.dev");
193+
195+ it("makes the org as the box's person, sending the box's sign-in and the shown name", async () => {
197+ const s = server({ "/box/orgs": { status: 200, body: { name: "acme-labs", displayName: "Acme Labs" } } });
198+ const out = await runOrg(args(["new", "acme-labs", "--name", "Acme Labs"]), SERVER, { home, fetch: s.fetcher });
206+ assert.deepEqual(JSON.parse(s.asked[0]?.body ?? "{}"), { name: "acme-labs", displayName: "Acme Labs" });
208+ it("says what the server says when the box's grant is a list, and never shows the credential", async () => {
211+ "/box/orgs": { status: 403, body: { error: "only a box approved for all your projects makes organizations" } },
216+ /refused \(403\): only a box approved for all your projects/.test(e.message) && !e.message.includes(CREDENTIAL),
226+ runOrg(args(["new", "acme-labs", "--leave"]), SERVER, { home: signedIn(), fetch: server({}).fetcher }),
231+
236+ /isn't signed in to https:\/\/api\.example\.dev.*abso init --org acme-labs again; or New project at https:\/\/example\.dev\./,
- MCP
- compare on this site's /mcp
- CLI
- abso diff 32 318 client/test/orgs.test.ts --json
- JSON
- /christopher/abso-core/compare/32..318?file=client%2Ftest%2Forgs.test.ts&format=json