Skip to content

Commit 794c701

Browse files
committed
Add e2e test
1 parent d235af4 commit 794c701

File tree

5 files changed

+100
-0
lines changed

5 files changed

+100
-0
lines changed

packages/core/e2e/e2e.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,4 +524,31 @@ describe('e2e', () => {
524524
expect(returnValue.retryableResult.duration).toBeGreaterThan(10_000);
525525
expect(returnValue.gotFatalError).toBe(true);
526526
});
527+
528+
test(
529+
'stepDirectCallWorkflow - calling step functions directly outside workflow context',
530+
{ timeout: 60_000 },
531+
async () => {
532+
// Call the API route that directly calls a step function (no workflow context)
533+
const url = new URL('/api/test-direct-step-call', deploymentUrl);
534+
const res = await fetch(url, {
535+
method: 'POST',
536+
headers: { 'Content-Type': 'application/json' },
537+
body: JSON.stringify({ x: 3, y: 5 }),
538+
});
539+
540+
if (!res.ok) {
541+
throw new Error(
542+
`Failed to call step function directly: ${res.url} ${
543+
res.status
544+
}: ${await res.text()}`
545+
);
546+
}
547+
548+
const { result } = await res.json();
549+
550+
// Expected: add(3, 5) = 8
551+
expect(result).toBe(8);
552+
}
553+
);
527554
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// This route tests calling step functions directly outside of any workflow context
2+
// After the SWC compiler changes, step functions in client mode have their directive removed
3+
// and keep their original implementation, allowing them to be called as regular async functions
4+
5+
import { add } from '../workflows/99_e2e.js';
6+
7+
export async function POST(req: Request) {
8+
const body = await req.json();
9+
const { x, y } = body;
10+
11+
console.log(`Calling step function directly with x=${x}, y=${y}`);
12+
13+
// Call step function directly as a regular async function (no workflow context)
14+
const result = await add(x, y);
15+
console.log(`add(${x}, ${y}) = ${result}`);
16+
17+
return Response.json({ result });
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// This route tests calling step functions directly outside of any workflow context
2+
// After the SWC compiler changes, step functions in client mode have their directive removed
3+
// and keep their original implementation, allowing them to be called as regular async functions
4+
5+
import { add } from '@/workflows/99_e2e';
6+
7+
export async function POST(req: Request) {
8+
const body = await req.json();
9+
const { x, y } = body;
10+
11+
console.log(`Calling step function directly with x=${x}, y=${y}`);
12+
13+
// Call step function directly as a regular async function (no workflow context)
14+
const result = await add(x, y);
15+
console.log(`add(${x}, ${y}) = ${result}`);
16+
17+
return Response.json({ result });
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// This route tests calling step functions directly outside of any workflow context
2+
// After the SWC compiler changes, step functions in client mode have their directive removed
3+
// and keep their original implementation, allowing them to be called as regular async functions
4+
5+
import { add } from '../../workflows/99_e2e.js';
6+
7+
export default async ({ req }: { req: Request }) => {
8+
const body = await req.json();
9+
const { x, y } = body;
10+
11+
console.log(`Calling step function directly with x=${x}, y=${y}`);
12+
13+
// Call step function directly as a regular async function (no workflow context)
14+
const result = await add(x, y);
15+
console.log(`add(${x}, ${y}) = ${result}`);
16+
17+
return Response.json({ result });
18+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// This route tests calling step functions directly outside of any workflow context
2+
// After the SWC compiler changes, step functions in client mode have their directive removed
3+
// and keep their original implementation, allowing them to be called as regular async functions
4+
5+
import { json, type RequestHandler } from '@sveltejs/kit';
6+
import { add } from '../../../../workflows/99_e2e.js';
7+
8+
export const POST: RequestHandler = async ({ request }) => {
9+
const body = await request.json();
10+
const { x, y } = body;
11+
12+
console.log(`Calling step function directly with x=${x}, y=${y}`);
13+
14+
// Call step function directly as a regular async function (no workflow context)
15+
const result = await add(x, y);
16+
console.log(`add(${x}, ${y}) = ${result}`);
17+
18+
return json({ result });
19+
};

0 commit comments

Comments
 (0)