[MOV] web, base_import: mobile tests should be in mobile suite

This fix some inconsistent error on runbot.

In mobile, some views* depend on 'jquery.touchSwipe' library which
is lazy loaded. As a result, the views become asynchronous...
It's why this library is already loaded before running tests in the
mobile test suite. So we can continue to use synchronous views whether
in mobile tests or not.

But some mobile tests weren't in mobile suite...
In desktop, 'jquery.touchSwipe' is lazy loaded and the first test will
load it for others. It's why the first one has to be asynchronous:
https://github.com/odoo/odoo/commit/da7b59045d246c159f93bc75e3f19c6b1221d31c

The inconsistency comes from the fact that all tests are sequential but
we can't garantee the execution order. So, if the test mentionned is not
the first executed one, an error will occur because the view is not
asynchronous.

Now, all mobile tests are moved in mobile suite to be sure that
'jquery.touchSwipe' is loaded.

We also set the default value for size_class because we want a
coherent environment. It is very rare to find mobile devices with
more than 474px wide.

*: form_view, kanban_view, res_config_settings

closes odoo/odoo#28195
This commit is contained in:
Adrien Dieudonne
2018-10-29 10:25:05 +00:00
parent f2932f9f0a
commit 497dfb6917
5 changed files with 63 additions and 49 deletions
@@ -0,0 +1,56 @@
odoo.define('web.base_import_mobile_tests', function (require) {
"use strict";
var KanbanView = require('web.KanbanView');
var ListView = require('web.ListView');
var testUtils = require('web.test_utils');
var createView = testUtils.createView;
QUnit.module('Base Import Mobile Tests', {
beforeEach: function () {
this.data = {
foo: {
fields: {
foo: {string: "Foo", type: "char"},
},
},
};
}
});
QUnit.test('import button should be hidden in list on mobile screens', function (assert) {
assert.expect(1);
var list = createView({
View: ListView,
model: 'foo',
data: this.data,
arch: '<tree><field name="foo"/></tree>',
});
assert.notOk(list.$buttons.find('.o_button_import').is(':visible'),
"import button should be hidden");
list.destroy();
});
QUnit.test('import button should be hidden in kanban on mobile screens', function (assert) {
assert.expect(1);
var kanban = createView({
View: KanbanView,
model: 'foo',
data: this.data,
arch: '<kanban><templates><t t-name="kanban-box">' +
'<div>' +
'<field name="foo"/>' +
'</div>' +
'</t></templates></kanban>',
});
assert.notOk(kanban.$buttons.find('.o_button_import').is(':visible'),
"import button should be hidden");
kanban.destroy();
});
});
@@ -1,7 +1,6 @@
odoo.define('web.base_import_tests', function (require) {
"use strict";
var config = require('web.config');
var KanbanView = require('web.KanbanView');
var ListView = require('web.ListView');
var testUtils = require('web.test_utils');
@@ -107,50 +106,4 @@ QUnit.test('kanban without import button', function(assert) {
kanban.destroy();
});
QUnit.test('import button should be hidden in list on mobile screens', function (assert) {
assert.expect(1);
var list = createView({
View: ListView,
model: 'foo',
data: this.data,
arch: '<tree><field name="foo"/></tree>',
config: {
device: {
size_class: config.device.SIZES.XS,
},
},
});
assert.notOk(list.$buttons.find('.o_button_import').is(':visible'), "import button should be hidden");
list.destroy();
});
QUnit.test('import button should be hidden in kanban on mobile screens', function (assert) {
assert.expect(1);
var done = assert.async();
// the kanban view is async in mobile mode, because it has to load an
// external additional library
testUtils.createAsyncView({
View: KanbanView,
model: 'foo',
data: this.data,
arch: '<kanban><templates><t t-name="kanban-box">' +
'<div>' +
'<field name="foo"/>' +
'</div>' +
'</t></templates></kanban>',
config: {
device: {
size_class: config.device.SIZES.XS,
},
},
}).then(function (kanban){
assert.notOk(kanban.$buttons.find('.o_button_import').is(':visible'), "import button should be hidden");
kanban.destroy();
done();
});
});
});
@@ -10,11 +10,16 @@
</xpath>
</template>
<template id="qunit_suite" name="base_import_tests" inherit_id="web.qunit_suite">
<xpath expr="//t[@t-set='head']" position="inside">
<script type="text/javascript" src="/base_import/static/tests/import_buttons_tests.js"></script>
</xpath>
</template>
<template id="qunit_mobile_suite" name="base_import_mobile_tests" inherit_id="web.qunit_mobile_suite">
<xpath expr="//t[@t-set='head']" position="inside">
<script type="text/javascript" src="/base_import/static/tests/import_buttons_mobile_tests.js"></script>
</xpath>
</template>
</data>
</odoo>
@@ -438,7 +438,6 @@ function addMockEnvironment(widget, params) {
initialConfig.device = _.clone(config.device);
if ('device' in params.config) {
_.extend(config.device, params.config.device);
config.device.isMobile = config.device.size_class <= config.device.SIZES.VSM;
}
if ('debug' in params.config) {
config.debug = params.config.debug;
+1
View File
@@ -583,6 +583,7 @@
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;
});
}
};