diff options
| author | Vincent Schippefilt <vsc@odoo.com> | 2019-03-06 14:02:32 +0100 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2019-03-06 20:07:17 +0100 |
| commit | ab56e637b7f97ddcdbcc9baea99ae097e342409c (patch) | |
| tree | 4cb47da9f7ef89b19d18429220a7507470ec12a9 /addons/web/static/tests/widgets/domain_selector_tests.js | |
| parent | eeed894fd50e477135e1ac9a82f6e98ce063ab90 (diff) | |
[REF] web: adapt code after jQuery update
Part of task 1896658
Co-authored-by: Aaron Bohy <aab@odoo.com>
Co-authored-by: Christophe Matthieu <chm@odoo.com>
Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
Co-authored-by: David Monjoie <dmo@odoo.com>
Co-authored-by: Martin Geubelle <mge@odoo.com>
Co-authored-by: svs-odoo <svs@odoo.com>
Co-authored-by: Vincent Schippefilt <vsc@odoo.com>
Diffstat (limited to 'addons/web/static/tests/widgets/domain_selector_tests.js')
| -rw-r--r-- | addons/web/static/tests/widgets/domain_selector_tests.js | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/addons/web/static/tests/widgets/domain_selector_tests.js b/addons/web/static/tests/widgets/domain_selector_tests.js index 53f1d9cff26..305315b72c6 100644 --- a/addons/web/static/tests/widgets/domain_selector_tests.js +++ b/addons/web/static/tests/widgets/domain_selector_tests.js @@ -50,7 +50,7 @@ QUnit.module('DomainSelector', { }, }, function () { - QUnit.test("creating a domain from scratch", function (assert) { + QUnit.test("creating a domain from scratch", async function (assert) { assert.expect(13); var $target = $("#qunit-fixture"); @@ -61,7 +61,7 @@ QUnit.module('DomainSelector', { debugMode: true, }); testUtils.mock.addMockEnvironment(domainSelector, {data: this.data}); - domainSelector.appendTo($target); + await domainSelector.appendTo($target); // As we gave an empty domain, there should be a visible button to add // the first domain part @@ -71,13 +71,14 @@ QUnit.module('DomainSelector', { // Clicking on the button should add a visible field selector in the // widget so that the user can change the field chain - testUtils.dom.click($domainAddFirstNodeButton); + await testUtils.dom.click($domainAddFirstNodeButton); var $fieldSelector = domainSelector.$(".o_field_selector:visible"); assert.strictEqual($fieldSelector.length, 1, "there should be a field selector"); // Focusing the field selector input should open a field selector popover $fieldSelector.trigger('focusin'); + await testUtils.nextTick(); var $fieldSelectorPopover = $fieldSelector.find(".o_field_selector_popover:visible"); assert.strictEqual($fieldSelectorPopover.length, 1, "field selector popover should be visible"); @@ -97,7 +98,7 @@ QUnit.module('DomainSelector', { // Clicking the "Bar" field should change the internal domain and this // should be displayed in the debug input - testUtils.dom.click($barLi); + await testUtils.dom.click($barLi); assert.strictEqual( domainSelector.$(".o_domain_debug_input").val(), '[["bar","=",True]]', @@ -108,7 +109,7 @@ QUnit.module('DomainSelector', { // should add the default "['id', '=', 1]" domain var $plus = domainSelector.$(".fa-plus-circle"); assert.strictEqual($plus.length, 1, "there should be a '+' button"); - testUtils.dom.click($plus); + await testUtils.dom.click($plus); assert.strictEqual( domainSelector.$(".o_domain_debug_input").val(), '["&",["bar","=",True],["id","=",1]]', @@ -119,7 +120,7 @@ QUnit.module('DomainSelector', { // domains and the "|" operator var $dots = domainSelector.$(".fa-ellipsis-h"); assert.strictEqual($dots.length, 2, "there should be two '...' buttons"); - testUtils.dom.click($dots.first()); + await testUtils.dom.click($dots.first()); assert.strictEqual( domainSelector.$(".o_domain_debug_input").val(), '["&","&",["bar","=",True],"|",["id","=",1],["id","=",1],["id","=",1]]', @@ -130,6 +131,7 @@ QUnit.module('DomainSelector', { // field instead of "id" should rerender the widget and adapt the // widget suggestions domainSelector.$(".o_domain_debug_input").val('["&","&",["bar","=",True],"|",["foo","=","hello"],["id","=",1],["id","=",1]]').change(); + await testUtils.nextTick(); assert.strictEqual(domainSelector.$(".o_field_selector").eq(1).find("input.o_field_selector_debug").val(), "foo", "the second field selector should now contain the 'foo' value"); assert.ok(domainSelector.$(".o_domain_leaf_operator_select").eq(1).html().indexOf("contains") >= 0, @@ -140,8 +142,8 @@ QUnit.module('DomainSelector', { // "foo" fields, with the initial "&" operator var $minus = domainSelector.$(".o_domain_delete_node_button"); assert.strictEqual($minus.length, 5, "there should be five 'x' buttons"); - testUtils.dom.click($minus.last()); - testUtils.dom.click(domainSelector.$(".o_domain_delete_node_button").last()); + await testUtils.dom.click($minus.last()); + await testUtils.dom.click(domainSelector.$(".o_domain_delete_node_button").last()); assert.strictEqual( domainSelector.$(".o_domain_debug_input").val(), '["&",["bar","=",True],["foo","=","hello"]]', @@ -150,7 +152,7 @@ QUnit.module('DomainSelector', { domainSelector.destroy(); }); - QUnit.test("building a domain with a datetime", function (assert) { + QUnit.test("building a domain with a datetime", async function (assert) { assert.expect(2); var $target = $("#qunit-fixture"); @@ -160,7 +162,7 @@ QUnit.module('DomainSelector', { readonly: false, }); testUtils.mock.addMockEnvironment(domainSelector, {data: this.data}); - domainSelector.appendTo($target); + await domainSelector.appendTo($target); // Check that there is a datepicker to choose the date var $datepicker = domainSelector.$(".o_datepicker:visible"); @@ -168,15 +170,15 @@ QUnit.module('DomainSelector', { "there should be a datepicker"); var val = $datepicker.find('input').val(); - testUtils.dom.openDatepicker($datepicker); - testUtils.dom.clickFirst($('.bootstrap-datetimepicker-widget :not(.today)[data-action="selectDay"]')); + await testUtils.dom.openDatepicker($datepicker); + await testUtils.dom.clickFirst($('.bootstrap-datetimepicker-widget :not(.today)[data-action="selectDay"]')); assert.notEqual(domainSelector.$(".o_datepicker:visible input").val(), val, "datepicker value should have changed"); domainSelector.destroy(); }); - QUnit.test("building a domain with a m2o without following the relation", function (assert) { + QUnit.test("building a domain with a m2o without following the relation", async function (assert) { assert.expect(1); var $target = $("#qunit-fixture"); @@ -187,16 +189,17 @@ QUnit.module('DomainSelector', { readonly: false, }); testUtils.mock.addMockEnvironment(domainSelector, {data: this.data}); - domainSelector.appendTo($target); + await domainSelector.appendTo($target); - testUtils.fields.editAndTrigger(domainSelector.$('.o_domain_leaf_value_input'), 'pad', ['input', 'change']); + await testUtils.fields.editAndTrigger(domainSelector.$('.o_domain_leaf_value_input'), + 'pad', ['input', 'change']); assert.strictEqual(domainSelector.$('.o_domain_debug_input').val(), '[["product_id","ilike","pad"]]', "string should have been allowed as m2o value"); domainSelector.destroy(); }); - QUnit.test("editing a domain with `parent` key", function (assert) { + QUnit.test("editing a domain with `parent` key", async function (assert) { assert.expect(1); var $target = $("#qunit-fixture"); @@ -207,7 +210,7 @@ QUnit.module('DomainSelector', { readonly: false, }); testUtils.mock.addMockEnvironment(domainSelector, {data: this.data}); - domainSelector.appendTo($target); + await domainSelector.appendTo($target); assert.strictEqual(domainSelector.$el.text(), "This domain is not supported.", "an error message should be displayed because of the `parent` key"); @@ -215,7 +218,7 @@ QUnit.module('DomainSelector', { domainSelector.destroy(); }); - QUnit.test("creating a domain with a default option", function (assert) { + QUnit.test("creating a domain with a default option", async function (assert) { assert.expect(1); var $target = $("#qunit-fixture"); @@ -227,11 +230,11 @@ QUnit.module('DomainSelector', { default: [["foo","=","kikou"]], }); testUtils.mock.addMockEnvironment(domainSelector, {data: this.data}); - domainSelector.appendTo($target); + await domainSelector.appendTo($target); // Clicking on the button should add a visible field selector in the // widget so that the user can change the field chain - testUtils.dom.click(domainSelector.$(".o_domain_add_first_node_button:visible")); + await testUtils.dom.click(domainSelector.$(".o_domain_add_first_node_button:visible")); assert.strictEqual( domainSelector.$(".o_domain_debug_input").val(), |
