27 lines
1.1 KiB
TypeScript
27 lines
1.1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { createTestHarness } from "@paperclipai/plugin-sdk/testing";
|
|
import manifest from "../src/manifest.js";
|
|
import plugin from "../src/worker.js";
|
|
|
|
describe("plugin log viewer", () => {
|
|
it("registers data + actions and handles events", async () => {
|
|
const harness = createTestHarness({ manifest, capabilities: [...manifest.capabilities, "events.emit"] });
|
|
await plugin.definition.setup(harness.ctx);
|
|
|
|
await harness.emit("issue.created", { companyId: "comp_1" }, { entityId: "iss_1", entityType: "issue", companyId: "comp_1" });
|
|
|
|
const logs = await harness.getData<Array<{ eventType: string; entityId: string }>>("logs");
|
|
expect(logs).toBeDefined();
|
|
expect(logs.length).toBeGreaterThan(0);
|
|
expect(logs[0].eventType).toBe("issue.created");
|
|
expect(logs[0].entityId).toBe("iss_1");
|
|
|
|
const health = await harness.getData<{ status: string; logCount: number }>("health");
|
|
expect(health.status).toBe("ok");
|
|
expect(health.logCount).toBe(1);
|
|
|
|
const action = await harness.performAction<{ pong: boolean }>("ping");
|
|
expect(action.pong).toBe(true);
|
|
});
|
|
});
|