Skip to content

Commit

Permalink
Merge d8d21b9 into b185750
Browse files Browse the repository at this point in the history
  • Loading branch information
peuter committed Mar 21, 2019
2 parents b185750 + d8d21b9 commit 6cecca3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 33 deletions.
36 changes: 3 additions & 33 deletions source/class/cv/io/Mockup.js
Expand Up @@ -46,6 +46,9 @@ qx.Class.define('cv.io.Mockup', {
if (qx.core.Environment.get('cv.testMode') && cv.Config.initialDemoData && cv.Config.initialDemoData.xhr) {
this.__xhr = cv.Config.initialDemoData.xhr;
// configure server
qx.dev.FakeServer.getInstance().addFilter(function (method, url) {
return url.startsWith('https://sentry.io');
}, this);
var server = qx.dev.FakeServer.getInstance().getFakeServer();
server.respondWith(function (request) {
var url = cv.report.Record.normalizeUrl(request.url);
Expand Down Expand Up @@ -131,39 +134,6 @@ qx.Class.define('cv.io.Mockup', {
i: new Date().getTime(),
d: cv.Config.initialDemoData.states
});
if (cv.Config.initialDemoData.xhr) {
this.__xhr = cv.Config.initialDemoData.xhr;
// configure server
qx.dev.FakeServer.getInstance().addFilter(function (method, url) {
return url.startsWith('https://sentry.io');
}, this);
var server = qx.dev.FakeServer.getInstance().getFakeServer();
server.respondWith(function (request) {
var url = cv.report.Record.normalizeUrl(request.url);
if (url.indexOf("nocache=") >= 0) {
url = url.replace(/[\?|&]nocache=[0-9]+/, "");
}
if (!this.__xhr[url] || this.__xhr[url].length === 0) {
qx.log.Logger.error(this, "404: no logged responses for URI " + url + " found");
} else {
qx.log.Logger.debug(this, "faking response for " + url);
var response = "";
if (this.__xhr[url].length === 1) {
response = this.__xhr[url][0];
} else {
// multiple responses recorded use them as LIFO stack
response = this.__xhr[url].shift();
}

if (request.readyState === 4 && request.status === 404) {
// This is a hack, sometimes the request has a 404 status and send readystate
// the respond would fail if we do not override it here
request.readyState = 1;
}
request.respond(response.status, response.headers, qx.lang.Json.stringify(response.body));
}
}.bind(this));
}

if (cv.Config.initialDemoData.sequence) {
this.__sequence = cv.Config.initialDemoData.sequence;
Expand Down

0 comments on commit 6cecca3

Please sign in to comment.