[FIX] UI tests imps & fixes

bzr revid: ddm@openerp.com-20140106153906-tvibq7wjrgflatd6
This commit is contained in:
ddm@openerp.com
2014-01-06 16:39:06 +01:00
parent 63e2da36a6
commit b4b52bbcac
2 changed files with 28 additions and 16 deletions
@@ -6,14 +6,12 @@ testRunner.run(function homepageTest (page) {
page.evaluate(function () { localStorage.clear(); });
waitFor(function clientReady () {
return page.evaluate(function () {
return window.openerp && window.openerp.website
return window.$ && window.openerp && window.openerp.website
&& window.openerp.website.TestConsole
&& window.openerp.website.TestConsole.test
&& window.openerp.website.TestConsole.test('banner');
});
}, function executeTest () {
page.onResourceError = function(error) {
console.log('{ "event": "error", "message": "'+error.url+' failed to load ('+error.errorString+') "}');
};
var before = page.evaluate(function () {
var result = {
carousel: $('#wrap [data-snippet-id=carousel]').length,
@@ -24,7 +22,7 @@ testRunner.run(function homepageTest (page) {
});
waitFor(function testExecuted () {
var after = page.evaluate(function () {
return $('button[data-action=edit]').is(":visible") && {
return window.$ && $('button[data-action=edit]').is(":visible") && {
carousel: $('#wrap [data-snippet-id=carousel]').length,
columns: $('#wrap [data-snippet-id=three-columns]').length,
};
@@ -35,4 +33,4 @@ testRunner.run(function homepageTest (page) {
phantom.exit();
}, 90000);
}, 20000);
});
});
+24 -10
View File
@@ -51,19 +51,33 @@ function run (test) {
phantom.exit(1);
};
page.onConsoleMessage = function(message) {
console.log(message);
phantom.exit(1);
// Disabled because of the 'web_hello' addon
//console.log(message);
//phantom.exit(1);
};
page.open(url, function (status) {
if (status !== 'success') {
console.log('{ "event": "error", "message": "'+url+' failed to load"}');
phantom.exit(1);
} else {
page.onLoadFinished = function(status) {
test(page);
};
page.onCallback = function(data) {
if (data.event && data.event === 'start') {
test(page);
}
};
var tries = 0;
page.open(url, function openPage (status) {
if (status !== 'success') {
tries++;
if (tries < 5) {
page.open(url, openPage);
} else {
console.log('{ "event": "error", "message": "'+url+' failed to load '+tries+' times ('+status+')"}');
phantom.exit(1);
}
} else {
page.evaluate(function () {
window.callPhantom({ event: 'start' });
});
}
});
}