diff options
| author | Christophe Simonis <chs@odoo.com> | 2019-09-13 13:32:51 +0000 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2019-09-13 13:32:51 +0000 |
| commit | 5a273e74f0fff18df5ab6cb240c9e260be4bb7ff (patch) | |
| tree | 4fbc7e142335d110fa0a984ff2c345a487e37ca4 /addons/web/static/tests/fields/relational_fields_tests.js | |
| parent | dc5f83b63313018999b598210b972636986c5bea (diff) | |
| parent | fe59754c5201f9392b75d5d4cce8ca1400a7ef5d (diff) | |
[MERGE] forward port branch saas-12.4 up to fe59754c520
closes odoo/odoo#36721
Signed-off-by: Christophe Simonis <chs@odoo.com>
Diffstat (limited to 'addons/web/static/tests/fields/relational_fields_tests.js')
| -rw-r--r-- | addons/web/static/tests/fields/relational_fields_tests.js | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js index 7284b9099d8..7f3f54e3ad7 100644 --- a/addons/web/static/tests/fields/relational_fields_tests.js +++ b/addons/web/static/tests/fields/relational_fields_tests.js @@ -1191,7 +1191,7 @@ QUnit.module('relational_fields', { }); QUnit.test('required selection widget should not have blank option', async function (assert) { - assert.expect(3); + assert.expect(12); this.data.partner.fields.feedback_value = { type: "selection", @@ -1212,15 +1212,38 @@ QUnit.module('relational_fields', { }); await testUtils.form.clickEdit(form); - assert.strictEqual(form.$('.o_field_widget[name=color]')[0].options.length, 3, - "non required selection field must have 3 options 1 blank option and 2 value options"); - assert.strictEqual(form.$('.o_field_widget[name=feedback_value]')[0].options.length, 2, - "should have only 2 options without blank option"); + + var $colorField = form.$('.o_field_widget[name=color]'); + assert.containsN($colorField, 'option', 3, "Three options in non required field"); + + assert.hasAttrValue($colorField.find('option:first()'), 'style', "", + "Should not have display=none"); + assert.hasAttrValue($colorField.find('option:eq(1)'), 'style', "", + "Should not have display=none"); + assert.hasAttrValue($colorField.find('option:eq(2)'), 'style', "", + "Should not have display=none"); + + const $requiredSelect = form.$('.o_field_widget[name=feedback_value]'); + + assert.containsN($requiredSelect, 'option', 3, "Three options in required field"); + assert.hasAttrValue($requiredSelect.find('option:first()'), 'style', "display: none", + "Should have display=none"); + assert.hasAttrValue($requiredSelect.find('option:eq(1)'), 'style', "", + "Should not have display=none"); + assert.hasAttrValue($requiredSelect.find('option:eq(2)'), 'style', "", + "Should not have display=none"); // change value to update widget modifier values - await testUtils.fields.editSelect(form.$('.o_field_widget[name=feedback_value]'), '"bad"'); - assert.strictEqual(form.$('.o_field_widget[name=color]')[0].options.length, 2, - "should have only 2 options"); + await testUtils.fields.editSelect($requiredSelect, '"bad"'); + $colorField = form.$('.o_field_widget[name=color]'); + + assert.containsN($colorField, 'option', 3, "Three options in required field"); + assert.hasAttrValue($colorField.find('option:first()'), 'style', "display: none", + "Should have display=none"); + assert.hasAttrValue($colorField.find('option:eq(1)'), 'style', "", + "Should not have display=none"); + assert.hasAttrValue($colorField.find('option:eq(2)'), 'style', "", + "Should not have display=none"); form.destroy(); }); |
