feat: add low-level Wrenn client resources
Implement WrennClient with typed resource mappings for auth, account, API keys, users, teams, capsules, files, snapshots, hosts, and channels. Add endpoint mapping tests plus live integration tess that authenticate with WRENN_TEST_EMAIL/WRENN_TEST_PASS and use WRENN_API_KEY for API-key scoped endpoints
This commit is contained in:
85
tests/integration/client.integration.test.ts
Normal file
85
tests/integration/client.integration.test.ts
Normal file
@ -0,0 +1,85 @@
|
||||
import { beforeAll, describe, expect, it } from "vitest";
|
||||
|
||||
import { WrennClient } from "../../src/client.js";
|
||||
import { 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;
|
||||
|
||||
describeWithApiKey("WrennClient live API key integration", () => {
|
||||
const client = new WrennClient({ apiKey, baseUrl });
|
||||
|
||||
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");
|
||||
client = new WrennClient({ baseUrl, token: auth.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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user