@xtr-dev/payload-automation 0.0.38 → 0.0.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/README.md +6 -1
  2. package/dist/collections/Workflow.js +2 -4
  3. package/dist/collections/Workflow.js.map +1 -1
  4. package/dist/components/WorkflowBuilder/StepConfigurationForm.js +316 -0
  5. package/dist/components/WorkflowBuilder/StepConfigurationForm.js.map +1 -0
  6. package/dist/components/WorkflowBuilder/WorkflowBuilder.js +211 -0
  7. package/dist/components/WorkflowBuilder/WorkflowBuilder.js.map +1 -0
  8. package/dist/components/WorkflowBuilder/WorkflowToolbar.js +107 -0
  9. package/dist/components/WorkflowBuilder/WorkflowToolbar.js.map +1 -0
  10. package/dist/components/WorkflowBuilder/index.js +6 -0
  11. package/dist/components/WorkflowBuilder/index.js.map +1 -0
  12. package/dist/components/WorkflowBuilder/nodes/StepNode.js +139 -0
  13. package/dist/components/WorkflowBuilder/nodes/StepNode.js.map +1 -0
  14. package/dist/core/workflow-executor.js +150 -116
  15. package/dist/core/workflow-executor.js.map +1 -1
  16. package/dist/fields/WorkflowBuilderField.js +119 -0
  17. package/dist/fields/WorkflowBuilderField.js.map +1 -0
  18. package/dist/plugin/collection-hook.js +34 -0
  19. package/dist/plugin/collection-hook.js.map +1 -1
  20. package/package.json +4 -3
  21. package/dist/collections/Workflow.d.ts +0 -3
  22. package/dist/collections/WorkflowRuns.d.ts +0 -2
  23. package/dist/components/ErrorDisplay.d.ts +0 -9
  24. package/dist/components/StatusCell.d.ts +0 -6
  25. package/dist/core/trigger-custom-workflow.d.ts +0 -52
  26. package/dist/core/workflow-executor.d.ts +0 -90
  27. package/dist/exports/client.d.ts +0 -2
  28. package/dist/exports/fields.d.ts +0 -1
  29. package/dist/exports/rsc.d.ts +0 -1
  30. package/dist/exports/server.d.ts +0 -5
  31. package/dist/exports/views.d.ts +0 -1
  32. package/dist/fields/parameter.d.ts +0 -4
  33. package/dist/index.d.ts +0 -2
  34. package/dist/plugin/collection-hook.d.ts +0 -1
  35. package/dist/plugin/config-types.d.ts +0 -18
  36. package/dist/plugin/global-hook.d.ts +0 -1
  37. package/dist/plugin/index.d.ts +0 -4
  38. package/dist/plugin/logger.d.ts +0 -20
  39. package/dist/steps/create-document-handler.d.ts +0 -2
  40. package/dist/steps/create-document.d.ts +0 -46
  41. package/dist/steps/delete-document-handler.d.ts +0 -2
  42. package/dist/steps/delete-document.d.ts +0 -39
  43. package/dist/steps/http-request-handler.d.ts +0 -2
  44. package/dist/steps/http-request.d.ts +0 -155
  45. package/dist/steps/index.d.ts +0 -12
  46. package/dist/steps/read-document-handler.d.ts +0 -2
  47. package/dist/steps/read-document.d.ts +0 -46
  48. package/dist/steps/send-email-handler.d.ts +0 -2
  49. package/dist/steps/send-email.d.ts +0 -44
  50. package/dist/steps/update-document-handler.d.ts +0 -2
  51. package/dist/steps/update-document.d.ts +0 -46
  52. package/dist/test/basic.test.js +0 -14
  53. package/dist/test/basic.test.js.map +0 -1
  54. package/dist/test/create-document-step.test.js +0 -378
  55. package/dist/test/create-document-step.test.js.map +0 -1
  56. package/dist/test/http-request-step.test.js +0 -361
  57. package/dist/test/http-request-step.test.js.map +0 -1
  58. package/dist/test/workflow-executor.test.js +0 -530
  59. package/dist/test/workflow-executor.test.js.map +0 -1
  60. package/dist/triggers/collection-trigger.d.ts +0 -2
  61. package/dist/triggers/global-trigger.d.ts +0 -2
  62. package/dist/triggers/index.d.ts +0 -2
  63. package/dist/triggers/types.d.ts +0 -5
  64. package/dist/types/index.d.ts +0 -31
@@ -1,361 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from 'vitest';
2
- import { httpRequestStepHandler } from '../steps/http-request-handler.js';
3
- // Mock fetch globally
4
- global.fetch = vi.fn();
5
- describe('HttpRequestStepHandler', ()=>{
6
- let mockPayload;
7
- let mockReq;
8
- beforeEach(()=>{
9
- mockPayload = {};
10
- mockReq = {
11
- payload: mockPayload,
12
- user: null
13
- };
14
- vi.clearAllMocks();
15
- });
16
- describe('GET requests', ()=>{
17
- it('should handle successful GET request', async ()=>{
18
- const mockResponse = {
19
- ok: true,
20
- status: 200,
21
- statusText: 'OK',
22
- headers: new Headers({
23
- 'content-type': 'application/json'
24
- }),
25
- text: vi.fn().mockResolvedValue('{"success": true}')
26
- };
27
- global.fetch.mockResolvedValue(mockResponse);
28
- const input = {
29
- url: 'https://api.example.com/data',
30
- method: 'GET',
31
- stepName: 'test-get-step'
32
- };
33
- const result = await httpRequestStepHandler({
34
- input,
35
- req: mockReq
36
- });
37
- expect(result.state).toBe('succeeded');
38
- expect(result.output.status).toBe(200);
39
- expect(result.output.statusText).toBe('OK');
40
- expect(result.output.body).toBe('{"success": true}');
41
- expect(result.output.headers).toEqual({
42
- 'content-type': 'application/json'
43
- });
44
- expect(global.fetch).toHaveBeenCalledWith('https://api.example.com/data', {
45
- method: 'GET',
46
- headers: {},
47
- signal: expect.any(AbortSignal)
48
- });
49
- });
50
- it('should handle GET request with custom headers', async ()=>{
51
- const mockResponse = {
52
- ok: true,
53
- status: 200,
54
- statusText: 'OK',
55
- headers: new Headers(),
56
- text: vi.fn().mockResolvedValue('success')
57
- };
58
- global.fetch.mockResolvedValue(mockResponse);
59
- const input = {
60
- url: 'https://api.example.com/data',
61
- method: 'GET',
62
- headers: {
63
- 'Authorization': 'Bearer token123',
64
- 'User-Agent': 'PayloadCMS-Workflow/1.0'
65
- },
66
- stepName: 'test-get-with-headers'
67
- };
68
- await httpRequestStepHandler({
69
- input,
70
- req: mockReq
71
- });
72
- expect(global.fetch).toHaveBeenCalledWith('https://api.example.com/data', {
73
- method: 'GET',
74
- headers: {
75
- 'Authorization': 'Bearer token123',
76
- 'User-Agent': 'PayloadCMS-Workflow/1.0'
77
- },
78
- signal: expect.any(AbortSignal)
79
- });
80
- });
81
- });
82
- describe('POST requests', ()=>{
83
- it('should handle POST request with JSON body', async ()=>{
84
- const mockResponse = {
85
- ok: true,
86
- status: 201,
87
- statusText: 'Created',
88
- headers: new Headers(),
89
- text: vi.fn().mockResolvedValue('{"id": "123"}')
90
- };
91
- global.fetch.mockResolvedValue(mockResponse);
92
- const input = {
93
- url: 'https://api.example.com/posts',
94
- method: 'POST',
95
- body: {
96
- title: 'Test Post',
97
- content: 'Test content'
98
- },
99
- headers: {
100
- 'Content-Type': 'application/json'
101
- },
102
- stepName: 'test-post-step'
103
- };
104
- const result = await httpRequestStepHandler({
105
- input,
106
- req: mockReq
107
- });
108
- expect(result.state).toBe('succeeded');
109
- expect(result.output.status).toBe(201);
110
- expect(global.fetch).toHaveBeenCalledWith('https://api.example.com/posts', {
111
- method: 'POST',
112
- headers: {
113
- 'Content-Type': 'application/json'
114
- },
115
- body: JSON.stringify({
116
- title: 'Test Post',
117
- content: 'Test content'
118
- }),
119
- signal: expect.any(AbortSignal)
120
- });
121
- });
122
- it('should handle POST request with string body', async ()=>{
123
- const mockResponse = {
124
- ok: true,
125
- status: 200,
126
- statusText: 'OK',
127
- headers: new Headers(),
128
- text: vi.fn().mockResolvedValue('OK')
129
- };
130
- global.fetch.mockResolvedValue(mockResponse);
131
- const input = {
132
- url: 'https://api.example.com/webhook',
133
- method: 'POST',
134
- body: 'plain text data',
135
- headers: {
136
- 'Content-Type': 'text/plain'
137
- },
138
- stepName: 'test-post-string'
139
- };
140
- await httpRequestStepHandler({
141
- input,
142
- req: mockReq
143
- });
144
- expect(global.fetch).toHaveBeenCalledWith('https://api.example.com/webhook', {
145
- method: 'POST',
146
- headers: {
147
- 'Content-Type': 'text/plain'
148
- },
149
- body: 'plain text data',
150
- signal: expect.any(AbortSignal)
151
- });
152
- });
153
- });
154
- describe('Error handling', ()=>{
155
- it('should handle network errors', async ()=>{
156
- ;
157
- global.fetch.mockRejectedValue(new Error('Network error'));
158
- const input = {
159
- url: 'https://invalid-url.example.com',
160
- method: 'GET',
161
- stepName: 'test-network-error'
162
- };
163
- const result = await httpRequestStepHandler({
164
- input,
165
- req: mockReq
166
- });
167
- expect(result.state).toBe('failed');
168
- expect(result.error).toContain('Network error');
169
- });
170
- it('should handle HTTP error status codes', async ()=>{
171
- const mockResponse = {
172
- ok: false,
173
- status: 404,
174
- statusText: 'Not Found',
175
- headers: new Headers(),
176
- text: vi.fn().mockResolvedValue('Page not found')
177
- };
178
- global.fetch.mockResolvedValue(mockResponse);
179
- const input = {
180
- url: 'https://api.example.com/nonexistent',
181
- method: 'GET',
182
- stepName: 'test-404-error'
183
- };
184
- const result = await httpRequestStepHandler({
185
- input,
186
- req: mockReq
187
- });
188
- expect(result.state).toBe('failed');
189
- expect(result.error).toContain('HTTP 404');
190
- expect(result.output.status).toBe(404);
191
- expect(result.output.statusText).toBe('Not Found');
192
- });
193
- it('should handle timeout errors', async ()=>{
194
- const abortError = new Error('The operation was aborted');
195
- abortError.name = 'AbortError';
196
- global.fetch.mockRejectedValue(abortError);
197
- const input = {
198
- url: 'https://slow-api.example.com',
199
- method: 'GET',
200
- timeout: 1000,
201
- stepName: 'test-timeout'
202
- };
203
- const result = await httpRequestStepHandler({
204
- input,
205
- req: mockReq
206
- });
207
- expect(result.state).toBe('failed');
208
- expect(result.error).toContain('timeout');
209
- });
210
- it('should handle invalid JSON response parsing', async ()=>{
211
- const mockResponse = {
212
- ok: true,
213
- status: 200,
214
- statusText: 'OK',
215
- headers: new Headers({
216
- 'content-type': 'application/json'
217
- }),
218
- text: vi.fn().mockResolvedValue('invalid json {')
219
- };
220
- global.fetch.mockResolvedValue(mockResponse);
221
- const input = {
222
- url: 'https://api.example.com/invalid-json',
223
- method: 'GET',
224
- stepName: 'test-invalid-json'
225
- };
226
- const result = await httpRequestStepHandler({
227
- input,
228
- req: mockReq
229
- });
230
- // Should still succeed but with raw text body
231
- expect(result.state).toBe('succeeded');
232
- expect(result.output.body).toBe('invalid json {');
233
- });
234
- });
235
- describe('Request validation', ()=>{
236
- it('should validate required URL field', async ()=>{
237
- const input = {
238
- method: 'GET',
239
- stepName: 'test-missing-url'
240
- };
241
- const result = await httpRequestStepHandler({
242
- input,
243
- req: mockReq
244
- });
245
- expect(result.state).toBe('failed');
246
- expect(result.error).toContain('URL is required');
247
- });
248
- it('should validate HTTP method', async ()=>{
249
- const input = {
250
- url: 'https://api.example.com',
251
- method: 'INVALID',
252
- stepName: 'test-invalid-method'
253
- };
254
- const result = await httpRequestStepHandler({
255
- input,
256
- req: mockReq
257
- });
258
- expect(result.state).toBe('failed');
259
- expect(result.error).toContain('Invalid HTTP method');
260
- });
261
- it('should validate URL format', async ()=>{
262
- const input = {
263
- url: 'not-a-valid-url',
264
- method: 'GET',
265
- stepName: 'test-invalid-url'
266
- };
267
- const result = await httpRequestStepHandler({
268
- input,
269
- req: mockReq
270
- });
271
- expect(result.state).toBe('failed');
272
- expect(result.error).toContain('Invalid URL');
273
- });
274
- });
275
- describe('Response processing', ()=>{
276
- it('should parse JSON responses automatically', async ()=>{
277
- const responseData = {
278
- id: 123,
279
- name: 'Test Item'
280
- };
281
- const mockResponse = {
282
- ok: true,
283
- status: 200,
284
- statusText: 'OK',
285
- headers: new Headers({
286
- 'content-type': 'application/json'
287
- }),
288
- text: vi.fn().mockResolvedValue(JSON.stringify(responseData))
289
- };
290
- global.fetch.mockResolvedValue(mockResponse);
291
- const input = {
292
- url: 'https://api.example.com/item/123',
293
- method: 'GET',
294
- stepName: 'test-json-parsing'
295
- };
296
- const result = await httpRequestStepHandler({
297
- input,
298
- req: mockReq
299
- });
300
- expect(result.state).toBe('succeeded');
301
- expect(typeof result.output.body).toBe('string');
302
- // Should contain the JSON as string for safe storage
303
- expect(result.output.body).toBe(JSON.stringify(responseData));
304
- });
305
- it('should handle non-JSON responses', async ()=>{
306
- const htmlContent = '<html><body>Hello World</body></html>';
307
- const mockResponse = {
308
- ok: true,
309
- status: 200,
310
- statusText: 'OK',
311
- headers: new Headers({
312
- 'content-type': 'text/html'
313
- }),
314
- text: vi.fn().mockResolvedValue(htmlContent)
315
- };
316
- global.fetch.mockResolvedValue(mockResponse);
317
- const input = {
318
- url: 'https://example.com/page',
319
- method: 'GET',
320
- stepName: 'test-html-response'
321
- };
322
- const result = await httpRequestStepHandler({
323
- input,
324
- req: mockReq
325
- });
326
- expect(result.state).toBe('succeeded');
327
- expect(result.output.body).toBe(htmlContent);
328
- });
329
- it('should capture response headers', async ()=>{
330
- const mockResponse = {
331
- ok: true,
332
- status: 200,
333
- statusText: 'OK',
334
- headers: new Headers({
335
- 'content-type': 'application/json',
336
- 'x-rate-limit': '100',
337
- 'x-custom-header': 'custom-value'
338
- }),
339
- text: vi.fn().mockResolvedValue('{}')
340
- };
341
- global.fetch.mockResolvedValue(mockResponse);
342
- const input = {
343
- url: 'https://api.example.com/data',
344
- method: 'GET',
345
- stepName: 'test-response-headers'
346
- };
347
- const result = await httpRequestStepHandler({
348
- input,
349
- req: mockReq
350
- });
351
- expect(result.state).toBe('succeeded');
352
- expect(result.output.headers).toEqual({
353
- 'content-type': 'application/json',
354
- 'x-rate-limit': '100',
355
- 'x-custom-header': 'custom-value'
356
- });
357
- });
358
- });
359
- });
360
-
361
- //# sourceMappingURL=http-request-step.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/test/http-request-step.test.ts"],"sourcesContent":["import { describe, it, expect, vi, beforeEach } from 'vitest'\nimport { httpRequestStepHandler } from '../steps/http-request-handler.js'\nimport type { Payload } from 'payload'\n\n// Mock fetch globally\nglobal.fetch = vi.fn()\n\ndescribe('HttpRequestStepHandler', () => {\n let mockPayload: Payload\n let mockReq: any\n\n beforeEach(() => {\n mockPayload = {} as Payload\n mockReq = {\n payload: mockPayload,\n user: null\n }\n vi.clearAllMocks()\n })\n\n describe('GET requests', () => {\n it('should handle successful GET request', async () => {\n const mockResponse = {\n ok: true,\n status: 200,\n statusText: 'OK',\n headers: new Headers({ 'content-type': 'application/json' }),\n text: vi.fn().mockResolvedValue('{\"success\": true}')\n }\n ;(global.fetch as any).mockResolvedValue(mockResponse)\n\n const input = {\n url: 'https://api.example.com/data',\n method: 'GET' as const,\n stepName: 'test-get-step'\n }\n\n const result = await httpRequestStepHandler({ input, req: mockReq })\n\n expect(result.state).toBe('succeeded')\n expect(result.output.status).toBe(200)\n expect(result.output.statusText).toBe('OK')\n expect(result.output.body).toBe('{\"success\": true}')\n expect(result.output.headers).toEqual({ 'content-type': 'application/json' })\n\n expect(global.fetch).toHaveBeenCalledWith('https://api.example.com/data', {\n method: 'GET',\n headers: {},\n signal: expect.any(AbortSignal)\n })\n })\n\n it('should handle GET request with custom headers', async () => {\n const mockResponse = {\n ok: true,\n status: 200,\n statusText: 'OK',\n headers: new Headers(),\n text: vi.fn().mockResolvedValue('success')\n }\n ;(global.fetch as any).mockResolvedValue(mockResponse)\n\n const input = {\n url: 'https://api.example.com/data',\n method: 'GET' as const,\n headers: {\n 'Authorization': 'Bearer token123',\n 'User-Agent': 'PayloadCMS-Workflow/1.0'\n },\n stepName: 'test-get-with-headers'\n }\n\n await httpRequestStepHandler({ input, req: mockReq })\n\n expect(global.fetch).toHaveBeenCalledWith('https://api.example.com/data', {\n method: 'GET',\n headers: {\n 'Authorization': 'Bearer token123',\n 'User-Agent': 'PayloadCMS-Workflow/1.0'\n },\n signal: expect.any(AbortSignal)\n })\n })\n })\n\n describe('POST requests', () => {\n it('should handle POST request with JSON body', async () => {\n const mockResponse = {\n ok: true,\n status: 201,\n statusText: 'Created',\n headers: new Headers(),\n text: vi.fn().mockResolvedValue('{\"id\": \"123\"}')\n }\n ;(global.fetch as any).mockResolvedValue(mockResponse)\n\n const input = {\n url: 'https://api.example.com/posts',\n method: 'POST' as const,\n body: { title: 'Test Post', content: 'Test content' },\n headers: { 'Content-Type': 'application/json' },\n stepName: 'test-post-step'\n }\n\n const result = await httpRequestStepHandler({ input, req: mockReq })\n\n expect(result.state).toBe('succeeded')\n expect(result.output.status).toBe(201)\n\n expect(global.fetch).toHaveBeenCalledWith('https://api.example.com/posts', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ title: 'Test Post', content: 'Test content' }),\n signal: expect.any(AbortSignal)\n })\n })\n\n it('should handle POST request with string body', async () => {\n const mockResponse = {\n ok: true,\n status: 200,\n statusText: 'OK',\n headers: new Headers(),\n text: vi.fn().mockResolvedValue('OK')\n }\n ;(global.fetch as any).mockResolvedValue(mockResponse)\n\n const input = {\n url: 'https://api.example.com/webhook',\n method: 'POST' as const,\n body: 'plain text data',\n headers: { 'Content-Type': 'text/plain' },\n stepName: 'test-post-string'\n }\n\n await httpRequestStepHandler({ input, req: mockReq })\n\n expect(global.fetch).toHaveBeenCalledWith('https://api.example.com/webhook', {\n method: 'POST',\n headers: { 'Content-Type': 'text/plain' },\n body: 'plain text data',\n signal: expect.any(AbortSignal)\n })\n })\n })\n\n describe('Error handling', () => {\n it('should handle network errors', async () => {\n ;(global.fetch as any).mockRejectedValue(new Error('Network error'))\n\n const input = {\n url: 'https://invalid-url.example.com',\n method: 'GET' as const,\n stepName: 'test-network-error'\n }\n\n const result = await httpRequestStepHandler({ input, req: mockReq })\n\n expect(result.state).toBe('failed')\n expect(result.error).toContain('Network error')\n })\n\n it('should handle HTTP error status codes', async () => {\n const mockResponse = {\n ok: false,\n status: 404,\n statusText: 'Not Found',\n headers: new Headers(),\n text: vi.fn().mockResolvedValue('Page not found')\n }\n ;(global.fetch as any).mockResolvedValue(mockResponse)\n\n const input = {\n url: 'https://api.example.com/nonexistent',\n method: 'GET' as const,\n stepName: 'test-404-error'\n }\n\n const result = await httpRequestStepHandler({ input, req: mockReq })\n\n expect(result.state).toBe('failed')\n expect(result.error).toContain('HTTP 404')\n expect(result.output.status).toBe(404)\n expect(result.output.statusText).toBe('Not Found')\n })\n\n it('should handle timeout errors', async () => {\n const abortError = new Error('The operation was aborted')\n abortError.name = 'AbortError'\n ;(global.fetch as any).mockRejectedValue(abortError)\n\n const input = {\n url: 'https://slow-api.example.com',\n method: 'GET' as const,\n timeout: 1000,\n stepName: 'test-timeout'\n }\n\n const result = await httpRequestStepHandler({ input, req: mockReq })\n\n expect(result.state).toBe('failed')\n expect(result.error).toContain('timeout')\n })\n\n it('should handle invalid JSON response parsing', async () => {\n const mockResponse = {\n ok: true,\n status: 200,\n statusText: 'OK',\n headers: new Headers({ 'content-type': 'application/json' }),\n text: vi.fn().mockResolvedValue('invalid json {')\n }\n ;(global.fetch as any).mockResolvedValue(mockResponse)\n\n const input = {\n url: 'https://api.example.com/invalid-json',\n method: 'GET' as const,\n stepName: 'test-invalid-json'\n }\n\n const result = await httpRequestStepHandler({ input, req: mockReq })\n\n // Should still succeed but with raw text body\n expect(result.state).toBe('succeeded')\n expect(result.output.body).toBe('invalid json {')\n })\n })\n\n describe('Request validation', () => {\n it('should validate required URL field', async () => {\n const input = {\n method: 'GET' as const,\n stepName: 'test-missing-url'\n }\n\n const result = await httpRequestStepHandler({ input, req: mockReq } as any)\n\n expect(result.state).toBe('failed')\n expect(result.error).toContain('URL is required')\n })\n\n it('should validate HTTP method', async () => {\n const input = {\n url: 'https://api.example.com',\n method: 'INVALID' as any,\n stepName: 'test-invalid-method'\n }\n\n const result = await httpRequestStepHandler({ input, req: mockReq })\n\n expect(result.state).toBe('failed')\n expect(result.error).toContain('Invalid HTTP method')\n })\n\n it('should validate URL format', async () => {\n const input = {\n url: 'not-a-valid-url',\n method: 'GET' as const,\n stepName: 'test-invalid-url'\n }\n\n const result = await httpRequestStepHandler({ input, req: mockReq })\n\n expect(result.state).toBe('failed')\n expect(result.error).toContain('Invalid URL')\n })\n })\n\n describe('Response processing', () => {\n it('should parse JSON responses automatically', async () => {\n const responseData = { id: 123, name: 'Test Item' }\n const mockResponse = {\n ok: true,\n status: 200,\n statusText: 'OK',\n headers: new Headers({ 'content-type': 'application/json' }),\n text: vi.fn().mockResolvedValue(JSON.stringify(responseData))\n }\n ;(global.fetch as any).mockResolvedValue(mockResponse)\n\n const input = {\n url: 'https://api.example.com/item/123',\n method: 'GET' as const,\n stepName: 'test-json-parsing'\n }\n\n const result = await httpRequestStepHandler({ input, req: mockReq })\n\n expect(result.state).toBe('succeeded')\n expect(typeof result.output.body).toBe('string')\n // Should contain the JSON as string for safe storage\n expect(result.output.body).toBe(JSON.stringify(responseData))\n })\n\n it('should handle non-JSON responses', async () => {\n const htmlContent = '<html><body>Hello World</body></html>'\n const mockResponse = {\n ok: true,\n status: 200,\n statusText: 'OK',\n headers: new Headers({ 'content-type': 'text/html' }),\n text: vi.fn().mockResolvedValue(htmlContent)\n }\n ;(global.fetch as any).mockResolvedValue(mockResponse)\n\n const input = {\n url: 'https://example.com/page',\n method: 'GET' as const,\n stepName: 'test-html-response'\n }\n\n const result = await httpRequestStepHandler({ input, req: mockReq })\n\n expect(result.state).toBe('succeeded')\n expect(result.output.body).toBe(htmlContent)\n })\n\n it('should capture response headers', async () => {\n const mockResponse = {\n ok: true,\n status: 200,\n statusText: 'OK',\n headers: new Headers({\n 'content-type': 'application/json',\n 'x-rate-limit': '100',\n 'x-custom-header': 'custom-value'\n }),\n text: vi.fn().mockResolvedValue('{}')\n }\n ;(global.fetch as any).mockResolvedValue(mockResponse)\n\n const input = {\n url: 'https://api.example.com/data',\n method: 'GET' as const,\n stepName: 'test-response-headers'\n }\n\n const result = await httpRequestStepHandler({ input, req: mockReq })\n\n expect(result.state).toBe('succeeded')\n expect(result.output.headers).toEqual({\n 'content-type': 'application/json',\n 'x-rate-limit': '100',\n 'x-custom-header': 'custom-value'\n })\n })\n })\n})"],"names":["describe","it","expect","vi","beforeEach","httpRequestStepHandler","global","fetch","fn","mockPayload","mockReq","payload","user","clearAllMocks","mockResponse","ok","status","statusText","headers","Headers","text","mockResolvedValue","input","url","method","stepName","result","req","state","toBe","output","body","toEqual","toHaveBeenCalledWith","signal","any","AbortSignal","title","content","JSON","stringify","mockRejectedValue","Error","error","toContain","abortError","name","timeout","responseData","id","htmlContent"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,EAAE,EAAEC,MAAM,EAAEC,EAAE,EAAEC,UAAU,QAAQ,SAAQ;AAC7D,SAASC,sBAAsB,QAAQ,mCAAkC;AAGzE,sBAAsB;AAC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