[IMP] web: better test modal backdrop behaviors
Part of https://github.com/odoo/odoo/pull/49142 task-2229551
This commit is contained in:
@@ -14,7 +14,7 @@ odoo.define('web.owl_dialog_tests', function (require) {
|
||||
QUnit.module('OwlDialog');
|
||||
|
||||
QUnit.test("Rendering of all props", async function (assert) {
|
||||
assert.expect(26);
|
||||
assert.expect(33);
|
||||
|
||||
class SubComponent extends Component {
|
||||
// Handlers
|
||||
@@ -80,15 +80,27 @@ odoo.define('web.owl_dialog_tests', function (require) {
|
||||
// Backdrop (default: 'static')
|
||||
// Static backdrop click should focus first button
|
||||
// => we need to reset that property
|
||||
dialog.querySelector('.btn-primary').blur(); // Remove the focus explicitely
|
||||
assert.containsOnce(document.body, '.modal-backdrop');
|
||||
await testUtils.dom.click(dialog.querySelector('.modal-backdrop'));
|
||||
assert.strictEqual(document.activeElement, dialog.querySelector('.btn-primary'),
|
||||
"Button should be focused when clicking on backdrop");
|
||||
assert.verifySteps([]); // Ensure not closed
|
||||
dialog.querySelector('.btn-primary').blur(); // Remove the focus explicitely
|
||||
|
||||
await changeProps('backdrop', false);
|
||||
assert.containsNone(document.body, '.modal-backdrop');
|
||||
await testUtils.dom.click(dialog.querySelector('.modal'));
|
||||
assert.notEqual(document.activeElement, dialog.querySelector('.btn-primary'),
|
||||
"Button should not be focused when clicking on backdrop 'false'");
|
||||
assert.verifySteps([]); // Ensure not closed
|
||||
|
||||
await changeProps('backdrop', true);
|
||||
assert.containsOnce(document.body, '.modal-backdrop');
|
||||
await testUtils.dom.click(dialog.querySelector('.modal-backdrop'));
|
||||
assert.notEqual(document.activeElement, dialog.querySelector('.btn-primary'),
|
||||
"Button should not be focused when clicking on backdrop 'true'");
|
||||
assert.verifySteps(['dialog_closed']);
|
||||
|
||||
// Dialog class (default: '')
|
||||
await changeProps('contentClass', 'my_dialog_class');
|
||||
@@ -144,7 +156,7 @@ odoo.define('web.owl_dialog_tests', function (require) {
|
||||
"Subcomponent should match with its given text");
|
||||
await testUtils.dom.click(dialog.querySelector('.o_subcomponent'));
|
||||
|
||||
assert.verifySteps(['dialog_closed', 'button_clicked', 'subcomponent_clicked']);
|
||||
assert.verifySteps(['button_clicked', 'subcomponent_clicked']);
|
||||
|
||||
parent.destroy();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user