@formhaus/core 0.10.0 → 0.11.0

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.
@@ -0,0 +1,612 @@
1
+ [
2
+ {
3
+ "name": "201 stores the submission",
4
+ "request": "submit",
5
+ "response": {
6
+ "status": 201,
7
+ "body": {
8
+ "id": "7b2f",
9
+ "values": {
10
+ "email": "ada@example.com"
11
+ }
12
+ }
13
+ },
14
+ "expect": {
15
+ "submission": {
16
+ "id": "7b2f",
17
+ "values": {
18
+ "email": "ada@example.com"
19
+ }
20
+ }
21
+ }
22
+ },
23
+ {
24
+ "name": "400 malformed body",
25
+ "request": "submit",
26
+ "response": {
27
+ "status": 400,
28
+ "body": {
29
+ "error": "malformed_body"
30
+ }
31
+ },
32
+ "expect": {
33
+ "error": {
34
+ "status": 400,
35
+ "code": "malformed_body",
36
+ "action": "reload"
37
+ }
38
+ }
39
+ },
40
+ {
41
+ "name": "400 invalid idempotency key",
42
+ "request": "submit",
43
+ "response": {
44
+ "status": 400,
45
+ "body": {
46
+ "error": "invalid_idempotency_key"
47
+ }
48
+ },
49
+ "expect": {
50
+ "error": {
51
+ "status": 400,
52
+ "code": "invalid_idempotency_key",
53
+ "action": "reload"
54
+ }
55
+ }
56
+ },
57
+ {
58
+ "name": "402 limit reached",
59
+ "request": "submit",
60
+ "response": {
61
+ "status": 402,
62
+ "body": {
63
+ "error": "limit_reached"
64
+ }
65
+ },
66
+ "expect": {
67
+ "error": {
68
+ "status": 402,
69
+ "code": "limit_reached",
70
+ "action": null
71
+ }
72
+ }
73
+ },
74
+ {
75
+ "name": "404 not found",
76
+ "request": "submit",
77
+ "response": {
78
+ "status": 404,
79
+ "body": {
80
+ "error": "not_found"
81
+ }
82
+ },
83
+ "expect": {
84
+ "error": {
85
+ "status": 404,
86
+ "code": "not_found",
87
+ "action": null
88
+ }
89
+ }
90
+ },
91
+ {
92
+ "name": "409 paused",
93
+ "request": "submit",
94
+ "response": {
95
+ "status": 409,
96
+ "body": {
97
+ "error": "paused"
98
+ }
99
+ },
100
+ "expect": {
101
+ "error": {
102
+ "status": 409,
103
+ "code": "paused",
104
+ "action": null
105
+ }
106
+ }
107
+ },
108
+ {
109
+ "name": "409 idempotency key reused",
110
+ "request": "submit",
111
+ "response": {
112
+ "status": 409,
113
+ "body": {
114
+ "error": "idempotency_key_reused"
115
+ }
116
+ },
117
+ "expect": {
118
+ "error": {
119
+ "status": 409,
120
+ "code": "idempotency_key_reused",
121
+ "action": "retry"
122
+ }
123
+ }
124
+ },
125
+ {
126
+ "name": "409 form updated",
127
+ "request": "submit",
128
+ "response": {
129
+ "status": 409,
130
+ "body": {
131
+ "error": "form_updated",
132
+ "version": 4,
133
+ "errors": {
134
+ "email": "Enter a valid email"
135
+ }
136
+ }
137
+ },
138
+ "expect": {
139
+ "error": {
140
+ "status": 409,
141
+ "code": "form_updated",
142
+ "action": "reload",
143
+ "version": 4,
144
+ "errors": {
145
+ "email": "Enter a valid email"
146
+ }
147
+ }
148
+ }
149
+ },
150
+ {
151
+ "name": "410 expired",
152
+ "request": "submit",
153
+ "response": {
154
+ "status": 410,
155
+ "body": {
156
+ "error": "expired"
157
+ }
158
+ },
159
+ "expect": {
160
+ "error": {
161
+ "status": 410,
162
+ "code": "expired",
163
+ "action": null
164
+ }
165
+ }
166
+ },
167
+ {
168
+ "name": "413 body too large",
169
+ "request": "submit",
170
+ "response": {
171
+ "status": 413,
172
+ "body": {
173
+ "error": "body_too_large"
174
+ }
175
+ },
176
+ "expect": {
177
+ "error": {
178
+ "status": 413,
179
+ "code": "body_too_large",
180
+ "action": null
181
+ }
182
+ }
183
+ },
184
+ {
185
+ "name": "415 unsupported media type",
186
+ "request": "submit",
187
+ "response": {
188
+ "status": 415,
189
+ "body": {
190
+ "error": "unsupported_media_type"
191
+ }
192
+ },
193
+ "expect": {
194
+ "error": {
195
+ "status": 415,
196
+ "code": "unsupported_media_type",
197
+ "action": "reload"
198
+ }
199
+ }
200
+ },
201
+ {
202
+ "name": "422 field errors without a code",
203
+ "request": "submit",
204
+ "response": {
205
+ "status": 422,
206
+ "body": {
207
+ "errors": {
208
+ "email": "Enter a valid email"
209
+ }
210
+ }
211
+ },
212
+ "expect": {
213
+ "error": {
214
+ "status": 422,
215
+ "code": "unknown",
216
+ "action": null,
217
+ "errors": {
218
+ "email": "Enter a valid email"
219
+ }
220
+ }
221
+ }
222
+ },
223
+ {
224
+ "name": "422 invalid with field errors",
225
+ "request": "submit",
226
+ "response": {
227
+ "status": 422,
228
+ "body": {
229
+ "error": "invalid",
230
+ "errors": {
231
+ "email": "Enter a valid email"
232
+ }
233
+ }
234
+ },
235
+ "expect": {
236
+ "error": {
237
+ "status": 422,
238
+ "code": "invalid",
239
+ "action": null,
240
+ "errors": {
241
+ "email": "Enter a valid email"
242
+ }
243
+ }
244
+ }
245
+ },
246
+ {
247
+ "name": "426 client outdated",
248
+ "request": "submit",
249
+ "response": {
250
+ "status": 426,
251
+ "body": {
252
+ "error": "client_outdated",
253
+ "minCore": "0.12.0"
254
+ }
255
+ },
256
+ "expect": {
257
+ "error": {
258
+ "status": 426,
259
+ "code": "client_outdated",
260
+ "action": null
261
+ }
262
+ }
263
+ },
264
+ {
265
+ "name": "429 rate limited",
266
+ "request": "submit",
267
+ "response": {
268
+ "status": 429,
269
+ "body": {
270
+ "error": "rate_limited",
271
+ "message": "Too many requests"
272
+ }
273
+ },
274
+ "expect": {
275
+ "error": {
276
+ "status": 429,
277
+ "code": "rate_limited",
278
+ "action": "retry"
279
+ }
280
+ }
281
+ },
282
+ {
283
+ "name": "500 internal",
284
+ "request": "submit",
285
+ "response": {
286
+ "status": 500,
287
+ "body": {
288
+ "error": "internal"
289
+ }
290
+ },
291
+ "expect": {
292
+ "error": {
293
+ "status": 500,
294
+ "code": "internal",
295
+ "action": "retry"
296
+ }
297
+ }
298
+ },
299
+ {
300
+ "name": "503 unavailable",
301
+ "request": "submit",
302
+ "response": {
303
+ "status": 503,
304
+ "body": {
305
+ "error": "unavailable"
306
+ }
307
+ },
308
+ "expect": {
309
+ "error": {
310
+ "status": 503,
311
+ "code": "unavailable",
312
+ "action": "retry"
313
+ }
314
+ }
315
+ },
316
+ {
317
+ "name": "load envelope",
318
+ "request": "load",
319
+ "response": {
320
+ "status": 200,
321
+ "body": {
322
+ "definition": {
323
+ "id": "contact",
324
+ "title": "Contact",
325
+ "submit": {
326
+ "label": "Send"
327
+ },
328
+ "fields": [
329
+ {
330
+ "key": "email",
331
+ "type": "email",
332
+ "label": "Email"
333
+ }
334
+ ]
335
+ },
336
+ "version": 3,
337
+ "settings": {
338
+ "successMessage": "Thanks!",
339
+ "redirectUrl": "https://example.com/done",
340
+ "allowAnother": true
341
+ },
342
+ "renderToken": "rt_abc"
343
+ }
344
+ },
345
+ "expect": {
346
+ "form": {
347
+ "definition": {
348
+ "id": "contact",
349
+ "title": "Contact",
350
+ "submit": {
351
+ "label": "Send"
352
+ },
353
+ "fields": [
354
+ {
355
+ "key": "email",
356
+ "type": "email",
357
+ "label": "Email"
358
+ }
359
+ ]
360
+ },
361
+ "version": 3,
362
+ "settings": {
363
+ "successMessage": "Thanks!",
364
+ "redirectUrl": "https://example.com/done",
365
+ "allowAnother": true
366
+ },
367
+ "renderToken": "rt_abc"
368
+ }
369
+ }
370
+ },
371
+ {
372
+ "name": "load legacy bare definition",
373
+ "request": "load",
374
+ "response": {
375
+ "status": 200,
376
+ "headers": {
377
+ "Formhaus-Version": "2"
378
+ },
379
+ "body": {
380
+ "id": "contact",
381
+ "title": "Contact",
382
+ "submit": {
383
+ "label": "Send"
384
+ },
385
+ "fields": [
386
+ {
387
+ "key": "email",
388
+ "type": "email",
389
+ "label": "Email"
390
+ }
391
+ ]
392
+ }
393
+ },
394
+ "expect": {
395
+ "form": {
396
+ "definition": {
397
+ "id": "contact",
398
+ "title": "Contact",
399
+ "submit": {
400
+ "label": "Send"
401
+ },
402
+ "fields": [
403
+ {
404
+ "key": "email",
405
+ "type": "email",
406
+ "label": "Email"
407
+ }
408
+ ]
409
+ },
410
+ "version": 2,
411
+ "settings": {}
412
+ }
413
+ }
414
+ },
415
+ {
416
+ "name": "load not found",
417
+ "request": "load",
418
+ "response": {
419
+ "status": 404,
420
+ "body": {
421
+ "error": "not_found",
422
+ "message": "Form not found"
423
+ }
424
+ },
425
+ "expect": {
426
+ "error": {
427
+ "status": 404,
428
+ "code": "not_found",
429
+ "action": null
430
+ }
431
+ }
432
+ },
433
+ {
434
+ "name": "load paused, legacy text",
435
+ "request": "load",
436
+ "response": {
437
+ "status": 409,
438
+ "body": {
439
+ "error": "Form paused"
440
+ }
441
+ },
442
+ "expect": {
443
+ "error": {
444
+ "status": 409,
445
+ "code": "paused",
446
+ "action": null
447
+ }
448
+ }
449
+ },
450
+ {
451
+ "name": "load expired",
452
+ "request": "load",
453
+ "response": {
454
+ "status": 410,
455
+ "body": {
456
+ "error": "expired",
457
+ "message": "Form expired"
458
+ }
459
+ },
460
+ "expect": {
461
+ "error": {
462
+ "status": 410,
463
+ "code": "expired",
464
+ "action": null
465
+ }
466
+ }
467
+ },
468
+ {
469
+ "name": "load envelope without a render token and with an unsafe redirect",
470
+ "request": "load",
471
+ "response": {
472
+ "status": 200,
473
+ "body": {
474
+ "definition": {
475
+ "id": "contact",
476
+ "title": "Contact",
477
+ "submit": {
478
+ "label": "Send"
479
+ },
480
+ "fields": [
481
+ {
482
+ "key": "email",
483
+ "type": "email",
484
+ "label": "Email"
485
+ }
486
+ ]
487
+ },
488
+ "version": 1,
489
+ "settings": {
490
+ "redirectUrl": "javascript:alert(1)"
491
+ }
492
+ }
493
+ },
494
+ "expect": {
495
+ "form": {
496
+ "definition": {
497
+ "id": "contact",
498
+ "title": "Contact",
499
+ "submit": {
500
+ "label": "Send"
501
+ },
502
+ "fields": [
503
+ {
504
+ "key": "email",
505
+ "type": "email",
506
+ "label": "Email"
507
+ }
508
+ ]
509
+ },
510
+ "version": 1,
511
+ "settings": {}
512
+ }
513
+ }
514
+ },
515
+ {
516
+ "name": "load legacy definition with Formhaus-Form-Version",
517
+ "request": "load",
518
+ "response": {
519
+ "status": 200,
520
+ "headers": {
521
+ "Formhaus-Form-Version": "7"
522
+ },
523
+ "body": {
524
+ "id": "contact",
525
+ "title": "Contact",
526
+ "submit": {
527
+ "label": "Send"
528
+ },
529
+ "fields": [
530
+ {
531
+ "key": "email",
532
+ "type": "email",
533
+ "label": "Email"
534
+ }
535
+ ]
536
+ }
537
+ },
538
+ "expect": {
539
+ "form": {
540
+ "definition": {
541
+ "id": "contact",
542
+ "title": "Contact",
543
+ "submit": {
544
+ "label": "Send"
545
+ },
546
+ "fields": [
547
+ {
548
+ "key": "email",
549
+ "type": "email",
550
+ "label": "Email"
551
+ }
552
+ ]
553
+ },
554
+ "version": 7,
555
+ "settings": {}
556
+ }
557
+ }
558
+ },
559
+ {
560
+ "name": "load envelope with a null definition",
561
+ "request": "load",
562
+ "response": {
563
+ "status": 200,
564
+ "body": {
565
+ "definition": null,
566
+ "version": 1
567
+ }
568
+ },
569
+ "expect": {
570
+ "error": {
571
+ "status": 200,
572
+ "code": "invalid_response",
573
+ "action": "retry"
574
+ }
575
+ }
576
+ },
577
+ {
578
+ "name": "load client outdated",
579
+ "request": "load",
580
+ "response": {
581
+ "status": 426,
582
+ "body": {
583
+ "error": "client_outdated",
584
+ "minCore": "0.12.0"
585
+ }
586
+ },
587
+ "expect": {
588
+ "error": {
589
+ "status": 426,
590
+ "code": "client_outdated",
591
+ "action": null
592
+ }
593
+ }
594
+ },
595
+ {
596
+ "name": "load internal error",
597
+ "request": "load",
598
+ "response": {
599
+ "status": 500,
600
+ "body": {
601
+ "error": "internal"
602
+ }
603
+ },
604
+ "expect": {
605
+ "error": {
606
+ "status": 500,
607
+ "code": "internal",
608
+ "action": "retry"
609
+ }
610
+ }
611
+ }
612
+ ]