[IMP] web,mail: add resetLocalState to rendererWrapper

add resetLocalState method to rendererWrapper and test activity view is not
crashed on on_destroy_callback

task-2466057

closes odoo/odoo#73022

Signed-off-by: Simon Genin (ges@odoo) <ges@odoo.com>
This commit is contained in:
Simon Genin
2021-07-02 12:48:52 +00:00
committed by Mohammed Shekha
parent afa4ac684d
commit 063e38c4fd
3 changed files with 41 additions and 0 deletions
@@ -1,10 +1,13 @@
/** @odoo-module **/
import ActivityRenderer from '@mail/js/views/activity/activity_renderer';
import ActivityView from '@mail/js/views/activity/activity_view';
import testUtils from 'web.test_utils';
import domUtils from 'web.dom';
import { legacyExtraNextTick, patchWithCleanup } from "@web/../tests/helpers/utils";
import { createWebClient, doAction } from "@web/../tests/webclient/helpers";
import { patch, unpatch } from 'web.utils';
import { registry } from "@web/core/registry";
let serverData;
@@ -581,4 +584,40 @@ QUnit.test('Activity view: many2one_avatar_user widget in activity view', async
"should not have text on many2one_avatar_user if onlyImage node option is passed");
});
QUnit.test("Activity view: on_destroy_callback doesn't crash", async function (assert) {
assert.expect(3);
const params = {
View: ActivityView,
model: 'task',
data: this.data,
arch: `<activity string="Task">
<templates>
<div t-name="activity-box">
<field name="foo"/>
</div>
</templates>
</activity>`,
};
patchWithCleanup(ActivityRenderer.prototype, {
mounted() {
assert.step('mounted');
},
willUnmount() {
assert.step('willUnmount');
}
});
const activity = await createView(params);
domUtils.detach([{ widget: activity }]);
assert.verifySteps([
'mounted',
'willUnmount'
]);
activity.destroy();
});
});
@@ -7,6 +7,7 @@
getLocalState() { }
setLocalState() { }
giveFocus() { }
resetLocalState() { }
}
export default RendererWrapper;
@@ -1097,6 +1097,7 @@ QUnit.module('Views', {
await doAction(webClient, 1);
await testUtils.dom.click(webClient.el.querySelector('.o_list_button_add'));
await legacyExtraNextTick();
assert.containsOnce(webClient, '.o_form_view');
// click on second page tab