import { beforeAll, describe, expect, it } from "vitest"; import { WrennClient } from "../../src/client.js"; import { type ClientConfig, DEFAULT_BASE_URL } from "../../src/config.js"; const baseUrl = process.env.WRENN_BASE_URL ?? DEFAULT_BASE_URL; const apiKey = process.env.WRENN_API_KEY; const testEmail = process.env.WRENN_TEST_EMAIL; const testPassword = process.env.WRENN_TEST_PASS; const describeWithApiKey = apiKey ? describe : describe.skip; const describeWithLogin = testEmail && testPassword ? describe : describe.skip; const apiKeyClientOpts: ClientConfig = { baseUrl }; if (apiKey) apiKeyClientOpts.apiKey = apiKey; describeWithApiKey("WrennClient live API key integration", () => { const client = new WrennClient(apiKeyClientOpts); it("lists capsules from the real Wrenn API", async () => { const capsules = await client.capsules.list(); expect(Array.isArray(capsules)).toBe(true); }); it("lists snapshot templates from the real Wrenn API", async () => { const snapshots = await client.snapshots.list(); expect(Array.isArray(snapshots)).toBe(true); }); it("gets capsule stats from the real Wrenn API", async () => { const stats = await client.capsules.stats({ range: "1h" }); expect(stats).toBeTypeOf("object"); }); it("gets capsule usage from the real Wrenn API", async () => { const usage = await client.capsules.usage(); expect(usage).toBeTypeOf("object"); }); }); describeWithLogin("WrennClient live login integration", () => { let client: WrennClient; beforeAll(async () => { const authClient = new WrennClient({ baseUrl }); const auth = await authClient.auth.login({ email: testEmail as string, password: testPassword as string, }); expect(auth.token).toBeTypeOf("string"); const token = auth.token; if (!token) throw new Error("Login response did not include a token"); client = new WrennClient({ baseUrl, token }); }); it("gets the current account profile from the real Wrenn API", async () => { const me = await client.account.getMe(); expect(me).toBeTypeOf("object"); }); it("lists teams from the real Wrenn API", async () => { const teams = await client.teams.list(); expect(Array.isArray(teams)).toBe(true); }); it("lists API keys from the real Wrenn API", async () => { const keys = await client.apiKeys.list(); expect(Array.isArray(keys)).toBe(true); }); it("lists notification channels from the real Wrenn API", async () => { const channels = await client.channels.list(); expect(Array.isArray(channels)).toBe(true); }); it("lists hosts from the real Wrenn API", async () => { const hosts = await client.hosts.list(); expect(Array.isArray(hosts)).toBe(true); }); });