summaryrefslogtreecommitdiff
path: root/addons/mail
diff options
context:
space:
mode:
authorRobot Odoo <xmo+roboto@odoo.com>2018-11-19 15:38:25 +0100
committerGitHub <noreply@github.com>2018-11-19 15:38:25 +0100
commit7c3d5dc067c7c331dcc0b52bafbdfd067087a3c4 (patch)
tree6058f8a893815bf0ed2495649c125523f4def762 /addons/mail
parent8fc246da31aa2a1c770732ae97e0cb4e840f07cf (diff)
parentabf32b8b21394491040e5c11c1fea809c1d7c62c (diff)
[MERGE][REF] *: update js test suite to use helpers
This rev. introduces robust helpers to use in the JS tests suite to interact with DOM and components, and starts using them (almost) everywhere. All the helpers are exposed though testUtils.js. There are 2 kinds of helpers: 1. Assertions ------------- * assert.containsNone, containsN, containsOnce check that the DOM (or a specific part of the DOM) contains a `selector`. It generates a correct error message automatically. ex: assert.notOk(form.$('button').hasClass('btn-primary')); -> assert.doesNotHaveClass(form.$('button'), 'btn-primary'); * assert.isVisible, isNotVisible check that the DOM has an element visible or not. They also check that the element is actually in the DOM (before most tests didn't verify this). * assert.hasClass, doesNotHaveClass, hasAttrVAlue, check specific properties of a DOM element, and also validate that it is applied on a single existing DOM element (before most tests didn't verify this). 2. Utilities ------------ The goal of the utilities is to centralize the definition of many standard components and interactions, ensuring that when we refactor the JS framework, we do not need to change all the tests. Existing mock utilities (addMockEnvironment, intercept, path, patchDate, unpatch and fieldsViewGet) are moved to 'testUtils.mock.*'. Existing DOM utilities are moved to 'testUtils.dom.*'. New dom utilities are created for opendDatePicker, click, clickFirst and clickLast. Helper `click` verifies that there is exactly 1 element visible in the DOM you click on, `clickFirst` and `clickLast` verify that there are more than one element on the DOM. ex: form.$('button').click(); -> testUtils.dom.click(form.$('button')); New Form utilities: (testUtils.form.*) clickEdit, clickSave, clickCreate, clickDiscard, all clicks on the control panel buttons of the form. `reload` reloads the form data. New modal, graph, kanban and pivot utils (testUtils.pivot.*, testUtils.kanban.*, etc.). New fields utils: (testUtils.fields.*) * editInput, editSelect: allow to change the value of a field, using a selector to identify it. They validate that the input exists and trigger the change event automatically. * editAndTrigger: allow to modify a field and trigger specific events after the value change * many2one (testUtils.fields.many2one.*) clickOpenDropdown, clickHighlightedItem, clickItem, searchAndClickItem: use a field name instead of a selector and do all the complex mechanism to open, filter and highlight many2one fields. Joint work with aab, dam, ged, mge, svs and vsc. closes odoo/odoo#28784
Diffstat (limited to 'addons/mail')
-rw-r--r--addons/mail/static/tests/activity_tests.js30
-rw-r--r--addons/mail/static/tests/chatter_tests.js321
-rw-r--r--addons/mail/static/tests/discuss_mobile_tests.js50
-rw-r--r--addons/mail/static/tests/discuss_moderation_tests.js92
-rw-r--r--addons/mail/static/tests/discuss_tests.js104
-rw-r--r--addons/mail/static/tests/discuss_typing_notification_tests.js61
-rw-r--r--addons/mail/static/tests/document_thread_window_tests.js46
-rw-r--r--addons/mail/static/tests/document_viewer_tests.js44
-rw-r--r--addons/mail/static/tests/helpers/test_utils.js2
-rw-r--r--addons/mail/static/tests/systray/systray_activity_menu_tests.js52
-rw-r--r--addons/mail/static/tests/systray/systray_messaging_menu_mail_failure_tests.js18
-rw-r--r--addons/mail/static/tests/systray/systray_messaging_menu_tests.js66
-rw-r--r--addons/mail/static/tests/thread_window/basic_thread_window_tests.js14
-rw-r--r--addons/mail/static/tests/thread_window/blank_thread_window_tests.js14
-rw-r--r--addons/mail/static/tests/thread_window/hidden_thread_window_tests.js10
-rw-r--r--addons/mail/static/tests/thread_window/moderation_thread_window_tests.js2
-rw-r--r--addons/mail/static/tests/tools/debug_manager_tests.js4
17 files changed, 472 insertions, 458 deletions
diff --git a/addons/mail/static/tests/activity_tests.js b/addons/mail/static/tests/activity_tests.js
index 9f7f7fd8808..0c3a9311dec 100644
--- a/addons/mail/static/tests/activity_tests.js
+++ b/addons/mail/static/tests/activity_tests.js
@@ -172,7 +172,7 @@ QUnit.test('activity view: simple activity rendering', function (assert) {
}
});
- assert.strictEqual(activity.$('table').length, 1,
+ assert.containsOnce(activity, 'table',
'should have a table');
assert.ok(activity.$('table thead tr:first th:nth-child(2) span:first:contains(Email)').length,
'should contain "Email" in header of first column');
@@ -204,7 +204,7 @@ QUnit.test('activity view: no content rendering', function (assert) {
},
});
- assert.strictEqual(activity.$('.o_view_nocontent').length, 1,
+ assert.containsOnce(activity, '.o_view_nocontent',
"should display the no content helper");
assert.strictEqual(activity.$('.o_view_nocontent .o_view_nocontent_empty_folder').text().trim(),
"No data to display",
@@ -234,16 +234,16 @@ QUnit.test('activity view: batch send mail on activity', function (assert) {
assert.notOk(activity.$('table thead tr:first th:nth-child(2) span:nth-child(2) .dropdown-menu.show').length,
'dropdown shouldn\'t be displayed');
- activity.$('table thead tr:first th:nth-child(2) span:nth-child(2) i.fa-ellipsis-v').click();
+ testUtils.dom.click(activity.$('table thead tr:first th:nth-child(2) span:nth-child(2) i.fa-ellipsis-v'));
assert.ok(activity.$('table thead tr:first th:nth-child(2) span:nth-child(2) .dropdown-menu.show').length,
'dropdown should have appeared');
- activity.$('table thead tr:first th:nth-child(2) span:nth-child(2) .dropdown-menu.show .o_send_mail_template:first:contains(Task: Rating Request)').click();
+ testUtils.dom.click(activity.$('table thead tr:first th:nth-child(2) span:nth-child(2) .dropdown-menu.show .o_send_mail_template:first:contains(Task: Rating Request)'));
assert.notOk(activity.$('table thead tr:first th:nth-child(2) span:nth-child(2) .dropdown-menu.show').length,
'dropdown shouldn\'t be displayed');
- activity.$('table thead tr:first th:nth-child(2) span:nth-child(2) i.fa-ellipsis-v').click();
- activity.$('table thead tr:first th:nth-child(2) span:nth-child(2) .dropdown-menu.show .o_send_mail_template:nth-child(2):contains(Task: Reception Acknowledgment)').click();
+ testUtils.dom.click(activity.$('table thead tr:first th:nth-child(2) span:nth-child(2) i.fa-ellipsis-v'));
+ testUtils.dom.click(activity.$('table thead tr:first th:nth-child(2) span:nth-child(2) .dropdown-menu.show .o_send_mail_template:nth-child(2):contains(Task: Reception Acknowledgment)'));
assert.verifySteps([
[[13, 30], 9], //send mail template 9 on tasl 13 and 30
[[13, 30], 8] //send mail template 8 on tasl 13 and 30
@@ -305,28 +305,28 @@ QUnit.test('activity view: activity widget', function (assert) {
var today = activity.$('table tbody tr:first td:nth-child(2).today');
var dropdown = today.find('.dropdown-menu.o_activity');
- today.find('.o_closest_deadline').click();
- assert.ok(dropdown.hasClass('show'), "dropdown should be displayed");
+ testUtils.dom.click(today.find('.o_closest_deadline'));
+ assert.hasClass(dropdown,'show', "dropdown should be displayed");
assert.ok(dropdown.find('.o_activity_color_today:contains(Today)').length, "Title should be today");
assert.ok(dropdown.find('.o_activity_title_entry[data-activity-id="2"]:first div:contains(template8)').length,
"template8 should be available");
assert.ok(dropdown.find('.o_activity_title_entry[data-activity-id="2"]:eq(1) div:contains(template9)').length,
"template9 should be available");
- dropdown.find('.o_activity_title_entry[data-activity-id="2"]:first .o_activity_template_preview').click();
- dropdown.find('.o_activity_title_entry[data-activity-id="2"]:first .o_activity_template_send').click();
+ testUtils.dom.click(dropdown.find('.o_activity_title_entry[data-activity-id="2"]:first .o_activity_template_preview'));
+ testUtils.dom.click(dropdown.find('.o_activity_title_entry[data-activity-id="2"]:first .o_activity_template_send'));
var overdue = activity.$('table tbody tr:first td:nth-child(3).overdue');
- overdue.find('.o_closest_deadline').click();
+ testUtils.dom.click(overdue.find('.o_closest_deadline'));
dropdown = overdue.find('.dropdown-menu.o_activity');
assert.notOk(dropdown.find('.o_activity_title div div div:first span').length,
"No template should be available");
- dropdown.find('.o_schedule_activity').click();
- overdue.find('.o_closest_deadline').click();
- dropdown.find('.o_mark_as_done').click();
+ testUtils.dom.click(dropdown.find('.o_schedule_activity'));
+ testUtils.dom.click(overdue.find('.o_closest_deadline'));
+ testUtils.dom.click(dropdown.find('.o_mark_as_done'));
dropdown.find('#activity_feedback').val("feedback2");
- dropdown.find('.o_activity_popover_done_next').click();
+ testUtils.dom.click(dropdown.find('.o_activity_popover_done_next'));
assert.verifySteps([
"do_action_compose",
"activity_send_mail",
diff --git a/addons/mail/static/tests/chatter_tests.js b/addons/mail/static/tests/chatter_tests.js
index 4bcce4ab352..470b6045797 100644
--- a/addons/mail/static/tests/chatter_tests.js
+++ b/addons/mail/static/tests/chatter_tests.js
@@ -213,11 +213,11 @@ QUnit.test('basic rendering', function (assert) {
"there should be a followers widget, moved inside the chatter's topbar");
assert.ok(form.$('.o_chatter').length, "there should be a chatter widget");
assert.ok(form.$('.o_mail_thread').length, "there should be a mail thread");
- assert.strictEqual(form.$('.o_chatter_button_attachment').length, 1, "should have one attachment button");
+ assert.containsOnce(form, '.o_chatter_button_attachment', "should have one attachment button");
assert.ok(!form.$('.o_chatter_topbar .o_chatter_button_log_note').length,
"log note button should not be available");
- form.$buttons.find('.o_form_button_edit').click();
+ testUtils.form.clickEdit(form);
assert.strictEqual(count, 0, "should have done no read_followers rpc as there are no followers");
assert.strictEqual(unwanted_read_count, 0, "followers should only be fetched with read_followers route");
form.destroy();
@@ -234,7 +234,7 @@ QUnit.test('Activity Done keep feedback on blur', function (assert) {
var shownDef = $.Deferred();
var hiddenDef = $.Deferred();
- testUtils.patch(Activity, {
+ testUtils.mock.patch(Activity, {
_bindPopoverFocusout: function () {
this._super.apply(this, arguments);
shownDef.resolve();
@@ -265,7 +265,7 @@ QUnit.test('Activity Done keep feedback on blur', function (assert) {
$popoverEl.on('hidden.bs.popover', hiddenDef.resolve.bind(hiddenDef));
// open popover
- $popoverEl.click();
+ testUtils.dom.click($popoverEl);
shownDef.then(function () {
// write a feedback and focusout
@@ -276,7 +276,7 @@ QUnit.test('Activity Done keep feedback on blur', function (assert) {
shownDef = $.Deferred();
// re-open popover
- $popoverEl.click();
+ testUtils.dom.click($popoverEl);
shownDef.then(function () {
var $feedbackPopover = $($popoverEl.data('bs.popover').tip);
@@ -284,7 +284,7 @@ QUnit.test('Activity Done keep feedback on blur', function (assert) {
"feedback should have been kept");
form.destroy();
- testUtils.unpatch(Activity);
+ testUtils.mock.unpatch(Activity);
done();
});
});
@@ -308,18 +308,32 @@ QUnit.test('attachmentBox basic rendering', function (assert) {
'<field name="foo"/>' +
'</sheet>' +
'<div class="oe_chatter">' +
+ '<field name="message_ids" widget="mail_thread"/>' +
'</div>' +
'</form>',
res_id: 7,
+ mockRPC: function (route, args) {
+ var result = this._super.apply(this, arguments);
+ if (args.method === 'read' && args.model === 'partner') {
+ return result.then(function (records) {
+ // here we force the attachment_count to 1 (which is correct
+ // actually), so that the attachment button is visible
+ // FIXME: this could be handled by an extension of mockRead
+ records[0].message_attachment_count = 1;
+ return records;
+ });
+ }
+ return result;
+ },
});
var $button = form.$('.o_chatter_button_attachment');
assert.strictEqual($button.length, 1, "should have one attachment button");
- $button.click();
- assert.strictEqual(form.$('.o_mail_chatter_attachments').length, 1,
+ testUtils.dom.click($button);
+ assert.containsOnce(form, '.o_mail_chatter_attachments',
"attachment widget should exist after a first click on the button");
- assert.strictEqual(form.$('.o_attachment_image').length, 1, "there should be an image preview");
- assert.strictEqual(form.$('.o_attachments_previews').length, 1, "there should be a list of previews");
- assert.strictEqual(form.$('.o_attachments_list').length, 1, "there should be a list of non previewable attachments");
+ assert.containsOnce(form, '.o_attachment_image', "there should be an image preview");
+ assert.containsOnce(form, '.o_attachments_previews', "there should be a list of previews");
+ assert.containsOnce(form, '.o_attachments_list', "there should be a list of non previewable attachments");
assert.strictEqual(form.$('.o_attachment_title').text(), 'name1',
"the image name should be correct");
// since there are two elements "Download name2"; one "name" and the other "txt" as text content, the following test
@@ -328,13 +342,12 @@ QUnit.test('attachmentBox basic rendering', function (assert) {
"the attachment name should be correct");
assert.ok(form.$('.o_attachment_image').css('background-image').indexOf('/web/image/1/160x160/?crop=true') >= 0,
"the attachment image URL should be correct");
- assert.strictEqual(form.$('.o_attachment_download').eq(0).attr('href'), '/web/content/1?download=true',
+ assert.hasAttrValue(form.$('.o_attachment_download').eq(0), 'href', '/web/content/1?download=true',
"the download URL of name1 must be correct");
- assert.strictEqual(form.$('.o_attachment_download').eq(1).attr('href'), '/web/content/2?download=true',
+ assert.hasAttrValue(form.$('.o_attachment_download').eq(1), 'href', '/web/content/2?download=true',
"the download URL of name2 must be correct");
- $button.click();
- assert.strictEqual(form.$('.o_mail_chatter_attachments').length, 0,
- "attachment widget should de destroyed after we reclick the button");
+ testUtils.dom.click($button);
+ assert.containsNone(form, '.o_mail_chatter_attachments')
form.destroy();
});
@@ -363,14 +376,14 @@ QUnit.test('chatter in create mode', function (assert) {
},
});
- assert.strictEqual(form.$('.o_chatter').length, 1,
+ assert.containsOnce(form, '.o_chatter',
"chatter should be displayed");
// entering create mode
- form.$buttons.find('.o_form_button_create').click();
- assert.ok(form.$el.find('.o_form_view').hasClass('o_form_editable'),
+ testUtils.form.clickCreate(form);
+ assert.hasClass(form.$el.find('.o_form_view'),'o_form_editable',
"we should be in create mode");
- assert.strictEqual(form.$('.o_chatter').length, 1,
+ assert.containsOnce(form, '.o_chatter',
"chatter should still be displayed in create mode");
// topbar buttons disabled in create mode (e.g. 'send message')
@@ -378,24 +391,24 @@ QUnit.test('chatter in create mode', function (assert) {
"button should be disabled in create mode");
// chatter containing a single message with 'Creating a record...'
- assert.strictEqual(form.$('.o_mail_thread').length, 1,
+ assert.containsOnce(form, '.o_mail_thread',
"there should be a mail thread");
- assert.strictEqual(form.$('.o_thread_message').length, 1,
+ assert.containsOnce(form, '.o_thread_message',
"there should be a single thread message");
assert.strictEqual(form.$('.o_thread_message_content').text().trim(),
"Creating a new record...",
"the content of the message should be 'Creating a new record...'");
// getting out of create mode by saving
- form.$('.o_field_char').val('coucou').trigger('input');
- form.$buttons.find('.o_form_button_save').click();
+ testUtils.fields.editInput(form.$('.o_field_char'), 'coucou');
+ testUtils.form.clickSave(form);
- assert.strictEqual(form.$('.o_chatter').length, 1,
+ assert.containsOnce(form, '.o_chatter',
"chatter should still be displayed after saving from create mode");
// check if chatter buttons still work
- form.$('.o_chatter_button_new_message').click();
- assert.strictEqual(form.$('.o_thread_composer:visible').length, 1,
+ testUtils.dom.click(form.$('.o_chatter_button_new_message'));
+ assert.containsOnce(form, '.o_thread_composer:visible',
"chatter should be opened");
form.destroy();
@@ -430,25 +443,25 @@ QUnit.test('chatter rendering inside the sheet', function (assert) {
},
});
- assert.strictEqual(form.$('.o_chatter').length, 1,
+ assert.containsOnce(form, '.o_chatter',
"chatter should be displayed");
- form.$buttons.find('.o_form_button_create').click();
- assert.ok(form.$el.find('.o_form_view').hasClass('o_form_editable'),
+ testUtils.form.clickCreate(form);
+ assert.hasClass(form.$el.find('.o_form_view'),'o_form_editable',
"we should be in create mode");
- assert.strictEqual(form.$('.o_chatter').length, 1,
+ assert.containsOnce(form, '.o_chatter',
"chatter should be displayed");
- form.$('.o_field_char').val('coucou').trigger('input');
- form.$buttons.find('.o_form_button_save').click();
+ testUtils.fields.editInput(form.$('.o_field_char'), 'coucou');
+ testUtils.form.clickSave(form);
- assert.strictEqual(form.$('.o_chatter').length, 1,
+ assert.containsOnce(form, '.o_chatter',
"chatter should be displayed");
// check if chatter buttons still work
- form.$('.o_chatter_button_new_message').click();
- assert.strictEqual(form.$('.o_thread_composer:visible').length, 1,
+ testUtils.dom.click(form.$('.o_chatter_button_new_message'));
+ assert.containsOnce(form, '.o_thread_composer:visible',
"chatter should be opened");
form.destroy();
@@ -481,7 +494,7 @@ QUnit.test('kanban activity widget with no activity', function (assert) {
assert.strictEqual(rpcCount, 1, '1 RPC (search_read) should have been done');
// click on the activity button
- $record.find('.o_activity_btn').click();
+ testUtils.dom.click($record.find('.o_activity_btn'));
assert.strictEqual(rpcCount, 1, 'no RPC should have been done as there is no activity');
assert.strictEqual($record.find('.o_no_activity').length, 1, "should have no activity scheduled");
@@ -535,7 +548,7 @@ QUnit.test('kanban activity widget with an activity', function (assert) {
assert.strictEqual(rpcCount, 1, '1 RPC (search_read) should have been done');
// click on the activity button
- $record.find('.o_activity_btn').click();
+ testUtils.dom.click($record.find('.o_activity_btn'));
assert.strictEqual(rpcCount, 2, 'a read should have been done to fetch the activity details');
assert.strictEqual($record.find('.o_activity_title').length, 1, "should have an activity scheduled");
var label = $record.find('.o_activity_log .o_activity_color_today');
@@ -543,16 +556,16 @@ QUnit.test('kanban activity widget with an activity', function (assert) {
assert.strictEqual(label.find('.badge-warning').text(), "1", "should display the correct count");
// click on the activity button to close the dropdown
- $record.find('.o_activity_btn').click();
+ testUtils.dom.click($record.find('.o_activity_btn'));
assert.strictEqual(rpcCount, 2, 'no RPC should be done when closing the dropdown');
// click on the activity button to re-open dropdown
- $record.find('.o_activity_btn').click();
+ testUtils.dom.click($record.find('.o_activity_btn'));
assert.strictEqual(rpcCount, 3, 'should have reloaded the activities');
// mark activity as done
- $record.find('.o_mark_as_done').click();
- $record.find('.o_activity_popover_done').click();
+ testUtils.dom.click($record.find('.o_mark_as_done'));
+ testUtils.dom.click($record.find('.o_activity_popover_done'));
$record = kanban.$('.o_kanban_record').first(); // the record widget has been reset
assert.strictEqual(rpcCount, 5, 'should have done an RPC to mark activity as done, and a read');
assert.ok($record.find('.o_mail_activity .o_activity_color_default:not(.o_activity_color_today)').length,
@@ -605,17 +618,17 @@ QUnit.test('kanban activity widget popover test', function (assert) {
var $record = kanban.$('.o_kanban_record').first();
- $record.find('.o_activity_btn').click();
+ testUtils.dom.click($record.find('.o_activity_btn'));
// Click on button and see popover no RPC call
- $record.find('.o_mark_as_done').click();
+ testUtils.dom.click($record.find('.o_mark_as_done'));
assert.equal(rpcCount, 0, "");
// Click on discard no RPC call
- $record.find('.o_activity_popover_discard').click();
+ testUtils.dom.click($record.find('.o_activity_popover_discard'));
assert.equal(rpcCount, 0, "");
// Click on button and then on done and schedule next
// RPC call
- $record.find('.o_activity_popover_done_next').click();
+ testUtils.dom.click($record.find('.o_activity_popover_done_next'));
assert.equal(rpcCount, 1, "");
kanban.destroy();
@@ -708,7 +721,7 @@ QUnit.test('chatter: post, receive and star messages', function (assert) {
assert.ok(form.$('.o_chatter_topbar .o_chatter_button_log_note').length,
"log note button should be available");
- assert.strictEqual(form.$('.o_thread_message').length, 1, "thread should contain one message");
+ assert.containsOnce(form, '.o_thread_message', "thread should contain one message");
assert.ok(form.$('.o_thread_message:first().o_mail_discussion').length,
"the message should be a discussion");
assert.ok(form.$('.o_thread_message:first() .o_thread_message_core').text().indexOf('A message') >= 0,
@@ -717,12 +730,12 @@ QUnit.test('chatter: post, receive and star messages', function (assert) {
"the message's author should be correct");
// send a message
- form.$('.o_chatter_button_new_message').click();
- assert.ok(!$('.oe_chatter .o_thread_composer').hasClass('o_hidden'), "chatter should be opened");
+ testUtils.dom.click(form.$('.o_chatter_button_new_message'));
+ assert.isVisible($('.oe_chatter .o_thread_composer'), "chatter should be opened");
form.$('.oe_chatter .o_composer_text_field:first()').val("My first message");
- form.$('.oe_chatter .o_composer_button_send').click();
- assert.ok($('.oe_chatter .o_thread_composer').hasClass('o_hidden'), "chatter should be closed");
- assert.strictEqual(form.$('.o_thread_message').length, 2, "thread should contain two messages");
+ testUtils.dom.click(form.$('.oe_chatter .o_composer_button_send'));
+ assert.isNotVisible($('.oe_chatter .o_thread_composer'), "chatter should be closed");
+ assert.containsN(form, '.o_thread_message', 2, "thread should contain two messages");
assert.ok(form.$('.o_thread_message:first().o_mail_discussion').length,
"the last message should be a discussion");
assert.ok(form.$('.o_thread_message:first() .o_thread_message_core').text().indexOf('My first message') >= 0,
@@ -731,12 +744,12 @@ QUnit.test('chatter: post, receive and star messages', function (assert) {
"the message's author should be correct");
// log a note
- form.$('.o_chatter_button_log_note').click();
- assert.ok(!$('.oe_chatter .o_thread_composer').hasClass('o_hidden'), "chatter should be opened");
+ testUtils.dom.click(form.$('.o_chatter_button_log_note'));
+ assert.isVisible($('.oe_chatter .o_thread_composer'), "chatter should be opened");
form.$('.oe_chatter .o_composer_text_field:first()').val("My first note");
- form.$('.oe_chatter .o_composer_button_send').click();
- assert.ok($('.oe_chatter .o_thread_composer').hasClass('o_hidden'), "chatter should be closed");
- assert.strictEqual(form.$('.o_thread_message').length, 3, "thread should contain three messages");
+ testUtils.dom.click(form.$('.oe_chatter .o_composer_button_send'));
+ assert.isNotVisible($('.oe_chatter .o_thread_composer'), "chatter should be closed");
+ assert.containsN(form, '.o_thread_message', 3, "thread should contain three messages");
assert.ok(!form.$('.o_thread_message:first().o_mail_discussion').length,
"the last message should not be a discussion");
assert.ok(form.$('.o_thread_message:first() .o_thread_message_core').text().indexOf('My first note') >= 0,
@@ -747,17 +760,17 @@ QUnit.test('chatter: post, receive and star messages', function (assert) {
// star message 2
assert.ok(form.$('.o_thread_message[data-message-id=2] .o_thread_message_star.fa-star-o').length,
"message 2 should not be starred");
- form.$('.o_thread_message[data-message-id=2] .o_thread_message_star').click();
+ testUtils.dom.click(form.$('.o_thread_message[data-message-id=2] .o_thread_message_star'));
assert.ok(form.$('.o_thread_message[data-message-id=2] .o_thread_message_star.fa-star').length,
"message 2 should be starred");
// unstar message 2
- form.$('.o_thread_message[data-message-id=2] .o_thread_message_star').click();
+ testUtils.dom.click(form.$('.o_thread_message[data-message-id=2] .o_thread_message_star'));
assert.ok(form.$('.o_thread_message[data-message-id=2] .o_thread_message_star.fa-star-o').length,
"message 2 should not be starred");
// very basic test of mention
- form.$('.o_chatter_button_new_message').click();
+ testUtils.dom.click(form.$('.o_chatter_button_new_message'));
var $input = form.$('.oe_chatter .o_composer_text_field:first()');
$input.val('@');
// the cursor position must be set for the mention manager to detect that we are mentionning
@@ -771,7 +784,7 @@ QUnit.test('chatter: post, receive and star messages', function (assert) {
getSuggestionsDef
.then(concurrency.delay.bind(concurrency, 0))
.then(function () {
- assert.strictEqual(form.$('.o_mention_proposition:visible').length, 1,
+ assert.containsOnce(form, '.o_mention_proposition:visible',
"there should be one mention suggestion");
assert.strictEqual(form.$('.o_mention_proposition').data('id'), 1,
"suggestion's id should be correct");
@@ -822,12 +835,12 @@ QUnit.test('chatter: post a message disable the send button', function(assert) {
},
});
- form.$('.o_chatter_button_new_message').click();
+ testUtils.dom.click(form.$('.o_chatter_button_new_message'));
assert.notOk(form.$('.o_composer_button_send').prop('disabled'),
"Send button should be enabled when posting a message");
form.$('.oe_chatter .o_composer_text_field:first()').val("My first message");
- form.$('.oe_chatter .o_composer_button_send').click();
- form.$('.o_chatter_button_new_message').click();
+ testUtils.dom.click(form.$('.oe_chatter .o_composer_button_send'));
+ testUtils.dom.click(form.$('.o_chatter_button_new_message'));
assert.notOk(form.$('.o_composer_button_send').prop('disabled'),
"Send button should be enabled when posting another message");
form.destroy();
@@ -867,11 +880,11 @@ QUnit.test('chatter: post message failure keep message', function(assert) {
},
});
- form.$('.o_chatter_button_new_message').click();
+ testUtils.dom.click(form.$('.o_chatter_button_new_message'));
assert.notOk(form.$('.o_composer_button_send').prop('disabled'),
"Send button should be enabled initially");
form.$('.oe_chatter .o_composer_text_field:first()').val("My first message");
- form.$('.oe_chatter .o_composer_button_send').click();
+ testUtils.dom.click(form.$('.oe_chatter .o_composer_button_send'));
assert.strictEqual(form.$('.o_composer_text_field').val(), "My first message",
"Should keep unsent message in the composer on failure");
assert.notOk(form.$('.o_composer_button_send').prop('disabled'),
@@ -1019,19 +1032,19 @@ QUnit.test('chatter: post a message and switch in edit mode', function (assert)
},
});
- assert.strictEqual(form.$('.o_thread_message').length, 0, "thread should not contain messages");
+ assert.containsNone(form, '.o_thread_message', "thread should not contain messages");
// send a message
- form.$('.o_chatter_button_new_message').click();
+ testUtils.dom.click(form.$('.o_chatter_button_new_message'));
form.$('.oe_chatter .o_composer_text_field:first()').val("My first message");
- form.$('.oe_chatter .o_composer_button_send').click();
- assert.strictEqual(form.$('.o_thread_message').length, 1, "thread should contain a message");
+ testUtils.dom.click(form.$('.oe_chatter .o_composer_button_send'));
+ assert.containsOnce(form, '.o_thread_message', "thread should contain a message");
assert.ok(form.$('.o_thread_message:first() .o_thread_message_core').text().indexOf('My first message') >= 0,
"the message's body should be correct");
// switch in edit mode
- form.$buttons.find('.o_form_button_edit').click();
- assert.strictEqual(form.$('.o_thread_message').length, 1, "thread should contain a message");
+ testUtils.form.clickEdit(form);
+ assert.containsOnce(form, '.o_thread_message', "thread should contain a message");
assert.ok(form.$('.o_thread_message:first() .o_thread_message_core').text().indexOf('My first message') >= 0,
"the message's body should be correct");
@@ -1072,12 +1085,12 @@ QUnit.test('chatter: discard changes on message post with post_refresh "always"'
});
// Make record dirty
- form.$('.o_form_sheet input').val('trululu').trigger('input');
+ testUtils.fields.editInput(form.$('.o_form_sheet input'), 'trululu');
// Send a message
- form.$('.o_chatter_button_new_message').click();
+ testUtils.dom.click(form.$('.o_chatter_button_new_message'));
form.$('.oe_chatter .o_composer_text_field:first()').val("My first message");
- form.$('.oe_chatter .o_composer_button_send').click();
+ testUtils.dom.click(form.$('.oe_chatter .o_composer_button_send'));
var $modal = $('.modal-dialog');
assert.strictEqual($modal.length, 1, "should have a modal opened");
@@ -1149,12 +1162,12 @@ QUnit.test('chatter: discard changes on message post without post_refresh', func
});
// Make record dirty
- form.$('.o_form_sheet input').val('trululu').trigger('input');
+ testUtils.fields.editInput(form.$('.o_form_sheet input'), 'trululu');
// Send a message
- form.$('.o_chatter_button_new_message').click();
+ testUtils.dom.click(form.$('.o_chatter_button_new_message'));
form.$('.oe_chatter .o_composer_text_field:first()').val("My first message");
- form.$('.oe_chatter .o_composer_button_send').click();
+ testUtils.dom.click(form.$('.oe_chatter .o_composer_button_send'));
var $modal = $('.modal-dialog');
assert.strictEqual($modal.length, 0, "should have no modal opened");
@@ -1227,10 +1240,10 @@ QUnit.test('chatter: discard changes on message post with post_refresh "recipien
});
// Make record dirty
- form.$('.o_form_sheet input').val('trululu').trigger('input');
+ testUtils.fields.editInput(form.$('.o_form_sheet input'), 'trululu');
// create a new message
- form.$('.o_chatter_button_new_message').click();
+ testUtils.dom.click(form.$('.o_chatter_button_new_message'));
// Add a user as mention
form.$('.oe_chatter .o_composer_text_field:first()').val("@");
@@ -1252,7 +1265,7 @@ QUnit.test('chatter: discard changes on message post with post_refresh "recipien
form.$('input[type="checkbox"]').prop('checked', false);
// send message
- form.$('.oe_chatter .o_composer_button_send').click();
+ testUtils.dom.click(form.$('.oe_chatter .o_composer_button_send'));
var $modal = $('.modal-dialog');
assert.strictEqual($modal.length, 1, "should have a modal opened");
@@ -1301,11 +1314,11 @@ QUnit.test('chatter: discard changes on opening full-composer', function (assert
});
// Make record dirty
- form.$('.o_form_sheet input').val('trululu').trigger('input');
+ testUtils.fields.editInput(form.$('.o_form_sheet input'), 'trululu');
// Open full-composer
- form.$('.o_chatter_button_new_message').click();
- form.$('.o_composer_button_full_composer').click();
+ testUtils.dom.click(form.$('.o_chatter_button_new_message'));
+ testUtils.dom.click(form.$('.o_composer_button_full_composer'));
var $modal = $('.modal-dialog');
assert.strictEqual($modal.length, 1, "should have a modal opened");
@@ -1350,7 +1363,7 @@ QUnit.test('chatter in x2many form view', function (assert) {
},
});
- form.$('.o_data_row:first').click();
+ testUtils.dom.click(form.$('.o_data_row:first'));
assert.strictEqual($('.modal .o_form_view').length, 1,
"should have open a form view in a modal");
@@ -1426,28 +1439,28 @@ QUnit.test('chatter: Attachment viewer', function (assert) {
return this._super.apply(this, arguments);
},
});
- assert.strictEqual(form.$('.o_thread_message .o_attachment').length, 4,
+ assert.containsN(form, '.o_thread_message .o_attachment', 4,
"there should be three attachment on message");
- assert.strictEqual(form.$('.o_thread_message .o_attachment a').first().attr('href'), '/web/content/1?download=true',
+ assert.hasAttrValue(form.$('.o_thread_message .o_attachment a').first(), 'href', '/web/content/1?download=true',
"image caption should have correct download link");
// click on first image attachement
- form.$('.o_thread_message .o_attachment .o_image_box .o_image_overlay').first().click();
+ testUtils.dom.click(form.$('.o_thread_message .o_attachment .o_image_box .o_image_overlay').first());
assert.strictEqual($('.o_modal_fullscreen img.o_viewer_img[data-src="/web/image/1?unique=1&signature=999"]').length, 1,
"Modal popup should open with first image src");
// click on next button
- $('.modal .arrow.arrow-right.move_next span').click();
+ testUtils.dom.click($('.modal .arrow.arrow-right.move_next span'));
assert.strictEqual($('.o_modal_fullscreen img.o_viewer_img[data-src="/web/image/2?unique=1&signature=999"]').length, 1,
"Modal popup should have now second image src");
assert.strictEqual($('.o_modal_fullscreen .o_viewer_toolbar .o_download_btn').length, 1,
"Modal popup should have download button");
// close attachment popup
- $('.o_modal_fullscreen .o_viewer-header .o_close_btn').click();
+ testUtils.dom.click($('.o_modal_fullscreen .o_viewer-header .o_close_btn'));
// click on pdf attachement
- form.$('span:contains(Test PDF 1)').click();
+ testUtils.dom.click(form.$('span:contains(Test PDF 1)'));
assert.strictEqual($('.o_modal_fullscreen iframe[data-src*="/web/content/4"]').length, 1,
"Modal popup should open with the pdf preview");
// close attachment popup
- $('.o_modal_fullscreen .o_viewer-header .o_close_btn').click();
+ testUtils.dom.click($('.o_modal_fullscreen .o_viewer-header .o_close_btn'));
form.destroy();
});
@@ -1491,13 +1504,13 @@ QUnit.test('form activity widget: read RPCs', function (assert) {
});
assert.strictEqual(nbReads, 1, "should have read the activities");
- assert.strictEqual(form.$('.o_mail_activity .o_thread_message').length, 1,
+ assert.containsOnce(form, '.o_mail_activity .o_thread_message',
"should display an activity");
assert.strictEqual(form.$('.o_mail_activity .o_thread_message .o_activity_date').text(),
'Today', "the activity should be today");
- form.$buttons.find('.o_form_button_edit').click();
- form.$buttons.find('.o_form_button_save').click();
+ testUtils.form.clickEdit(form);
+ testUtils.form.clickSave(form);
assert.strictEqual(nbReads, 1, "should not have re-read the activities");
@@ -1569,7 +1582,7 @@ QUnit.test('form activity widget with another x2many field in view', function (a
res_id: 2,
});
- assert.strictEqual(form.$('.o_mail_activity .o_thread_message').length, 1,
+ assert.containsOnce(form, '.o_mail_activity .o_thread_message',
"should display an activity");
form.destroy();
@@ -1621,11 +1634,11 @@ QUnit.test('form activity widget: schedule next activity', function (assert) {
},
});
//Schedule next activity
- form.$('.o_mail_activity .o_mark_as_done[data-activity-id=1]').click();
- assert.strictEqual(form.$('.o_mail_activity_feedback.popover').length, 1,
+ testUtils.dom.click(form.$('.o_mail_activity .o_mark_as_done[data-activity-id=1]'));
+ assert.containsOnce(form, '.o_mail_activity_feedback.popover',
"a feedback popover should be visible");
$('.o_mail_activity_feedback.popover textarea').val('everything is ok'); // write a feedback
- form.$('.o_activity_popover_done_next').click(); // schedule next activity
+ testUtils.dom.click(form.$('.o_activity_popover_done_next'));
form.destroy();
});
@@ -1686,10 +1699,10 @@ QUnit.test('form activity widget: edit next activity', function (assert) {
},
},
});
- assert.strictEqual(form.$('.o_mail_activity .o_mail_info strong:eq(1)').text(), " Type 2",
+ assert.strictEqual(form.$('.o_mail_activity .o_mail_info strong:eq(1)').text(), " Type 2",
"Initial type should be Type 2");
- form.$('.o_mail_activity .o_edit_activity[data-activity-id=1]').click();
- assert.strictEqual(form.$('.o_mail_activity .o_mail_info strong:eq(1)').text(), " Type 1",
+ testUtils.dom.click(form.$('.o_mail_activity .o_edit_activity[data-activity-id=1]'));
+ assert.strictEqual(form.$('.o_mail_activity .o_mail_info strong:eq(1)').text(), " Type 1",
"After edit type should be Type 1");
form.destroy();
});
@@ -1752,12 +1765,12 @@ QUnit.test('form activity widget: clic mail template', function (assert) {
},
},
});
- assert.strictEqual(form.$('.o_mail_activity .o_thread_message').length, 1,
+ assert.containsOnce(form, '.o_mail_activity .o_thread_message',
"we should have one activity");
- assert.strictEqual(form.$('.o_activity_template_preview').length, 1,
+ assert.containsOnce(form, '.o_activity_template_preview',
"Activity should contains one mail template");
- form.$('.o_activity_template_preview[data-template-id=100]').click();
- assert.strictEqual(form.$('.o_mail_activity .o_thread_message').length, 1,
+ testUtils.dom.click(form.$('.o_activity_template_preview[data-template-id=100]'));
+ assert.containsOnce(form, '.o_mail_activity .o_thread_message',
"activity should still be there");
form.destroy();
});
@@ -1797,13 +1810,13 @@ QUnit.test('form activity widget: schedule activity does not discard changes', f
});
// update value of foo field
- form.$('.o_field_widget[name=foo]').val('new value').trigger('input');
+ testUtils.fields.editInput(form.$('.o_field_widget[name=foo]'), 'new value');
// schedule an activity (this triggers a do_action)
- form.$('.o_chatter_button_schedule_activity').click();
+ testUtils.dom.click(form.$('.o_chatter_button_schedule_activity'));
// save the record
- form.$buttons.find('.o_form_button_save').click();
+ testUtils.form.clickSave(form);
form.destroy();
});
@@ -1887,12 +1900,12 @@ QUnit.test('form activity widget: mark as done and remove', function (assert) {
},
});
- assert.strictEqual(form.$('.o_mail_activity .o_thread_message').length, 2,
+ assert.containsN(form, '.o_mail_activity .o_thread_message', 2,
"there should be two activities");
// remove activity 1
- form.$('.o_mail_activity .o_unlink_activity[data-activity-id=1]').click();
- assert.strictEqual(form.$('.o_mail_activity .o_thread_message').length, 1,
+ testUtils.dom.click(form.$('.o_mail_activity .o_unlink_activity[data-activity-id=1]'));
+ assert.containsOnce(form, '.o_mail_activity .o_thread_message',
"there should be one remaining activity");
assert.ok(!form.$('.o_mail_activity .o_unlink_activity[data-activity-id=1]').length,
"activity 1 should have been removed");
@@ -1900,16 +1913,15 @@ QUnit.test('form activity widget: mark as done and remove', function (assert) {
// mark activity done
assert.ok(!form.$('.o_mail_thread .o_thread_message').length,
"there should be no chatter message");
- form.$('.o_mail_activity .o_mark_as_done[data-activity-id=2]').click();
- assert.strictEqual(form.$('.o_mail_activity_feedback.popover').length, 1,
+ testUtils.dom.click(form.$('.o_mail_activity .o_mark_as_done[data-activity-id=2]'));
+ assert.containsOnce(form, '.o_mail_activity_feedback.popover',
"a feedback popover should be visible");
$('.o_mail_activity_feedback.popover textarea').val('everything is ok'); // write a feedback
- form.$('.o_activity_popover_done').click(); // send feedback
- assert.strictEqual(form.$('.o_mail_activity_feedback.popover').length, 0,
- "the feedback popover should be closed");
+ testUtils.dom.click(form.$('.o_activity_popover_done'));
+ assert.containsNone(form, '.o_mail_activity_feedback.popover')
assert.ok(!form.$('.o_mail_activity .o_thread_message').length,
"there should be no more activity");
- assert.strictEqual(form.$('.o_mail_thread .o_thread_message').length, 1,
+ assert.containsOnce(form, '.o_mail_thread .o_thread_message',
"a chatter message should have been generated");
assert.strictEqual(form.$('.o_thread_message:contains(The activity has been done)').length, 1,
"the message's body should be correct");
@@ -2002,29 +2014,29 @@ QUnit.test('followers widget: follow/unfollow, edit subtypes', function (assert)
'should display the "Follow" button');
// click to follow the document
- form.$('.o_followers_follow_button').click();
+ testUtils.dom.click(form.$('.o_followers_follow_button'));
assert.strictEqual(form.$('.o_followers_count').text(), "1", 'should have one follower');
assert.ok(form.$('.o_followers_follow_button.o_followers_following').length,
'should display the "Following/Unfollow" button');
- assert.strictEqual(form.$('.o_followers_list .o_partner').length, 1,
+ assert.containsOnce(form, '.o_followers_list .o_partner',
"there should be one follower in the follower dropdown");
// edit the subtypes
- assert.strictEqual(form.$('.o_subtypes_list .o_subtype').length, 3,
+ assert.containsN(form, '.o_subtypes_list .o_subtype', 3,
'subtype list should contain 3 subtypes');
- assert.strictEqual(form.$('.o_subtypes_list .o_subtype_checkbox:checked').length, 2,
+ assert.containsN(form, '.o_subtypes_list .o_subtype_checkbox:checked', 2,
'two subtypes should be checked by default');
- form.$('.o_subtypes_list .dropdown-toggle').click(); // click to open the dropdown
+ testUtils.dom.click(form.$('.o_subtypes_list .dropdown-toggle'));
assert.ok(form.$('.o_subtypes_list.show').length, 'dropdown should be opened');
- form.$('.o_subtypes_list .o_subtype input[data-id=2]').click(); // uncheck second subtype
+ testUtils.dom.click(form.$('.o_subtypes_list .o_subtype input[data-id=2]'));
assert.ok(form.$('.o_subtypes_list.show').length, 'dropdown should remain opened');
assert.ok(!form.$('.o_subtypes_list .o_subtype_checkbox[data-id=2]:checked').length,
'second subtype should now be unchecked');
// click to unfollow
- form.$('.o_followers_follow_button').click(); // click to open the dropdown
+ testUtils.dom.click(form.$('.o_followers_follow_button'));
assert.ok($('.modal').length, 'a confirm modal should be opened');
- $('.modal .modal-footer .btn-primary').click(); // click on 'OK'
+ testUtils.dom.click($('.modal .modal-footer .btn-primary'));
assert.strictEqual(form.$('.o_followers_count').text(), "0", 'should have no followers');
assert.ok(form.$('.o_followers_follow_button.o_followers_notfollow').length,
'should display the "Follow" button');
@@ -2093,7 +2105,7 @@ QUnit.test('followers widget: do not display follower duplications', function (a
assert.strictEqual(form.$('.o_followers_count').text(), '2',
"should have 2 followers");
- assert.strictEqual(form.$('.o_followers_list .o_partner').length, 2,
+ assert.containsN(form, '.o_followers_list .o_partner', 2,
"there should be 2 followers in the follower dropdown");
form.destroy();
@@ -2209,19 +2221,19 @@ QUnit.test('chatter: do not duplicate messages on (un)star message', function (a
session: {},
});
- assert.strictEqual(form.$('.o_thread_message').length, 1,
+ assert.containsOnce(form, '.o_thread_message',
"there should be a single message in the chatter");
assert.ok(form.$('.o_thread_message .o_thread_message_star.fa-star-o').length,
"message should not be starred");
// star message
- form.$('.o_thread_message .o_thread_message_star').click();
- assert.strictEqual(form.$('.o_thread_message').length, 1,
+ testUtils.dom.click(form.$('.o_thread_message .o_thread_message_star'));
+ assert.containsOnce(form, '.o_thread_message',
"there should still be a single message in the chatter after starring the message");
// unstar message
- form.$('.o_thread_message .o_thread_message_star').click();
- assert.strictEqual(form.$('.o_thread_message').length, 1,
+ testUtils.dom.click(form.$('.o_thread_message .o_thread_message_star'));
+ assert.containsOnce(form, '.o_thread_message',
"there should still be a single message in the chatter after unstarring the message");
//cleanup
@@ -2263,9 +2275,9 @@ QUnit.test('chatter: new messages on document without any "display_name"', funct
session: {},
});
- assert.strictEqual(form.$('.o_thread_message').length, 1,
+ assert.containsOnce(form, '.o_thread_message',
"should have a single message in the chatter");
- assert.strictEqual(form.$('.o_thread_message[data-message-id="1"]').length, 1,
+ assert.containsOnce(form, '.o_thread_message[data-message-id="1"]',
"single message should have ID 1");
// Simulate a new message in the chatter
@@ -2285,11 +2297,11 @@ QUnit.test('chatter: new messages on document without any "display_name"', funct
form.reload();
- assert.strictEqual(form.$('.o_thread_message').length, 2,
+ assert.containsN(form, '.o_thread_message', 2,
"should have a two messages in the chatter after reload");
- assert.strictEqual(form.$('.o_thread_message[data-message-id="1"]').length, 1,
+ assert.containsOnce(form, '.o_thread_message[data-message-id="1"]',
"one of the message should have ID 1");
- assert.strictEqual(form.$('.o_thread_message[data-message-id="2"]').length, 1,
+ assert.containsOnce(form, '.o_thread_message[data-message-id="2"]',
"the other message should have ID 2");
//cleanup
@@ -2399,25 +2411,25 @@ QUnit.test('chatter: suggested partner auto-follow on message post', function (a
session: {},
});
- assert.strictEqual(form.$('.o_thread_message').length, 1, "thread should contain one message");
+ assert.containsOnce(form, '.o_thread_message', "thread should contain one message");
assert.ok(form.$('.o_thread_message:first().o_mail_discussion').length,
"the message should be a discussion");
assert.ok(form.$('.o_thread_message:first() .o_thread_message_core').text().indexOf('A message') >= 0,
"the message's body should be correct");
assert.ok(form.$('.o_thread_message:first() .o_mail_info').text().indexOf('John Doe') >= 0,
"the message's author should be correct");
- assert.strictEqual(form.$('.o_followers').length, 1,
+ assert.containsOnce(form, '.o_followers',
"should display follower widget");
assert.strictEqual(form.$('.o_followers_count').text(), "1",
"should have a single follower (widget counter)");
- assert.strictEqual(form.$('.o_followers_list > div.o_partner').length, 1,
+ assert.containsOnce(form, '.o_followers_list > div.o_partner',
"should have a single follower (listed partners)");
assert.strictEqual(form.$('.o_followers_list > div.o_partner > a').text(), "Admin",
"should have 'Admin' as follower");
// open composer
- form.$('.o_chatter_button_new_message').click();
- assert.ok(!$('.oe_chatter .o_thread_composer').hasClass('o_hidden'), "chatter should be opened");
+ testUtils.dom.click(form.$('.o_chatter_button_new_message'));
+ assert.isVisible($('.oe_chatter .o_thread_composer'), "chatter should be opened");
assert.strictEqual($('.o_composer_suggested_partners').length, 1,
"should display suggested partners");
assert.strictEqual($('.o_composer_suggested_partners > div').length, 1,
@@ -2433,11 +2445,11 @@ QUnit.test('chatter: suggested partner auto-follow on message post', function (a
// send message
form.$('.oe_chatter .o_composer_text_field:first()').val("My first message");
- form.$('.oe_chatter .o_composer_button_send').click();
+ testUtils.dom.click(form.$('.oe_chatter .o_composer_button_send'));
assert.strictEqual(form.$('.o_followers_count').text(), "2",
"should have a two followers (widget counter)");
- assert.strictEqual(form.$('.o_followers_list > div.o_partner').length, 2,
+ assert.containsN(form, '.o_followers_list > div.o_partner', 2,
"should have two followers (listed partners)");
assert.strictEqual(form.$('.o_followers_list > div.o_partner > a[data-oe-id="5"]').text(),
"Admin",
@@ -2630,12 +2642,12 @@ QUnit.test('fieldmany2many tags email', function (assert) {
}).then(function (form) {
// should read it 3 times (1 with the form view, one with the form dialog and one after save)
assert.verifySteps([[12, 14], [14], [14]]);
- assert.strictEqual(form.$('.o_field_many2manytags[name="timmy"] .badge.o_tag_color_0').length, 2,
+ assert.containsN(form, '.o_field_many2manytags[name="timmy"] .badge.o_tag_color_0', 2,
"two tags should be present");
var firstTag = form.$('.o_field_many2manytags[name="timmy"] .badge.o_tag_color_0').first();
assert.strictEqual(firstTag.find('.o_badge_text').text(), "gold",
"tag should only show display_name");
- assert.strictEqual(firstTag.find('.o_badge_text').attr('title'), "coucou@petite.perruche",
+ assert.hasAttrValue(firstTag.find('.o_badge_text'), 'title', "coucou@petite.perruche",
"tag should show email address on mouse hover");
form.destroy();
done();
@@ -2649,8 +2661,8 @@ QUnit.test('fieldmany2many tags email', function (assert) {
"there should be an email field in the modal");
// set the email and save the modal (will render the form view)
- $('.modal-body.o_act_window input[name="email"]').val('coucou@petite.perruche').trigger('input');
- $('.modal-footer .btn-primary').click();
+ testUtils.fields.editInput($('.modal-body.o_act_window input[name="email"]'), 'coucou@petite.perruche');
+ testUtils.dom.click($('.modal-footer .btn-primary'));
});
QUnit.test('fieldmany2many tags email (edition)', function (assert) {
@@ -2685,13 +2697,12 @@ QUnit.test('fieldmany2many tags email (edition)', function (assert) {
});
assert.verifySteps([[12]]);
- assert.strictEqual(form.$('.o_field_many2manytags[name="timmy"] .badge.o_tag_color_0').length, 1,
+ assert.containsOnce(form, '.o_field_many2manytags[name="timmy"] .badge.o_tag_color_0',
"should contain one tag");
// add an other existing tag
- var $input = form.$('.o_field_many2manytags input');
- $input.click(); // opens the dropdown
- $input.autocomplete('widget').find('li:first').click(); // add 'silver'
+ testUtils.fields.many2one.clickOpenDropdown('timmy');
+ testUtils.fields.many2one.clickHighlightedItem('timmy');
assert.strictEqual($('.modal-body.o_act_window').length, 1,
"there should be one modal opened to edit the empty email");
@@ -2701,10 +2712,10 @@ QUnit.test('fieldmany2many tags email (edition)', function (assert) {
"there should be an email field in the modal");
// set the email and save the modal (will rerender the form view)
- $('.modal-body.o_act_window input[name="email"]').val('coucou@petite.perruche').trigger('input');
- $('.modal-footer .btn-primary').click();
+ testUtils.fields.editInput($('.modal-body.o_act_window input[name="email"]'), 'coucou@petite.perruche');
+ testUtils.dom.click($('.modal-footer .btn-primary'));
- assert.strictEqual(form.$('.o_field_many2manytags[name="timmy"] .badge.o_tag_color_0').length, 2,
+ assert.containsN(form, '.o_field_many2manytags[name="timmy"] .badge.o_tag_color_0', 2,
"should contain the second tag");
// should have read [14] three times: when opening the dropdown, when opening the modal, and
// after the save
diff --git a/addons/mail/static/tests/discuss_mobile_tests.js b/addons/mail/static/tests/discuss_mobile_tests.js
index 2f0fd5de647..498c3fb42ef 100644
--- a/addons/mail/static/tests/discuss_mobile_tests.js
+++ b/addons/mail/static/tests/discuss_mobile_tests.js
@@ -3,6 +3,8 @@ odoo.define('mail.discuss_mobile_tests', function (require) {
var mailTestUtils = require('mail.testUtils');
+var testUtils = require('web.test_utils');
+
var createDiscuss = mailTestUtils.createDiscuss;
QUnit.module('mail', {}, function () {
@@ -35,55 +37,55 @@ QUnit.test('mobile basic rendering', function (assert) {
services: this.services,
}).then(function (discuss) {
// test basic rendering in mobile
- assert.strictEqual(discuss.$('.o_mail_discuss_content .o_mail_no_content').length, 1,
+ assert.containsOnce(discuss, '.o_mail_discuss_content .o_mail_no_content',
"should display the no content message");
- assert.strictEqual(discuss.$('.o_mail_mobile_tabs').length, 1,
+ assert.containsOnce(discuss, '.o_mail_mobile_tabs',
"should have rendered the tabs");
- assert.ok(discuss.$('.o_mail_mobile_tab[data-type=mailbox_inbox]').hasClass('active'),
+ assert.hasClass(discuss.$('.o_mail_mobile_tab[data-type=mailbox_inbox]'),'active',
"should be in inbox tab");
- assert.strictEqual(discuss.$('.o_mail_discuss_mobile_mailboxes_buttons:visible').length, 1,
+ assert.containsOnce(discuss, '.o_mail_discuss_mobile_mailboxes_buttons:visible',
"inbox/starred buttons should be visible");
- assert.ok(discuss.$('.o_mail_discuss_mobile_mailboxes_buttons .o_mailbox_inbox_item[data-type=mailbox_inbox]').hasClass('btn-primary'),
+ assert.hasClass(discuss.$('.o_mail_discuss_mobile_mailboxes_buttons .o_mailbox_inbox_item[data-type=mailbox_inbox]'),'btn-primary',
"should be in inbox");
- assert.ok($('.o_mail_discuss_button_dm_chat').hasClass('d-none'),
+ assert.hasClass($('.o_mail_discuss_button_dm_chat'),'d-none',
"should have invisible button 'New Message'");
- assert.ok($('.o_mail_discuss_button_public').hasClass('d-none'),
+ assert.hasClass($('.o_mail_discuss_button_public'),'d-none',
"should have invisible button 'New Channel'");
// move to 'Chat' tab
- discuss.$('.o_mail_mobile_tab[data-type=dm_chat]').click();
- assert.ok(discuss.$('.o_mail_mobile_tab[data-type=dm_chat]').hasClass('active'),
+ testUtils.dom.click(discuss.$('.o_mail_mobile_tab[data-type=dm_chat]'));
+ assert.hasClass(discuss.$('.o_mail_mobile_tab[data-type=dm_chat]'),'active',
"should be in 'Chat' tab");
- assert.strictEqual(discuss.$('.o_mail_discuss_content .o_mail_no_content').length, 0,
+ assert.containsNone(discuss, '.o_mail_discuss_content .o_mail_no_content',
"should display the no content message");
assert.strictEqual($('.o_mail_discuss_button_dm_chat').length, 1,
"should have a button to open DM chat in 'Chat' tab");
- assert.notOk($('.o_mail_discuss_button_dm_chat').hasClass('d-none'),
+ assert.doesNotHaveClass($('.o_mail_discuss_button_dm_chat'), 'd-none',
"should be visible in 'Chat' tab");
- assert.ok($('.o_mail_discuss_button_public').hasClass('d-none'),
+ assert.hasClass($('.o_mail_discuss_button_public'),'d-none',
"should have invisible button 'New Channel' in 'Chat' tab");
- $('.o_mail_discuss_button_dm_chat').click(); // click to open a chat
- assert.strictEqual(discuss.$('.o_mail_add_thread input:visible').length, 1,
+ testUtils.dom.click($('.o_mail_discuss_button_dm_chat'));
+ assert.containsOnce(discuss, '.o_mail_add_thread input:visible',
"should display the input to add a channel");
// move to 'Channels' tab
- discuss.$('.o_mail_mobile_tab[data-type=public]').click();
- assert.ok($('.o_mail_discuss_button_dm_chat').hasClass('d-none'),
+ testUtils.dom.click(discuss.$('.o_mail_mobile_tab[data-type=public]'));
+ assert.hasClass($('.o_mail_discuss_button_dm_chat'),'d-none',
"should have invisible button 'New Message' in 'Channels' tab");
- assert.notOk($('.o_mail_discuss_button_public').hasClass('d-none'),
+ assert.doesNotHaveClass($('.o_mail_discuss_button_public'), 'd-none',
"should have visible button 'New Channel' in 'Channels' tab");
- $('.o_mail_discuss_button_public').click(); // click to open a chat
- assert.strictEqual(discuss.$('.o_mail_add_thread input:visible').length, 1,
+ testUtils.dom.click($('.o_mail_discuss_button_public'));
+ assert.containsOnce(discuss, '.o_mail_add_thread input:visible',
"should display the input to add a channel");
// move to Private Channels tab
- discuss.$('.o_mail_mobile_tab[data-type=private]').click();
- assert.ok($('.o_mail_discuss_button_dm_chat').hasClass('d-none'),
+ testUtils.dom.click(discuss.$('.o_mail_mobile_tab[data-type=private]'));
+ assert.hasClass($('.o_mail_discuss_button_dm_chat'),'d-none',
"should have invisible button 'New Message' in 'Private Channels' tab");
- assert.notOk($('.o_mail_discuss_button_private').hasClass('d-none'),
+ assert.doesNotHaveClass($('.o_mail_discuss_button_private'), 'd-none',
"should have invisible button 'New Channel' in 'Private Channels' tab");
- $('.o_mail_discuss_button_private').click(); // click to open a chat
- assert.strictEqual(discuss.$('.o_mail_add_thread input:visible').length, 1,
+ testUtils.dom.click($('.o_mail_discuss_button_private'));
+ assert.containsOnce(discuss, '.o_mail_add_thread input:visible',
"should display the input to add a channel");
discuss.destroy();
diff --git a/addons/mail/static/tests/discuss_moderation_tests.js b/addons/mail/static/tests/discuss_moderation_tests.js
index 4d8e48b4dcb..9c3807527ce 100644
--- a/addons/mail/static/tests/discuss_moderation_tests.js
+++ b/addons/mail/static/tests/discuss_moderation_tests.js
@@ -4,6 +4,8 @@ odoo.define('mail.discuss_moderation_tests', function (require) {
var Thread = require('mail.model.Thread');
var mailTestUtils = require('mail.testUtils');
+var testUtils = require('web.test_utils');
+
var createDiscuss = mailTestUtils.createDiscuss;
QUnit.module('mail', {}, function () {
@@ -102,7 +104,7 @@ QUnit.test('moderator: display moderation box', function (assert) {
.then(function (discuss) {
var moderationBoxSelector = '.o_mail_discuss_item' +
'[data-thread-id="mailbox_moderation"]';
- assert.strictEqual(discuss.$(moderationBoxSelector).length, 1,
+ assert.containsOnce(discuss, moderationBoxSelector,
"there should be a moderation mailbox");
discuss.destroy();
done();
@@ -154,7 +156,7 @@ QUnit.test('moderator: moderated channel with pending moderation message', funct
"the mailbox counter of the moderation mailbox should display '1'");
// 1. go to moderation mailbox
- $moderationBox.click();
+ testUtils.dom.click($moderationBox);
var $message = discuss.$('.o_thread_message');
// check message
assert.strictEqual($message.length, 1,
@@ -168,27 +170,27 @@ QUnit.test('moderator: moderated channel with pending moderation message', funct
assert.notOk($message.find('.moderation_checkbox').prop('checked'), false,
"the moderation checkbox should be unchecked by default");
// check moderation actions next to message
- assert.strictEqual(discuss.$('.o_thread_message_moderation').length, 5,
+ assert.containsN(discuss, '.o_thread_message_moderation', 5,
"there should be 5 contextual moderation decisions next to the message");
- assert.strictEqual(discuss.$('.o_thread_message_moderation[data-decision="accept"]').length, 1,
+ assert.containsOnce(discuss, '.o_thread_message_moderation[data-decision="accept"]',
"there should be a contextual moderation decision to accept the message");
- assert.strictEqual(discuss.$('.o_thread_message_moderation[data-decision="reject"]').length, 1,
+ assert.containsOnce(discuss, '.o_thread_message_moderation[data-decision="reject"]',
"there should be a contextual moderation decision to reject the message");
- assert.strictEqual(discuss.$('.o_thread_message_moderation[data-decision="discard"]').length, 1,
+ assert.containsOnce(discuss, '.o_thread_message_moderation[data-decision="discard"]',
"there should be a contextual moderation decision to discard the message");
- assert.strictEqual(discuss.$('.o_thread_message_moderation[data-decision="allow"]').length, 1,
+ assert.containsOnce(discuss, '.o_thread_message_moderation[data-decision="allow"]',
"there should be a contextual moderation decision to allow the user of the message)");
- assert.strictEqual(discuss.$('.o_thread_message_moderation[data-decision="ban"]').length, 1,
+ assert.containsOnce(discuss, '.o_thread_message_moderation[data-decision="ban"]',
"there should be a contextual moderation decision to ban the user of the message");
// check select all (enabled) / unselect all (disabled) buttons
assert.strictEqual($('.o_mail_discuss_button_select_all').length, 1,
"there should be a 'Select All' button in the control panel");
- assert.notOk($('.o_mail_discuss_button_select_all').hasClass('disabled'),
+ assert.doesNotHaveClass($('.o_mail_discuss_button_select_all'), 'disabled',
"the 'Select All' button should not be disabled");
assert.strictEqual($('.o_mail_discuss_button_unselect_all').length, 1,
"there should be a 'Unselect All' button in the control panel");
- assert.ok($('.o_mail_discuss_button_unselect_all').hasClass('disabled'),
+ assert.hasClass($('.o_mail_discuss_button_unselect_all'),'disabled',
"the 'Unselect All' button should be disabled");
// check moderate all buttons (invisible)
var moderateAllSelector = '.o_mail_discuss_button_moderate_all';
@@ -196,36 +198,36 @@ QUnit.test('moderator: moderated channel with pending moderation message', funct
"there should be 3 buttons to moderate selected messages in the control panel");
assert.strictEqual($(moderateAllSelector + '[data-decision="accept"]').length, 1,
"there should one moderate button to accept messages pending moderation");
- assert.ok($(moderateAllSelector + '[data-decision="accept"]').hasClass('d-none'),
+ assert.hasClass($(moderateAllSelector + '[data-decision="accept"]'),'d-none',
'the moderate button "Accept" should be invisible by default');
assert.strictEqual($(moderateAllSelector + '[data-decision="reject"]').length, 1,
"there should one moderate button to reject messages pending moderation");
- assert.ok($(moderateAllSelector + '[data-decision="reject"]').hasClass('d-none'),
+ assert.hasClass($(moderateAllSelector + '[data-decision="reject"]'),'d-none',
'the moderate button "Reject" should be invisible by default');
assert.strictEqual($(moderateAllSelector + '[data-decision="discard"]').length, 1,
"there should one moderate button to discard messages pending moderation");
- assert.ok($(moderateAllSelector + '[data-decision="discard"]').hasClass('d-none'),
+ assert.hasClass($(moderateAllSelector + '[data-decision="discard"]'),'d-none',
'the moderate button "Discard" should be invisible by default');
// click on message moderation checkbox
- $message.find('.moderation_checkbox').click();
+ testUtils.dom.click($message.find('.moderation_checkbox'));
assert.ok($message.find('.moderation_checkbox').prop('checked'),
"the moderation checkbox should become checked after click");
// check select all (disabled) / unselect all buttons (enabled)
- assert.ok($('.o_mail_discuss_button_select_all').hasClass('disabled'),
+ assert.hasClass($('.o_mail_discuss_button_select_all'),'disabled',
"the 'Select All' button should be disabled");
- assert.notOk($('.o_mail_discuss_button_unselect_all').hasClass('disabled'),
+ assert.doesNotHaveClass($('.o_mail_discuss_button_unselect_all'), 'disabled',
"the 'Unselect All' button should not be disabled");
// check moderate all buttons updated (visible)
- assert.notOk($(moderateAllSelector + '[data-decision="accept"]').hasClass('d-none'),
+ assert.doesNotHaveClass($(moderateAllSelector + '[data-decision="accept"]'), 'd-none',
'the moderate button "Accept" should become visible');
- assert.notOk($(moderateAllSelector + '[data-decision="reject"]').hasClass('d-none'),
+ assert.doesNotHaveClass($(moderateAllSelector + '[data-decision="reject"]'), 'd-none',
'the moderate button "Reject" should become visible');
- assert.notOk($(moderateAllSelector + '[data-decision="discard"]').hasClass('d-none'),
+ assert.doesNotHaveClass($(moderateAllSelector + '[data-decision="discard"]'), 'd-none',
'the moderate button "Discard" should become visible');
// 2. go to channel 'general'
- discuss.$('.o_mail_discuss_item[data-thread-id="1"]').click();
+ testUtils.dom.click(discuss.$('.o_mail_discuss_item[data-thread-id="1"]'));
$message = discuss.$('.o_thread_message');
// check correct message
assert.strictEqual($message.length, 1,
@@ -292,7 +294,7 @@ QUnit.test('moderator: accept pending moderation message', function (assert) {
var $moderationBox = discuss.$(
'.o_mail_discuss_item' +
'[data-thread-id="mailbox_moderation"]');
- $moderationBox.click();
+ testUtils.dom.click($moderationBox);
// check there is a message to moderate
var $message = discuss.$('.o_thread_message');
assert.strictEqual($message.length, 1,
@@ -302,16 +304,16 @@ QUnit.test('moderator: accept pending moderation message', function (assert) {
assert.strictEqual($message.find('.moderation_checkbox').length, 1,
"the message should have a moderation checkbox");
// accept the message pending moderation
- discuss.$('.o_thread_message_moderation[data-decision="accept"]').click();
+ testUtils.dom.click(discuss.$('.o_thread_message_moderation[data-decision="accept"]'));
assert.verifySteps(['moderate']);
// stop the fadeout animation and immediately remove the element
discuss.$('.o_thread_message').stop(false, true);
- assert.strictEqual(discuss.$('.o_thread_message').length, 0,
+ assert.containsNone(discuss, '.o_thread_message',
"should now have no message displayed in moderation box");
// 2. go to channel 'general'
- discuss.$('.o_mail_discuss_item[data-thread-id="1"]').click();
+ testUtils.dom.click(discuss.$('.o_mail_discuss_item[data-thread-id="1"]'));
$message = discuss.$('.o_thread_message');
// check message is there and has no moderate checkbox
assert.strictEqual($message.length, 1,
@@ -382,7 +384,7 @@ QUnit.test('moderator: reject pending moderation message (reject with explanatio
var $moderationBox = discuss.$(
'.o_mail_discuss_item' +
'[data-thread-id="mailbox_moderation"]');
- $moderationBox.click();
+ testUtils.dom.click($moderationBox);
// check there is a message to moderate
var $message = discuss.$('.o_thread_message');
assert.strictEqual($message.length, 1,
@@ -392,7 +394,7 @@ QUnit.test('moderator: reject pending moderation message (reject with explanatio
assert.strictEqual($message.find('.moderation_checkbox').length, 1,
"the message should have a moderation checkbox");
// reject the message pending moderation
- discuss.$('.o_thread_message_moderation[data-decision="reject"]').click();
+ testUtils.dom.click(discuss.$('.o_thread_message_moderation[data-decision="reject"]'));
// check reject dialog prompt
assert.strictEqual($('.modal-dialog').length, 1,
@@ -402,14 +404,14 @@ QUnit.test('moderator: reject pending moderation message (reject with explanatio
var $messageTitle = $('.modal-body input[id="message_title"]');
assert.strictEqual($messageTitle.length, 1,
"should have a title of message for rejecting the message");
- assert.strictEqual($messageTitle.attr('placeholder'), "Subject",
+ assert.hasAttrValue($messageTitle, 'placeholder', "Subject",
"message title for reject reason should have correct placeholder");
assert.strictEqual($messageTitle.val(), "Message Rejected",
"message title for reject reason should have correct default value");
var $messageBody = $('.modal-body textarea[id="reject_message"]');
assert.strictEqual($messageBody.length, 1,
"should have a body of message for rejecting the message");
- assert.strictEqual($messageBody.attr('placeholder'), "Mail Body",
+ assert.hasAttrValue($messageBody, 'placeholder', "Mail Body",
"message body for reject reason should have correct placeholder");
assert.strictEqual($messageBody.text(), "Your message was rejected by moderator.",
"message body for reject reason should have correct default text content");
@@ -417,18 +419,17 @@ QUnit.test('moderator: reject pending moderation message (reject with explanatio
"should have a send button on the reject dialog");
// send mesage
- $('.modal-footer button').click();
+ testUtils.dom.click($('.modal-footer button'));
assert.verifySteps(['moderate']);
// // stop the fadeout animation and immediately remove the element
discuss.$('.o_thread_message').stop(false, true);
- assert.strictEqual(discuss.$('.o_thread_message').length, 0,
+ assert.containsNone(discuss, '.o_thread_message',
"should now have no message displayed in moderation box");
// 2. go to channel 'general'
- discuss.$('.o_mail_discuss_item[data-thread-id="1"]').click();
- assert.strictEqual(discuss.$('.o_thread_message').length, 0,
- "should now have no message displayed in moderated channel");
+ testUtils.dom.click(discuss.$('.o_mail_discuss_item[data-thread-id="1"]'));
+ assert.containsNone(discuss, '.o_thread_message')
discuss.destroy();
done();
@@ -486,7 +487,7 @@ QUnit.test('moderator: discard pending moderation message (reject without explan
var $moderationBox = discuss.$(
'.o_mail_discuss_item' +
'[data-thread-id="mailbox_moderation"]');
- $moderationBox.click();
+ testUtils.dom.click($moderationBox);
// check there is a message to moderate
var $message = discuss.$('.o_thread_message');
assert.strictEqual($message.length, 1,
@@ -496,7 +497,7 @@ QUnit.test('moderator: discard pending moderation message (reject without explan
assert.strictEqual($message.find('.moderation_checkbox').length, 1,
"the message should have a moderation checkbox");
// discard the message pending moderation
- discuss.$('.o_thread_message_moderation[data-decision="discard"]').click();
+ testUtils.dom.click(discuss.$('.o_thread_message_moderation[data-decision="discard"]'));
// check discard dialog prompt
assert.strictEqual($('.modal-dialog').length, 1,
@@ -512,18 +513,17 @@ QUnit.test('moderator: discard pending moderation message (reject without explan
"should have a cancel button in the dialog for discard");
// discard mesage
- $('.modal-footer button.btn-primary').click();
+ testUtils.dom.click($('.modal-footer button.btn-primary'));
assert.verifySteps(['moderate']);
// stop the fadeout animation and immediately remove the element
discuss.$('.o_thread_message').stop(false, true);
- assert.strictEqual(discuss.$('.o_thread_message').length, 0,
+ assert.containsNone(discuss, '.o_thread_message',
"should now have no message displayed in moderation box");
// 2. go to channel 'general'
- discuss.$('.o_mail_discuss_item[data-thread-id="1"]').click();
- assert.strictEqual(discuss.$('.o_thread_message').length, 0,
- "should now have no message displayed in moderated channel");
+ testUtils.dom.click(discuss.$('.o_mail_discuss_item[data-thread-id="1"]'));
+ assert.containsNone(discuss, '.o_thread_message')
discuss.destroy();
done();
@@ -586,10 +586,10 @@ QUnit.test('author: send message in moderated channel', function (assert) {
objectDiscuss = discuss;
// go to channel 'general'
- discuss.$('.o_mail_discuss_item[data-thread-id="1"]').click();
+ testUtils.dom.click(discuss.$('.o_mail_discuss_item[data-thread-id="1"]'));
// post a message
discuss.$('.o_composer_input textarea').first().val("some text");
- discuss.$('.o_composer_send button').click();
+ testUtils.dom.click(discuss.$('.o_composer_send button'));
messagePostDef
.then(function () {
@@ -649,7 +649,7 @@ QUnit.test('author: sent message accepted in moderated channel', function (asser
.then(function (discuss) {
// go to channel 'general'
- discuss.$('.o_mail_discuss_item[data-thread-id="1"]').click();
+ testUtils.dom.click(discuss.$('.o_mail_discuss_item[data-thread-id="1"]'));
// check message is pending
var $message = discuss.$('.o_thread_message');
assert.strictEqual($message.length, 1,
@@ -683,7 +683,7 @@ QUnit.test('author: sent message accepted in moderated channel', function (asser
"message should still have ID returned from 'message_post'");
assert.strictEqual($message.find('.o_thread_author').text().trim(),
"Someone", "message should still have correct author displayed name");
- assert.strictEqual(discuss.$('.o_thread_icons i.text-danger').length, 0,
+ assert.containsNone(discuss, '.o_thread_icons i.text-danger',
"the message should not be in pending moderation anymore");
discuss.destroy();
@@ -730,7 +730,7 @@ QUnit.test('author: sent message rejected in moderated channel', function (asser
.then(function (discuss) {
// go to channel 'general'
- discuss.$('.o_mail_discuss_item[data-thread-id="1"]').click();
+ testUtils.dom.click(discuss.$('.o_mail_discuss_item[data-thread-id="1"]'));
// check message is pending
var $message = discuss.$('.o_thread_message');
assert.strictEqual($message.length, 1,
@@ -753,7 +753,7 @@ QUnit.test('author: sent message rejected in moderated channel', function (asser
discuss.call('bus_service', 'trigger', 'notification', [notification]);
// // check no message
- assert.strictEqual(discuss.$('.o_thread_message').length, 0,
+ assert.containsNone(discuss, '.o_thread_message',
"message should be removed from channel after reject");
discuss.destroy();
diff --git a/addons/mail/static/tests/discuss_tests.js b/addons/mail/static/tests/discuss_tests.js
index 68aee02ded6..1684ad821df 100644
--- a/addons/mail/static/tests/discuss_tests.js
+++ b/addons/mail/static/tests/discuss_tests.js
@@ -90,9 +90,9 @@ QUnit.test('basic rendering', function (assert) {
assert.strictEqual($sidebar.length, 1,
"should have rendered a sidebar");
- assert.strictEqual(discuss.$('.o_mail_discuss_content').length, 1,
+ assert.containsOnce(discuss, '.o_mail_discuss_content',
"should have rendered the content");
- assert.strictEqual(discuss.$('.o_mail_no_content').length, 1,
+ assert.containsOnce(discuss, '.o_mail_no_content',
"should display no content message");
var $inbox = $sidebar.find('.o_mail_discuss_item[data-thread-id=mailbox_inbox]');
@@ -128,7 +128,7 @@ QUnit.test('searchview options visibility', function (assert) {
assert.strictEqual($searchviewOptions.css('display'), 'block',
"search options should be visible by default");
- $searchviewOptionsToggler.click();
+ testUtils.dom.click($searchviewOptionsToggler);
assert.strictEqual($searchviewOptions.css('display'), 'none',
"search options should be hidden after clicking on search option toggler");
@@ -172,7 +172,7 @@ QUnit.test('searchview filter messages', function (assert) {
},
})
.then(function (discuss) {
- assert.strictEqual(discuss.$('.o_thread_message').length, 2,
+ assert.containsN(discuss, '.o_thread_message', 2,
"there should be two messages in the inbox mailbox");
assert.strictEqual($('.o_searchview_input').length, 1,
"there should be a searchview on discuss");
@@ -187,11 +187,11 @@ QUnit.test('searchview filter messages', function (assert) {
"the searchview should have a facet");
assert.strictEqual($('.o_facet_values').text().trim(), 'ab',
"the facet should be a search on 'ab'");
- assert.strictEqual(discuss.$('.o_thread_message').length, 1,
+ assert.containsOnce(discuss, '.o_thread_message',
"there should be a single message after filter");
// interact with search view so that there are no matching messages
- $('.o_facet_remove').click();
+ testUtils.dom.click($('.o_facet_remove'));
$('.o_searchview_input').val("abcd").trigger('keyup');
$('.o_searchview').trigger($.Event('keydown', { which: $.ui.keyCode.ENTER }));
@@ -199,7 +199,7 @@ QUnit.test('searchview filter messages', function (assert) {
"the searchview should have a facet");
assert.strictEqual($('.o_facet_values').text().trim(), 'abcd',
"the facet should be a search on 'abcd'");
- assert.strictEqual(discuss.$('.o_thread_message').length, 0,
+ assert.containsNone(discuss, '.o_thread_message',
"there should be no message after 2nd filter");
assert.strictEqual(discuss.$('.o_thread_title').text().trim(),
"No matches found",
@@ -304,11 +304,11 @@ QUnit.test('@ mention in channel', function (assert) {
.find('.o_mail_discuss_item[data-thread-id=1]');
assert.strictEqual($general.length, 1,
"should have the channel item with id 1");
- assert.strictEqual($general.attr('title'), 'general',
+ assert.hasAttrValue($general, 'title', 'general',
"should have the title 'general'");
// click on general
- $general.click();
+ testUtils.dom.click($general);
var $input = discuss.$('textarea.o_composer_text_field').first();
assert.ok($input.length, "should display a composer input");
@@ -320,7 +320,7 @@ QUnit.test('@ mention in channel', function (assert) {
fetchListenersDef
.then(concurrency.delay.bind(concurrency, 0))
.then(function () {
- assert.strictEqual(discuss.$('.dropup.o_composer_mention_dropdown.show').length, 1,
+ assert.containsOnce(discuss, '.dropup.o_composer_mention_dropdown.show',
"dropup menu for partner mentions should be open");
var $mentionPropositions = discuss.$('.o_mention_proposition');
@@ -332,21 +332,21 @@ QUnit.test('@ mention in channel', function (assert) {
var $mention3 = $mentionPropositions.first().next().next();
// correct 1st mention proposition
- assert.ok($mention1.hasClass('active'),
+ assert.hasClass($mention1,'active',
"first partner mention should be active");
assert.strictEqual($mention1.data('id'), 1,
"first partner mention should link to the correct partner id");
assert.strictEqual($mention1.find('.o_mention_name').text(), "Admin",
"first partner mention should display the correct partner name");
// correct 2nd mention proposition
- assert.notOk($mention2.hasClass('active'),
+ assert.doesNotHaveClass($mention2, 'active',
"second partner mention should not be active");
assert.strictEqual($mention2.data('id'), 2,
"second partner mention should link to the correct partner id");
assert.strictEqual($mention2.find('.o_mention_name').text(), "TestUser",
"second partner mention should display the correct partner name");
// correct 3rd mention proposition
- assert.notOk($mention3.hasClass('active'),
+ assert.doesNotHaveClass($mention3, 'active',
"third partner mention should not be active");
assert.strictEqual($mention3.data('id'), 3,
"third partner mention should link to the correct partner id");
@@ -355,50 +355,50 @@ QUnit.test('@ mention in channel', function (assert) {
// check DOWN event
$input.trigger($.Event('keyup', {which: $.ui.keyCode.DOWN}));
- assert.notOk($mention1.hasClass('active'),
+ assert.doesNotHaveClass($mention1, 'active',
"first partner mention should not be active");
- assert.ok($mention2.hasClass('active'),
+ assert.hasClass($mention2,'active',
"second partner mention should be active");
- assert.notOk($mention3.hasClass('active'),
+ assert.doesNotHaveClass($mention3, 'active',
"third partner mention should not be active");
// check UP event
$input.trigger($.Event('keyup', {which: $.ui.keyCode.UP}));
- assert.ok($mention1.hasClass('active'),
+ assert.hasClass($mention1,'active',
"first partner mention should be active");
- assert.notOk($mention2.hasClass('active'),
+ assert.doesNotHaveClass($mention2, 'active',
"second partner mention should not be active");
- assert.notOk($mention3.hasClass('active'),
+ assert.doesNotHaveClass($mention3, 'active',
"third partner mention should not be active");
// check TAB event (full cycle, hence 3 TABs)
$input.trigger($.Event('keyup', {which: $.ui.keyCode.TAB}));
- assert.notOk($mention1.hasClass('active'),
+ assert.doesNotHaveClass($mention1, 'active',
"first partner mention should not be active");
- assert.ok($mention2.hasClass('active'),
+ assert.hasClass($mention2,'active',
"second partner mention should be active");
- assert.notOk($mention3.hasClass('active'),
+ assert.doesNotHaveClass($mention3, 'active',
"third partner mention should not be active");
$input.trigger($.Event('keyup', {which: $.ui.keyCode.TAB}));
- assert.notOk($mention1.hasClass('active'),
+ assert.doesNotHaveClass($mention1, 'active',
"first partner mention should not be active");
- assert.notOk($mention2.hasClass('active'),
+ assert.doesNotHaveClass($mention2, 'active',
"second partner mention should not be active");
- assert.ok($mention3.hasClass('active'),
+ assert.hasClass($mention3,'active',
"third partner mention should be active");
$input.trigger($.Event('keyup', {which: $.ui.keyCode.TAB}));
- assert.ok($mention1.hasClass('active'),
+ assert.hasClass($mention1,'active',
"first partner mention should be active");
- assert.notOk($mention2.hasClass('active'),
+ assert.doesNotHaveClass($mention2, 'active',
"second partner mention should not be active");
- assert.notOk($mention3.hasClass('active'),
+ assert.doesNotHaveClass($mention3, 'active',
"third partner mention should not be active");
- // equivalent to $mentionPropositions.find('active').click();
+// testUtils.dom.click( equivalent to $mentionPropositions.find('active'));
$input.trigger($.Event('keyup', {which: $.ui.keyCode.ENTER}));
- assert.strictEqual(discuss.$('.o_mention_proposition').length, 0,
+ assert.containsNone(discuss, '.o_mention_proposition',
"should not have any partner mention proposition after ENTER");
assert.strictEqual($input.val().trim() , "@Admin",
"should have the correct mention link in the composer input");
@@ -409,9 +409,9 @@ QUnit.test('@ mention in channel', function (assert) {
receiveMessageDef
.then(concurrency.delay.bind(concurrency, 0))
.then(function () {
- assert.strictEqual(discuss.$('.o_thread_message_content').length, 1,
+ assert.containsOnce(discuss, '.o_thread_message_content',
"should display one message with some content");
- assert.strictEqual(discuss.$('.o_thread_message_content a').length, 1,
+ assert.containsOnce(discuss, '.o_thread_message_content a',
"should contain a link in the message content");
assert.strictEqual(discuss.$('.o_thread_message_content a').text(),
"@Admin", "should have correct mention link in the message content");
@@ -449,11 +449,11 @@ QUnit.test('no crash focusout emoji button', function (assert) {
.find('.o_mail_discuss_item[data-thread-id=1]');
assert.strictEqual($general.length, 1,
"should have the channel item with id 1");
- assert.strictEqual($general.attr('title'), 'general',
+ assert.hasAttrValue($general, 'title', 'general',
"should have the title 'general'");
// click on general
- $general.click();
+ testUtils.dom.click($general);
discuss.$('.o_composer_button_emoji').focus();
try {
discuss.$('.o_composer_button_emoji').focusout();
@@ -525,12 +525,12 @@ QUnit.test('older messages are loaded on scroll', function (assert) {
"should have a channel item with id 1");
// switch to 'general'
- $general.click();
+ testUtils.dom.click($general);
assert.verifySteps(['message_fetch', 'message_fetch'],
"should fetch a second time for general channel messages (30 last messages)");
- assert.strictEqual(discuss.$('.o_thread_message').length, 30,
+ assert.containsN(discuss, '.o_thread_message', 30,
"should display the 30 messages");
// simulate a scroll to top to load more messages
@@ -541,7 +541,7 @@ QUnit.test('older messages are loaded on scroll', function (assert) {
.then(function () {
assert.verifySteps(['message_fetch', 'message_fetch', 'message_fetch'],
"should fetch a third time for general channel messages (5 remaining messages)");
- assert.strictEqual(discuss.$('.o_thread_message').length, 35,
+ assert.containsN(discuss, '.o_thread_message', 35,
"all messages should now be loaded");
discuss.destroy();
@@ -608,12 +608,12 @@ QUnit.test('"Unstar all" button should reset the starred counter', function (ass
var $starredCounter = $('.o_mail_mailbox_title_starred > .o_mail_sidebar_needaction');
// Go to Starred channel
- $starred.click();
+ testUtils.dom.click($starred);
// Test Initial Value
assert.strictEqual($starredCounter.text().trim(), "40", "40 messages should be starred");
// Unstar all and wait 'update_starred'
- $('.o_control_panel .o_mail_discuss_button_unstar_all').click();
+ testUtils.dom.click($('.o_control_panel .o_mail_discuss_button_unstar_all'));
$starredCounter = $('.o_mail_mailbox_title_starred > .o_mail_sidebar_needaction');
assert.strictEqual($starredCounter.text().trim(), "0",
"All messages should be unstarred");
@@ -627,7 +627,7 @@ QUnit.test('do not crash when destroyed before start is completed', function (as
assert.expect(3);
var discuss;
- testUtils.patch(Discuss, {
+ testUtils.mock.patch(Discuss, {
init: function () {
discuss = this;
this._super.apply(this, arguments);
@@ -657,14 +657,14 @@ QUnit.test('do not crash when destroyed before start is completed', function (as
"message_fetch"
]);
- testUtils.unpatch(Discuss);
+ testUtils.mock.unpatch(Discuss);
});
QUnit.test('do not crash when destroyed between start en end of _renderSearchView', function (assert) {
assert.expect(2);
var discuss;
- testUtils.patch(Discuss, {
+ testUtils.mock.patch(Discuss, {
init: function () {
discuss = this;
this._super.apply(this, arguments);
@@ -673,7 +673,7 @@ QUnit.test('do not crash when destroyed between start en end of _renderSearchVie
var def = $.Deferred();
- testUtils.patch(SearchView, {
+ testUtils.mock.patch(SearchView, {
willStart: function () {
var result = this._super.apply(this, arguments);
return def.then($.when(result));
@@ -700,8 +700,8 @@ QUnit.test('do not crash when destroyed between start en end of _renderSearchVie
"load_views",
]);
- testUtils.unpatch(Discuss);
- testUtils.unpatch(SearchView);
+ testUtils.mock.unpatch(Discuss);
+ testUtils.mock.unpatch(SearchView);
});
QUnit.test('confirm dialog when administrator leave (not chat) channel', function (assert) {
@@ -731,7 +731,7 @@ QUnit.test('confirm dialog when administrator leave (not chat) channel', functio
})
.then(function (discuss) {
// Unsubscribe on MyChannel as administrator
- discuss.$('.o_mail_partner_unpin').click();
+ testUtils.dom.click(discuss.$('.o_mail_partner_unpin'));
assert.strictEqual($('.modal-dialog').length, 1,
"should display a dialog");
@@ -791,7 +791,7 @@ QUnit.test('convert emoji sources to unicodes on message_post', function (assert
.find('.o_mail_discuss_item[data-thread-id=1]');
// click on general
- $general.click();
+ testUtils.dom.click($general);
var $input = discuss.$('textarea.o_composer_text_field').first();
$input.focus();
@@ -868,21 +868,21 @@ QUnit.test('mark all messages as read from Inbox', function (assert) {
"there should be an 'Inbox' item in Discuss sidebar");
assert.strictEqual($inbox.find('.o_mail_sidebar_needaction').text().trim(), "2",
"the mailbox counter of 'Inbox' should be 2");
- assert.ok($inbox.hasClass('o_active'),
+ assert.hasClass($inbox,'o_active',
"'Inbox' should be the currently active thread");
- assert.strictEqual(discuss.$('.o_thread_message').length, 2,
+ assert.containsN(discuss, '.o_thread_message', 2,
"there should be 2 messages in inbox");
var $markAllReadButton = $('.o_mail_discuss_button_mark_all_read');
assert.strictEqual($markAllReadButton.length, 1,
"there should be a 'Mark All As Read' button");
- assert.strictEqual($markAllReadButton.attr('style'),
+ assert.hasAttrValue($markAllReadButton, 'style',
'display: inline-block;',
"the 'Mark All As Read' button should be visible");
assert.notOk($markAllReadButton.prop('disabled'),
"the 'Mark All As Read' button should not be disabled");
- $markAllReadButton.click();
+ testUtils.dom.click($markAllReadButton);
markAllReadDef.then(function () {
// immediately jump to end of the fadeout animation on messages
@@ -890,7 +890,7 @@ QUnit.test('mark all messages as read from Inbox', function (assert) {
discuss.$('.o_thread_message').stop(false, true);
assert.strictEqual($inbox.find('.o_mail_sidebar_needaction').text().trim(), "0",
"the mailbox counter of 'Inbox' should have reset to 0");
- assert.strictEqual(discuss.$('.o_thread_message').length, 0,
+ assert.containsNone(discuss, '.o_thread_message',
"there should no message in inbox anymore");
discuss.destroy();
diff --git a/addons/mail/static/tests/discuss_typing_notification_tests.js b/addons/mail/static/tests/discuss_typing_notification_tests.js
index 0009c3d799b..fee8040fc24 100644
--- a/addons/mail/static/tests/discuss_typing_notification_tests.js
+++ b/addons/mail/static/tests/discuss_typing_notification_tests.js
@@ -4,6 +4,7 @@ odoo.define('mail.discuss_typing_notification_test', function (require) {
var Timer = require('mail.model.Timer');
var CCThrottleFunctionObject = require('mail.model.CCThrottleFunctionObject');
var mailTestUtils = require('mail.testUtils');
+var testUtils = require('web.test_utils');
var createDiscuss = mailTestUtils.createDiscuss;
@@ -195,11 +196,11 @@ QUnit.test('notify is typing', function (assert) {
.find('.o_mail_discuss_item[data-thread-id=1]');
assert.strictEqual($general.length, 1,
"should have the channel item with id 1");
- assert.strictEqual($general.attr('title'), 'general',
+ assert.hasAttrValue($general, 'title', 'general',
"should have the title 'general'");
// click on general
- $general.click();
+ testUtils.dom.click($general);
var $input = discuss.$('textarea.o_composer_text_field').first();
assert.ok($input.length, "should display a composer input");
@@ -207,14 +208,14 @@ QUnit.test('notify is typing', function (assert) {
// STEP 1: current user is typing something
step = 1;
$input.focus();
- $input.val("1");
- $input.trigger('input');
+ testUtils.fields.editInput($input, '1');
+
assert.verifySteps(['notify_typing']);
// STEP 2: current user clears input
step = 2;
- $input.val("");
- $input.trigger('input');
+ testUtils.fields.editInput($input, '');
+
assert.verifySteps(['notify_typing', 'notify_typing']);
discuss.destroy();
@@ -253,14 +254,14 @@ QUnit.test('receive is typing notification', function (assert) {
.find('.o_mail_discuss_item[data-thread-id=1]');
assert.strictEqual($general.length, 1,
"should have the channel item with id 1");
- assert.strictEqual($general.attr('title'), 'general',
+ assert.hasAttrValue($general, 'title', 'general',
"should have the title 'general'");
// click on general
- $general.click();
- assert.strictEqual(discuss.$('.o_thread_typing_notification_bar').length, 1,
+ testUtils.dom.click($general);
+ assert.containsOnce(discuss, '.o_thread_typing_notification_bar',
"there should be a typing notification bar on the thread");
- assert.ok(discuss.$('.o_thread_typing_notification_bar').hasClass('o_hidden'),
+ assert.isNotVisible(discuss.$('.o_thread_typing_notification_bar'),
"the typing notification bar should be hidden by default");
self.simulateIsTyping({
@@ -271,7 +272,7 @@ QUnit.test('receive is typing notification', function (assert) {
});
fetchListenersDef.then(function () {
- assert.notOk(discuss.$('.o_thread_typing_notification_bar').hasClass('o_hidden'),
+ assert.isVisible(discuss.$('.o_thread_typing_notification_bar'),
"the typing notification bar should be visible when someone is typing something");
assert.strictEqual(discuss.$('.o_thread_typing_notification_bar').text(),
"Someone is typing...",
@@ -283,7 +284,7 @@ QUnit.test('receive is typing notification', function (assert) {
partnerID: 42,
widget: discuss,
});
- assert.ok(discuss.$('.o_thread_typing_notification_bar').hasClass('o_hidden'),
+ assert.isNotVisible(discuss.$('.o_thread_typing_notification_bar'),
"the typing notification bar should be hidden when someone stops typing something");
discuss.destroy();
@@ -320,11 +321,10 @@ QUnit.test('receive message of someone that was typing something', function (ass
session: { partner_id: this.myPartnerID },
}).then(function (discuss) {
// click on general channel
- discuss.$('.o_mail_discuss_sidebar')
- .find('.o_mail_discuss_item[data-thread-id=1]')
- .click();
+ var $general = discuss.$('.o_mail_discuss_sidebar .o_mail_discuss_item[data-thread-id=1]');
+ testUtils.dom.click($general);
- assert.ok(discuss.$('.o_thread_typing_notification_bar').hasClass('o_hidden'),
+ assert.isNotVisible(discuss.$('.o_thread_typing_notification_bar'),
"the typing notification bar should be hidden by default");
self.simulateIsTyping({
@@ -335,7 +335,7 @@ QUnit.test('receive message of someone that was typing something', function (ass
});
fetchListenersDef.then(function () {
- assert.notOk(discuss.$('.o_thread_typing_notification_bar').hasClass('o_hidden'),
+ assert.isVisible(discuss.$('.o_thread_typing_notification_bar'),
"the typing notification bar should be visible when someone is typing something");
assert.strictEqual(discuss.$('.o_thread_typing_notification_bar').text(),
"Someone is typing...",
@@ -353,7 +353,7 @@ QUnit.test('receive message of someone that was typing something', function (ass
var notification = [[false, 'mail.channel', self.generalChannelID], messageData];
discuss.call('bus_service', 'trigger', 'notification', [notification]);
- assert.ok(discuss.$('.o_thread_typing_notification_bar').hasClass('o_hidden'),
+ assert.isNotVisible(discuss.$('.o_thread_typing_notification_bar'),
"the typing notification bar should be hidden when receiving message from someone that was typing some text");
discuss.destroy();
@@ -391,10 +391,10 @@ QUnit.test('do not display myself as typing', function (assert) {
// click on general
var $general = discuss.$('.o_mail_discuss_sidebar')
.find('.o_mail_discuss_item[data-thread-id=1]');
- $general.click();
- assert.strictEqual(discuss.$('.o_thread_typing_notification_bar').length, 1,
+ testUtils.dom.click($general);
+ assert.containsOnce(discuss, '.o_thread_typing_notification_bar',
"there should be a typing notification bar on the thread");
- assert.ok(discuss.$('.o_thread_typing_notification_bar').hasClass('o_hidden'),
+ assert.isNotVisible(discuss.$('.o_thread_typing_notification_bar'),
"the typing notification bar should be hidden by default");
self.simulateIsTyping({
@@ -405,7 +405,7 @@ QUnit.test('do not display myself as typing', function (assert) {
});
fetchListenersDef.then(function () {
- assert.ok(discuss.$('.o_thread_typing_notification_bar').hasClass('o_hidden'),
+ assert.isNotVisible(discuss.$('.o_thread_typing_notification_bar'),
"the typing notification bar should still be hidden when I am typing something");
discuss.destroy();
@@ -453,14 +453,14 @@ QUnit.test('several users typing something at the same time', function (assert)
.find('.o_mail_discuss_item[data-thread-id=1]');
assert.strictEqual($general.length, 1,
"should have the channel item with id 1");
- assert.strictEqual($general.attr('title'), 'general',
+ assert.hasAttrValue($general, 'title', 'general',
"should have the title 'general'");
// click on general
- $general.click();
- assert.strictEqual(discuss.$('.o_thread_typing_notification_bar').length, 1,
+ testUtils.dom.click($general);
+ assert.containsOnce(discuss, '.o_thread_typing_notification_bar',
"there should be a typing notification bar on the thread");
- assert.ok(discuss.$('.o_thread_typing_notification_bar').hasClass('o_hidden'),
+ assert.isNotVisible(discuss.$('.o_thread_typing_notification_bar'),
"the typing notification bar should be hidden by default");
self.simulateIsTyping({
@@ -471,7 +471,7 @@ QUnit.test('several users typing something at the same time', function (assert)
});
fetchListenersDef.then(function () {
- assert.notOk(discuss.$('.o_thread_typing_notification_bar').hasClass('o_hidden'),
+ assert.isVisible(discuss.$('.o_thread_typing_notification_bar'),
"the typing notification bar should be visible when someone is typing something");
assert.strictEqual(discuss.$('.o_thread_typing_notification_bar').text(),
"Someone is typing...",
@@ -548,9 +548,8 @@ QUnit.test('long typing partner A and in-between short typing partner B', functi
session: { partner_id: this.myPartnerID },
}).then(function (discuss) {
// click on general channel
- discuss.$('.o_mail_discuss_sidebar')
- .find('.o_mail_discuss_item[data-thread-id=1]')
- .click();
+ var $general = discuss.$('.o_mail_discuss_sidebar .o_mail_discuss_item[data-thread-id=1]');
+ testUtils.dom.click($general);
self.simulateIsTyping({
channelID: self.generalChannelID,
@@ -560,7 +559,7 @@ QUnit.test('long typing partner A and in-between short typing partner B', functi
});
fetchListenersDef.then(function () {
- assert.notOk(discuss.$('.o_thread_typing_notification_bar').hasClass('o_hidden'),
+ assert.isVisible(discuss.$('.o_thread_typing_notification_bar'),
"the typing notification bar should be visible when someone is typing something");
assert.strictEqual(discuss.$('.o_thread_typing_notification_bar').text(),
"A is typing...",
diff --git a/addons/mail/static/tests/document_thread_window_tests.js b/addons/mail/static/tests/document_thread_window_tests.js
index d7064b8695d..811b01f62e4 100644
--- a/addons/mail/static/tests/document_thread_window_tests.js
+++ b/addons/mail/static/tests/document_thread_window_tests.js
@@ -91,7 +91,7 @@ QUnit.test('open a document thread in a thread window', function (assert) {
assert.expect(6);
var messagingMenu = new MessagingMenu();
- testUtils.addMockEnvironment(messagingMenu, {
+ testUtils.mock.addMockEnvironment(messagingMenu, {
services: this.services,
data: this.data,
session: this.session,
@@ -110,10 +110,10 @@ QUnit.test('open a document thread in a thread window', function (assert) {
messagingMenu.appendTo($('#qunit-fixture'));
// toggle the messaging menu and open the documentThread
- messagingMenu.$('.dropdown-toggle').click();
- assert.strictEqual(messagingMenu.$('.o_mail_preview').length, 1,
+ testUtils.dom.click(messagingMenu.$('.dropdown-toggle'));
+ assert.containsOnce(messagingMenu, '.o_mail_preview',
"should display one preview");
- messagingMenu.$('.o_mail_preview').click();
+ testUtils.dom.click(messagingMenu.$('.o_mail_preview'));
assert.strictEqual($('.o_thread_window').length, 1,
"should have open the DocumentThread in a thread window");
@@ -129,7 +129,7 @@ QUnit.test('expand a document thread window', function (assert) {
assert.expect(4);
var messagingMenu = new MessagingMenu();
- testUtils.addMockEnvironment(messagingMenu, {
+ testUtils.mock.addMockEnvironment(messagingMenu, {
services: this.services,
data: this.data,
session: this.session,
@@ -147,18 +147,18 @@ QUnit.test('expand a document thread window', function (assert) {
messagingMenu.appendTo($('#qunit-fixture'));
// toggle the messaging menu and open the documentThread
- messagingMenu.$('.dropdown-toggle').click();
- assert.strictEqual(messagingMenu.$('.o_mail_preview').length, 1,
+ testUtils.dom.click(messagingMenu.$('.dropdown-toggle'));
+ assert.containsOnce(messagingMenu, '.o_mail_preview',
"should display one preview");
- messagingMenu.$('.o_mail_preview').click();
+ testUtils.dom.click(messagingMenu.$('.o_mail_preview'));
assert.strictEqual($('.o_thread_window').length, 1,
"should have open the DocumentThread in a thread window");
- assert.strictEqual($('.o_thread_window .o_thread_window_expand').attr('title'),
+ assert.hasAttrValue($('.o_thread_window .o_thread_window_expand'), 'title',
'Open document', "button should have correct title");
// click to expand
- $('.o_thread_window .o_thread_window_expand').click();
+ testUtils.dom.click($('.o_thread_window .o_thread_window_expand'));
messagingMenu.destroy();
});
@@ -177,7 +177,7 @@ QUnit.test('post messages in a document thread window', function (assert) {
res_id: 1,
};
var messagingMenu = new MessagingMenu();
- testUtils.addMockEnvironment(messagingMenu, {
+ testUtils.mock.addMockEnvironment(messagingMenu, {
services: this.services,
data: this.data,
session: this.session,
@@ -198,7 +198,7 @@ QUnit.test('post messages in a document thread window', function (assert) {
return this._super.apply(this, arguments);
},
});
- testUtils.intercept(messagingMenu, 'call_service', function (ev) {
+ testUtils.mock.intercept(messagingMenu, 'call_service', function (ev) {
if (ev.data.service === 'local_storage' && ev.data.method === 'setItem' &&
ev.data.args[0] === 'mail.document_threads_last_message') {
assert.deepEqual(ev.data.args[1], newMessage,
@@ -208,10 +208,10 @@ QUnit.test('post messages in a document thread window', function (assert) {
messagingMenu.appendTo($('#qunit-fixture'));
// toggle the messaging menu and open the documentThread
- messagingMenu.$('.dropdown-toggle').click();
- assert.strictEqual(messagingMenu.$('.o_mail_preview').length, 1,
+ testUtils.dom.click(messagingMenu.$('.dropdown-toggle'));
+ assert.containsOnce(messagingMenu, '.o_mail_preview',
"should display one preview");
- messagingMenu.$('.o_mail_preview').click();
+ testUtils.dom.click(messagingMenu.$('.o_mail_preview'));
assert.strictEqual($('.o_thread_window').length, 1,
"should have open the DocumentThread in a thread window");
assert.strictEqual($('.o_thread_window .o_thread_message').length, 2,
@@ -232,12 +232,12 @@ QUnit.test('open, fold, unfold and close a document thread window', function (as
assert.expect(8);
var messagingMenu = new MessagingMenu();
- testUtils.addMockEnvironment(messagingMenu, {
+ testUtils.mock.addMockEnvironment(messagingMenu, {
services: this.services,
data: this.data,
session: this.session,
});
- testUtils.intercept(messagingMenu, 'call_service', function (ev) {
+ testUtils.mock.intercept(messagingMenu, 'call_service', function (ev) {
if (ev.data.service === 'local_storage' && ev.data.method === 'setItem') {
assert.step(ev.data.args);
}
@@ -245,21 +245,21 @@ QUnit.test('open, fold, unfold and close a document thread window', function (as
messagingMenu.appendTo($('#qunit-fixture'));
// toggle the messaging menu and open the documentThread
- messagingMenu.$('.dropdown-toggle').click();
- assert.strictEqual(messagingMenu.$('.o_mail_preview').length, 1,
+ testUtils.dom.click(messagingMenu.$('.dropdown-toggle'));
+ assert.containsOnce(messagingMenu, '.o_mail_preview',
"should display one preview");
- messagingMenu.$('.o_mail_preview').click();
+ testUtils.dom.click(messagingMenu.$('.o_mail_preview'));
assert.strictEqual($('.o_thread_window').length, 1,
"should have open the DocumentThread in a thread window");
assert.strictEqual($('.o_thread_window .o_thread_message').length, 2,
"should display 2 messages in the thread window");
// fold and unfold thread window
- $('.o_thread_window .o_thread_window_title').click();
- $('.o_thread_window .o_thread_window_title').click();
+ testUtils.dom.click($('.o_thread_window .o_thread_window_title'));
+ testUtils.dom.click($('.o_thread_window .o_thread_window_title'));
// close thread window
- $('.o_thread_window .o_thread_window_close').click();
+ testUtils.dom.click($('.o_thread_window .o_thread_window_close'));
assert.verifySteps([
['mail.document_threads_state', {"some.res.model_1": {"name": "Some Record", "windowState": "open"}}],
diff --git a/addons/mail/static/tests/document_viewer_tests.js b/addons/mail/static/tests/document_viewer_tests.js
index bbd2d9a6fa1..ef825f84e2a 100644
--- a/addons/mail/static/tests/document_viewer_tests.js
+++ b/addons/mail/static/tests/document_viewer_tests.js
@@ -32,7 +32,7 @@ var createViewer = function (params) {
return $.when();
}
};
- testUtils.addMockEnvironment(parent, {
+ testUtils.mock.addMockEnvironment(parent, {
mockRPC: function () {
if (params.mockRPC) {
var _super = this._super;
@@ -82,19 +82,19 @@ QUnit.module('DocumentViewer', {
attachments: this.attachments,
});
- assert.strictEqual(viewer.$('.o_viewer_content').length, 1,
+ assert.containsOnce(viewer, '.o_viewer_content',
"there should be a preview");
- assert.strictEqual(viewer.$('.o_close_btn').length, 1,
+ assert.containsOnce(viewer, '.o_close_btn',
"there should be a close button");
- assert.strictEqual(viewer.$('.o_viewer-header').length, 1,
+ assert.containsOnce(viewer, '.o_viewer-header',
"there should be a header");
- assert.strictEqual(viewer.$('.o_image_caption').length, 1,
+ assert.containsOnce(viewer, '.o_image_caption',
"there should be an image caption");
- assert.strictEqual(viewer.$('.o_viewer_zoomer').length, 1,
+ assert.containsOnce(viewer, '.o_viewer_zoomer',
"there should be a zoomer");
- assert.strictEqual(viewer.$('.fa-chevron-right').length, 1,
+ assert.containsOnce(viewer, '.fa-chevron-right',
"there should be a right nav icon");
- assert.strictEqual(viewer.$('.fa-chevron-left').length, 1,
+ assert.containsOnce(viewer, '.fa-chevron-left',
"there should be a left nav icon");
viewer.destroy();
@@ -120,14 +120,14 @@ QUnit.module('DocumentViewer', {
},
});
- assert.strictEqual(viewer.$('.o_page_number_input').length, 1,
+ assert.containsOnce(viewer, '.o_page_number_input',
"pdf should have a page input");
- assert.strictEqual(viewer.$('.o_remainder_input').length, 1,
+ assert.containsOnce(viewer, '.o_remainder_input',
"pdf should have a remainder checkbox");
- assert.strictEqual(viewer.$('.o_split_btn').length, 1,
+ assert.containsOnce(viewer, '.o_split_btn',
"pdf should have a split button");
- viewer.$('.o_split_btn').click();
+ testUtils.dom.click(viewer.$('.o_split_btn'));
assert.ok(viewer.isDestroyed(), 'viewer should be destroyed');
});
@@ -149,7 +149,7 @@ QUnit.module('DocumentViewer', {
assert.strictEqual(viewer.$(".o_image_caption:contains('urlYoutubeName')").length, 1,
"the viewer should be on the right attachment");
- assert.strictEqual(viewer.$('.o_viewer_text[data-src="' + youtubeURL + '"]').length, 1,
+ assert.containsOnce(viewer, '.o_viewer_text[data-src="' + youtubeURL + '"]',
"there should be a video player");
viewer.destroy();
@@ -165,7 +165,7 @@ QUnit.module('DocumentViewer', {
assert.strictEqual(viewer.$(".o_image_caption:contains('text.html')").length, 1,
"the viewer be on the right attachment");
- assert.strictEqual(viewer.$('iframe[data-src="/web/content/4"]').length, 1,
+ assert.containsOnce(viewer, 'iframe[data-src="/web/content/4"]',
"there should be an iframe with the right src");
viewer.destroy();
@@ -181,7 +181,7 @@ QUnit.module('DocumentViewer', {
assert.strictEqual(viewer.$(".o_image_caption:contains('video.mp4')").length, 1,
"the viewer be on the right attachment");
- assert.strictEqual(viewer.$('.o_viewer_video').length, 1,
+ assert.containsOnce(viewer, '.o_viewer_video',
"there should be a video player");
viewer.destroy();
@@ -197,7 +197,7 @@ QUnit.module('DocumentViewer', {
assert.strictEqual(viewer.$(".o_image_caption:contains('image.jpg')").length, 1,
"the viewer be on the right attachment");
- assert.strictEqual(viewer.$('img[data-src="/web/image/6?unique=1&signature=999"]').length, 1,
+ assert.containsOnce(viewer, 'img[data-src="/web/image/6?unique=1&signature=999"]',
"there should be a video player");
viewer.destroy();
@@ -211,12 +211,12 @@ QUnit.module('DocumentViewer', {
attachments: this.attachments,
});
- assert.strictEqual(viewer.$('.o_viewer_content').length, 1,
+ assert.containsOnce(viewer, '.o_viewer_content',
"should have a document viewer");
- assert.strictEqual(viewer.$('.o_close_btn').length, 1,
+ assert.containsOnce(viewer, '.o_close_btn',
"should have a close button");
- viewer.$('.o_close_btn').click();
+ testUtils.dom.click(viewer.$('.o_close_btn'));
assert.ok(viewer.isDestroyed(), 'viewer should be destroyed');
});
@@ -229,12 +229,12 @@ QUnit.module('DocumentViewer', {
attachments: this.attachments,
});
- assert.strictEqual(viewer.$('.o_viewer_content').length, 1,
+ assert.containsOnce(viewer, '.o_viewer_content',
"should have a document viewer");
- assert.strictEqual(viewer.$('.o_viewer_img_wrapper').length, 1,
+ assert.containsOnce(viewer, '.o_viewer_img_wrapper',
"should have a wrapper");
- viewer.$('.o_viewer_img_wrapper').click();
+ testUtils.dom.click(viewer.$('.o_viewer_img_wrapper'));
assert.ok(viewer.isDestroyed(), 'viewer should be destroyed');
});
diff --git a/addons/mail/static/tests/helpers/test_utils.js b/addons/mail/static/tests/helpers/test_utils.js
index f2c095a77b8..3b998a88b00 100644
--- a/addons/mail/static/tests/helpers/test_utils.js
+++ b/addons/mail/static/tests/helpers/test_utils.js
@@ -35,7 +35,7 @@ function createDiscuss(params) {
params.archs = params.archs || {
'mail.message,false,search': '<search/>',
};
- testUtils.addMockEnvironment(parent, params);
+ testUtils.mock.addMockEnvironment(parent, params);
var discuss = new Discuss(parent, params);
discuss.set_cp_bus(new Widget());
var selector = params.debug ? 'body' : '#qunit-fixture';
diff --git a/addons/mail/static/tests/systray/systray_activity_menu_tests.js b/addons/mail/static/tests/systray/systray_activity_menu_tests.js
index c666628624c..d9977822916 100644
--- a/addons/mail/static/tests/systray/systray_activity_menu_tests.js
+++ b/addons/mail/static/tests/systray/systray_activity_menu_tests.js
@@ -80,7 +80,7 @@ QUnit.test('activity menu widget: menu with no records', function (assert) {
assert.expect(1);
var activityMenu = new ActivityMenu();
- testUtils.addMockEnvironment(activityMenu, {
+ testUtils.mock.addMockEnvironment(activityMenu, {
services: this.services,
mockRPC: function (route, args) {
if (args.method === 'systray_get_activities') {
@@ -90,7 +90,7 @@ QUnit.test('activity menu widget: menu with no records', function (assert) {
},
});
activityMenu.appendTo($('#qunit-fixture'));
- assert.ok(activityMenu.$('.o_no_activity').hasClass('o_no_activity'), "should not have instance of widget");
+ assert.hasClass(activityMenu.$('.o_no_activity'),'o_no_activity', "should not have instance of widget");
activityMenu.destroy();
});
@@ -98,7 +98,7 @@ QUnit.test('activity menu widget: activity menu with 3 records', function (asser
assert.expect(10);
var self = this;
var activityMenu = new ActivityMenu();
- testUtils.addMockEnvironment(activityMenu, {
+ testUtils.mock.addMockEnvironment(activityMenu, {
services: this.services,
mockRPC: function (route, args) {
if (args.method === 'systray_get_activities') {
@@ -108,13 +108,14 @@ QUnit.test('activity menu widget: activity menu with 3 records', function (asser
},
});
activityMenu.appendTo($('#qunit-fixture'));
- assert.ok(activityMenu.$el.hasClass('o_mail_systray_item'), 'should be the instance of widget');
- assert.ok(activityMenu.$('.o_mail_preview').hasClass('o_mail_preview'), "should instance of widget");
- assert.ok(activityMenu.$('.o_notification_counter').hasClass('o_notification_counter'), "widget should have notification counter");
+ assert.hasClass(activityMenu.$el, 'o_mail_systray_item', 'should be the instance of widget');
+ // the assertion below has not been replace because there are includes of ActivityMenu that modify the length.
+ assert.ok(activityMenu.$('.o_mail_preview').length);
+ assert.containsOnce(activityMenu.$el, '.o_notification_counter', "widget should have notification counter");
assert.strictEqual(parseInt(activityMenu.el.innerText), 8, "widget should have 8 notification counter");
var context = {};
- testUtils.intercept(activityMenu, 'do_action', function (event) {
+ testUtils.mock.intercept(activityMenu, 'do_action', function (event) {
assert.deepEqual(event.data.action.context, context, "wrong context value");
}, true);
@@ -122,29 +123,29 @@ QUnit.test('activity menu widget: activity menu with 3 records', function (asser
context = {
search_default_activities_overdue: 1,
};
- activityMenu.$('.dropdown-toggle').click();
- assert.strictEqual(activityMenu.$el.hasClass("show"), true, 'ActivityMenu should be open');
- activityMenu.$(".o_activity_filter_button[data-model_name='Issue'][data-filter='overdue']").click();
- assert.strictEqual(activityMenu.$el.hasClass("show"), false, 'ActivityMenu should be closed');
+ testUtils.dom.click(activityMenu.$('.dropdown-toggle'));
+ assert.hasClass(activityMenu.$el, 'show', 'ActivityMenu should be open');
+ testUtils.dom.click(activityMenu.$(".o_activity_filter_button[data-model_name='Issue'][data-filter='overdue']"));
+ assert.doesNotHaveClass(activityMenu.$el, 'show', 'ActivityMenu should be closed');
// case 2: click on "today"
context = {
search_default_activities_today: 1,
};
- activityMenu.$('.dropdown-toggle').click();
- activityMenu.$(".o_activity_filter_button[data-model_name='Issue'][data-filter='today']").click();
+ testUtils.dom.click(activityMenu.$('.dropdown-toggle'));
+ testUtils.dom.click(activityMenu.$(".o_activity_filter_button[data-model_name='Issue'][data-filter='today']"));
// case 3: click on "future"
context = {
search_default_activities_upcoming_all: 1,
};
- activityMenu.$('.dropdown-toggle').click();
- activityMenu.$(".o_activity_filter_button[data-model_name='Issue'][data-filter='upcoming_all']").click();
+ testUtils.dom.click(activityMenu.$('.dropdown-toggle'));
+ testUtils.dom.click(activityMenu.$(".o_activity_filter_button[data-model_name='Issue'][data-filter='upcoming_all']"));
// case 4: click anywere else
context = {
search_default_activities_overdue: 1,
search_default_activities_today: 1,
};
- activityMenu.$('.dropdown-toggle').click();
- activityMenu.$(".o_mail_systray_dropdown_items > div[data-model_name='Issue']").click();
+ testUtils.dom.click(activityMenu.$('.dropdown-toggle'));
+ testUtils.dom.click(activityMenu.$(".o_mail_systray_dropdown_items > div[data-model_name='Issue']"));
activityMenu.destroy();
});
@@ -153,7 +154,7 @@ QUnit.test('activity menu widget: activity view icon', function (assert) {
assert.expect(8);
var self = this;
var activityMenu = new ActivityMenu();
- testUtils.addMockEnvironment(activityMenu, {
+ testUtils.mock.addMockEnvironment(activityMenu, {
services: this.services,
mockRPC: function (route, args) {
if (args.method === 'systray_get_activities') {
@@ -163,31 +164,30 @@ QUnit.test('activity menu widget: activity view icon', function (assert) {
},
});
activityMenu.appendTo($('#qunit-fixture'));
- assert.strictEqual(activityMenu.$('.o_mail_activity_action').length, 2,
+ assert.containsN(activityMenu, '.o_mail_activity_action', 2,
"widget should have 2 activity view icons");
var $first = activityMenu.$('.o_mail_activity_action').eq(0);
var $second = activityMenu.$('.o_mail_activity_action').eq(1);
assert.strictEqual($first.data('model_name'), "Issue",
"first activity action should link to 'Issue'");
- assert.ok($first.hasClass('fa-clock-o'), "should display the activity action icon");
+ assert.hasClass($first,'fa-clock-o', "should display the activity action icon");
assert.strictEqual($second.data('model_name'), "Note",
"Second activity action should link to 'Note'");
- assert.ok($second.hasClass('fa-clock-o'), "should display the activity action icon");
+ assert.hasClass($second,'fa-clock-o', "should display the activity action icon");
- testUtils.intercept(activityMenu, 'do_action', function (event) {
+ testUtils.mock.intercept(activityMenu, 'do_action', function (event) {
assert.step('do_action:' +
(event.data.action.name ? event.data.action.name : event.data.action));
}, true);
// click on the "Issue" activity icon
- activityMenu.$('.dropdown-toggle').click();
- activityMenu.$(".o_mail_activity_action[data-model_name='Issue']").click();
+ testUtils.dom.click(activityMenu.$('.dropdown-toggle'));
+ testUtils.dom.click(activityMenu.$(".o_mail_activity_action[data-model_name='Issue']"));
// click on the "Note" activity icon
- activityMenu.$('.dropdown-toggle').click();
- activityMenu.$(".o_mail_activity_action[data-model_name='Note']").click();
+ testUtils.dom.click(activityMenu.$(".o_mail_activity_action[data-model_name='Note']"));
assert.verifySteps([
'do_action:Issue',
diff --git a/addons/mail/static/tests/systray/systray_messaging_menu_mail_failure_tests.js b/addons/mail/static/tests/systray/systray_messaging_menu_mail_failure_tests.js
index c1fc1bd8dae..c03259697cd 100644
--- a/addons/mail/static/tests/systray/systray_messaging_menu_mail_failure_tests.js
+++ b/addons/mail/static/tests/systray/systray_messaging_menu_mail_failure_tests.js
@@ -82,14 +82,14 @@ QUnit.test('preview of mail failure', function (assert) {
}];
var messagingMenu = new MessagingMenu();
- testUtils.addMockEnvironment(messagingMenu, {
+ testUtils.mock.addMockEnvironment(messagingMenu, {
data: this.data,
services: this.services,
});
messagingMenu.appendTo($('#qunit-fixture'));
- messagingMenu.$('.dropdown-toggle').click();
+ testUtils.dom.click(messagingMenu.$('.dropdown-toggle'));
- assert.strictEqual(messagingMenu.$('.o_mail_preview').length, 1,
+ assert.containsOnce(messagingMenu, '.o_mail_preview',
"should display one preview for the mail failure");
assert.strictEqual(messagingMenu.$('.o_mail_preview').data('document-model'), 'mail.channel',
"preview should link to correct document model");
@@ -138,14 +138,14 @@ QUnit.test('preview grouped failures by document', function (assert) {
}];
var messagingMenu = new MessagingMenu();
- testUtils.addMockEnvironment(messagingMenu, {
+ testUtils.mock.addMockEnvironment(messagingMenu, {
data: this.data,
services: this.services,
});
messagingMenu.appendTo($('#qunit-fixture'));
- messagingMenu.$('.dropdown-toggle').click();
+ testUtils.dom.click(messagingMenu.$('.dropdown-toggle'));
- assert.strictEqual(messagingMenu.$('.o_mail_preview').length, 2,
+ assert.containsN(messagingMenu, '.o_mail_preview', 2,
"should have a two messaging previews for the mail failures");
var $channelPreview = messagingMenu.$('.o_mail_preview[data-document-model="mail.channel"]');
assert.strictEqual($channelPreview.data('document-id'), 100,
@@ -194,14 +194,14 @@ QUnit.test('preview grouped failures by document model', function (assert) {
}];
var messagingMenu = new MessagingMenu();
- testUtils.addMockEnvironment(messagingMenu, {
+ testUtils.mock.addMockEnvironment(messagingMenu, {
data: this.data,
services: this.services,
});
messagingMenu.appendTo($('#qunit-fixture'));
- messagingMenu.$('.dropdown-toggle').click();
+ testUtils.dom.click(messagingMenu.$('.dropdown-toggle'));
- assert.strictEqual(messagingMenu.$('.o_mail_preview').length, 2,
+ assert.containsN(messagingMenu, '.o_mail_preview', 2,
"should have a two messaging previews for the mail failures");
var $channelPreview = messagingMenu.$('.o_mail_preview[data-document-model="mail.channel"]');
assert.notOk($channelPreview.data('document-id'),
diff --git a/addons/mail/static/tests/systray/systray_messaging_menu_tests.js b/addons/mail/static/tests/systray/systray_messaging_menu_tests.js
index 1b608f5c37b..a1633ada574 100644
--- a/addons/mail/static/tests/systray/systray_messaging_menu_tests.js
+++ b/addons/mail/static/tests/systray/systray_messaging_menu_tests.js
@@ -105,7 +105,7 @@ QUnit.test('messaging menu widget: menu with no records', function (assert) {
assert.expect(1);
var messagingMenu = new MessagingMenu();
- testUtils.addMockEnvironment(messagingMenu, {
+ testUtils.mock.addMockEnvironment(messagingMenu, {
services: this.services,
mockRPC: function (route, args) {
if (args.method === 'message_fetch') {
@@ -115,23 +115,23 @@ QUnit.test('messaging menu widget: menu with no records', function (assert) {
}
});
messagingMenu.appendTo($('#qunit-fixture'));
- messagingMenu.$('.dropdown-toggle').click();
- assert.ok(messagingMenu.$('.o_no_activity').hasClass('o_no_activity'), "should not have instance of widget");
+ testUtils.dom.click(messagingMenu.$('.dropdown-toggle'));
+ assert.hasClass(messagingMenu.$('.o_no_activity'),'o_no_activity', "should not have instance of widget");
messagingMenu.destroy();
});
QUnit.test('messaging menu widget: messaging menu with 1 record', function (assert) {
assert.expect(3);
var messagingMenu = new MessagingMenu();
- testUtils.addMockEnvironment(messagingMenu, {
+ testUtils.mock.addMockEnvironment(messagingMenu, {
services: this.services,
data: this.data,
});
messagingMenu.appendTo($('#qunit-fixture'));
- messagingMenu.$('.dropdown-toggle').click();
+ testUtils.dom.click(messagingMenu.$('.dropdown-toggle'));
- assert.strictEqual(messagingMenu.$('.o_mail_preview').length, 1,
+ assert.containsOnce(messagingMenu, '.o_mail_preview',
"should display a preview");
assert.strictEqual(messagingMenu.$('.o_preview_name').text().trim(), "general",
"should display correct name of channel in preview");
@@ -150,7 +150,7 @@ QUnit.test('messaging menu widget: open inbox for needaction not linked to any d
assert.expect(4);
var messagingMenu = new MessagingMenu();
- testUtils.addMockEnvironment(messagingMenu, {
+ testUtils.mock.addMockEnvironment(messagingMenu, {
services: this.services,
data: this.data,
session: {
@@ -174,7 +174,7 @@ QUnit.test('messaging menu widget: open inbox for needaction not linked to any d
messagingMenu.call('bus_service', 'trigger', 'notification', notifications);
// Open messaging menu
- messagingMenu.$('.dropdown-toggle').click();
+ testUtils.dom.click(messagingMenu.$('.dropdown-toggle'));
var $firstChannelPreview =
messagingMenu.$('.o_mail_preview').first();
@@ -185,12 +185,12 @@ QUnit.test('messaging menu widget: open inbox for needaction not linked to any d
'mailbox_inbox',
"should be a preview from channel inbox");
- testUtils.intercept(messagingMenu, 'do_action', function (ev) {
+ testUtils.mock.intercept(messagingMenu, 'do_action', function (ev) {
if (ev.data.action === 'mail.action_discuss') {
assert.step('do_action:' + ev.data.action + ':' + ev.data.options.active_id);
}
}, true);
- $firstChannelPreview.click();
+ testUtils.dom.click($firstChannelPreview);
assert.verifySteps(
['do_action:mail.action_discuss:mailbox_inbox'],
"should open Discuss with Inbox");
@@ -201,7 +201,7 @@ QUnit.test('messaging menu widget: open inbox for needaction not linked to any d
QUnit.test("messaging menu widget: mark as read on thread preview", function ( assert ) {
assert.expect(8);
- testUtils.patch(DocumentThread, {
+ testUtils.mock.patch(DocumentThread, {
markAsRead: function () {
if (
this.getDocumentModel() === 'crm.lead' &&
@@ -225,16 +225,16 @@ QUnit.test("messaging menu widget: mark as read on thread preview", function ( a
}];
var messagingMenu = new MessagingMenu();
- testUtils.addMockEnvironment(messagingMenu, {
+ testUtils.mock.addMockEnvironment(messagingMenu, {
services: this.services,
data: this.data,
});
messagingMenu.appendTo($('#qunit-fixture'));
- messagingMenu.$('.dropdown-toggle').click();
- assert.ok(messagingMenu.$el.hasClass('o_mail_systray_item'),
+ testUtils.dom.click(messagingMenu.$('.dropdown-toggle'));
+ assert.hasClass(messagingMenu.$el,'o_mail_systray_item',
'should be the instance of widget');
- assert.ok(messagingMenu.$el.hasClass('show'),
+ assert.hasClass(messagingMenu.$el,'show',
'MessagingMenu should be open');
var $preview = messagingMenu.$('.o_mail_preview.o_preview_unread');
@@ -244,15 +244,15 @@ QUnit.test("messaging menu widget: mark as read on thread preview", function ( a
"should preview be linked to correct document model");
assert.strictEqual($preview.data('document-id'), 126,
"should preview be linked to correct document ID");
- assert.strictEqual(messagingMenu.$('.o_mail_preview_mark_as_read').length, 1,
+ assert.containsOnce(messagingMenu, '.o_mail_preview_mark_as_read',
"should have mark as read icon next to preview");
- messagingMenu.$(".o_mail_preview_mark_as_read").click();
+ testUtils.dom.click(messagingMenu.$(".o_mail_preview_mark_as_read"));
assert.verifySteps(['markedAsRead'],
"the document thread should be marked as read");
- testUtils.unpatch(DocumentThread);
+ testUtils.mock.unpatch(DocumentThread);
messagingMenu.destroy();
});
@@ -288,7 +288,7 @@ QUnit.test('needaction messages in channels should appear, in addition to channe
this.data['mail.message'].records = [needactionMessage, lastMessage];
var messagingMenu = new MessagingMenu();
- testUtils.addMockEnvironment(messagingMenu, {
+ testUtils.mock.addMockEnvironment(messagingMenu, {
services: this.services,
data: this.data,
session: {
@@ -297,9 +297,9 @@ QUnit.test('needaction messages in channels should appear, in addition to channe
});
messagingMenu.appendTo($('#qunit-fixture'));
- messagingMenu.$('.dropdown-toggle').click();
+ testUtils.dom.click(messagingMenu.$('.dropdown-toggle'));
- assert.strictEqual(messagingMenu.$('.o_mail_preview').length, 2,
+ assert.containsN(messagingMenu, '.o_mail_preview', 2,
"should display two previews");
var $preview1 = messagingMenu.$('.o_mail_preview').eq(0);
var $preview2 = messagingMenu.$('.o_mail_preview').eq(1);
@@ -344,7 +344,7 @@ QUnit.test('preview of message on a document + mark as read', function (assert)
this.data['mail.message'].records.push(needactionMessage);
var messagingMenu = new MessagingMenu();
- testUtils.addMockEnvironment(messagingMenu, {
+ testUtils.mock.addMockEnvironment(messagingMenu, {
services: this.services,
data: this.data,
session: {
@@ -355,22 +355,22 @@ QUnit.test('preview of message on a document + mark as read', function (assert)
assert.strictEqual(messagingMenu.$('.o_notification_counter').text(), '1',
"should display a counter of 1 on the messaging menu icon");
- messagingMenu.$('.dropdown-toggle').click();
+ testUtils.dom.click(messagingMenu.$('.dropdown-toggle'));
- assert.strictEqual(messagingMenu.$('.o_mail_preview').length, 1,
+ assert.containsOnce(messagingMenu, '.o_mail_preview',
"should display one preview");
assert.strictEqual(messagingMenu.$('.o_mail_preview').data('preview-id'),
"some.res.model_1",
"preview should be the document thread preview");
- assert.ok(messagingMenu.$('.o_mail_preview:first').hasClass('o_preview_unread'),
+ assert.hasClass(messagingMenu.$('.o_mail_preview:first'),'o_preview_unread',
"document thread preview should be marked as unread");
assert.strictEqual(messagingMenu.$('.o_preview_unread .o_last_message_preview').text().replace(/\s/g, ''),
"Demo:*MessageOnDocument*", "should correctly display the preview");
- messagingMenu.$('.o_mail_preview_mark_as_read').click();
+ testUtils.dom.click(messagingMenu.$('.o_mail_preview_mark_as_read'));
assert.strictEqual(messagingMenu.$('.o_notification_counter').text(), '0',
"should display a counter of 0 on the messaging menu icon");
- assert.strictEqual(messagingMenu.$('.o_mail_preview').length, 0,
+ assert.containsNone(messagingMenu, '.o_mail_preview',
"should not display any preview");
messagingMenu.destroy();
@@ -380,15 +380,15 @@ QUnit.test('update messaging preview on receiving a new message in channel previ
assert.expect(8);
var messagingMenu = new MessagingMenu();
- testUtils.addMockEnvironment(messagingMenu, {
+ testUtils.mock.addMockEnvironment(messagingMenu, {
services: this.services,
data: this.data,
});
messagingMenu.appendTo($('#qunit-fixture'));
- messagingMenu.$('.dropdown-toggle').click();
+ testUtils.dom.click(messagingMenu.$('.dropdown-toggle'));
- assert.strictEqual(messagingMenu.$('.o_mail_preview').length, 1,
+ assert.containsOnce(messagingMenu, '.o_mail_preview',
"should display a single channel preview");
assert.strictEqual(messagingMenu.$('.o_preview_name').text().trim(), "general",
"should display channel preview of 'general' channel");
@@ -411,7 +411,7 @@ QUnit.test('update messaging preview on receiving a new message in channel previ
var notification = [[false, 'mail.channel', 1], data];
messagingMenu.call('bus_service', 'trigger', 'notification', [notification]);
- assert.strictEqual(messagingMenu.$('.o_mail_preview').length, 1,
+ assert.containsOnce(messagingMenu, '.o_mail_preview',
"should still display a single channel preview");
assert.strictEqual(messagingMenu.$('.o_preview_name').text().trim(), "general",
"should still display channel preview of 'general' channel");
@@ -451,7 +451,7 @@ QUnit.test('preview of inbox message not linked to document + mark as read', fun
this.data['mail.message'].records.concat(needactionMessages);
var messagingMenu = new MessagingMenu();
- testUtils.addMockEnvironment(messagingMenu, {
+ testUtils.mock.addMockEnvironment(messagingMenu, {
services: this.services,
data: this.data,
session: {
@@ -554,7 +554,7 @@ QUnit.test('grouped preview for needaction messages linked to same document', fu
this.data.initMessaging.needaction_inbox_counter = 2;
var messagingMenu = new MessagingMenu();
- testUtils.addMockEnvironment(messagingMenu, {
+ testUtils.mock.addMockEnvironment(messagingMenu, {
services: this.services,
data: this.data,
session: {
diff --git a/addons/mail/static/tests/thread_window/basic_thread_window_tests.js b/addons/mail/static/tests/thread_window/basic_thread_window_tests.js
index 4b8935e81cf..b820972bef8 100644
--- a/addons/mail/static/tests/thread_window/basic_thread_window_tests.js
+++ b/addons/mail/static/tests/thread_window/basic_thread_window_tests.js
@@ -44,7 +44,7 @@ QUnit.module('Basic', {
self.services.mail_service.prototype.THREAD_WINDOW_APPENDTO = '#qunit-fixture';
}
- testUtils.addMockEnvironment(widget, params);
+ testUtils.mock.addMockEnvironment(widget, params);
return widget;
};
},
@@ -121,7 +121,7 @@ QUnit.test('close thread window using ESCAPE key', function (assert) {
"there should be a thread window that is opened");
// focus on the thread window and press ESCAPE
- $('.o_thread_window .o_composer_text_field').click();
+ testUtils.dom.click($('.o_thread_window .o_composer_text_field'));
assert.strictEqual(document.activeElement,
$('.o_thread_window .o_composer_text_field')[0],
"thread window's input should now be focused");
@@ -150,7 +150,7 @@ QUnit.test('thread window\'s input can still be focused when the UI is blocked',
channel.detach();
var $input = $('<input/>', {type: 'text'}).appendTo($dom);
- $input.focus().click();
+ testUtils.dom.click($input.focus());
assert.strictEqual(document.activeElement, $input[0],
"fake input should be focused");
@@ -159,7 +159,7 @@ QUnit.test('thread window\'s input can still be focused when the UI is blocked',
// makes no sense, this test is just about
// making sure that the code which forces the
// focus on click is not removed
- $('.o_thread_window .o_composer_text_field').click();
+ testUtils.dom.click($('.o_thread_window .o_composer_text_field'));
assert.strictEqual(document.activeElement,
$('.o_thread_window .o_composer_text_field')[0],
"thread window's input should now be focused");
@@ -181,7 +181,7 @@ QUnit.test('emoji popover should open correctly in thread windows', function (as
channel.detach();
var $emojiButton = $('.o_composer_button_emoji');
- $emojiButton.trigger('focusin').focus().click();
+ testUtils.dom.click($emojiButton.trigger('focusin').focus());
var $popover = $('.o_mail_emoji_container');
var done = assert.async();
@@ -254,7 +254,7 @@ QUnit.test('do not increment unread counter with focus on thread window', functi
"thread should have unread counter to 0 initially");
// hard focus on thread window composer
- $('.o_composer_text_field').click();
+ testUtils.dom.click($('.o_composer_text_field'));
// simulate receiving message from someone else
var messageData = {
@@ -346,7 +346,7 @@ QUnit.test('do not mark as read the newly open thread window from received messa
assert.strictEqual($threadWindow.find('.o_thread_window_title').text().replace(/\s/g, ''), '#DM(1)',
"open DM chat window should have one unread message");
- $threadWindow.find('.o_thread_composer').click();
+ testUtils.dom.click($threadWindow.find('.o_thread_composer'));
assert.strictEqual($threadWindow.find('.o_thread_window_title').text().replace(/\s/g, ''), '#DM',
"open DM chat window should have message marked as read on composer focus");
diff --git a/addons/mail/static/tests/thread_window/blank_thread_window_tests.js b/addons/mail/static/tests/thread_window/blank_thread_window_tests.js
index 883494a4ec6..0f3c7c7bbe7 100644
--- a/addons/mail/static/tests/thread_window/blank_thread_window_tests.js
+++ b/addons/mail/static/tests/thread_window/blank_thread_window_tests.js
@@ -44,7 +44,7 @@ QUnit.module('Blank', {
self.services.mail_service.prototype.THREAD_WINDOW_APPENDTO = '#qunit-fixture';
}
- testUtils.addMockEnvironment(widget, params);
+ testUtils.mock.addMockEnvironment(widget, params);
return widget;
};
@@ -125,7 +125,7 @@ QUnit.test('close blank thread window', function (assert) {
// open blank thread window
parent.call('mail_service', 'openBlankThreadWindow');
- $('.o_thread_window_close').click();
+ testUtils.dom.click($('.o_thread_window_close'));
assert.strictEqual($('.o_thread_window').length, 0,
"blank thread window should be closed");
@@ -147,7 +147,7 @@ QUnit.test('fold blank thread window', function (assert) {
var HEIGHT_OPEN = AbstractThreadWindow.prototype.HEIGHT_OPEN;
// Make fold animation instantaneous
- testUtils.patch(AbstractThreadWindow, {
+ testUtils.mock.patch(AbstractThreadWindow, {
FOLD_ANIMATION_DURATION: 0,
});
@@ -159,12 +159,12 @@ QUnit.test('fold blank thread window', function (assert) {
console.warn('Assertion above may fail due to too narrow height of browser');
}
- $('.o_thread_window_title').click();
+ testUtils.dom.click($('.o_thread_window_title'));
assert.strictEqual($('.o_thread_window').css('height'), HEIGHT_FOLDED,
"blank thread window should be open");
parent.destroy();
- testUtils.unpatch(AbstractThreadWindow);
+ testUtils.mock.unpatch(AbstractThreadWindow);
});
QUnit.test('open new DM chat from blank thread window', function (assert) {
@@ -224,7 +224,7 @@ QUnit.test('open new DM chat from blank thread window', function (assert) {
assert.strictEqual($('.ui-menu-item a').eq(1).text(), "DemoUser2",
"second suggestion should be 'DemoUser2'");
- $('.ui-menu-item a').eq(0).click();
+ testUtils.dom.click($('.ui-menu-item a').eq(0));
});
selectDef.then(function () {
assert.strictEqual($('.o_thread_window').length, 1,
@@ -299,7 +299,7 @@ QUnit.test('open already detached DM chat from blank thread window', function (a
$('.o_thread_search_input input').val("D").trigger('keydown');
$.when(sourceDef, def).then(function () {
- $('.ui-menu-item a').eq(0).click();
+ testUtils.dom.click($('.ui-menu-item a').eq(0));
});
selectDef.then(function () {
assert.strictEqual($('.o_thread_window').length, 1,
diff --git a/addons/mail/static/tests/thread_window/hidden_thread_window_tests.js b/addons/mail/static/tests/thread_window/hidden_thread_window_tests.js
index 29e05c59da9..b87dbe0f794 100644
--- a/addons/mail/static/tests/thread_window/hidden_thread_window_tests.js
+++ b/addons/mail/static/tests/thread_window/hidden_thread_window_tests.js
@@ -43,7 +43,7 @@ QUnit.module('Hidden', {
self.services.mail_service.prototype.THREAD_WINDOW_APPENDTO = '#qunit-fixture';
}
- testUtils.addMockEnvironment(widget, params);
+ testUtils.mock.addMockEnvironment(widget, params);
return widget;
};
},
@@ -62,7 +62,7 @@ QUnit.test('hidden thread windows dropdown when not enough horizontal space (ver
// single thread window.
assert.expect(13);
- testUtils.patch(this.services.mail_service, {
+ testUtils.mock.patch(this.services.mail_service, {
HIDDEN_THREAD_WINDOW_DROPDOWN_BUTTON_WIDTH: 100,
THREAD_WINDOW_WIDTH: 300,
_getGlobalWidth: function () { return 800; },
@@ -128,7 +128,7 @@ QUnit.test('hidden thread windows dropdown when not enough horizontal space (ver
1, "should contain thread window with ID 1 in hidden dropdown menu");
parent.destroy();
- testUtils.unpatch(this.services.mail_service);
+ testUtils.mock.unpatch(this.services.mail_service);
});
QUnit.test('hidden thread windows dropdown when not enough horizontal space (version 2)', function (assert) {
@@ -146,7 +146,7 @@ QUnit.test('hidden thread windows dropdown when not enough horizontal space (ver
// With button: 2 thread windows (2*250px + 100px = 600px < 800px)
assert.expect(16);
- testUtils.patch(this.services.mail_service, {
+ testUtils.mock.patch(this.services.mail_service, {
HIDDEN_THREAD_WINDOW_DROPDOWN_BUTTON_WIDTH: 100,
THREAD_WINDOW_WIDTH: 250,
_getGlobalWidth: function () { return 800; },
@@ -219,7 +219,7 @@ QUnit.test('hidden thread windows dropdown when not enough horizontal space (ver
1, "should contain thread window with ID 2 in hidden dropdown menu");
parent.destroy();
- testUtils.unpatch(this.services.mail_service);
+ testUtils.mock.unpatch(this.services.mail_service);
});
});
diff --git a/addons/mail/static/tests/thread_window/moderation_thread_window_tests.js b/addons/mail/static/tests/thread_window/moderation_thread_window_tests.js
index 4a8cc9e2af0..b35405a2243 100644
--- a/addons/mail/static/tests/thread_window/moderation_thread_window_tests.js
+++ b/addons/mail/static/tests/thread_window/moderation_thread_window_tests.js
@@ -74,7 +74,7 @@ QUnit.module('Moderation', {
self.services.mail_service.prototype.THREAD_WINDOW_APPENDTO = '#qunit-fixture';
}
- testUtils.addMockEnvironment(widget, params);
+ testUtils.mock.addMockEnvironment(widget, params);
return widget;
};
},
diff --git a/addons/mail/static/tests/tools/debug_manager_tests.js b/addons/mail/static/tests/tools/debug_manager_tests.js
index 71314e244fc..fa7aecd40d1 100644
--- a/addons/mail/static/tests/tools/debug_manager_tests.js
+++ b/addons/mail/static/tests/tools/debug_manager_tests.js
@@ -49,7 +49,9 @@ QUnit.module('Mail DebugManager', {}, function () {
assert.strictEqual($messageMenu.length, 1, "should have Manage Message menu item");
assert.strictEqual($messageMenu.text().trim(), "Manage Messages",
"should have correct menu item text");
- $messageMenu.click();
+
+ testUtils.dom.click(debugManager.$('> a')); // open dropdown
+ testUtils.dom.click($messageMenu);
debugManager.destroy();
});