fix(medusa): avoid throwing on error on set step failure endpoint (#14066)
* Avoid throwing on setStepFailure endpoint * Add changeset * Add tests
This commit is contained in:
1 parent
beb91d88a2
commit
32eaa9dd81
3 files changed
+56
-1
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/medusa": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(medusa): avoid throwing on error on set step failure endpoint
|
||||||
@@ -6,7 +6,7 @@ import {
|
|||||||
WorkflowResponse,
|
WorkflowResponse,
|
||||||
} from "@medusajs/framework/workflows-sdk"
|
} from "@medusajs/framework/workflows-sdk"
|
||||||
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
||||||
import { Modules } from "@medusajs/utils"
|
import { Modules, TransactionState } from "@medusajs/utils"
|
||||||
import {
|
import {
|
||||||
adminHeaders,
|
adminHeaders,
|
||||||
createAdminUser,
|
createAdminUser,
|
||||||
@@ -95,6 +95,54 @@ medusaIntegrationTestRunner({
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe("POST /admin/workflow-execution/[workflow_id]/steps/failure", function () {
|
||||||
|
it("should set step as failed", async () => {
|
||||||
|
const stepId = 'test-step'
|
||||||
|
const step = createStep({
|
||||||
|
name: stepId,
|
||||||
|
async: true,
|
||||||
|
}, () => { })
|
||||||
|
|
||||||
|
const workflowId = 'test-workflow'
|
||||||
|
createWorkflow({
|
||||||
|
name: workflowId,
|
||||||
|
retentionTime: 60,
|
||||||
|
}, () => {
|
||||||
|
step()
|
||||||
|
return new WorkflowResponse(void 0)
|
||||||
|
})
|
||||||
|
|
||||||
|
const transactionId = "test-transaction"
|
||||||
|
const engine = container.resolve(Modules.WORKFLOW_ENGINE) as IWorkflowEngineService
|
||||||
|
await engine.run(workflowId, {
|
||||||
|
transactionId
|
||||||
|
})
|
||||||
|
let workflowDetail = (await api.get(`/admin/workflows-executions/${workflowId}/${transactionId}`, adminHeaders)).data.workflow_execution
|
||||||
|
|
||||||
|
expect(workflowDetail.state).toBe(TransactionState.INVOKING)
|
||||||
|
|
||||||
|
const setFailureResponse = await api.post(`/admin/workflows-executions/${workflowId}/steps/failure`, {
|
||||||
|
transaction_id: transactionId,
|
||||||
|
step_id: stepId
|
||||||
|
}, adminHeaders)
|
||||||
|
|
||||||
|
expect(setFailureResponse.status).toBe(200)
|
||||||
|
expect(setFailureResponse.data).toEqual(
|
||||||
|
expect.objectContaining({
|
||||||
|
success: true,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
workflowDetail = (await api.get(`/admin/workflows-executions/${workflowId}/${transactionId}`, adminHeaders)).data.workflow_execution
|
||||||
|
|
||||||
|
expect(workflowDetail).toEqual(
|
||||||
|
expect.objectContaining({
|
||||||
|
state: TransactionState.REVERTED,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe("Workflow Orchestrator module subscribe", function () {
|
describe("Workflow Orchestrator module subscribe", function () {
|
||||||
it("should subscribe to a workflow and receive the response when it finishes", async () => {
|
it("should subscribe to a workflow and receive the response when it finishes", async () => {
|
||||||
const step1 = createStep({ name: "step1" }, async () => {
|
const step1 = createStep({ name: "step1" }, async () => {
|
||||||
|
|||||||
+2
@@ -45,6 +45,8 @@ export const POST = async (
|
|||||||
context: {
|
context: {
|
||||||
requestId: req.requestId,
|
requestId: req.requestId,
|
||||||
},
|
},
|
||||||
|
throwOnError: false,
|
||||||
|
logOnError: true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user