From 399dddc0c75fc9b72d49166b572c477af69b0f14 Mon Sep 17 00:00:00 2001 From: Adrien de Peretti Date: Fri, 16 May 2025 15:03:38 +0200 Subject: [PATCH] test(workflow-engine-redist): Update tests to ensure behaviour validation properly (#12514) --- .../__fixtures__/workflow_transaction_timeout.ts | 8 +++++++- .../integration-tests/__tests__/index.spec.ts | 11 +++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/modules/workflow-engine-redis/integration-tests/__fixtures__/workflow_transaction_timeout.ts b/packages/modules/workflow-engine-redis/integration-tests/__fixtures__/workflow_transaction_timeout.ts index 14ad92ae50..630709536b 100644 --- a/packages/modules/workflow-engine-redis/integration-tests/__fixtures__/workflow_transaction_timeout.ts +++ b/packages/modules/workflow-engine-redis/integration-tests/__fixtures__/workflow_transaction_timeout.ts @@ -29,6 +29,12 @@ createWorkflow( } ) +const step_1_async = createStep( + "step_1_async", + jest.fn(async (input) => {}), + jest.fn() +) + createWorkflow( { name: "workflow_transaction_timeout_async", @@ -37,7 +43,7 @@ createWorkflow( retentionTime: 5, }, function (input) { - const resp = step_1(input).config({ + const resp = step_1_async(input).config({ async: true, }) diff --git a/packages/modules/workflow-engine-redis/integration-tests/__tests__/index.spec.ts b/packages/modules/workflow-engine-redis/integration-tests/__tests__/index.spec.ts index f6a6c6f612..0a586220e5 100644 --- a/packages/modules/workflow-engine-redis/integration-tests/__tests__/index.spec.ts +++ b/packages/modules/workflow-engine-redis/integration-tests/__tests__/index.spec.ts @@ -654,7 +654,7 @@ moduleIntegrationTestRunner({ "workflow_transaction_timeout", { input: {}, - transactionId: "trx", + transactionId: "trx" + ulid(), throwOnError: false, } )) as Awaited<{ @@ -663,6 +663,8 @@ moduleIntegrationTestRunner({ errors: any }> + await setTimeout(500) + expect(transaction.getFlow().state).toEqual("reverted") expect(result).toEqual({ executed: true }) expect(errors).toHaveLength(1) @@ -710,9 +712,10 @@ moduleIntegrationTestRunner({ }) it("should revert the entire transaction when the transaction timeout expires in a transaction containing an async step", async () => { + const transactionId = "transaction_1" + ulid() await workflowOrcModule.run("workflow_transaction_timeout_async", { input: {}, - transactionId: "transaction_1", + transactionId, throwOnError: false, }) @@ -722,7 +725,7 @@ moduleIntegrationTestRunner({ "workflow_transaction_timeout_async", { input: {}, - transactionId: "transaction_1", + transactionId, throwOnError: false, } )) as Awaited<{ @@ -734,7 +737,7 @@ moduleIntegrationTestRunner({ expect(transaction.getFlow().state).toEqual("reverted") expect(result).toEqual(undefined) expect(errors).toHaveLength(1) - expect(errors[0].action).toEqual("step_1") + expect(errors[0].action).toEqual("step_1_async") expect( TransactionTimeoutError.isTransactionTimeoutError(errors[0].error) ).toBe(true)