-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added test workflow feature to JS SDK - https://orkes.io/content/developer-guides/unit-and-regression-tests * Added registerWorkflowDef to MetadataClient * CI: Fix tests + Publish Test reports
- Loading branch information
1 parent
0c07a54
commit d324604
Showing
9 changed files
with
156 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/common/open-api/__test__/WorkflowResourceService.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { expect, describe, test, jest } from "@jest/globals"; | ||
import { MetadataClient } from "../../../core"; | ||
import { simpleTask, workflow } from "../../../core/sdk"; | ||
import { orkesConductorClient } from "../../../orkes"; | ||
import { TaskDefTypes } from "../../types"; | ||
|
||
const config = { | ||
keyId: `${process.env.KEY_ID}`, | ||
keySecret: `${process.env.KEY_SECRET}`, | ||
serverUrl: `${process.env.SERVER_URL}`, | ||
}; | ||
|
||
describe("WorkflowResourceService", () => { | ||
jest.setTimeout(120000); | ||
|
||
test("Should test a workflow", async () => { | ||
const client = await orkesConductorClient(config); | ||
const metadataClient = new MetadataClient(client); | ||
const tasks: TaskDefTypes[] = [ | ||
simpleTask("simple_ref", "le_simple_task", {}), | ||
]; | ||
|
||
const wfDef = workflow("unit_test_wf", tasks); | ||
wfDef.outputParameters = { message: "${simple_ref.output.message}" }; | ||
metadataClient.registerWorkflowDef(wfDef, true); | ||
|
||
const status = "COMPLETED"; | ||
const output = { message: "Mocked message" }; | ||
|
||
const wf = await client.workflowResource.testWorkflow({ | ||
name: wfDef.name, | ||
taskRefToMockOutput: { | ||
"simple_ref": [{ status, output }], | ||
}, | ||
}); | ||
|
||
expect(wf.status).toEqual(status); | ||
expect(wf.output).toEqual(output); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* istanbul ignore file */ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
export type TaskMock = { | ||
executionTime?: number; | ||
output: Record<string, any>; | ||
queueWaitTime?: number; | ||
status: | ||
| "IN_PROGRESS" | ||
| "FAILED" | ||
| "FAILED_WITH_TERMINAL_ERROR" | ||
| "COMPLETED"; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* istanbul ignore file */ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
import type { TaskMock } from "./TaskMock"; | ||
import type { WorkflowDef } from "./WorkflowDef"; | ||
export type WorkflowTestRequest = { | ||
correlationId?: string; | ||
createdBy?: string; | ||
externalInputPayloadStoragePath?: string; | ||
idempotencyKey?: string; | ||
idempotencyStrategy?: "FAIL" | "RETURN_EXISTING"; | ||
input?: Record<string, Record<string, any>>; | ||
name: string; | ||
priority?: number; | ||
subWorkflowTestRequest?: Record<string, WorkflowTestRequest>; | ||
taskRefToMockOutput?: Record<string, Array<TaskMock>>; | ||
taskToDomain?: Record<string, string>; | ||
version?: number; | ||
workflowDef?: WorkflowDef; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2413,6 +2413,16 @@ jest-haste-map@^29.5.0: | |
optionalDependencies: | ||
fsevents "^2.3.2" | ||
|
||
jest-junit@^16.0.0: | ||
version "16.0.0" | ||
resolved "https://registry.yarnpkg.com/jest-junit/-/jest-junit-16.0.0.tgz#d838e8c561cf9fdd7eb54f63020777eee4136785" | ||
integrity sha512-A94mmw6NfJab4Fg/BlvVOUXzXgF0XIH6EmTgJ5NDPp4xoKq0Kr7sErb+4Xs9nZvu58pJojz5RFGpqnZYJTrRfQ== | ||
dependencies: | ||
mkdirp "^1.0.4" | ||
strip-ansi "^6.0.1" | ||
uuid "^8.3.2" | ||
xml "^1.0.1" | ||
|
||
jest-leak-detector@^29.5.0: | ||
version "29.5.0" | ||
resolved "https://registry.yarnpkg.com/jest-leak-detector/-/jest-leak-detector-29.5.0.tgz#cf4bdea9615c72bac4a3a7ba7e7930f9c0610c8c" | ||
|
@@ -2823,6 +2833,11 @@ mkdirp@^0.5.1: | |
dependencies: | ||
minimist "^1.2.6" | ||
|
||
mkdirp@^1.0.4: | ||
version "1.0.4" | ||
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" | ||
integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== | ||
|
||
[email protected]: | ||
version "2.1.2" | ||
resolved "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz" | ||
|
@@ -3578,6 +3593,11 @@ uri-js@^4.2.2: | |
dependencies: | ||
punycode "^2.1.0" | ||
|
||
uuid@^8.3.2: | ||
version "8.3.2" | ||
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" | ||
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== | ||
|
||
uuid@^9.0.0: | ||
version "9.0.0" | ||
resolved "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz" | ||
|
@@ -3686,6 +3706,11 @@ [email protected]: | |
dependencies: | ||
mkdirp "^0.5.1" | ||
|
||
xml@^1.0.1: | ||
version "1.0.1" | ||
resolved "https://registry.yarnpkg.com/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5" | ||
integrity sha512-huCv9IH9Tcf95zuYCsQraZtWnJvBtLVE0QHMOs8bWyZAFZNDcYjsPq1nEx8jKA9y+Beo9v+7OBPRisQTjinQMw== | ||
|
||
y18n@^5.0.5: | ||
version "5.0.8" | ||
resolved "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz" | ||
|