summaryrefslogtreecommitdiff
path: root/addons/web/static/tests
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2019-05-29 14:06:12 +0200
committerChristophe Simonis <chs@odoo.com>2019-05-29 14:06:12 +0200
commit8d7ee3921384ce070d3333cbc4073ffc4f8febc4 (patch)
tree197e81ea4c35bc56a898d63add666d53ea79f15b /addons/web/static/tests
parent7ca0fe3c9f1050eac2d117ea35fd7414d1b0742f (diff)
parent8a0e819d0bb0e4184ed64559b7be91605d044e19 (diff)
[MERGE] forward port branch saas-11.3 up to 8a0e819d0bb
Diffstat (limited to 'addons/web/static/tests')
-rw-r--r--addons/web/static/tests/chrome/action_manager_tests.js24
-rw-r--r--addons/web/static/tests/views/form_tests.js62
2 files changed, 86 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 45076903d9e..54152d27b0e 100644
--- a/addons/web/static/tests/chrome/action_manager_tests.js
+++ b/addons/web/static/tests/chrome/action_manager_tests.js
@@ -1143,6 +1143,30 @@ QUnit.module('ActionManager', {
actionManager.destroy();
});
+ QUnit.test('state.sa should load action from session', function (assert) {
+ assert.expect(1);
+
+ var actionManager = createActionManager({
+ actions: this.actions,
+ archs: this.archs,
+ data: this.data,
+ mockRPC: function (route, args) {
+ if (route === '/web/session/get_session_action') {
+ return $.when(1);
+ }
+ return this._super.apply(this, arguments);
+ },
+ });
+ 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', function (assert) {
diff --git a/addons/web/static/tests/views/form_tests.js b/addons/web/static/tests/views/form_tests.js
index 64d34ebf378..31b0e333887 100644
--- a/addons/web/static/tests/views/form_tests.js
+++ b/addons/web/static/tests/views/form_tests.js
@@ -7982,6 +7982,68 @@ QUnit.module('Views', {
.trigger($.Event('keydown', {which: $.ui.keyCode.ESCAPE}));
form.destroy();
});
+
+ QUnit.test('resequence list lines when discardable lines are present', function (assert) {
+ assert.expect(8);
+
+ var onchangeNum = 0;
+
+ this.data.partner.onchanges = {
+ p: function (obj) {
+ onchangeNum++;
+ obj.foo = obj.p.length.toString();
+ },
+ };
+
+ var form = 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
+ form.$('.o_field_x2many_list_row_add a').click();
+ form.$('.o_field_one2many input:first').focus();
+ form.$('.o_field_one2many input:first').val('first line').trigger('input');
+ form.$('input[name="foo"]').click();
+ 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)
+ form.$('.o_field_x2many_list_row_add a').click();
+ testUtils.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
+ form.$('.o_field_x2many_list_row_add a').click();
+ form.$('.o_field_one2many input:first').focus();
+ form.$('.o_field_one2many input:first').val('second line').trigger('input');
+ form.$('input[name="foo"]').click();
+ 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', function (assert) {
assert.expect(1);