import { beforeEach, describe, expect, mock, test } from "bun:test";
import type { Viewer } from "~/lib/types";
import type { RequestCredential, TokenGrant } from "../token-scope";
class StubEntrypoint {}
mock.module("cloudflare:workers", () => ({
env: { PUBLIC_URL: "https://forge.example.com" },
waitUntil: () => undefined,
WorkflowEntrypoint: StubEntrypoint,
DurableObject: StubEntrypoint,
WorkerEntrypoint: StubEntrypoint,
}));
mock.module("../repo-provisioning", () => ({
describeProvisioningError: () => "",
markProvisioningFailed: async () => undefined,
startProvisioning: async () => undefined,
RepoProvisionWorkflow: StubEntrypoint,
}));
const people: Record<string, Viewer> = Object.fromEntries(
["owner", "admin", "writer", "reader"].map((name) => [
name,
{
id: `u-${name}`,
name,
displayName: null,
email: `${name}@example.com`,
isAdmin: false,
emailVerified: true,
},
]),
);
const collaborators: Record<string, string> = {
"u-admin": "admin",
"u-writer": "write",
"u-reader": "read",
};
const repo = {
id: "repo-1",
owner_id: "u-owner",