summaryrefslogtreecommitdiff
path: root/addons/note/static
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2018-11-19 08:18:28 +0000
committerAaron Bohy <aab@odoo.com>2018-11-19 11:24:28 +0000
commitabf32b8b21394491040e5c11c1fea809c1d7c62c (patch)
tree6058f8a893815bf0ed2495649c125523f4def762 /addons/note/static
parentbcbb7ee3fecaad3c7e801fa5dbc90a566faac27f (diff)
[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.strictEqual(form.$('.o_form_editable'), 1, "msg"); -> assert.containsOnce(form, '.o_form_editable'); * 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). ex: assert.notOk(form.$('button').hasClass('btn-primary')); -> assert.doesNotHaveClass(form.$('button'), 'btn-primary'); 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.
Diffstat (limited to 'addons/note/static')
-rw-r--r--addons/note/static/tests/systray_activity_menu_tests.js34
1 files changed, 17 insertions, 17 deletions
diff --git a/addons/note/static/tests/systray_activity_menu_tests.js b/addons/note/static/tests/systray_activity_menu_tests.js
index 81b2c5ac198..8c4e2dde60a 100644
--- a/addons/note/static/tests/systray_activity_menu_tests.js
+++ b/addons/note/static/tests/systray_activity_menu_tests.js
@@ -38,7 +38,7 @@ QUnit.test('note activity menu widget: create note from activity menu', function
assert.expect(15);
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') {
@@ -72,52 +72,52 @@ QUnit.test('note activity menu widget: create note from activity menu', function
},
});
activityMenu.appendTo($('#qunit-fixture'));
- assert.ok(activityMenu.$el.hasClass('o_mail_systray_item'),
+ assert.hasClass(activityMenu.$el,'o_mail_systray_item',
'should be the instance of widget');
assert.strictEqual(activityMenu.$('.o_notification_counter').text(), '0',
"should not have any activity notification initially");
// toggle quick create for note
- activityMenu.$('.dropdown-toggle').click();
- assert.strictEqual(activityMenu.$('.o_no_activity').length, 1,
+ testUtils.dom.click(activityMenu.$('.dropdown-toggle'));
+ assert.containsOnce(activityMenu, '.o_no_activity',
"should not have any activity preview");
- assert.strictEqual(activityMenu.$('.o_note_show').hasClass('d-none'), false,
+ assert.doesNotHaveClass(activityMenu.$('.o_note_show'), 'd-none',
'ActivityMenu should have Add new note CTA');
- activityMenu.$('.o_note_show').click();
- assert.strictEqual(activityMenu.$('.o_note_show').hasClass('d-none'), true,
+ testUtils.dom.click(activityMenu.$('.o_note_show'));
+ assert.hasClass(activityMenu.$('.o_note_show'), 'd-none',
'ActivityMenu should hide CTA when entering a new note');
- assert.strictEqual(activityMenu.$('.o_note').hasClass('d-none'), false,
+ assert.doesNotHaveClass(activityMenu.$('.o_note'), 'd-none',
'ActivityMenu should display input for new note');
// creating quick note without date
activityMenu.$("input.o_note_input").val("New Note");
- activityMenu.$(".o_note_save").click();
+ testUtils.dom.click(activityMenu.$(".o_note_save"));
assert.strictEqual(activityMenu.$('.o_notification_counter').text(), '1',
"should increment activity notification counter after creating a note");
- assert.strictEqual(activityMenu.$('.o_mail_preview[data-res_model="note.note"]').length, 1,
+ assert.containsOnce(activityMenu, '.o_mail_preview[data-res_model="note.note"]',
"should have an activity preview that is a note");
assert.strictEqual(activityMenu.$('.o_activity_filter_button[data-filter="today"]').text().trim(),
"1 Today",
"should display one note for today");
- assert.strictEqual(activityMenu.$('.o_note_show').hasClass('d-none'), false,
+ assert.doesNotHaveClass(activityMenu.$('.o_note_show'), 'd-none',
'ActivityMenu add note button should be displayed');
- assert.strictEqual(activityMenu.$('.o_note').hasClass('d-none'), true,
+ assert.hasClass(activityMenu.$('.o_note'), 'd-none',
'ActivityMenu add note input should be hidden');
// creating quick note with date
- activityMenu.$('.o_note_show').click();
+ testUtils.dom.click(activityMenu.$('.o_note_show'));
activityMenu.$('input.o_note_input').val("New Note");
- activityMenu.$('.o_note_set_datetime').click();
- activityMenu.$(".o_note_save").click();
+ testUtils.dom.click(activityMenu.$('.o_note_set_datetime'));
+ testUtils.dom.click(activityMenu.$(".o_note_save"));
assert.strictEqual(activityMenu.$('.o_notification_counter').text(), '2',
"should increment activity notification counter after creating a second note");
assert.strictEqual(activityMenu.$('.o_activity_filter_button[data-filter="today"]').text().trim(),
"2 Today",
"should display 2 notes for today");
- assert.strictEqual(activityMenu.$('.o_note_show').hasClass('d-none'), false,
+ assert.doesNotHaveClass(activityMenu.$('.o_note_show'), 'd-none',
'ActivityMenu add note button should be displayed');
- assert.strictEqual(activityMenu.$('.o_note').hasClass('d-none'), true,
+ assert.hasClass(activityMenu.$('.o_note'), 'd-none',
'ActivityMenu add note input should be hidden');
activityMenu.destroy();
});