import { beforeEach, describe, expect, mock, test } from "bun:test";
import type { Viewer } from "~/lib/types";
import type { RequestCredential } from "../token-scope";
class StubEntrypoint {}
mock.module("cloudflare:workers", () => ({
env: { PUBLIC_URL: "https://forge.example.com" },
waitUntil: () => undefined,
WorkflowEntrypoint: StubEntrypoint,
DurableObject: StubEntrypoint,
WorkerEntrypoint: StubEntrypoint,
}));
const HEAD = "a".repeat(40);
const people: Record<string, Viewer> = Object.fromEntries(
["owner", "writer", "author", "stranger"].map((name) => [
name,
{ id: `u-${name}`, name, displayName: null, email: `${name}@example.com`, isAdmin: false, emailVerified: true },
]),
);
const baseRepo = {
id: "repo-1",
owner_id: "u-owner",
owner_name: "owner",
name: "app",
visibility: "public",
fork_of_id: null,
is_archived: 0,
default_branch: "main",
artifacts_name: "art-1",
description: null,
};
const pullRow = {
issue_id: "issue-1",
repo_id: "repo-1",
number: 1,
title: "Feature",
body: "",
state: "open",
author_id: "u-author",