源码快照 @ 2026-09-02 (source-only, 剔除非源码素材)

This commit is contained in:
agent-radar committed 2026-09-02 01:05:41 +08:00
commit 04bac1f6e2
2200 files changed
+489415

No files matched your search

+105
View File
@@ -0,0 +1,105 @@
import { afterEach, describe, expect, test } from "bun:test";
import {
createDenClient,
formatDenOrgRoleLabel,
getDenCanonicalOrgRole,
isDenOrgAdminRole,
} from "../src/app/lib/den";
const originalFetch = globalThis.fetch;
afterEach(() => {
Object.defineProperty(globalThis, "fetch", {
configurable: true,
value: originalFetch,
});
});
describe("Den organization roles", () => {
test("keeps super-admin organizations in the desktop organization list", async () => {
Object.defineProperty(globalThis, "fetch", {
configurable: true,
value: (async () =>
new Response(JSON.stringify({
orgs: [{
id: "org_super",
name: "Super organization",
slug: "super-organization",
role: "super-admin",
}],
activeOrgId: "org_super",
activeOrgSlug: "super-organization",
}), {
status: 200,
headers: { "Content-Type": "application/json" },
})) satisfies typeof fetch,
});
await expect(
createDenClient({
baseUrl: "https://den.test",
token: "tok_test",
}).listOrgs(),
).resolves.toEqual({
orgs: [{
id: "org_super",
name: "Super organization",
slug: "super-organization",
role: "super-admin",
}],
activeOrgId: "org_super",
activeOrgSlug: "super-organization",
defaultOrgId: "org_super",
});
});
test("keeps custom and combined roles without collapsing their role strings", async () => {
Object.defineProperty(globalThis, "fetch", {
configurable: true,
value: (async () =>
new Response(JSON.stringify({
orgs: [
{
id: "org_custom",
name: "Custom organization",
slug: "custom-organization",
role: "qa-reviewer",
},
{
id: "org_combined",
name: "Combined organization",
slug: "combined-organization",
role: "qa-reviewer, super-admin",
},
],
activeOrgId: "org_custom",
activeOrgSlug: "custom-organization",
}), {
status: 200,
headers: { "Content-Type": "application/json" },
})) satisfies typeof fetch,
});
await expect(
createDenClient({
baseUrl: "https://den.test",
token: "tok_test",
}).listOrgs(),
).resolves.toMatchObject({
orgs: [
{ id: "org_custom", role: "qa-reviewer" },
{ id: "org_combined", role: "qa-reviewer, super-admin" },
],
});
});
test("derives built-in access while preserving custom role labels", () => {
expect(getDenCanonicalOrgRole("qa-reviewer")).toBe("member");
expect(getDenCanonicalOrgRole("admin, qa-reviewer")).toBe("admin");
expect(getDenCanonicalOrgRole("qa-reviewer, super_admin")).toBe("super-admin");
expect(isDenOrgAdminRole("qa-reviewer")).toBe(false);
expect(isDenOrgAdminRole("qa-reviewer, super-admin")).toBe(true);
expect(formatDenOrgRoleLabel("qa-reviewer, super-admin")).toBe("Qa Reviewer, Super admin");
});
});