Skip to content

Commit ff4f1bf

Browse files
committed
chore(/series/info.html): make it possible to iterate between all possible server responses by submitting a form.
Prototype-only change. [skip ci]
1 parent 16c3c75 commit ff4f1bf

File tree

1 file changed

+8
-5
lines changed
  • src/main/webapp/WEB-INF/views/series

1 file changed

+8
-5
lines changed

src/main/webapp/WEB-INF/views/series/info.html

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -769,29 +769,32 @@ <h5 th:text="#{t_add_info_who_selling_series}">Add info about selling/buying thi
769769

770770
/*[- */
771771
var props = { 'l10n': {} };
772+
var responseCount = 0;
772773
window.fetch = function() {
773-
var failOnForm = false;
774-
var failOnField = false;
774+
var possibleOutcomes = [ 'failOnForm', 'failOnField', 'success' ];
775+
var outcome = possibleOutcomes[responseCount % possibleOutcomes.length];
775776
var stubResponse;
776777

777-
if (failOnForm) {
778+
if (outcome === 'failOnForm') {
778779
stubResponse = new Response(null, { status: 500, statusText: 'Fake Server Error' });
779780

780-
} else if (failOnField) {
781+
} else if (outcome === 'failOnField') {
781782
var body = new Blob(
782783
[ '{ "fieldErrors": { "url": [ "Invalid value" ] } }' ],
783784
{ type : 'application/json' }
784785
);
785786
stubResponse = new Response(body, { status: 400 });
786787

787-
} else {
788+
} else if (outcome === 'success') {
788789
var body = new Blob(
789790
[ '{ "sellerId": 3, "price": 3.5, "currency" : "USD" }' ],
790791
{ type : 'application/json' }
791792
);
792793
stubResponse = new Response(body, { status: 200 });
793794
}
794795

796+
responseCount++;
797+
795798
return new Promise(function delayExecution(resolve) {
796799
setTimeout(resolve, 500 /* 0.5 second */);
797800

0 commit comments

Comments
 (0)