From 3751379f1e9a4c215fb6eb898b4ccc67659b9ace Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 10 May 2022 21:51:50 +0700 Subject: initial commit 2 --- addons/stock/static/tests/popover_widget_tests.js | 53 +++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 addons/stock/static/tests/popover_widget_tests.js (limited to 'addons/stock/static/tests/popover_widget_tests.js') diff --git a/addons/stock/static/tests/popover_widget_tests.js b/addons/stock/static/tests/popover_widget_tests.js new file mode 100644 index 00000000..dff13d60 --- /dev/null +++ b/addons/stock/static/tests/popover_widget_tests.js @@ -0,0 +1,53 @@ +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:'
' + + '' + + '', + 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.triggerEvents($popoverButton, ['focus']); + $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(); + }); +}); +}); + +}); -- cgit v1.2.3