Skip to content
Permalink
Browse files

[FIX] web: fix all tests and test utils to use native events

  • Loading branch information
VincentSchippefilt committed Dec 2, 2019
1 parent 2f078f2 commit fc425b5d66f81d9240abfebdd70e97bf08ab736b
@@ -127,7 +127,7 @@ QUnit.test('Sent', async function (assert) {
assert.containsNone(form, '.o_thread_tooltip_snailmail',
"No tooltip should be present");

testUtils.dom.triggerMouseEvent(form.$('.o_thread_message_snailmail_sent'), 'mouseenter');
await testUtils.dom.triggerMouseEvent(form.$('.o_thread_message_snailmail_sent'), 'mouseover');
assert.ok($('.o_thread_tooltip_snailmail:visible').length,
"Tooltip should appear when hovering the Snailmail Icon");
assert.ok($('.o_thread_tooltip_snailmail_icon.fa-check').length,
@@ -162,7 +162,7 @@ QUnit.test('Canceled', async function (assert) {
assert.containsNone(form, '.o_thread_tooltip_snailmail',
"No tooltip should be present");

testUtils.dom.triggerMouseEvent(form.$('.o_thread_message_snailmail_canceled'), 'mouseenter');
testUtils.dom.triggerMouseEvent(form.$('.o_thread_message_snailmail_canceled'), 'mouseover');
assert.ok($('.o_thread_tooltip_snailmail:visible').length,
"Tooltip should appear when hovering the Snailmail Icon");
assert.ok($('.o_thread_tooltip_snailmail_icon.fa-trash-alt').length,
@@ -198,7 +198,7 @@ QUnit.test('Pending', async function (assert) {
assert.containsNone(form, '.o_thread_tooltip_snailmail',
"No tooltip should be present");

testUtils.dom.triggerMouseEvent(form.$('.o_thread_message_snailmail_pending'), 'mouseenter');
testUtils.dom.triggerMouseEvent(form.$('.o_thread_message_snailmail_pending'), 'mouseover');
assert.ok($('.o_thread_tooltip_snailmail:visible').length,
"Tooltip should appear when hovering the Snailmail Icon");
assert.ok($('.o_thread_tooltip_snailmail_icon.fa-clock').length,
@@ -241,7 +241,7 @@ QUnit.test('No Price Available', async function (assert) {
assert.containsNone(form, '.o_thread_tooltip_snailmail',
"No tooltip should be present");

testUtils.dom.triggerMouseEvent(form.$('.o_thread_message_snailmail_no_price_available'), 'mouseenter');
testUtils.dom.triggerMouseEvent(form.$('.o_thread_message_snailmail_no_price_available'), 'mouseover');
assert.ok($('.o_thread_tooltip_snailmail:visible').length,
"Tooltip should appear when hovering the Snailmail Icon");
assert.ok($('.o_thread_tooltip_snailmail_icon.fa-exclamation').length,
@@ -301,7 +301,7 @@ QUnit.test('Format Error', async function (assert) {
assert.containsNone(form, '.o_thread_tooltip_snailmail',
"No tooltip should be present");

testUtils.dom.triggerMouseEvent(form.$('.o_thread_message_snailmail_format_error'), 'mouseenter');
testUtils.dom.triggerMouseEvent(form.$('.o_thread_message_snailmail_format_error'), 'mouseover');
assert.ok($('.o_thread_tooltip_snailmail:visible').length,
"Tooltip should appear when hovering the Snailmail Icon");
assert.ok($('.o_thread_tooltip_snailmail_icon.fa-exclamation').length,
@@ -350,7 +350,7 @@ QUnit.test('Credit Error', async function (assert) {
assert.containsNone(form, '.o_thread_tooltip_snailmail',
"No tooltip should be present");

testUtils.dom.triggerMouseEvent(form.$('.o_thread_message_snailmail_credit_error'), 'mouseenter');
testUtils.dom.triggerMouseEvent(form.$('.o_thread_message_snailmail_credit_error'), 'mouseover');
assert.ok($('.o_thread_tooltip_snailmail:visible').length,
"Tooltip should appear when hovering the Snailmail Icon");
assert.ok($('.o_thread_tooltip_snailmail_icon.fa-exclamation').length,
@@ -418,7 +418,7 @@ QUnit.test('Trial Error', async function (assert) {
assert.containsNone(form, '.o_thread_tooltip_snailmail',
"No tooltip should be present");

testUtils.dom.triggerMouseEvent(form.$('.o_thread_message_snailmail_trial_error'), 'mouseenter');
testUtils.dom.triggerMouseEvent(form.$('.o_thread_message_snailmail_trial_error'), 'mouseover');
assert.ok($('.o_thread_tooltip_snailmail:visible').length,
"Tooltip should appear when hovering the Snailmail Icon");
assert.ok($('.o_thread_tooltip_snailmail_icon.fa-exclamation').length,
@@ -487,7 +487,7 @@ QUnit.test('Missing Required Fields', async function (assert) {
assert.containsNone(form, '.o_thread_tooltip_snailmail',
"No tooltip should be present");

testUtils.dom.triggerMouseEvent(form.$('.o_thread_message_snailmail_missing_required_fields'), 'mouseenter');
testUtils.dom.triggerMouseEvent(form.$('.o_thread_message_snailmail_missing_required_fields'), 'mouseover');
assert.ok($('.o_thread_tooltip_snailmail:visible').length,
"Tooltip should appear when hovering the Snailmail Icon");
assert.ok($('.o_thread_tooltip_snailmail_icon.fa-exclamation').length,
@@ -329,7 +329,7 @@ var FormRenderer = BasicRenderer.extend({
_addOnClickAction: function ($el, node) {
if (node.attrs.special || node.attrs.confirm || node.attrs.type || $el.hasClass('oe_stat_button')) {
var self = this;
$el.click(function () {
$el.on("click", function () {
self.trigger_up('button_clicked', {
attrs: node.attrs,
record: self.state,
@@ -2435,7 +2435,7 @@ QUnit.module('basic_fields', {
function waitForChangeTriggered() {
return def.then(function () {
def = testUtils.makeTestPromise();
return concurrency.delay(0);
return testUtils.nextTick();
});
}
});
@@ -5988,7 +5988,7 @@ QUnit.module('basic_fields', {

// Focusing the field selector input should open the field selector
// popover
await testUtils.dom.triggerEvents($fieldSelector, ['focusin']);
await testUtils.dom.triggerEvents($fieldSelector, 'focus');
var $fieldSelectorPopover = $fieldSelector.find(".o_field_selector_popover");
assert.ok($fieldSelectorPopover.is(":visible"),
"field selector popover should be visible");
@@ -6057,7 +6057,7 @@ QUnit.module('basic_fields', {
"there should be a field selector");

// Focusing its input should open the field selector popover
await testUtils.dom.triggerEvents($fieldSelector, ['focusin']);
await testUtils.dom.triggerEvents($fieldSelector, 'focus');
var $fieldSelectorPopover = $fieldSelector.find(".o_field_selector_popover");
assert.ok($fieldSelectorPopover.is(":visible"),
"field selector popover should be visible");
@@ -1824,7 +1824,7 @@ QUnit.module('fields', {}, function () {
});

QUnit.test('list in form: call button in sub view', async function (assert) {
assert.expect(6);
assert.expect(11);

this.data.partner.records[0].p = [2];
var form = await createView({
@@ -1855,6 +1855,7 @@ QUnit.module('fields', {}, function () {
'should call with correct currentID in env');
assert.deepEqual(event.data.env.resIDs, [37],
'should call with correct resIDs in env');
assert.step(event.data.action_data.name);
},
},
archs: {
@@ -1872,8 +1873,14 @@ QUnit.module('fields', {}, function () {
await testUtils.dom.click(form.$('td.o_data_cell:first'));
await testUtils.dom.click(form.$('.o_external_button'));
await testUtils.dom.click($('button:contains("Just do it !")'));
assert.verifySteps(['action']);
await testUtils.dom.click($('button:contains("Just don\'t do it !")'));
assert.verifySteps([]); // the second button is disabled, it can't be clicked

await testUtils.dom.click($('.modal .btn-secondary:contains(Discard)'));
await testUtils.dom.click(form.$('.o_external_button'));
await testUtils.dom.click($('button:contains("Just don\'t do it !")'));
assert.verifySteps(['object']);
form.destroy();
});

@@ -2149,9 +2156,9 @@ QUnit.module('fields', {}, function () {
},
});

form.$('.o_field_many2one input').focus();
await testUtils.dom.triggerEvent(form.$('.o_field_many2one input'),'focus');
await testUtils.fields.editAndTrigger(form.$('.o_field_many2one input'),
'new partner', ['keyup', 'focusout']);
'new partner', ['keyup', 'blur']);
await testUtils.dom.click($('.modal .modal-footer .btn-primary').first());

form.destroy();
@@ -17,6 +17,7 @@ var concurrency = require('web.concurrency');
var DebugManager = require('web.DebugManager.Backend');
var dom = require('web.dom');
var testUtilsMock = require('web.test_utils_mock');
var testUtilsDom = require('web.test_utils_dom');
var Widget = require('web.Widget');

// Variables used to get the current target and intercepts events
@@ -180,7 +181,7 @@ async function createView(params) {
// render the view in a fragment as they must be able to render correctly
// without being in the DOM
var fragment = document.createDocumentFragment();
return view.appendTo(fragment).then(function () {
return view.appendTo(fragment).then( () => {
dom.prepend($actionManager, fragment, {
callbacks: [{ widget: view }],
in_DOM: true,
@@ -189,6 +190,7 @@ async function createView(params) {
view.$el.on('click', 'a', function (ev) {
ev.preventDefault();
});
// await testUtilsDom.returnAfterNextAnimationFrame();
return view;
});
});

0 comments on commit fc425b5

Please sign in to comment.
You can’t perform that action at this time.