diff options
| author | Christophe Simonis <chs@odoo.com> | 2019-06-06 11:54:35 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2019-06-06 11:54:35 +0200 |
| commit | 71a50a2214748fec413c5a0f042d0e7172ae6ea9 (patch) | |
| tree | 2e9ee11551350e23923390d9c53baf630b6ed834 /addons/web/static/tests | |
| parent | a7621137cb0d75ec545152d5e1d413c9d3548e45 (diff) | |
| parent | 409679866b2ee8352a8cb27460e7332563526924 (diff) | |
[MERGE] forward port branch saas-12.3 up to 409679866b2
Diffstat (limited to 'addons/web/static/tests')
| -rw-r--r-- | addons/web/static/tests/chrome/action_manager_tests.js | 24 | ||||
| -rw-r--r-- | addons/web/static/tests/fields/basic_fields_tests.js | 19 | ||||
| -rw-r--r-- | addons/web/static/tests/views/calendar_tests.js | 41 | ||||
| -rw-r--r-- | addons/web/static/tests/views/form_tests.js | 66 | ||||
| -rw-r--r-- | addons/web/static/tests/views/list_tests.js | 42 |
5 files changed, 192 insertions, 0 deletions
diff --git a/addons/web/static/tests/chrome/action_manager_tests.js b/addons/web/static/tests/chrome/action_manager_tests.js index 7ac817af30c..c82755f2987 100644 --- a/addons/web/static/tests/chrome/action_manager_tests.js +++ b/addons/web/static/tests/chrome/action_manager_tests.js @@ -1177,6 +1177,30 @@ QUnit.module('ActionManager', { actionManager.destroy(); }); + QUnit.test('state.sa should load action from session', async function (assert) { + assert.expect(1); + + var actionManager = await createActionManager({ + actions: this.actions, + archs: this.archs, + data: this.data, + mockRPC: function (route, args) { + if (route === '/web/session/get_session_action') { + return Promise.resolve(1); + } + return this._super.apply(this, arguments); + }, + }); + await actionManager.loadState({ + sa: 1, + }); + + assert.strictEqual(actionManager.$('.o_kanban_view').length, 1, + "should have rendered a kanban view"); + + actionManager.destroy(); + }); + QUnit.module('Concurrency management'); QUnit.test('drop previous actions if possible', async function (assert) { diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js index e768c1b67ea..5c399547458 100644 --- a/addons/web/static/tests/fields/basic_fields_tests.js +++ b/addons/web/static/tests/fields/basic_fields_tests.js @@ -2549,6 +2549,25 @@ QUnit.module('basic_fields', { form.destroy(); }); + QUnit.test('date field should remove the date if the date is not valid', async function (assert) { + assert.expect(1); + + var form = await createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '<form string="Partners"><field name="date"/></form>', + res_id: 4, + }); + // switch to edit mode + await testUtils.form.clickEdit(form); + // set an invalid date + var $input = form.$('.o_field_widget[name=date] input'); + $input.val('mmmh').trigger('change'); + assert.strictEqual($input.text(), "", "The date field should be empty"); + form.destroy(); + }); + QUnit.test('date field value should not set on first click', async function (assert) { assert.expect(2); diff --git a/addons/web/static/tests/views/calendar_tests.js b/addons/web/static/tests/views/calendar_tests.js index d78424841ff..babb22a5ba1 100644 --- a/addons/web/static/tests/views/calendar_tests.js +++ b/addons/web/static/tests/views/calendar_tests.js @@ -1,11 +1,13 @@ odoo.define('web.calendar_tests', function (require) { "use strict"; +var AbstractStorageService = require('web.AbstractStorageService'); var CalendarView = require('web.CalendarView'); var CalendarRenderer = require('web.CalendarRenderer'); var Dialog = require('web.Dialog'); var fieldUtils = require('web.field_utils'); var mixins = require('web.mixins'); +var RamStorage = require('web.RamStorage'); var testUtils = require('web.test_utils'); var session = require('web.session'); @@ -2612,6 +2614,45 @@ QUnit.module('Views', { calendar.destroy(); }); + QUnit.test('calendar sidebar toggle', async function (assert) { + assert.expect(5); + + var calendar = await createCalendarView({ + View: CalendarView, + model: 'event', + data: this.data, + arch: + '<calendar date_start="start_date">'+ + '<field name="name"/>'+ + '</calendar>', + services: { + local_storage: AbstractStorageService.extend({storage: new RamStorage()}), + }, + }); + + var fullWidth = calendar.call('local_storage', 'getItem', 'calendar_fullWidth'); + assert.strictEqual(fullWidth, undefined, + "calendar_fullWidth should be undefined in local storage"); + assert.containsNone(calendar, '.o_calendar_sidebar_container.o_sidebar_hidden', + "sidebar should be opened"); + + // click on close + await testUtils.dom.click(calendar.$('.o_calendar_sidebar_toggler')); + fullWidth = calendar.call('local_storage', 'getItem', 'calendar_fullWidth'); + assert.strictEqual(fullWidth, true, + "calendar_fullWidth should be true in local storage"); + assert.containsOnce(calendar, '.o_calendar_sidebar_container.o_sidebar_hidden', + "sidebar should be hidden"); + + // reload calendar view and check calendar view has still full width + calendar.reload(); + await testUtils.nextTick(); + assert.containsOnce(calendar, '.o_calendar_sidebar_container.o_sidebar_hidden', + "sidebar should be hidden"); + + calendar.destroy(); + }); + }); }); diff --git a/addons/web/static/tests/views/form_tests.js b/addons/web/static/tests/views/form_tests.js index 4d8b751cc1a..7c6b0c5c335 100644 --- a/addons/web/static/tests/views/form_tests.js +++ b/addons/web/static/tests/views/form_tests.js @@ -8158,6 +8158,72 @@ QUnit.module('Views', { await testUtils.nextTick(); form.destroy(); }); + + QUnit.test('resequence list lines when discardable lines are present', async function (assert) { + assert.expect(8); + + var onchangeNum = 0; + + this.data.partner.onchanges = { + p: function (obj) { + onchangeNum++; + obj.foo = obj.p.length.toString(); + }, + }; + + var form = await createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '<form>' + + '<field name="foo"/>' + + '<field name="p"/>' + + '</form>', + archs: { + 'partner,false,list': + '<tree editable="bottom">' + + '<field name="int_field" widget="handle"/>' + + '<field name="display_name" required="1"/>' + + '</tree>', + }, + }); + + assert.strictEqual(onchangeNum, 1, "one onchange happens when form is opened"); + assert.strictEqual(form.$('[name="foo"]').val(), "0", "onchange worked there is 0 line"); + + // Add one line + await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a')); + form.$('.o_field_one2many input:first').focus(); + await testUtils.nextTick(); + form.$('.o_field_one2many input:first').val('first line').trigger('input'); + await testUtils.nextTick(); + await testUtils.dom.click(form.$('input[name="foo"]')); + assert.strictEqual(onchangeNum, 2, "one onchange happens when a line is added"); + assert.strictEqual(form.$('[name="foo"]').val(), "1", "onchange worked there is 1 line"); + + // Drag and drop second line before first one (with 1 draft and invalid line) + await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a')); + await testUtils.dom.dragAndDrop( + form.$('.ui-sortable-handle').eq(0), + form.$('.o_data_row').last(), + {position: 'bottom'} + ); + assert.strictEqual(onchangeNum, 3, "one onchange happens when lines are resequenced"); + assert.strictEqual(form.$('[name="foo"]').val(), "1", "onchange worked there is 1 line"); + + // Add a second line + await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a')); + form.$('.o_field_one2many input:first').focus(); + await testUtils.nextTick(); + form.$('.o_field_one2many input:first').val('second line').trigger('input'); + await testUtils.nextTick(); + await testUtils.dom.click(form.$('input[name="foo"]')); + assert.strictEqual(onchangeNum, 4, "one onchange happens when a line is added"); + assert.strictEqual(form.$('[name="foo"]').val(), "2", "onchange worked there is 2 lines"); + + form.destroy(); + }); + QUnit.test('if the focus is on the discard button, hitting ESCAPE should discard', async function (assert) { assert.expect(1); diff --git a/addons/web/static/tests/views/list_tests.js b/addons/web/static/tests/views/list_tests.js index ddf340f62df..4175a7171aa 100644 --- a/addons/web/static/tests/views/list_tests.js +++ b/addons/web/static/tests/views/list_tests.js @@ -15,6 +15,7 @@ var widgetRegistry = require('web.widget_registry'); var Widget = require('web.Widget'); var _t = core._t; +var createActionManager = testUtils.createActionManager; var createView = testUtils.createView; @@ -982,6 +983,47 @@ QUnit.module('Views', { list.destroy(); }); + QUnit.test('editable list view: check that controlpanel buttons are updating when groupby applied', async function (assert) { + assert.expect(4); + + this.data.foo.fields.foo = {string: "Foo", type: "char", required:true}; + + var actionManager = await createActionManager({ + actions: [{ + id: 11, + name: 'Partners Action 11', + res_model: 'foo', + type: 'ir.actions.act_window', + views: [[3, 'list']], + search_view_id: [9, 'search'], + }], + archs: { + 'foo,3,list': '<tree editable="top"><field name="display_name"/><field name="foo"/></tree>', + + 'foo,9,search': '<search>'+ + '<filter string="candle" name="itsName" context="{\'group_by\': \'foo\'}"/>' + + '</search>', + }, + data: this.data, + }); + + await actionManager.doAction(11); + await testUtils.dom.click(actionManager.$('.o_list_button_add')); + + assert.isNotVisible(actionManager.$('.o_list_button_add'), + "create button should be invisible"); + assert.isVisible(actionManager.$('.o_list_button_save'), "save button should be visible"); + + await testUtils.dom.click(actionManager.$('.o_dropdown_toggler_btn:contains("Group By")')); + await testUtils.dom.click(actionManager.$('.o_group_by_menu .o_menu_item a:contains("candle")')); + + assert.isNotVisible(actionManager.$('.o_list_button_add'), "create button should be invisible"); + assert.isNotVisible(actionManager.$('.o_list_button_save'), + "save button should be invisible after applying groupby"); + + actionManager.destroy(); + }); + QUnit.test('selection changes are triggered correctly', async function (assert) { assert.expect(8); |
