|
| 1 | +import { expect, describe, test, jest } from "@jest/globals"; |
| 2 | +import { MetadataClient } from "../../../core"; |
| 3 | +import { simpleTask, workflow } from "../../../core/sdk"; |
| 4 | +import { orkesConductorClient } from "../../../orkes"; |
| 5 | +import { TaskDefTypes } from "../../types"; |
| 6 | + |
| 7 | +const config = { |
| 8 | + keyId: `${process.env.KEY_ID}`, |
| 9 | + keySecret: `${process.env.KEY_SECRET}`, |
| 10 | + serverUrl: `${process.env.SERVER_URL}`, |
| 11 | +}; |
| 12 | + |
| 13 | +describe("WorkflowResourceService", () => { |
| 14 | + jest.setTimeout(120000); |
| 15 | + |
| 16 | + test("Should test a workflow", async () => { |
| 17 | + const client = await orkesConductorClient(config); |
| 18 | + const metadataClient = new MetadataClient(client); |
| 19 | + const tasks: TaskDefTypes[] = [ |
| 20 | + simpleTask("simple_ref", "le_simple_task", {}), |
| 21 | + ]; |
| 22 | + |
| 23 | + const wfDef = workflow("unit_test_wf", tasks); |
| 24 | + wfDef.outputParameters = { message: "${simple_ref.output.message}" }; |
| 25 | + metadataClient.registerWorkflowDef(wfDef, true); |
| 26 | + |
| 27 | + const status = "COMPLETED"; |
| 28 | + const output = { message: "Mocked message" }; |
| 29 | + |
| 30 | + const wf = await client.workflowResource.testWorkflow({ |
| 31 | + name: wfDef.name, |
| 32 | + taskRefToMockOutput: { |
| 33 | + "simple_ref": [{ status, output }], |
| 34 | + }, |
| 35 | + }); |
| 36 | + |
| 37 | + expect(wf.status).toEqual(status); |
| 38 | + expect(wf.output).toEqual(output); |
| 39 | + }); |
| 40 | +}); |
0 commit comments