diff --git a/addons/web/static/tests/views/list_tests.js b/addons/web/static/tests/views/list_tests.js index 924659be0f7..82607c43689 100644 --- a/addons/web/static/tests/views/list_tests.js +++ b/addons/web/static/tests/views/list_tests.js @@ -1564,7 +1564,7 @@ QUnit.module('Views', { '', }); - assert.containsNone(list, 'o_resize', "There shouldn't be any resize handle if no data"); + assert.containsNone(list, '.o_resize', "There shouldn't be any resize handle if no data"); assertions.forEach(a => { assert.strictEqual(list.$(`th[data-name="${a.field}"]`)[0].offsetWidth, a.expected, `Field ${a.type} should have a fixed width of ${a.expected} pixels`); @@ -1575,6 +1575,66 @@ QUnit.module('Views', { list.destroy(); }); + QUnit.test('width of some fields should be hardcoded if no data, and list initially invisible', async function (assert) { + const assertions = [ + { field: 'bar', expected: 40, type: 'Boolean' }, + { field: 'int_field', expected: 74, type: 'Integer' }, + { field: 'qux', expected: 92, type: 'Float' }, + { field: 'date', expected: 92, type: 'Date' }, + { field: 'datetime', expected: 146, type: 'Datetime' }, + { field: 'amount', expected: 104, type: 'Monetary' }, + { field: 'the_button', expected: 25, type: 'with custom width' }, + ]; + assert.expect(11); + + this.data.foo.fields.foo_o2m = {string: "Foo O2M", type: "one2many", relation: "foo"}; + const form = await createView({ + View: FormView, + model: 'foo', + data: this.data, + res_id: 1, + viewOptions: { mode: 'edit' }, + arch: `
`, + }); + + assert.isNotVisible(form.$('.o_field_one2many')); + + await testUtils.dom.click(form.$('.nav-item:last-child .nav-link')); + + assert.isVisible(form.$('.o_field_one2many')); + + assert.containsNone(form, '.o_field_one2many .o_resize', + "There shouldn't be any resize handle if no data"); + assertions.forEach(a => { + assert.strictEqual(form.$(`.o_field_one2many th[data-name="${a.field}"]`)[0].offsetWidth, a.expected, + `Field ${a.type} should have a fixed width of ${a.expected} pixels`); + }); + assert.strictEqual(form.$('.o_field_one2many th[data-name="foo"]')[0].style.width, '100%', + "Char field should occupy the remaining space"); + + form.destroy(); + }); + QUnit.test('editable list: list view in an initially unselected notebook page', async function (assert) { assert.expect(9); @@ -1874,7 +1934,7 @@ QUnit.module('Views', { groupBy: ['int_field'], }); - assert.containsNone(list, 'o_resize', "There shouldn't be any resize handle if no data"); + assert.containsNone(list, '.o_resize', "There shouldn't be any resize handle if no data"); assertions.forEach(a => { assert.strictEqual(list.$(`th[data-name="${a.field}"]`)[0].offsetWidth, a.expected, `Field ${a.type} should have a fixed width of ${a.expected} pixels`);