Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions packages/cli/src/__tests__/oauth-cov.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ describe("getOrPromptApiKey", () => {

it("throws after 3 failed OAuth + manual attempts", async () => {
// Mock Bun.serve to fail (so OAuth flow returns null)
// biome-ignore lint: test mock
const serveSpy = spyOn(Bun, "serve" as never).mockImplementation(() => {
const serveSpy = spyOn(Bun, "serve").mockImplementation(() => {
throw new Error("port in use");
});
// Mock p.text to return empty (manual entry fails)
Expand All @@ -168,8 +167,7 @@ describe("getOrPromptApiKey", () => {
process.env.SPAWN_ENABLED_STEPS = "github";

// OAuth will fail, manual will fail => throws
// biome-ignore lint: test mock
const serveSpy = spyOn(Bun, "serve" as never).mockImplementation(() => {
const serveSpy = spyOn(Bun, "serve").mockImplementation(() => {
throw new Error("port in use");
});
textSpy.mockImplementation(async () => "");
Expand Down Expand Up @@ -208,8 +206,7 @@ describe("getOrPromptApiKey", () => {

it("returns key from manual entry via prompt after OAuth fails", async () => {
// Simulate OAuth failure via Bun.serve throwing
// biome-ignore lint: test mock
const serveSpy = spyOn(Bun, "serve" as never).mockImplementation(() => {
const serveSpy = spyOn(Bun, "serve").mockImplementation(() => {
throw new Error("port in use");
});
const validKey = "sk-or-v1-" + "f".repeat(64);
Expand All @@ -223,8 +220,7 @@ describe("getOrPromptApiKey", () => {
});

it("sets OPENROUTER_API_KEY in process.env on success from manual entry", async () => {
// biome-ignore lint: test mock
const serveSpy = spyOn(Bun, "serve" as never).mockImplementation(() => {
const serveSpy = spyOn(Bun, "serve").mockImplementation(() => {
throw new Error("port in use");
});
const validKey = "sk-or-v1-" + "e".repeat(64);
Expand All @@ -239,8 +235,7 @@ describe("getOrPromptApiKey", () => {
});

it("accepts non-standard key format when user confirms", async () => {
// biome-ignore lint: test mock
const serveSpy = spyOn(Bun, "serve" as never).mockImplementation(() => {
const serveSpy = spyOn(Bun, "serve").mockImplementation(() => {
throw new Error("port in use");
});
let callCount = 0;
Expand Down
Loading