From 9699cb4d55a55f994d349fac0750596566ee4048 Mon Sep 17 00:00:00 2001 From: tsm-odoo Date: Thu, 12 May 2022 10:57:02 +0000 Subject: [PATCH] [IMP] mail: remove redundant FieldMany2ManyTagsEmail test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fieldmany2many tags email test is redundant and error prone (multiple callbacks relying on nextTick to be called in the right order). Let's remove it. closes odoo/odoo#91226 Signed-off-by: Sébastien Theys (seb) --- .../tests/qunit_suite_tests/chatter_tests.js | 73 ++----------------- 1 file changed, 6 insertions(+), 67 deletions(-) diff --git a/addons/mail/static/tests/qunit_suite_tests/chatter_tests.js b/addons/mail/static/tests/qunit_suite_tests/chatter_tests.js index 0d457cf2dac..6222f874bea 100644 --- a/addons/mail/static/tests/qunit_suite_tests/chatter_tests.js +++ b/addons/mail/static/tests/qunit_suite_tests/chatter_tests.js @@ -254,74 +254,8 @@ QUnit.test('list activity exception widget with activity', async function (asser QUnit.module('FieldMany2ManyTagsEmail'); -QUnit.test('fieldmany2many tags email', async function (assert) { - assert.expect(13); - var done = assert.async(); - - const pyEnv = await startServer(); - const [resPartnerId1, resPartnerId2] = pyEnv['res.partner'].create([ - { name: "gold", email: 'coucou@petite.perruche' }, - { name: "silver", email: '' }, - ]); - const mailMessageId1 = pyEnv['mail.message'].create({ - partner_ids: [resPartnerId1, resPartnerId2], - }); - - // the modals need to be closed before the form view rendering - start({ - hasView: true, - View: FormView, - model: 'mail.message', - res_id: mailMessageId1, - arch: '
' + - '' + - '' + - '' + - '' + - '
', - viewOptions: { - mode: 'edit', - }, - mockRPC: function (route, args) { - if (args.method === 'read' && args.model === 'res.partner') { - assert.step(JSON.stringify(args.args[0])); - assert.ok(args.args[1].includes('email'), "should read the email"); - } - return this._super.apply(this, arguments); - }, - archs: { - 'res.partner,false,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([`[${resPartnerId1},${resPartnerId2}]`, `[${resPartnerId2}]`, `[${resPartnerId2}]`]); - await testUtils.nextTick(); - 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="partner_ids"] .badge.o_tag_color_0').first(); - assert.strictEqual(firstTag.find('.o_badge_text').text(), "gold", - "tag should only show name"); - assert.hasAttrValue(firstTag.find('.o_badge_text'), 'title', "coucou@petite.perruche", - "tag should show email address on mouse hover"); - done(); - }); - 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="name"]').val(), "silver", - "the opened modal should be a form view dialog with the res.partner 2"); - assert.strictEqual($('.modal-body.o_act_window input[name="email"]').length, 1, - "there should be an email field in the modal"); - - // set the email and save the modal (will render the form view) - 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)', async function (assert) { - assert.expect(15); + assert.expect(17); const pyEnv = await startServer(); const [resPartnerId1, resPartnerId2] = pyEnv['res.partner'].create([ @@ -379,6 +313,11 @@ QUnit.test('fieldmany2many tags email (edition)', async function (assert) { assert.containsN(form, '.o_field_many2manytags[name="partner_ids"] .badge.o_tag_color_0', 2, "should contain the second tag"); + const 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 name"); + assert.hasAttrValue(firstTag.find('.o_badge_text'), 'title', "coucou@petite.perruche", + "tag should show email address on mouse hover"); // should have read resPartnerId2 three times: when opening the dropdown, when opening the modal, and // after the save assert.verifySteps([`[${resPartnerId2}]`, `[${resPartnerId2}]`, `[${resPartnerId2}]`]);