mirror of
https://github.com/bringout/oca-ocb-technical.git
synced 2026-04-18 17:12:06 +02:00
Initial commit: Technical packages
This commit is contained in:
commit
3473fa71a0
873 changed files with 297766 additions and 0 deletions
|
|
@ -0,0 +1,77 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
// ensure mail override is applied first.
|
||||
import '@mail/../tests/helpers/mock_server';
|
||||
|
||||
import { patch } from '@web/core/utils/patch';
|
||||
import { MockServer } from '@web/../tests/helpers/mock_server';
|
||||
|
||||
import { date_to_str } from 'web.time';
|
||||
|
||||
patch(MockServer.prototype, 'note', {
|
||||
//--------------------------------------------------------------------------
|
||||
// Private
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
async _performRPC(route, args) {
|
||||
if (route === '/note/new') {
|
||||
return this._mockRouteNoteNew(args);
|
||||
}
|
||||
return this._super(...arguments);
|
||||
},
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Private Mocked Routes
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Simulates the `/note/new` route.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
_mockRouteNoteNew(values) {
|
||||
const noteId = this.pyEnv['note.note'].create({ memo: values['note'] });
|
||||
if (values['date_deadline']) {
|
||||
this.pyEnv['mail.activity'].create({
|
||||
date_deadline: date_to_str(new Date(values['date_deadline'])),
|
||||
note_id: noteId,
|
||||
res_model: 'note.note',
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Private Mocked Methods
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Simulates `systray_get_activities` on `res.users`.
|
||||
*
|
||||
* @override
|
||||
*/
|
||||
_mockResUsersSystrayGetActivities() {
|
||||
const activities = this._super(...arguments);
|
||||
const noteCount = this.pyEnv['note.note'].searchCount([['user_id', '=', this.currentUserId]]);
|
||||
if (noteCount) {
|
||||
const noteIndex = activities.findIndex(act => act['model'] === 'note.note');
|
||||
if (noteIndex) {
|
||||
activities[noteIndex]['name'] = 'Notes';
|
||||
} else {
|
||||
activities.push({
|
||||
id: 'note.note', // for simplicity
|
||||
type: 'activity',
|
||||
name: 'Notes',
|
||||
model: 'note.note',
|
||||
planned_count: 0,
|
||||
today_count: 0,
|
||||
overdue_count: 0,
|
||||
total_count: 0,
|
||||
});
|
||||
}
|
||||
}
|
||||
return activities;
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import { addModelNamesToFetch } from '@bus/../tests/helpers/model_definitions_helpers';
|
||||
|
||||
addModelNamesToFetch(['note.note']);
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import { start } from '@mail/../tests/helpers/test_utils';
|
||||
|
||||
import testUtils from 'web.test_utils';
|
||||
|
||||
QUnit.module('note', {}, function () {
|
||||
QUnit.module("ActivityMenu");
|
||||
|
||||
QUnit.test('note activity menu widget: create note from activity menu', async function (assert) {
|
||||
assert.expect(15);
|
||||
|
||||
const { click } = await start();
|
||||
assert.containsOnce(document.body, '.o_ActivityMenuView',
|
||||
'should contain an instance of widget');
|
||||
assert.containsNone(document.body, '.o_ActivityMenuView_counter',
|
||||
"should not have any activity notification initially");
|
||||
|
||||
// toggle quick create for note
|
||||
await click('.dropdown-toggle[title="Activities"]');
|
||||
assert.containsOnce(document.body, '.o_ActivityMenuView_noActivity',
|
||||
"should not have any activity preview");
|
||||
assert.containsOnce(document.body, '.o_note_show',
|
||||
'ActivityMenu should have Add new note CTA');
|
||||
await click('.o_note_show');
|
||||
assert.containsNone(document.body, '.o_note_show',
|
||||
'ActivityMenu should hide CTA when entering a new note');
|
||||
assert.containsOnce(document.body, '.o_note',
|
||||
'ActivityMenu should display input for new note');
|
||||
|
||||
// creating quick note without date
|
||||
await testUtils.fields.editInput(document.querySelector("input.o_note_input"), "New Note");
|
||||
await click('.o_note_save');
|
||||
assert.strictEqual(document.querySelector('.o_ActivityMenuView_counter').innerText, '1',
|
||||
"should increment activity notification counter after creating a note");
|
||||
assert.containsOnce(document.body, '.o_ActivityMenuView_activityGroup[data-res_model="note.note"]',
|
||||
"should have an activity preview that is a note");
|
||||
assert.strictEqual(document.querySelector('.o_ActivityMenuView_activityGroupFilterButton[data-filter="today"]').innerText.trim(),
|
||||
"1 Today",
|
||||
"should display one note for today");
|
||||
|
||||
assert.doesNotHaveClass(document.querySelector('.o_note_show'), 'd-none',
|
||||
'ActivityMenu add note button should be displayed');
|
||||
assert.containsNone(document.body, '.o_note',
|
||||
'ActivityMenu add note input should be hidden');
|
||||
|
||||
// creating quick note with date
|
||||
await click('.o_note_show');
|
||||
document.querySelector('input.o_note_input').value = "New Note";
|
||||
await click(".o_note_save");
|
||||
assert.strictEqual(document.querySelector('.o_ActivityMenuView_counter').innerText, '2',
|
||||
"should increment activity notification counter after creating a second note");
|
||||
assert.strictEqual(document.querySelector('.o_ActivityMenuView_activityGroupFilterButton[data-filter="today"]').innerText.trim(),
|
||||
"2 Today",
|
||||
"should display 2 notes for today");
|
||||
assert.doesNotHaveClass(document.querySelector('.o_note_show'), 'd-none',
|
||||
'ActivityMenu add note button should be displayed');
|
||||
assert.containsNone(document.body, '.o_note',
|
||||
'ActivityMenu add note input should be hidden');
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue