diff --git a/addons/website/tests/test_ui.py b/addons/website/tests/test_ui.py index 259985ebbd5..6ce69369e6b 100644 --- a/addons/website/tests/test_ui.py +++ b/addons/website/tests/test_ui.py @@ -81,7 +81,8 @@ class WebsiteUiSuite(unittest.TestSuite): self._options['db'] = tools.config.get('db_name', '') # TODO Use correct key self._options['user'] = 'admin' - self._options['password'] = tools.config.get('admin_passwd', 'admin') + self._options['admin_password'] = tools.config.get('admin_passwd', 'admin') + self._options['db_password'] = tools.config.get('db_password', 'admin') phantom = subprocess.Popen([ 'phantomjs', @@ -139,6 +140,6 @@ class WebsiteUiSuite(unittest.TestSuite): def load_tests(loader, base, _): base.addTest(WebsiteUiSuite('dummy_test.js', {})) - base.addTest(WebsiteUiSuite('simple_dom_test.js', { 'action': 'website.action_website_homepage' })) + base.addTest(WebsiteUiSuite('simple_dom_test.js', { 'action': 'website.action_website_homepage' })) base.addTest(WebsiteUiSuite('banner_tour_test.js', { 'action': 'website.action_website_homepage' })) return base diff --git a/addons/website/tests/ui_suite/simple_dom_test.js b/addons/website/tests/ui_suite/simple_dom_test.js index e0c19ceef2a..9d96b9cfd86 100644 --- a/addons/website/tests/ui_suite/simple_dom_test.js +++ b/addons/website/tests/ui_suite/simple_dom_test.js @@ -3,13 +3,22 @@ var testRunner = require('./ui_test_runner.js'); var waitFor = testRunner.waitFor; testRunner.run(function simpleDomTest (page) { - waitFor(function () { + waitFor(function openerpFrameworkReady () { return page.evaluate(function () { - return window.openerp && window.openerp.website - && window.openerp.website.TestConsole; + return window.openerp && window.openerp.website; }); - }, function () { + }, function success () { console.log('{ "event": "success" }'); phantom.exit(); - }, 20000); + }, 20000, function errorStatus () { + var status = page.evaluate(function () { + return { + href: window.location.href, + jQueryFound: (typeof window.$ === 'function'), + openerpFound: (typeof window.openerp === 'object'), + websiteFound: (typeof window.openerp.website === 'object'), + } + }); + return status.href+" - jQuery: "+status.jQueryFound+" - openerp: " +status.openerpFound+ " - website: "+status.websiteFound; + }); }); \ No newline at end of file diff --git a/addons/website/tests/ui_suite/ui_test_runner.js b/addons/website/tests/ui_suite/ui_test_runner.js index a781db54674..a4a710fc81e 100644 --- a/addons/website/tests/ui_suite/ui_test_runner.js +++ b/addons/website/tests/ui_suite/ui_test_runner.js @@ -1,4 +1,4 @@ -function waitFor(ready, callback, timeout) { +function waitFor(ready, callback, timeout, timeoutMessageCallback) { timeout = timeout || 10000; var start = new Date().getTime(); var condition = ready(); @@ -7,7 +7,7 @@ function waitFor(ready, callback, timeout) { condition = ready(); } else { if(!condition) { - var message = "Timeout after "+timeout+" ms"; + var message = timeoutMessageCallback ? timeoutMessageCallback() : "Timeout after "+timeout+" ms"; console.log('{ "event": "error", "message": "'+message+'" }'); console.log("Waiting for...\n"+ready); phantom.exit(1); @@ -25,12 +25,18 @@ function run (test) { var host = options.host ? options.host : 'localhost'; var port = options.port ? ':'+options.port : ''; var path = options.path ? options.path : '/web'; - var params = []; - if (options.action) params.push('action='+options.action); - if (options.db) params.push('source='+options.db); - if (options.user) params.push('login='+options.user); - if (options.password) params.push('password='+options.password); - var url = scheme+host+port+path+'#'+params.join('&'); + + var queryParams = []; + if (options.db) queryParams.push('db='+options.db); + var query = queryParams.length > 0 ? '?'+queryParams.join('&') : ''; + + var hashParams = []; + if (options.user) hashParams.push('login='+options.user); + if (options.admin_password) hashParams.push('password='+options.admin_password); + if (options.action) hashParams.push('action='+options.action); + var hash = hashParams.length > 0 ? '#'+hashParams.join('&') : ''; + + var url = scheme+host+port+path+query+hash; var page = require('webpage').create(); page.viewportSize = { width: 1920, height: 1080 }; page.onError = function(message, trace) {