Some further work on automation webhook testing.
This commit is contained in:
parent
715399b755
commit
80bd561bba
|
@ -17,6 +17,7 @@ describe("Branching automations", () => {
|
|||
.createRow({
|
||||
row: { tableId: table._id!, name: "{{ trigger.parameter }}" },
|
||||
})
|
||||
.collect({ collection: `{{ trigger.parameter }}` })
|
||||
.save()
|
||||
|
||||
webhook = await config.api.webhook.save({
|
||||
|
@ -28,6 +29,10 @@ describe("Branching automations", () => {
|
|||
},
|
||||
bodySchema: {},
|
||||
})
|
||||
await config.api.webhook.buildSchema(config.getAppId(), webhook._id!, {
|
||||
parameter: "string",
|
||||
})
|
||||
return { webhook, automation }
|
||||
}
|
||||
|
||||
beforeEach(async () => {
|
||||
|
@ -38,5 +43,16 @@ describe("Branching automations", () => {
|
|||
|
||||
afterAll(setup.afterAll)
|
||||
|
||||
it("should run the webhook automation", async () => {})
|
||||
it("should run the webhook automation - checking for parameters", async () => {
|
||||
const { webhook } = await createWebhookAutomation(
|
||||
"Check a basic webhook works as expected"
|
||||
)
|
||||
const res = await config.api.webhook.trigger(
|
||||
config.getAppId(),
|
||||
webhook._id!,
|
||||
{
|
||||
parameter: "testing",
|
||||
}
|
||||
)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -17,6 +17,7 @@ import {
|
|||
BashStepInputs,
|
||||
Branch,
|
||||
BranchStepInputs,
|
||||
CollectStepInputs,
|
||||
CreateRowStepInputs,
|
||||
CronTriggerOutputs,
|
||||
DeleteRowStepInputs,
|
||||
|
@ -182,6 +183,7 @@ class BaseStepBuilder {
|
|||
opts
|
||||
)
|
||||
}
|
||||
|
||||
loop(
|
||||
inputs: LoopStepInputs,
|
||||
opts?: { stepName?: string; stepId?: string }
|
||||
|
@ -249,7 +251,20 @@ class BaseStepBuilder {
|
|||
opts
|
||||
)
|
||||
}
|
||||
|
||||
collect(
|
||||
input: CollectStepInputs,
|
||||
opts?: { stepName?: string; stepId?: string }
|
||||
): this {
|
||||
return this.step(
|
||||
AutomationActionStepId.COLLECT,
|
||||
BUILTIN_ACTION_DEFINITIONS.COLLECT,
|
||||
input,
|
||||
opts
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
class StepBuilder extends BaseStepBuilder {
|
||||
build(): AutomationStep[] {
|
||||
return this.steps
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { Expectations, TestAPI } from "./base"
|
||||
import {
|
||||
BuildWebhookSchemaResponse,
|
||||
SaveWebhookResponse,
|
||||
TriggerWebhookResponse,
|
||||
Webhook,
|
||||
|
@ -17,6 +18,25 @@ export class WebhookAPI extends TestAPI {
|
|||
return resp.webhook
|
||||
}
|
||||
|
||||
buildSchema = async (
|
||||
appId: string,
|
||||
webhookId: string,
|
||||
fields: Record<string, any>,
|
||||
expectations?: Expectations
|
||||
) => {
|
||||
const resp = await this._post<BuildWebhookSchemaResponse>(
|
||||
`/api/webhooks/schema/${appId}/${webhookId}`,
|
||||
{
|
||||
body: fields,
|
||||
expectations: {
|
||||
status: 200,
|
||||
...expectations,
|
||||
},
|
||||
}
|
||||
)
|
||||
return resp.id
|
||||
}
|
||||
|
||||
trigger = async (
|
||||
appId: string,
|
||||
webhookId: string,
|
||||
|
@ -33,6 +53,6 @@ export class WebhookAPI extends TestAPI {
|
|||
},
|
||||
}
|
||||
)
|
||||
return resp?.message
|
||||
return resp
|
||||
}
|
||||
}
|
||||
|
|
|
@ -150,6 +150,7 @@ export type OpenAIStepInputs = {
|
|||
prompt: string
|
||||
model: Model
|
||||
}
|
||||
|
||||
export enum Model {
|
||||
GPT_35_TURBO = "gpt-3.5-turbo",
|
||||
// will only work with api keys that have access to the GPT4 API
|
||||
|
|
Loading…
Reference in New Issue