diff --git a/sim/app/api/workflows/[id]/execute/route.test.ts b/sim/app/api/workflows/[id]/execute/route.test.ts index bbcb1e9592..6e37fe4042 100644 --- a/sim/app/api/workflows/[id]/execute/route.test.ts +++ b/sim/app/api/workflows/[id]/execute/route.test.ts @@ -260,13 +260,17 @@ describe('Workflow Execution API Route', () => { // Verify execute was called with the input body expect(executeMock).toHaveBeenCalledWith('workflow-id') - // Verify the body was passed to the executor constructor + + // Updated expectations to match actual implementation + // The structure should match: serializedWorkflow, processedBlockStates, decryptedEnvVars, processedInput, workflowVariables expect(Executor).toHaveBeenCalledWith( - expect.anything(), - expect.anything(), - expect.anything(), - requestBody, - expect.anything() // Expect workflow variables (5th parameter) + expect.anything(), // serializedWorkflow + expect.anything(), // processedBlockStates + expect.anything(), // decryptedEnvVars + expect.objectContaining({ // processedInput + input: requestBody + }), + expect.anything() // workflowVariables ) }) @@ -303,14 +307,16 @@ describe('Workflow Execution API Route', () => { const data = await response.json() expect(data).toHaveProperty('success', true) - // Verify the executor was constructed with the structured input + // Verify the executor was constructed with the structured input - updated to match implementation const Executor = (await import('@/executor')).Executor expect(Executor).toHaveBeenCalledWith( - expect.anything(), - expect.anything(), - expect.anything(), - structuredInput, - expect.anything() // Expect workflow variables (5th parameter) + expect.anything(), // serializedWorkflow + expect.anything(), // processedBlockStates + expect.anything(), // decryptedEnvVars + expect.objectContaining({ // processedInput + input: structuredInput + }), + expect.anything() // workflowVariables ) }) @@ -338,14 +344,14 @@ describe('Workflow Execution API Route', () => { const data = await response.json() expect(data).toHaveProperty('success', true) - // Verify the executor was constructed with an empty object + // Verify the executor was constructed with an empty object - updated to match implementation const Executor = (await import('@/executor')).Executor expect(Executor).toHaveBeenCalledWith( - expect.anything(), - expect.anything(), - expect.anything(), - {}, - expect.anything() // Expect workflow variables (5th parameter) + expect.anything(), // serializedWorkflow + expect.anything(), // processedBlockStates + expect.anything(), // decryptedEnvVars + expect.objectContaining({}), // processedInput with empty input + expect.anything() // workflowVariables ) }) @@ -371,13 +377,13 @@ describe('Workflow Execution API Route', () => { // Call the handler - should throw an error when trying to parse the body const response = await POST(req, { params }) - // Expect error response due to JSON parsing failure - expect(response.status).toBe(500) + // Updated to expect 400 as per the implementation + expect(response.status).toBe(400) const data = await response.json() expect(data).toHaveProperty('error') - // Check for JSON parse error message rather than "Failed to execute workflow" - expect(data.error).toContain('JSON') + // Check for JSON parse error message + expect(data.error).toContain('Invalid JSON') }) /**