<feed xmlns='http://www.w3.org/2005/Atom'>
<title>Odoo/addons/web/static/tests/helpers/test_utils.js, branch 14.0</title>
<subtitle>The current checkout of upstream Odoo</subtitle>
<link rel='alternate' type='text/html' href='http://erp.ceuconsult.com:9000/Odoo/'/>
<entry>
<title>[FIX] web: show warning on create onchange</title>
<updated>2020-12-15T16:41:34+00:00</updated>
<author>
<name>Nicolas Lempereur</name>
<email>nle@odoo.com</email>
</author>
<published>2020-11-13T16:29:36+00:00</published>
<link rel='alternate' type='text/html' href='http://erp.ceuconsult.com:9000/Odoo/commit/?id=ff61ab121e3fb3c0c9b269c0dc9a65b3f1c8e664'/>
<id>ff61ab121e3fb3c0c9b269c0dc9a65b3f1c8e664</id>
<content type='text'>
When you create a new record, you will have in this order:

- default_get
- onchange (can trigger a warning)
- _pushController =&gt; close all dialogs since ea2207afeab8c

This is an issue since the possible warning is directly hidden to the
user.

Without the change, the added test failed with:

 Warning modal should be opened
 "executing a window action with onchange warning do not hide it":
 Found 0 elements to click on, instead of 1

opw-2342273
opw-2374051
closes #61732

closes odoo/odoo#63270

X-original-commit: 0784d9ab562379f31558fa44f9b9540c36a03760
Signed-off-by: Nicolas Lempereur (nle) &lt;nle@odoo.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When you create a new record, you will have in this order:

- default_get
- onchange (can trigger a warning)
- _pushController =&gt; close all dialogs since ea2207afeab8c

This is an issue since the possible warning is directly hidden to the
user.

Without the change, the added test failed with:

 Warning modal should be opened
 "executing a window action with onchange warning do not hide it":
 Found 0 elements to click on, instead of 1

opw-2342273
opw-2374051
closes #61732

closes odoo/odoo#63270

X-original-commit: 0784d9ab562379f31558fa44f9b9540c36a03760
Signed-off-by: Nicolas Lempereur (nle) &lt;nle@odoo.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>[FIX] web: race condition with x2many control panel</title>
<updated>2020-11-18T08:39:40+00:00</updated>
<author>
<name>Aaron Bohy</name>
<email>aab@odoo.com</email>
</author>
<published>2020-11-10T14:52:14+00:00</published>
<link rel='alternate' type='text/html' href='http://erp.ceuconsult.com:9000/Odoo/commit/?id=e8e64f75606f1501a8be7b0bb418a296cfd8be61'/>
<id>e8e64f75606f1501a8be7b0bb418a296cfd8be61</id>
<content type='text'>
The ControlPanel has been converted in Owl [1], and the code using
it has been adapted accordingly. However, in the FieldX2Many, we
didn't properly wait for the ControlPanel to be updated (an update
of the ControlPanel was synchronous before owl, and is now async,
like every Owl renderings, as it waits for the nextAnimationFrame).

As a consequence, we might have tricky issues because the mounted
hook of the control panel might be called multiple times for a
single call to willUnmount later on. In mobile, we bind a global
event handler (on scroll) in mounted, and unbind it in willUnmount,
so we had leftover event handlers, that crashed when called after
the ControlPanel was destroyed. Note that even if the issue popped
in mobile, calling mounted on already mounted Components isn't a
good idea, and this should be fixed anyway.

The issue could be reproduced for instance in FieldService (with
collaborative pads activated in Project), in mobile, by opening
a task in Edit mode. Then, you might get a traceback by scrolling
after having discarded the edition

Here is a description of what technically happened:
 - when clicking on Edit, all widgets (including the FieldX2Many
   are destroyed and re-instantiated in 'edit' mode).
 - the pad widget directly triggers a field_changed event which
   causes a reset of the FieldX2Many (i.e. 'render' is called
   again)
 - the FieldX2Many detects that it already has a renderer (and a
   ControlPanel) so it updates them
 - it first updates the renderer, and when it's done, it updates
   the ControlPanel BUT doesn't wait for its promise, so the
   promise returned by that call to 'render' in FieldX2Many is
   resolved before the ControlPanel is actually updated
 - note that at this point, all thoses new widgets are not in the
   DOM yet
 - when all widgets are ready, the renderer patches the view (i.e.
   the former content is removed from the DOM, and the new one is
   attached into the DOM). As soon as this is done, the renderer
   calls 'on_attach_callback' on its children, including the
   FieldX2Many, which leads to a call to 'mounted' on the CP.
 - then, just before the nextAnimationFrame, Owl complete the
   rendering of the CP, and detects that it is now in the DOM (it
   wasn't at the beginning), so 'mounted' is called a second time,
   will cause the issue described above.

This commit fixes the issue by properly waiting for the CP to be
rendered in the FieldX2Many. However, this required on cascade
changes:
 - Form view renderings with a FieldX2Many are now *really* async
   (+- 16ms), meaning that the user can easily trigger concurrent
   renderings by, e.g. clicking quickly several times on 'Edit',
   'Save' or 'Discard'. Concurrent renderings are properly handled
   so to prevent this from happening, we disable the buttons and
   re-enable them when the rendering is done (like already done in
   [2])
 - in the FieldX2Many, '_updateControlPanel' was called at several
   placed, but we never waited for it. As this method was
   originally sync, its calls have probably been naively adapted,
   whereas their should have been deeply rethought (for instance,
   as it is async, and we need to wait for it, we don't want it
   to be called multiple times sequentially when something happens).
   This commit does that work, i.e. we clean the places where this
   function is called such that it is (hopefully) never called
   sequentially twice. To do so, we changed a bit the spec of the
   pager in multi page, and we also fixed a paging-related  bug.
   In a few words, here is what we did/do when adding a new row
   in the bottom of a full page:
     - before: tweak the count in the data to fool the pager and
       make it think that no new record has been added (so
       basically, let it display something wrong)
     - now: temporarily increase the pager limit so that the new
       record is displayed on the current pager, and the pager
       values are correct w.r.t. the displayed records.
    Some tests needed to be adapted accordingly.
 - By waiting for the ControlPanel when updating the FieldX2Many,
   a bunch of QUnit tests failed. Those tests have something in
   common: they spawn an X2Many (list or kanban theoretically,
   but always list in practice) containing a FieldBoolean (only
   field widget of /web converted in owl). When the FieldX2Many
   is updated, we update the renderer (i.e. re-renderer the
   FieldBoolean, so we have to wait for the nextAnimationFrame),
   and when this is done, we update the page (again, we have
   to wait for the nextAnimationFrame). So basically, we have
   to wait for two nextAnimationFrames to see the result in the
   DOM. For this, we added a new test util which basically does
   a nextTick ('owlCompatibilityNextTick'), and called it
   everywhere it was necessary. When everything will be written
   in Owl, we could get rid of this util and its calls.

[1] https://github.com/odoo/odoo/commit/fbf347498f1cc7b74ef373179b7bcae201715c24
[2] https://github.com/odoo/odoo/commit/39f08950d6e20460e3a20a5b9c33e4ddf66dce78

closes odoo/odoo#61593

Signed-off-by: Adrien Dieudonné (adr) &lt;adr@odoo.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The ControlPanel has been converted in Owl [1], and the code using
it has been adapted accordingly. However, in the FieldX2Many, we
didn't properly wait for the ControlPanel to be updated (an update
of the ControlPanel was synchronous before owl, and is now async,
like every Owl renderings, as it waits for the nextAnimationFrame).

As a consequence, we might have tricky issues because the mounted
hook of the control panel might be called multiple times for a
single call to willUnmount later on. In mobile, we bind a global
event handler (on scroll) in mounted, and unbind it in willUnmount,
so we had leftover event handlers, that crashed when called after
the ControlPanel was destroyed. Note that even if the issue popped
in mobile, calling mounted on already mounted Components isn't a
good idea, and this should be fixed anyway.

The issue could be reproduced for instance in FieldService (with
collaborative pads activated in Project), in mobile, by opening
a task in Edit mode. Then, you might get a traceback by scrolling
after having discarded the edition

Here is a description of what technically happened:
 - when clicking on Edit, all widgets (including the FieldX2Many
   are destroyed and re-instantiated in 'edit' mode).
 - the pad widget directly triggers a field_changed event which
   causes a reset of the FieldX2Many (i.e. 'render' is called
   again)
 - the FieldX2Many detects that it already has a renderer (and a
   ControlPanel) so it updates them
 - it first updates the renderer, and when it's done, it updates
   the ControlPanel BUT doesn't wait for its promise, so the
   promise returned by that call to 'render' in FieldX2Many is
   resolved before the ControlPanel is actually updated
 - note that at this point, all thoses new widgets are not in the
   DOM yet
 - when all widgets are ready, the renderer patches the view (i.e.
   the former content is removed from the DOM, and the new one is
   attached into the DOM). As soon as this is done, the renderer
   calls 'on_attach_callback' on its children, including the
   FieldX2Many, which leads to a call to 'mounted' on the CP.
 - then, just before the nextAnimationFrame, Owl complete the
   rendering of the CP, and detects that it is now in the DOM (it
   wasn't at the beginning), so 'mounted' is called a second time,
   will cause the issue described above.

This commit fixes the issue by properly waiting for the CP to be
rendered in the FieldX2Many. However, this required on cascade
changes:
 - Form view renderings with a FieldX2Many are now *really* async
   (+- 16ms), meaning that the user can easily trigger concurrent
   renderings by, e.g. clicking quickly several times on 'Edit',
   'Save' or 'Discard'. Concurrent renderings are properly handled
   so to prevent this from happening, we disable the buttons and
   re-enable them when the rendering is done (like already done in
   [2])
 - in the FieldX2Many, '_updateControlPanel' was called at several
   placed, but we never waited for it. As this method was
   originally sync, its calls have probably been naively adapted,
   whereas their should have been deeply rethought (for instance,
   as it is async, and we need to wait for it, we don't want it
   to be called multiple times sequentially when something happens).
   This commit does that work, i.e. we clean the places where this
   function is called such that it is (hopefully) never called
   sequentially twice. To do so, we changed a bit the spec of the
   pager in multi page, and we also fixed a paging-related  bug.
   In a few words, here is what we did/do when adding a new row
   in the bottom of a full page:
     - before: tweak the count in the data to fool the pager and
       make it think that no new record has been added (so
       basically, let it display something wrong)
     - now: temporarily increase the pager limit so that the new
       record is displayed on the current pager, and the pager
       values are correct w.r.t. the displayed records.
    Some tests needed to be adapted accordingly.
 - By waiting for the ControlPanel when updating the FieldX2Many,
   a bunch of QUnit tests failed. Those tests have something in
   common: they spawn an X2Many (list or kanban theoretically,
   but always list in practice) containing a FieldBoolean (only
   field widget of /web converted in owl). When the FieldX2Many
   is updated, we update the renderer (i.e. re-renderer the
   FieldBoolean, so we have to wait for the nextAnimationFrame),
   and when this is done, we update the page (again, we have
   to wait for the nextAnimationFrame). So basically, we have
   to wait for two nextAnimationFrames to see the result in the
   DOM. For this, we added a new test util which basically does
   a nextTick ('owlCompatibilityNextTick'), and called it
   everywhere it was necessary. When everything will be written
   in Owl, we could get rid of this util and its calls.

[1] https://github.com/odoo/odoo/commit/fbf347498f1cc7b74ef373179b7bcae201715c24
[2] https://github.com/odoo/odoo/commit/39f08950d6e20460e3a20a5b9c33e4ddf66dce78

closes odoo/odoo#61593

Signed-off-by: Adrien Dieudonné (adr) &lt;adr@odoo.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>[FIX] mail: fix full composer opening with attachments</title>
<updated>2020-08-13T10:23:25+00:00</updated>
<author>
<name>Xavier Dubuc</name>
<email>xdu@odoo.com</email>
</author>
<published>2020-08-04T14:38:02+00:00</published>
<link rel='alternate' type='text/html' href='http://erp.ceuconsult.com:9000/Odoo/commit/?id=a17725e99899ff1e06996f7c9ab93704c840131e'/>
<id>a17725e99899ff1e06996f7c9ab93704c840131e</id>
<content type='text'>
task-2307201

closes odoo/odoo#55678

X-original-commit: 9c47bb0b0034a3419a0c6e3267d90cb520a59535
Signed-off-by: Alexandre Kühn (aku) &lt;aku@odoo.com&gt;
Signed-off-by: Sébastien Theys (seb) &lt;seb@odoo.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
task-2307201

closes odoo/odoo#55678

X-original-commit: 9c47bb0b0034a3419a0c6e3267d90cb520a59535
Signed-off-by: Alexandre Kühn (aku) &lt;aku@odoo.com&gt;
Signed-off-by: Sébastien Theys (seb) &lt;seb@odoo.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>[IMP] web: TestUtils findItem</title>
<updated>2020-07-23T08:21:09+00:00</updated>
<author>
<name>Julien Mougenot</name>
<email>jum@odoo.com</email>
</author>
<published>2020-07-13T12:58:36+00:00</published>
<link rel='alternate' type='text/html' href='http://erp.ceuconsult.com:9000/Odoo/commit/?id=20caa733c656c6f76cd075829e7854b2b2a22bf9'/>
<id>20caa733c656c6f76cd075829e7854b2b2a22bf9</id>
<content type='text'>
Extraction of the findItem function from the control panel test utils
to the dom utils.

This function helps find an item matching a given selector and:
- having the given text as its inner text
OR
- being the item at the given index

An error is thrown if no item matches the predicate</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Extraction of the findItem function from the control panel test utils
to the dom utils.

This function helps find an item matching a given selector and:
- having the given text as its inner text
OR
- being the item at the given index

An error is thrown if no item matches the predicate</pre>
</div>
</content>
</entry>
<entry>
<title>[IMP] web: tests: rework mock helpers</title>
<updated>2020-06-12T09:47:48+00:00</updated>
<author>
<name>Aaron Bohy</name>
<email>aab@odoo.com</email>
</author>
<published>2020-06-05T07:20:11+00:00</published>
<link rel='alternate' type='text/html' href='http://erp.ceuconsult.com:9000/Odoo/commit/?id=dc260c324170a90fa737cd21dd528e39d658d9b6'/>
<id>dc260c324170a90fa737cd21dd528e39d658d9b6</id>
<content type='text'>
This commit reworks the test helpers, following recent changes on
services deployed in the Owl env.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This commit reworks the test helpers, following recent changes on
services deployed in the Owl env.</pre>
</div>
</content>
</entry>
<entry>
<title>[IMP] web: add 'Create and edit' test helper</title>
<updated>2020-06-10T13:08:33+00:00</updated>
<author>
<name>Julien Mougenot</name>
<email>jum@odoo.com</email>
</author>
<published>2020-06-09T15:35:11+00:00</published>
<link rel='alternate' type='text/html' href='http://erp.ceuconsult.com:9000/Odoo/commit/?id=a392da16015c69161814e83f1cde5ddf40782505'/>
<id>a392da16015c69161814e83f1cde5ddf40782505</id>
<content type='text'>
Accessing the "Create and edit" option can be bothersome when testing:
- you must click on the m2o dropdown to open it
- input a value
- click on the "Create and edit" m2o item

Now, a helper exists to compile all these tasks into a single helper:
the many2one 'createAndEdit' function.

Usage:
`await testUtils.fields.many2one.createAndEdit('m2o_field', "ABC");`</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Accessing the "Create and edit" option can be bothersome when testing:
- you must click on the m2o dropdown to open it
- input a value
- click on the "Create and edit" m2o item

Now, a helper exists to compile all these tasks into a single helper:
the many2one 'createAndEdit' function.

Usage:
`await testUtils.fields.many2one.createAndEdit('m2o_field', "ABC");`</pre>
</div>
</content>
</entry>
<entry>
<title>[IMP] web: adapt test_utils_control_panel</title>
<updated>2020-06-04T19:32:52+00:00</updated>
<author>
<name>Mathieu Duckerts-Antoine</name>
<email>dam@odoo.com</email>
</author>
<published>2020-05-25T18:14:03+00:00</published>
<link rel='alternate' type='text/html' href='http://erp.ceuconsult.com:9000/Odoo/commit/?id=271dfe9ba3ba06f4ea58be54471d3affc269d53a'/>
<id>271dfe9ba3ba06f4ea58be54471d3affc269d53a</id>
<content type='text'>
The control panel test helpers related to the "time range" menu have
been removed and a new helper for the "comparison" menu has been added.

Task ID: 2245719

Co-authored-by: Mathieu Duckerts-Antoine &lt;dam@odoo.com&gt;
Co-authored-by: Julien Mougenot &lt;jum@odoo.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The control panel test helpers related to the "time range" menu have
been removed and a new helper for the "comparison" menu has been added.

Task ID: 2245719

Co-authored-by: Mathieu Duckerts-Antoine &lt;dam@odoo.com&gt;
Co-authored-by: Julien Mougenot &lt;jum@odoo.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>[IMP] web,*: Enhance test helpers</title>
<updated>2020-03-13T11:39:53+00:00</updated>
<author>
<name>Julien Mougenot</name>
<email>jum@odoo.com</email>
</author>
<published>2020-03-11T09:38:27+00:00</published>
<link rel='alternate' type='text/html' href='http://erp.ceuconsult.com:9000/Odoo/commit/?id=0a129284e4856b6485c48a194fd86c3ab5c736e7'/>
<id>0a129284e4856b6485c48a194fd86c3ab5c736e7</id>
<content type='text'>
1. Test utils helpers adapted to properly instantiate the new Owl control panel
2. New file 'test_utils_control_panel' to create a control panel and use helpers
3. New helper: createComponent (creates a generic component, see jsdoc)
4. Use of the new helpers in the current tests (more in sibling commits)
5. Helper 'addMockEnvironment' is now asynchronous
6. Owl config mode set to 'dev' in test suite (props validation)

Part of task 2196029

Co-authored-by: Mathieu Duckerts-Antoine &lt;dam@odoo.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
1. Test utils helpers adapted to properly instantiate the new Owl control panel
2. New file 'test_utils_control_panel' to create a control panel and use helpers
3. New helper: createComponent (creates a generic component, see jsdoc)
4. Use of the new helpers in the current tests (more in sibling commits)
5. Helper 'addMockEnvironment' is now asynchronous
6. Owl config mode set to 'dev' in test suite (props validation)

Part of task 2196029

Co-authored-by: Mathieu Duckerts-Antoine &lt;dam@odoo.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>[REF] web: Update generic files</title>
<updated>2020-03-13T09:37:29+00:00</updated>
<author>
<name>Julien Mougenot</name>
<email>jum@odoo.com</email>
</author>
<published>2020-02-25T12:52:41+00:00</published>
<link rel='alternate' type='text/html' href='http://erp.ceuconsult.com:9000/Odoo/commit/?id=384e516218375000461aa3fcb0ac1b9eaa960fb3'/>
<id>384e516218375000461aa3fcb0ac1b9eaa960fb3</id>
<content type='text'>
General cleaning of some helpers and generic files. The idea is that they are
less likely to be entirely re-written in the near future so this is a way to
keep the code clean, readable and compliant to the current standards. Changes include:
- Use of async/await when possible
- Use of const/let instead of var
- Removal of underscore.js
- Use of native JS instead of jQuery when possible

The logic of the affected code remains the same.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
General cleaning of some helpers and generic files. The idea is that they are
less likely to be entirely re-written in the near future so this is a way to
keep the code clean, readable and compliant to the current standards. Changes include:
- Use of async/await when possible
- Use of const/let instead of var
- Removal of underscore.js
- Use of native JS instead of jQuery when possible

The logic of the affected code remains the same.</pre>
</div>
</content>
</entry>
<entry>
<title>[REF] web: Indent and reorganize generic files</title>
<updated>2020-03-13T09:37:29+00:00</updated>
<author>
<name>Julien Mougenot</name>
<email>jum@odoo.com</email>
</author>
<published>2020-02-27T14:55:44+00:00</published>
<link rel='alternate' type='text/html' href='http://erp.ceuconsult.com:9000/Odoo/commit/?id=11ba58a311311b798a68183df18673e562bb97d3'/>
<id>11ba58a311311b798a68183df18673e562bb97d3</id>
<content type='text'>
The purpose of this commit is to correctly indent and order some generic files.
There is strictly no change in the code logic.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The purpose of this commit is to correctly indent and order some generic files.
There is strictly no change in the code logic.</pre>
</div>
</content>
</entry>
</feed>
