Files
streamline/control-server/test/actor_context.test.ts
T
2026-11-16 17:26:44 -08:00

25 lines
1.1 KiB
TypeScript

import { test, expect } from "bun:test";
import { currentActor, currentSsoEmail, runAsSystem } from "../src/actor_context";
test("no scope → null; system scope survives a detached promise chain like notifyStatusTransition's", async () => {
expect(await currentActor()).toBeNull();
const seen = await runAsSystem("unattended", async () => {
let out: string | null = "unset";
await new Promise<void>((done) => {
void Promise.resolve().then(() => new Promise((r) => setTimeout(r, 5))).then(async () => { out = await currentActor(); done(); });
});
return out;
});
expect(seen).toBe("system:unattended");
});
test("a transition long after the scope opened is not attributed to it", async () => {
const late = await runAsSystem("x", () => currentActor(Date.now() + 6 * 60_000));
expect(late).toBeNull();
});
test("commit-author SSO slot is empty without a session, and system actors are not emails", async () => {
expect(await currentSsoEmail()).toBeNull();
expect(await runAsSystem("unattended", () => currentSsoEmail())).toBeNull();
});