import { describe, expect, mock, test } from "bun:test";
const encoder = new TextEncoder();
const blobs: Record<string, string | Uint8Array> = {
a: "hello world\nnothing\nHello again",
b: "hello from a dependency",
c: new Uint8Array([104, 101, 108, 108, 111, 0, 1]),
d: "hello, edited in the room",
};
const entries = [
{ path: "src/a.ts", sha: "a", type: "blob" },
{ path: "node_modules/x/b.js", sha: "b", type: "blob" },
{ path: "logo.png", sha: "c", type: "blob" },
{ path: "src/d.ts", sha: "d", type: "exec" },
{ path: "lib", sha: "s", type: "symlink" },
];
mock.module("cloudflare:workers", () => ({ env: {}, waitUntil: () => undefined }));
const actualSession = await import("./session");
mock.module("./session", () => ({
...actualSession,
editorSessionFromRequest: async () => ({
repo: { id: "r1", artifacts_name: "art", owner_name: "o", name: "n" },
revision: { name: "main", kind: "branch", sha: "c0" },
viewer: { id: "u1", name: "alice" },
}),
canWrite: () => true,
needsPullRequest: async () => false,
}));
const actualLimits = await import("../limits");
mock.module("../limits", () => ({
...actualLimits,
limitBrowse: async () => undefined,
limitWrite: async () => undefined,
}));
const actualStore = await import("../git/store");
mock.module("../git/store", () => ({
...actualStore,
withStore: async (_name: string, run: (store: unknown) => Promise<Response>) =>
run({
commit: async () => ({ treeSha: "t0" }),