| @@ -0,0 +1,46 @@ |
| 1 | +import { describe, expect, it } from "@effect/vitest"; |
| 2 | +import { Effect } from "effect"; |
| 3 | +import type { InvokeOptions } from "@executor-js/sdk"; |
| 4 | + |
| 5 | +import { makePluginCtxAppsResolver, type AppsResolverPluginCtx } from "./resolver"; |
| 6 | + |
| 7 | +const run = <A, E>(effect: Effect.Effect<A, E>): Promise<A> => Effect.runPromise(effect); |
| 8 | + |
| 9 | +describe("makePluginCtxAppsResolver", () => { |
| 10 | + it("passes caller invoke options through bridged integration calls", async () => { |
| 11 | + const invokeOptions = { onElicitation: "accept-all" } satisfies InvokeOptions; |
| 12 | + let seenAddress = ""; |
| 13 | + let seenPayload: unknown; |
| 14 | + let seenOptions: InvokeOptions | undefined; |
| 15 | + |
| 16 | + const ctx: AppsResolverPluginCtx = { |
| 17 | + connections: { |
| 18 | + list: () => Effect.succeed([]), |
| 19 | + get: () => Effect.succeed(null), |
| 20 | + }, |
| 21 | + execute: (address: unknown, payload: unknown, options?: InvokeOptions) => |
| 22 | + Effect.sync(() => { |
| 23 | + seenAddress = String(address); |
| 24 | + seenPayload = payload; |
| 25 | + seenOptions = options; |
| 26 | + return "called"; |
| 27 | + }), |
| 28 | + }; |
| 29 | + |
| 30 | + const resolver = makePluginCtxAppsResolver({ ctx }); |
| 31 | + const result = await run( |
| 32 | + resolver.call({ |
| 33 | + integration: "github", |
| 34 | + connection: "tools.github.user.main", |
| 35 | + path: ["issues", "listForRepo"], |
| 36 | + args: [{ owner: "acme", repo: "tools" }], |
| 37 | + invokeOptions, |
| 38 | + }), |
| 39 | + ); |
| 40 | + |
| 41 | + expect(result).toBe("called"); |
| 42 | + expect(seenAddress).toBe("tools.github.user.main.issues.listForRepo"); |
| 43 | + expect(seenPayload).toEqual({ owner: "acme", repo: "tools" }); |
| 44 | + expect(seenOptions).toBe(invokeOptions); |
| 45 | + }); |
| 46 | +}); |