(ctx: any, auth: any, actions: { actionType: string; config: any }[], routeAutoToDone = false)
| 422 | async function apiAuth(ctx: any) { |
| 423 | const loginRes = await ctx.post(`${API_BASE}/membership/users/login`, { data: { email: "demo@b1.church", password: "password" } }); |
| 424 | expect(loginRes.ok()).toBeTruthy(); |
| 425 | const body = await loginRes.json(); |
| 426 | const uc = (body.userChurches || []).find((c: any) => c.church?.id === "CHU00000001") || body.userChurches?.[0]; |
| 427 | return { headers: { Authorization: "Bearer " + (uc?.jwt as string) } }; |
| 428 | } |
| 429 | // Build workflow with optional onEnter route so Auto step acts as pass-through. |
| 430 | async function buildActionWorkflow(ctx: any, auth: any, actions: { actionType: string; config: any }[], routeAutoToDone = false) { |
| 431 | const wfRes = await ctx.post(`${API_BASE}/doing/workflows`, { ...auth, data: [{ name: "Zacchaeus Action WF", active: true }] }); |
| 432 | const wf = (await wfRes.json())[0]; |
| 433 | const stepRes = await ctx.post(`${API_BASE}/doing/workflowSteps`, { |
| 434 | ...auth, |
| 435 | data: [ |
| 436 | { workflowId: wf.id, name: "Greet", sort: 1 }, |
| 437 | { workflowId: wf.id, name: "Auto", sort: 2 }, |
| 438 | { workflowId: wf.id, name: "Done", sort: 3 } |
| 439 | ] |
| 440 | }); |
| 441 | const steps = await stepRes.json(); |
| 442 | const auto = steps.find((s: any) => s.name === "Auto"); |
| 443 | const done = steps.find((s: any) => s.name === "Done"); |
| 444 | if (actions.length) { |
| 445 | await ctx.post(`${API_BASE}/doing/workflowStepActions`, { ...auth, data: actions.map((a, i) => ({ stepId: auto.id, sort: i + 1, actionType: a.actionType, config: JSON.stringify(a.config) })) }); |
| 446 | } |
| 447 | if (routeAutoToDone) { |
| 448 | await ctx.post(`${API_BASE}/doing/workflowStepRoutes`, { ...auth, data: [{ workflowId: wf.id, stepId: auto.id, trigger: "onEnter", kind: "always", sort: 1, targetStepId: done.id }] }); |
no outgoing calls
no test coverage detected