@@ -769,29 +769,32 @@ <h5 th:text="#{t_add_info_who_selling_series}">Add info about selling/buying thi
769
769
770
770
/*[- */
771
771
var props = { 'l10n' : { } } ;
772
+ var responseCount = 0 ;
772
773
window . fetch = function ( ) {
773
- var failOnForm = false ;
774
- var failOnField = false ;
774
+ var possibleOutcomes = [ 'failOnForm' , 'failOnField' , 'success' ] ;
775
+ var outcome = possibleOutcomes [ responseCount % possibleOutcomes . length ] ;
775
776
var stubResponse ;
776
777
777
- if ( failOnForm ) {
778
+ if ( outcome === ' failOnForm' ) {
778
779
stubResponse = new Response ( null , { status : 500 , statusText : 'Fake Server Error' } ) ;
779
780
780
- } else if ( failOnField ) {
781
+ } else if ( outcome === ' failOnField' ) {
781
782
var body = new Blob (
782
783
[ '{ "fieldErrors": { "url": [ "Invalid value" ] } }' ] ,
783
784
{ type : 'application/json' }
784
785
) ;
785
786
stubResponse = new Response ( body , { status : 400 } ) ;
786
787
787
- } else {
788
+ } else if ( outcome === 'success' ) {
788
789
var body = new Blob (
789
790
[ '{ "sellerId": 3, "price": 3.5, "currency" : "USD" }' ] ,
790
791
{ type : 'application/json' }
791
792
) ;
792
793
stubResponse = new Response ( body , { status : 200 } ) ;
793
794
}
794
795
796
+ responseCount ++ ;
797
+
795
798
return new Promise ( function delayExecution ( resolve ) {
796
799
setTimeout ( resolve , 500 /* 0.5 second */ ) ;
797
800
0 commit comments