* data('bs.popover') is not a jQuery data anymore
-> fetch data from the instance instead.
* use the new class name 'popover-arrow' instead of 'arrow'
* website_forum: offset is not a number anymore
-> Convert to string instead.
* BS5 event listener: 'focus' -> 'focusin'
* use `mouseover` event to show and `mouseout` to hide.
* disable at some point the animation to avoid remaining listener
in the DOM.
Ref:
https://getbootstrap.com/docs/5.1/migration/#popovers
Task ID: 2766483
Part-of: odoo/odoo#95450
54 lines
1.9 KiB
JavaScript
54 lines
1.9 KiB
JavaScript
odoo.define('stock.popover_widget_tests', function (require) {
|
|
"use strict";
|
|
|
|
var testUtils = require('web.test_utils');
|
|
var FormView = require('web.FormView');
|
|
var createView = testUtils.createView;
|
|
|
|
QUnit.module('widgets', {}, function () {
|
|
QUnit.module('ModelFieldSelector', {
|
|
beforeEach: function () {
|
|
this.data = {
|
|
partner: {
|
|
fields: {
|
|
json_data: {string: " ", type: "char"},
|
|
},
|
|
records: [
|
|
{id:1, json_data:'{"color": "text-danger", "msg": "var that = self // why not?", "title": "JS Master"}'}
|
|
]
|
|
}
|
|
};
|
|
},
|
|
}, function () {
|
|
QUnit.test("Test creation/usage popover widget form", async function (assert) {
|
|
assert.expect(6);
|
|
|
|
var form = await createView({
|
|
View: FormView,
|
|
model: 'partner',
|
|
data: this.data,
|
|
arch:'<form string="Partners">' +
|
|
'<field name="json_data" widget="popover_widget"/>' +
|
|
'</form>',
|
|
res_id: 1
|
|
});
|
|
|
|
var $popover = $('div.popover');
|
|
assert.strictEqual($popover.length, 0, "Shouldn't have a popover container in DOM");
|
|
|
|
var $popoverButton = form.$('a.fa.fa-info-circle.text-danger');
|
|
assert.strictEqual($popoverButton.length, 1, "Should have a popover icon/button in red");
|
|
assert.strictEqual($popoverButton.prop('special_click'), true, "Special click properpy should be activated");
|
|
await testUtils.dom.triggerEvent($popoverButton, 'focusin');
|
|
$popover = $('div.popover');
|
|
assert.strictEqual($popover.length, 1, "Should have a popover container in DOM");
|
|
assert.strictEqual($popover.html().includes("var that = self // why not?"), true, "The message should be in DOM");
|
|
assert.strictEqual($popover.html().includes("JS Master"), true, "The title should be in DOM");
|
|
|
|
form.destroy();
|
|
});
|
|
});
|
|
});
|
|
|
|
});
|