[IMP] website: add a log report in tour test
bzr revid: chm@openerp.com-20140122112041-id595hkptgzoym6w
This commit is contained in:
@@ -295,6 +295,7 @@
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
website.EditorBar.include({
|
||||
tours: [],
|
||||
init: function () {
|
||||
@@ -340,13 +341,23 @@
|
||||
window.onbeforeunload = function () {
|
||||
clearTimeout(overlapsCrash);
|
||||
};
|
||||
function throwError (message) {
|
||||
console.log(JSON.parse(window.localStorage.getItem("test-report")));
|
||||
test.reset();
|
||||
throw message;
|
||||
}
|
||||
function executeStep (step) {
|
||||
// check if they are a cycle
|
||||
var lastStep = window.localStorage.getItem(testId);
|
||||
var tryStep = lastStep != step.stepId ? 0 : parseInt(window.localStorage.getItem("last-"+testId) || 0, 10)+1;
|
||||
window.localStorage.setItem("last-"+testId, tryStep);
|
||||
var tryStep = lastStep != step.stepId ? 0 : (+(window.localStorage.getItem("test-last-"+testId) || 0) + 1);
|
||||
window.localStorage.setItem("test-last-"+testId, tryStep);
|
||||
if (tryStep > 2) {
|
||||
window.localStorage.removeItem(testId);
|
||||
throw "Test: '" + testId + "' cycling step: '" + step.stepId + "'";
|
||||
throwError("Test: '" + testId + "' cycling step: '" + step.stepId + "'");
|
||||
}
|
||||
|
||||
// set last time for report
|
||||
if (tryStep == 0 || !window.localStorage.getItem("test-last-time")) {
|
||||
window.localStorage.setItem("test-last-time", new Date().getTime());
|
||||
}
|
||||
|
||||
var _next = false;
|
||||
@@ -354,6 +365,12 @@
|
||||
function next () {
|
||||
clearTimeout(overlapsCrash);
|
||||
_next = true;
|
||||
|
||||
// set report
|
||||
var report = JSON.parse(window.localStorage.getItem("test-report")) || {};
|
||||
report[step.stepId] = (new Date().getTime() - window.localStorage.getItem("test-last-time")) + " ms";
|
||||
window.localStorage.setItem("test-report", JSON.stringify(report));
|
||||
|
||||
var nextStep = actionSteps.shift();
|
||||
if (nextStep) {
|
||||
setTimeout(function () {
|
||||
@@ -364,12 +381,17 @@
|
||||
}
|
||||
}
|
||||
overlapsCrash = setTimeout(function () {
|
||||
window.localStorage.removeItem(testId);
|
||||
throw "Test: '" + testId + "' can't resolve step: '" + step.stepId + "'";
|
||||
}, (step.delay || defaultDelay) + 500);
|
||||
throwError("Test: '" + testId + "' can't resolve step: '" + step.stepId + "'");
|
||||
}, (step.delay || defaultDelay) + 1000);
|
||||
|
||||
var $element = $(step.element);
|
||||
if (step.triggers) step.triggers(next);
|
||||
if (step.triggers) {
|
||||
try {
|
||||
step.triggers(next);
|
||||
} catch (e) {
|
||||
throwError(e);
|
||||
}
|
||||
}
|
||||
if ((step.trigger === 'reload' || (step.trigger && step.trigger.url)) && _next) return;
|
||||
|
||||
if (step.snippet && step.trigger === 'drag') {
|
||||
@@ -415,6 +437,12 @@
|
||||
},
|
||||
reset: function () {
|
||||
window.localStorage.removeItem(testId);
|
||||
window.localStorage.removeItem("test-report");
|
||||
for (var k in window.localStorage) {
|
||||
if (window.localStorage[k].indexOf("test-last")) {
|
||||
window.localStorage.removeItem(k);
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
website.TestConsole.tests.push(test);
|
||||
|
||||
@@ -10,6 +10,9 @@ function waitFor (ready, callback, timeout, timeoutMessageCallback) {
|
||||
var message = timeoutMessageCallback ? timeoutMessageCallback() : "Timeout after "+timeout+" ms";
|
||||
console.log('{ "event": "error", "message": "'+message+'" }');
|
||||
console.log("Waiting for...\n"+ready);
|
||||
if (window.localStorage.getItem("test-report")) {
|
||||
console.log(JSON.parse(website.localStorage.getItem("test-report")));
|
||||
}
|
||||
phantom.exit(1);
|
||||
} else {
|
||||
clearInterval(interval);
|
||||
|
||||
@@ -292,8 +292,7 @@
|
||||
url: /shop\/confirmation\//,
|
||||
},
|
||||
afterTrigger: function (tour) {
|
||||
window.localStorage.setItem("test-success", "{}");
|
||||
throw "afterTrigger test finish, remove this throw";
|
||||
window.localStorage.setItem("shoptest-test-success", "true");
|
||||
},
|
||||
}
|
||||
];
|
||||
|
||||
@@ -17,7 +17,7 @@ testRunner.run(function websiteSaleTest (page, timeout) {
|
||||
waitFor(function testExecuted () {
|
||||
return page.evaluate(function () {
|
||||
var res = window.localStorage && window.localStorage.getItem
|
||||
&& window.localStorage.getItem("test-success");
|
||||
&& window.localStorage.getItem("shoptest-test-success");
|
||||
return res;
|
||||
});
|
||||
}, function finish () {
|
||||
|
||||
Reference in New Issue
Block a user