[FIX] web: tests: click helper: throw error if target is disabled
This commit is a backport of odoo/odoo@f065276a46 Before chrome 116, programmatic clicks on disabled buttons weren't actually fired. With chrome 116, they are. As a consequence, some tests fails on chrome 116 because they click (on purpose) on disabled button to highlight the fact that nothing happens. This commit improves the click helper to make it throw an error when the target is disabled. It also adapts the tests that were clicking on disabled button, in general to simply assert that the button is disabled instead. closes odoo/odoo#139537 X-original-commit: 0e8b50d540c9eee0837282883d603937b94b2fd2 Signed-off-by: Romeo Fragomeli (rfr) <rfr@odoo.com> Signed-off-by: Pierre Paridans (app) <app@odoo.com> Co-authored-by: Aaron Bohy <aab@odoo.com>
This commit is contained in:
co-authored by
Aaron Bohy
parent
cd1ddc7cad
commit
feaa6d64bd
@@ -134,6 +134,9 @@ import { delay } from "@web/core/utils/concurrency";
|
||||
if (typeof el === 'string') {
|
||||
el = $(el);
|
||||
}
|
||||
if (el.disabled || (el instanceof jQuery && el.get(0).disabled)) {
|
||||
throw new Error("Can't click on a disabled button");
|
||||
}
|
||||
if (_isEventTarget(el)) {
|
||||
// EventTarget
|
||||
matches = [el];
|
||||
|
||||
@@ -9964,7 +9964,7 @@ QUnit.module("Views", (hooks) => {
|
||||
|
||||
await editInput(target, '.o_field_widget[name="foo"] input', "test");
|
||||
await clickSave(target);
|
||||
await clickSave(target);
|
||||
assert.ok(target.querySelector(".o_form_button_save").disabled); // Save button is disabled, it can't be clicked
|
||||
|
||||
def.resolve();
|
||||
await nextTick();
|
||||
|
||||
Reference in New Issue
Block a user