summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/widgets
diff options
context:
space:
mode:
authorSébastien Theys <seb@odoo.com>2020-11-16 12:36:47 +0000
committerSébastien Theys <seb@odoo.com>2020-11-16 12:36:47 +0000
commit2002c6a599a685f4a18fc670a9f7992c8d595c0f (patch)
treee4d273d6cd86496d68e9ebd02c3849d9f52d95d1 /addons/mail/static/src/widgets
parent8b32e558fde3cb3aaa1deb40acb07488d04d343e (diff)
[FIX] mail: fix race conditions, especially with scroll
The `_update` of some components must take place before the `_update` of other (usually sibling) components that might directly influence their layout. This is in particular the case for `_update` that are relying on height. Prevent force save of scroll position if there are pending hints to adjust it, and prevent pending hints from overriding new scroll value. Prevent flicker with message date. This should fix all known issues related to incorrectly saving or restoring scroll position. task-2344226 task-2358066 task-2369332 task-2372339 task-2373741 closes odoo/odoo#61054 Related: odoo/enterprise#14736 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Diffstat (limited to 'addons/mail/static/src/widgets')
-rw-r--r--addons/mail/static/src/widgets/form_renderer/form_renderer_tests.js41
1 files changed, 30 insertions, 11 deletions
diff --git a/addons/mail/static/src/widgets/form_renderer/form_renderer_tests.js b/addons/mail/static/src/widgets/form_renderer/form_renderer_tests.js
index 0984885ddb4..19f5381be37 100644
--- a/addons/mail/static/src/widgets/form_renderer/form_renderer_tests.js
+++ b/addons/mail/static/src/widgets/form_renderer/form_renderer_tests.js
@@ -40,7 +40,8 @@ QUnit.module('form_renderer_tests.js', {
},
viewParams,
);
- const { env, widget } = await start(viewArgs, ...args);
+ const { afterEvent, env, widget } = await start(viewArgs, ...args);
+ this.afterEvent = afterEvent;
this.env = env;
this.widget = widget;
});
@@ -639,6 +640,11 @@ QUnit.test('read more/less links are not duplicated when switching from read to
</div>
</form>
`,
+ waitUntilEvent: {
+ eventName: 'o-component-message-read-more-less-inserted',
+ message: "should wait until read more/less is inserted initially",
+ predicate: ({ message }) => message.id === 1000,
+ },
});
assert.containsOnce(
document.body,
@@ -655,19 +661,24 @@ QUnit.test('read more/less links are not duplicated when switching from read to
'.o_Message_readMoreLess',
"there should be only one read more"
);
-
- await afterNextRender(() => {
- document.querySelector('.o_form_button_edit').click();
- });
+ await afterNextRender(() => this.afterEvent({
+ eventName: 'o-component-message-read-more-less-inserted',
+ func: () => document.querySelector('.o_form_button_edit').click(),
+ message: "should wait until read more/less is inserted after clicking on edit",
+ predicate: ({ message }) => message.id === 1000,
+ }));
assert.containsOnce(
document.body,
'.o_Message_readMoreLess',
"there should still be only one read more after switching to edit mode"
);
- await afterNextRender(() => {
- document.querySelector('.o_form_button_cancel').click();
- });
+ await afterNextRender(() => this.afterEvent({
+ eventName: 'o-component-message-read-more-less-inserted',
+ func: () => document.querySelector('.o_form_button_cancel').click(),
+ message: "should wait until read more/less is inserted after canceling edit",
+ predicate: ({ message }) => message.id === 1000,
+ }));
assert.containsOnce(
document.body,
'.o_Message_readMoreLess',
@@ -718,6 +729,11 @@ QUnit.test('read more links becomes read less after being clicked', async functi
</div>
</form>
`,
+ waitUntilEvent: {
+ eventName: 'o-component-message-read-more-less-inserted',
+ message: "should wait until read more/less is inserted initially",
+ predicate: ({ message }) => message.id === 1000,
+ },
});
assert.containsOnce(
document.body,
@@ -740,9 +756,12 @@ QUnit.test('read more links becomes read less after being clicked', async functi
"read more/less link should contain 'read more' as text"
);
- await afterNextRender(() => {
- document.querySelector('.o_form_button_edit').click();
- });
+ await afterNextRender(() => this.afterEvent({
+ eventName: 'o-component-message-read-more-less-inserted',
+ func: () => document.querySelector('.o_form_button_edit').click(),
+ message: "should wait until read more/less is inserted after clicking on edit",
+ predicate: ({ message }) => message.id === 1000,
+ }));
assert.strictEqual(
document.querySelector('.o_Message_readMoreLess').textContent,
'read more',