summaryrefslogtreecommitdiff
path: root/addons/web/static/tests
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2018-04-18 18:30:35 +0200
committerChristophe Simonis <chs@odoo.com>2018-04-18 18:30:35 +0200
commitc309ccd7b3d7e2f4884f6e9e47a98d64ceac8ea1 (patch)
tree82deec2a691d9aee34d70aedac9b68ab75c2825c /addons/web/static/tests
parente63e9857411a056538f357b1800d31c835a1647c (diff)
parentfed775bc0c2d70463206bbdddd3cce9ae8469e6a (diff)
[MERGE] forward port branch saas-11.2 up to fed775bc0c2
Diffstat (limited to 'addons/web/static/tests')
-rw-r--r--addons/web/static/tests/fields/basic_fields_tests.js29
-rw-r--r--addons/web/static/tests/fields/relational_fields_tests.js58
-rw-r--r--addons/web/static/tests/views/pivot_tests.js41
3 files changed, 127 insertions, 1 deletions
diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js
index 6aa28fd9a2e..f2a49cbc387 100644
--- a/addons/web/static/tests/fields/basic_fields_tests.js
+++ b/addons/web/static/tests/fields/basic_fields_tests.js
@@ -1796,7 +1796,6 @@ QUnit.module('basic_fields', {
assert.strictEqual(form.$('div[name="document"] > img').css('max-width'), "90px",
"the image should correctly set its attributes");
form.destroy();
-
});
QUnit.test('image fields in subviews are loaded correctly', function (assert) {
@@ -1853,6 +1852,34 @@ QUnit.module('basic_fields', {
form.destroy();
});
+ QUnit.test('image fields with required attribute', function (assert) {
+ assert.expect(2);
+
+ var form = createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: '<form string="Partners">' +
+ '<field name="document" required="1" widget="image"/>' +
+ '</form>',
+ mockRPC: function (route, args) {
+ if (args.method === 'create') {
+ throw new Error("Should not do a create RPC with unset required image field");
+ }
+ return this._super.apply(this, arguments);
+ },
+ });
+
+ form.$buttons.find('.o_form_button_save').click();
+
+ assert.ok(form.$('.o_form_view').hasClass('o_form_editable'),
+ "form view should still be editable");
+ assert.ok(form.$('.o_field_widget').hasClass('o_field_invalid'),
+ "image field should be displayed as invalid");
+
+ form.destroy();
+ });
+
QUnit.module('JournalDashboardGraph', {
beforeEach: function () {
_.extend(this.data.partner.fields, {
diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js
index a046e79de6c..01739c7888c 100644
--- a/addons/web/static/tests/fields/relational_fields_tests.js
+++ b/addons/web/static/tests/fields/relational_fields_tests.js
@@ -11392,6 +11392,38 @@ QUnit.module('relational_fields', {
form.destroy();
});
+ QUnit.test('default_get a reference field in a x2m', function (assert) {
+ assert.expect(1);
+
+ this.data.partner.fields.turtles.default = [
+ [0, false, {turtle_ref: 'product,37'}]
+ ];
+
+ var form = createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: '<form string="Partners">' +
+ '<sheet>' +
+ '<field name="turtles">' +
+ '<tree>' +
+ '<field name="turtle_ref"/>' +
+ '</tree>' +
+ '</field>' +
+ '</sheet>' +
+ '</form>',
+ viewOptions: {
+ mode: 'edit',
+ },
+ archs: {
+ 'turtle,false,form': '<form><field name="display_name"/><field name="turtle_ref"/></form>',
+ },
+ });
+ assert.strictEqual(form.$('.o_field_one2many[name="turtles"] .o_data_row:first').text(), "xphone",
+ "the default value should be correctly handled");
+ form.destroy();
+ });
+
QUnit.test('widget reference on char field, reset by onchange', function (assert) {
assert.expect(4);
@@ -11442,6 +11474,32 @@ QUnit.module('relational_fields', {
form.destroy();
});
+ QUnit.test('reference and list navigation', function (assert) {
+ assert.expect(2);
+
+ var list = createView({
+ View: ListView,
+ model: 'partner',
+ data: this.data,
+ arch: '<tree editable="bottom"><field name="reference"/></tree>',
+ });
+
+ // edit first row
+ list.$('.o_data_row .o_data_cell').first().click();
+ assert.strictEqual(list.$('.o_data_row:eq(0) .o_field_widget[name="reference"] input')[0], document.activeElement,
+ 'input of first data row should be selected');
+
+ // press TAB to go to next line
+ list.$('.o_data_row:eq(0) input').trigger($.Event('keydown', {
+ which: $.ui.keyCode.TAB,
+ keyCode: $.ui.keyCode.TAB,
+ }));
+ assert.strictEqual(list.$('.o_data_row:eq(1) .o_field_widget[name="reference"] select')[0], document.activeElement,
+ 'select of second data row should be selected');
+
+ list.destroy();
+ });
+
QUnit.test('one2many with extra field from server not in form', function (assert) {
assert.expect(6);
diff --git a/addons/web/static/tests/views/pivot_tests.js b/addons/web/static/tests/views/pivot_tests.js
index 77c1c66fae8..26733a5edca 100644
--- a/addons/web/static/tests/views/pivot_tests.js
+++ b/addons/web/static/tests/views/pivot_tests.js
@@ -1083,4 +1083,45 @@ QUnit.module('Views', {
'should have loaded the proper data');
pivot.destroy();
});
+
+ QUnit.test('Row and column groupbys plus a domain', function (assert) {
+ assert.expect(3);
+
+ var pivot = createView({
+ View: PivotView,
+ model: "partner",
+ data: this.data,
+ arch: '<pivot>' +
+ '<field name="foo" type="measure"/>' +
+ '</pivot>',
+ });
+
+ // Set a column groupby
+ pivot.$('thead .o_pivot_header_cell_closed').click();
+ pivot.$('.o_field_selection li[data-field=customer] a').click();
+
+ // Set a Row groupby
+ pivot.$('tbody .o_pivot_header_cell_closed').click();
+ pivot.$('.o_pivot_field_menu li[data-field=product_id] a').click();
+
+ // Set a domain
+ pivot.update({domain: [['product_id', '=', 41]]});
+
+ var expectedContext = {pivot_column_groupby: ['customer'],
+ pivot_measures: ['foo'],
+ pivot_row_groupby: ['product_id']};
+
+ // Mock 'save as favorite'
+ assert.deepEqual(pivot.getContext(), expectedContext,
+ 'The pivot view should have the right context');
+
+ var $xpadHeader = pivot.$('tbody .o_pivot_header_cell_closed[data-original-title=Product]');
+ assert.equal($xpadHeader.length, 1,
+ 'There should be only one product line because of the domain');
+
+ assert.equal($xpadHeader.text(), 'xpad',
+ 'The product should be the right one');
+
+ pivot.destroy();
+ });
});});