[IMP] mail: remove fake model for FieldMany2ManyTagsEmail tests
task-2792108 closes odoo/odoo#87303 Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
@@ -372,26 +372,14 @@ QUnit.module('FieldMany2ManyTagsEmail', {
|
||||
async beforeEach() {
|
||||
await beforeEach(this);
|
||||
|
||||
Object.assign(this.data['res.users'].fields, {
|
||||
timmy: { string: "pokemon", type: "many2many", relation: 'partner_type' },
|
||||
});
|
||||
this.data['res.users'].records.push({
|
||||
this.data['mail.message'].records.push({
|
||||
id: 11,
|
||||
display_name: "first record",
|
||||
timmy: [],
|
||||
partner_ids: [],
|
||||
});
|
||||
Object.assign(this.data, {
|
||||
partner_type: {
|
||||
fields: {
|
||||
name: { string: "Partner Type", type: "char" },
|
||||
email: { string: "Email", type: "char" },
|
||||
},
|
||||
records: [],
|
||||
},
|
||||
});
|
||||
this.data['partner_type'].records.push(
|
||||
{ id: 12, display_name: "gold", email: 'coucou@petite.perruche' },
|
||||
{ id: 14, display_name: "silver", email: '' }
|
||||
this.data['res.partner'].records.push(
|
||||
{ id: 12, name: "gold", email: 'coucou@petite.perruche' },
|
||||
{ id: 14, name: "silver", email: '' },
|
||||
);
|
||||
},
|
||||
});
|
||||
@@ -400,44 +388,44 @@ QUnit.test('fieldmany2many tags email', function (assert) {
|
||||
assert.expect(13);
|
||||
var done = assert.async();
|
||||
|
||||
const user11 = this.data['res.users'].records.find(user => user.id === 11);
|
||||
user11.timmy = [12, 14];
|
||||
const message11 = this.data['mail.message'].records.find(message => message.id === 11);
|
||||
|
||||
message11.partner_ids = [12, 14];
|
||||
// the modals need to be closed before the form view rendering
|
||||
start({
|
||||
hasView: true,
|
||||
View: FormView,
|
||||
model: 'res.users',
|
||||
model: 'mail.message',
|
||||
data: this.data,
|
||||
res_id: 11,
|
||||
arch: '<form string="Partners">' +
|
||||
'<sheet>' +
|
||||
'<field name="display_name"/>' +
|
||||
'<field name="timmy" widget="many2many_tags_email"/>' +
|
||||
'<field name="body"/>' +
|
||||
'<field name="partner_ids" widget="many2many_tags_email"/>' +
|
||||
'</sheet>' +
|
||||
'</form>',
|
||||
viewOptions: {
|
||||
mode: 'edit',
|
||||
},
|
||||
mockRPC: function (route, args) {
|
||||
if (args.method === 'read' && args.model === 'partner_type') {
|
||||
if (args.method === 'read' && args.model === 'res.partner') {
|
||||
assert.step(JSON.stringify(args.args[0]));
|
||||
assert.deepEqual(args.args[1], ['display_name', 'email'], "should read the email");
|
||||
assert.ok(args.args[1].includes('email'), "should read the email");
|
||||
}
|
||||
return this._super.apply(this, arguments);
|
||||
},
|
||||
archs: {
|
||||
'partner_type,false,form': '<form string="Types"><field name="display_name"/><field name="email"/></form>',
|
||||
'res.partner,false,form': '<form string="Types"><field name="name"/><field name="email"/></form>',
|
||||
},
|
||||
}).then(async function ({ widget: 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]']);
|
||||
await testUtils.nextTick();
|
||||
assert.containsN(form, '.o_field_many2manytags[name="timmy"] .badge.o_tag_color_0', 2,
|
||||
assert.containsN(form, '.o_field_many2manytags[name="partner_ids"] .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();
|
||||
var firstTag = form.$('.o_field_many2manytags[name="partner_ids"] .badge.o_tag_color_0').first();
|
||||
assert.strictEqual(firstTag.find('.o_badge_text').text(), "gold",
|
||||
"tag should only show display_name");
|
||||
"tag should only show name");
|
||||
assert.hasAttrValue(firstTag.find('.o_badge_text'), 'title', "coucou@petite.perruche",
|
||||
"tag should show email address on mouse hover");
|
||||
form.destroy();
|
||||
@@ -446,8 +434,8 @@ QUnit.test('fieldmany2many tags email', function (assert) {
|
||||
testUtils.nextTick().then(function () {
|
||||
assert.strictEqual($('.modal-body.o_act_window').length, 1,
|
||||
"there should be one modal opened to edit the empty email");
|
||||
assert.strictEqual($('.modal-body.o_act_window input[name="display_name"]').val(), "silver",
|
||||
"the opened modal should be a form view dialog with the partner_type 14");
|
||||
assert.strictEqual($('.modal-body.o_act_window input[name="name"]').val(), "silver",
|
||||
"the opened modal should be a form view dialog with the res.partner 14");
|
||||
assert.strictEqual($('.modal-body.o_act_window input[name="email"]').length, 1,
|
||||
"there should be an email field in the modal");
|
||||
|
||||
@@ -461,48 +449,48 @@ QUnit.test('fieldmany2many tags email', function (assert) {
|
||||
QUnit.test('fieldmany2many tags email (edition)', async function (assert) {
|
||||
assert.expect(15);
|
||||
|
||||
const user11 = this.data['res.users'].records.find(user => user.id === 11);
|
||||
user11.timmy = [12];
|
||||
const message11 = this.data['mail.message'].records.find(message => message.id === 11);
|
||||
message11.partner_ids = [12];
|
||||
|
||||
var { widget: form } = await start({
|
||||
hasView: true,
|
||||
View: FormView,
|
||||
model: 'res.users',
|
||||
model: 'mail.message',
|
||||
data: this.data,
|
||||
res_id: 11,
|
||||
arch: '<form string="Partners">' +
|
||||
'<sheet>' +
|
||||
'<field name="display_name"/>' +
|
||||
'<field name="timmy" widget="many2many_tags_email"/>' +
|
||||
'<field name="body"/>' +
|
||||
'<field name="partner_ids" widget="many2many_tags_email"/>' +
|
||||
'</sheet>' +
|
||||
'</form>',
|
||||
viewOptions: {
|
||||
mode: 'edit',
|
||||
},
|
||||
mockRPC: function (route, args) {
|
||||
if (args.method === 'read' && args.model === 'partner_type') {
|
||||
if (args.method === 'read' && args.model === 'res.partner') {
|
||||
assert.step(JSON.stringify(args.args[0]));
|
||||
assert.deepEqual(args.args[1], ['display_name', 'email'], "should read the email");
|
||||
assert.ok(args.args[1].includes('email'), "should read the email");
|
||||
}
|
||||
return this._super.apply(this, arguments);
|
||||
},
|
||||
archs: {
|
||||
'partner_type,false,form': '<form string="Types"><field name="display_name"/><field name="email"/></form>',
|
||||
'res.partner,false,form': '<form string="Types"><field name="name"/><field name="email"/></form>',
|
||||
},
|
||||
});
|
||||
|
||||
assert.verifySteps(['[12]']);
|
||||
assert.containsOnce(form, '.o_field_many2manytags[name="timmy"] .badge.o_tag_color_0',
|
||||
assert.containsOnce(form, '.o_field_many2manytags[name="partner_ids"] .badge.o_tag_color_0',
|
||||
"should contain one tag");
|
||||
|
||||
// add an other existing tag
|
||||
await testUtils.fields.many2one.clickOpenDropdown('timmy');
|
||||
await testUtils.fields.many2one.clickHighlightedItem('timmy');
|
||||
await testUtils.fields.many2one.clickOpenDropdown('partner_ids');
|
||||
await testUtils.fields.many2one.searchAndClickItem('partner_ids', { search: 'silver' });
|
||||
|
||||
assert.strictEqual($('.modal-body.o_act_window').length, 1,
|
||||
"there should be one modal opened to edit the empty email");
|
||||
assert.strictEqual($('.modal-body.o_act_window input[name="display_name"]').val(), "silver",
|
||||
"the opened modal in edit mode should be a form view dialog with the partner_type 14");
|
||||
assert.strictEqual($('.modal-body.o_act_window input[name="name"]').val(), "silver",
|
||||
"the opened modal in edit mode should be a form view dialog with the res.partner 14");
|
||||
assert.strictEqual($('.modal-body.o_act_window input[name="email"]').length, 1,
|
||||
"there should be an email field in the modal");
|
||||
|
||||
@@ -510,7 +498,7 @@ QUnit.test('fieldmany2many tags email (edition)', async function (assert) {
|
||||
await testUtils.fields.editInput($('.modal-body.o_act_window input[name="email"]'), 'coucou@petite.perruche');
|
||||
await testUtils.dom.click($('.modal-footer .btn-primary'));
|
||||
|
||||
assert.containsN(form, '.o_field_many2manytags[name="timmy"] .badge.o_tag_color_0', 2,
|
||||
assert.containsN(form, '.o_field_many2manytags[name="partner_ids"] .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
|
||||
@@ -522,18 +510,17 @@ QUnit.test('fieldmany2many tags email (edition)', async function (assert) {
|
||||
QUnit.test('many2many_tags_email widget can load more than 40 records', async function (assert) {
|
||||
assert.expect(3);
|
||||
|
||||
const user11 = this.data['res.users'].records.find(user => user.id === 11);
|
||||
this.data['res.users'].fields.partner_ids = { string: "Partner", type: "many2many", relation: 'res.users' };
|
||||
user11.partner_ids = [];
|
||||
const message11 = this.data['mail.message'].records.find(message => message.id === 11);
|
||||
message11.partner_ids = [];
|
||||
for (let i = 100; i < 200; i++) {
|
||||
this.data['res.users'].records.push({ id: i, display_name: `partner${i}` });
|
||||
user11.partner_ids.push(i);
|
||||
this.data['res.partner'].records.push({ id: i, display_name: `partner${i}` });
|
||||
message11.partner_ids.push(i);
|
||||
}
|
||||
|
||||
const { widget: form } = await start({
|
||||
hasView: true,
|
||||
View: FormView,
|
||||
model: 'res.users',
|
||||
model: 'mail.message',
|
||||
data: this.data,
|
||||
arch: '<form><field name="partner_ids" widget="many2many_tags"/></form>',
|
||||
res_id: 11,
|
||||
|
||||
Reference in New Issue
Block a user