summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorAdrien Dieudonne <adr@odoo.com>2018-10-26 12:02:59 +0000
committerAdrien Dieudonne <adr@odoo.com>2018-10-29 10:25:05 +0000
commit497dfb691774bd7b893e836584482980b0d1be79 (patch)
tree327335c34e82f372011838aac7e3eb5ea3006770 /addons
parentf2932f9f0a09eefec6eb798825dd4fdf7b7b2c91 (diff)
[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
Diffstat (limited to 'addons')
-rw-r--r--addons/base_import/static/tests/import_buttons_mobile_tests.js56
-rw-r--r--addons/base_import/static/tests/import_buttons_tests.js47
-rw-r--r--addons/base_import/views/base_import_templates.xml7
-rw-r--r--addons/web/static/tests/helpers/test_utils.js1
-rw-r--r--addons/web/views/webclient_templates.xml1
5 files changed, 63 insertions, 49 deletions
diff --git a/addons/base_import/static/tests/import_buttons_mobile_tests.js b/addons/base_import/static/tests/import_buttons_mobile_tests.js
new file mode 100644
index 00000000000..ac3410b9369
--- /dev/null
+++ b/addons/base_import/static/tests/import_buttons_mobile_tests.js
@@ -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();
+});
+
+});
diff --git a/addons/base_import/static/tests/import_buttons_tests.js b/addons/base_import/static/tests/import_buttons_tests.js
index 049c43fe8a0..e5326c1d25e 100644
--- a/addons/base_import/static/tests/import_buttons_tests.js
+++ b/addons/base_import/static/tests/import_buttons_tests.js
@@ -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();
- });
-});
-
});
diff --git a/addons/base_import/views/base_import_templates.xml b/addons/base_import/views/base_import_templates.xml
index fdb8e5f0d2b..2b4670f3805 100644
--- a/addons/base_import/views/base_import_templates.xml
+++ b/addons/base_import/views/base_import_templates.xml
@@ -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>
diff --git a/addons/web/static/tests/helpers/test_utils.js b/addons/web/static/tests/helpers/test_utils.js
index 6b8ddfee91b..f20f183d799 100644
--- a/addons/web/static/tests/helpers/test_utils.js
+++ b/addons/web/static/tests/helpers/test_utils.js
@@ -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;
diff --git a/addons/web/views/webclient_templates.xml b/addons/web/views/webclient_templates.xml
index 80284eda520..4e9c32d5385 100644
--- a/addons/web/views/webclient_templates.xml
+++ b/addons/web/views/webclient_templates.xml
@@ -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;
});
}
};