Replaces legacy adapter ids (codex_local / claude_local / gemini_local / claude_compatible) across ~42 test files with pi-mono equivalents: - codex_local → openai-codex - claude_local → claude-pro - gemini_local → gemini-cli - claude_compatible → anthropic Hand-rewrites where fixture semantics changed: - connector-matching: TASK_TYPE_PREFERENCE ordering rebased (claude-pro first for code/content/management; google first for research) - connector-model-policy: getModels(provider) from pi-ai instead of the deleted adapter.module.models array - session-management + edge-case-session: adapter exemption removed; rotation now uniform under pi-mono - ipc-core-admin-handlers: CSV compat model replaced with pi-ai anthropic - connectors.spec: lookup by openai-codex id (catalog now starts with claude-pro) - onboarding-model-pool: listProviderModels(provider) helper; label text changed to "ChatGPT Plus/Pro (Codex)" - database integration: added vault insecure-fallback env + electron mock - command-paths: uses new @main/connector-helpers normalizeCommandValue - pi-mono-migrations: added `as string` casts for 3 negative-existence assertions verifying legacy ids were removed Drops: - pnpm-workspace.yaml packages: [] (was "packages/*"; directory empty) - obsolete CONNECTOR_STRENGTHS import; .module.models probing Verification: - pnpm typecheck → 0 errors - pnpm lint → 0 errors / 0 warnings - pnpm build:verify → 0 errors / 0 warnings - pnpm test:unit → 508/508 pass - pnpm test:integration → 96/96 pass - All 6 adapter hard gates pass (NOT FOUND / 0 matches / empty) - pi-ai / pi-agent-core / pi-coding-agent all resolved @0.67.6
65 lines
2.1 KiB
TypeScript
65 lines
2.1 KiB
TypeScript
import { mkdtemp, rm } from "node:fs/promises";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
|
import { AppDatabase } from "../../src/main/database";
|
|
import { CredentialStore } from "../../src/main/credentials/credential-store";
|
|
import { OAuthLoginService } from "../../src/main/credentials/oauth-login-service";
|
|
|
|
vi.mock("electron", () => ({
|
|
shell: { openExternal: vi.fn(async () => true) },
|
|
}));
|
|
|
|
beforeAll(() => {
|
|
process.env.AGENTCOMPANY_ALLOW_INSECURE_VAULT = "true";
|
|
});
|
|
|
|
const noopLogger = { info: vi.fn(), warn: vi.fn(), error: vi.fn() };
|
|
|
|
describe("OAuthLoginService", () => {
|
|
let tempDir: string;
|
|
let db: AppDatabase;
|
|
let store: CredentialStore;
|
|
let service: OAuthLoginService;
|
|
const emit = vi.fn();
|
|
|
|
beforeEach(async () => {
|
|
tempDir = await mkdtemp(join(tmpdir(), "agentcompany-oauth-service-"));
|
|
db = new AppDatabase(tempDir);
|
|
db.init();
|
|
store = new CredentialStore({ db });
|
|
service = new OAuthLoginService({
|
|
store,
|
|
emitEvent: emit,
|
|
refreshConnectorHealth: async () => {},
|
|
logger: noopLogger,
|
|
});
|
|
emit.mockClear();
|
|
});
|
|
|
|
afterEach(async () => {
|
|
db.close();
|
|
await rm(tempDir, { recursive: true, force: true });
|
|
});
|
|
|
|
it("rejects start() for a non-OAuth connector", async () => {
|
|
await expect(service.start("anthropic")).rejects.toThrow(/does not use OAuth/);
|
|
});
|
|
|
|
it("rejects start() for an unknown connector id", async () => {
|
|
await expect(service.start("definitely-not-a-connector")).rejects.toThrow(/Unknown connector/);
|
|
});
|
|
|
|
it("submitPromptResponse returns false when there is no pending prompt", () => {
|
|
expect(service.submitPromptResponse("nonexistent-request-id", "value")).toBe(false);
|
|
});
|
|
|
|
it("submitManualCode returns false when there is no pending request", () => {
|
|
expect(service.submitManualCode("nonexistent-request-id", "code")).toBe(false);
|
|
});
|
|
|
|
it("cancel() of a connector with no active flow is a no-op (does not throw)", () => {
|
|
expect(() => service.cancel("claude-pro")).not.toThrow();
|
|
});
|
|
});
|