(
stack: Awaited<ReturnType<typeof bootRealStack>>,
server: { readonly specJson: string },
slug: string,
)
| 169 | |
| 170 | /** addSpec + connection + live invocation through the booted executor. */ |
| 171 | const driveOpenApiWork = ( |
| 172 | stack: Awaited<ReturnType<typeof bootRealStack>>, |
| 173 | server: { readonly specJson: string }, |
| 174 | slug: string, |
| 175 | ) => |
| 176 | Effect.gen(function* () { |
| 177 | const added = yield* stack.executor.openapi.addSpec({ |
| 178 | spec: { kind: "blob", value: server.specJson }, |
| 179 | slug, |
| 180 | authenticationTemplate: [ |
| 181 | { |
| 182 | slug: AuthTemplateSlug.make("apiKey"), |
| 183 | type: "apiKey", |
| 184 | headers: { "x-api-key": [{ type: "variable" as const, name: "token" }] }, |
| 185 | }, |
| 186 | ], |
| 187 | }); |
| 188 | expect(added.toolCount).toBeGreaterThanOrEqual(2); |
| 189 | |
| 190 | yield* stack.executor.connections.create({ |
| 191 | owner: "org", |
| 192 | name: ConnectionName.make("main"), |
| 193 | integration: IntegrationSlug.make(slug), |
| 194 | template: AuthTemplateSlug.make("apiKey"), |
| 195 | value: "test-key-123", |
| 196 | }); |
| 197 | |
| 198 | const list = yield* stack.executor.execute( |
| 199 | ToolAddress.make(`tools.${slug}.org.main.widgets.listWidgets`), |
| 200 | {}, |
| 201 | ); |
| 202 | expect(isToolResult(list) && list.ok).toBe(true); |
| 203 | if (!isToolResult(list) || !list.ok) return; |
| 204 | // Payload-first contract holds through a migrated database too. |
| 205 | expect(list.data).toEqual(WIDGETS); |
| 206 | expect((list as { http?: { status: number } }).http?.status).toBe(200); |
| 207 | |
| 208 | const created = yield* stack.executor.execute( |
| 209 | ToolAddress.make(`tools.${slug}.org.main.widgets.createWidget`), |
| 210 | { body: { name: "doodad" } }, |
| 211 | ); |
| 212 | expect(isToolResult(created) && created.ok).toBe(true); |
| 213 | if (!isToolResult(created) || !created.ok) return; |
| 214 | expect(created.data).toEqual({ id: 3, name: "doodad" }); |
| 215 | }); |
| 216 | |
| 217 | const expectToolRows = async (dbPath: string, slug: string, minCount: number) => { |
| 218 | const client = await openLocalLibsql(dbPath); |
no test coverage detected