Skip to content

Commit

Permalink
[FIX] web: don't mock mobile test suite environment
Browse files Browse the repository at this point in the history
The mobile-specific code relies on the size of the browser <= SM
(currently 767px).

But when phantomjs was used to run the JS tests headlessly there was no
way to force that size for the mobile test suite (e.g. when running from
the command line, runbot...). The only solution was to mock some
variables (isMobile, size_class) in web.config to force them to
mobile-like values (see commits odoo/odoo@9bc5009481de188 and
odoo/odoo@497dfb691774bd7b8).

Since the switch to Chrome Headless the browser size is set to a
mobile-friendly size (currently 375x667) when the mobile test suite is
ran. So isMobile is automatically set to true.

The code to mock the web.config has then become redundant.

This commit removes it to only rely on the browser window size for the
mobile test suite execution.

Notes:

When testing manually in the browser it's now required to set the
browser window to a mobile-friendly size. Even if it was already the
case, it will provide a more realistic environment and allows to test
important/behavior-related media queries (e.g. clicking on a button only
visible/present on mobile).

BTW the easiest way to run all tests is to execute them directly using
Chrome Headless (except for debugging of course).

closes odoo#36328

Signed-off-by: Christophe Monniez (moc) <[email protected]>
  • Loading branch information
pparidans committed Sep 3, 2019
1 parent ac18767 commit 96f456a
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions addons/web/views/webclient_templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -720,30 +720,6 @@
<t t-set="html_data" t-value="{'style': 'height: 100%;'}"/>
<t t-set="title">Web Mobile Tests</t>
<t t-set="head">
<script>
// force the config.device.isMobile key to be true so that
// mobile specific files aren't rejected
window.odoo = {};
var odooDefine;
Object.defineProperty(window.odoo, 'define', {
get: function () {
return odooDefine;
},
set: function (define) {
odooDefine = function () {
define.apply(this, arguments);
if (arguments[0] === 'web.config') {
define.call(this, 'web.config.patch', function (require) {
var config = require('web.config');
config.device.isMobile = true;
config.device.size_class = config.device.SIZES.XS;
});
}
};
},
});
</script>

<t t-call="web.js_tests_assets"/>
<script type="text/javascript" src="/web/static/lib/jquery.touchSwipe/jquery.touchSwipe.js"></script>

Expand Down

0 comments on commit 96f456a

Please sign in to comment.