Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HOOT: various imps & fixes part 14 #158916

Closed
wants to merge 12 commits into from

Conversation

Arcasias
Copy link
Contributor

@Arcasias Arcasias commented Mar 22, 2024

Part 1: #152930
Part 2: #153018
Part 3: #153023
Part 4: #153203
Part 5: #153425
Part 6: #153700
Part 7: #154054
Part 8: #154579
Part 9: #155073
Part 10: #155639
Part 11: #156255 / https://github.com/odoo/enterprise/pull/58135
Part 12: #156869
Part 13: #158384 / https://github.com/odoo/enterprise/pull/59019

Enterprise: https://github.com/odoo/enterprise/pull/59291

This pull requests brings various improvements and fixes to Hoot and the Odoo unit test ecosystem. See the different commit messages for more details.

Note: these changes are made in stable to avoid having to support multiple versions of the HOOT API. As such, these changes are intended to be strictly limited to unit tests as to not put the rest of the code base at risk.


I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

@robodoo
Copy link
Contributor

robodoo commented Mar 22, 2024

@C3POdoo C3POdoo added the RD research & development, internal work label Mar 22, 2024
@Arcasias Arcasias force-pushed the saas-17.2-hoot-jum-2 branch 7 times, most recently from 9a27819 to fe12c51 Compare March 27, 2024 12:12
@Arcasias Arcasias marked this pull request as ready for review March 27, 2024 12:16
@C3POdoo C3POdoo requested review from a team and Julien00859 and removed request for a team March 27, 2024 12:17
@Arcasias Arcasias force-pushed the saas-17.2-hoot-jum-2 branch 3 times, most recently from be42b81 to 7467f6d Compare March 27, 2024 14:25
@Arcasias Arcasias force-pushed the saas-17.2-hoot-jum-2 branch 5 times, most recently from 2aa1535 to 5ebddc2 Compare March 28, 2024 14:30
This commit removes HOOT and HOOT-DOM from the list of exclusions in
the tooling configuration file (_jsconfig.json).

This effectively allows HOOT and HOOT-DOM to be included in the tooling
and to be auto-formatted and linted when committing changes.
This commit adds the test path and name in the warning logged by
`expect(...).toEqual(...)` in case the values are strictly equal.

This is useful to identify which test is concerned by the warning.
This commit temporarily disables the "Stop" button in the UI after
clicking on it to avoid immediatly re-running the test runner right
after stopping it.
This commit ensures that all registries are registered for cleanup after
every single test.

Before this commit, this was partially the case as registries were
registered for cleanup when creating a mock environment. This means that
before that any content that was modified before that point would NOT
be cleaned up.
robodoo pushed a commit that referenced this pull request Mar 28, 2024
This commit removes HOOT and HOOT-DOM from the list of exclusions in
the tooling configuration file (_jsconfig.json).

This effectively allows HOOT and HOOT-DOM to be included in the tooling
and to be auto-formatted and linted when committing changes.

Part-of: #158916
robodoo pushed a commit that referenced this pull request Mar 28, 2024
This commit adds the test path and name in the warning logged by
`expect(...).toEqual(...)` in case the values are strictly equal.

This is useful to identify which test is concerned by the warning.

Part-of: #158916
robodoo pushed a commit that referenced this pull request Mar 28, 2024
This commit temporarily disables the "Stop" button in the UI after
clicking on it to avoid immediatly re-running the test runner right
after stopping it.

Part-of: #158916
robodoo pushed a commit that referenced this pull request Mar 28, 2024
This commit ensures that all registries are registered for cleanup after
every single test.

Before this commit, this was partially the case as registries were
registered for cleanup when creating a mock environment. This means that
before that any content that was modified before that point would NOT
be cleaned up.

Part-of: #158916
robodoo pushed a commit that referenced this pull request Mar 28, 2024
This commit changes the shape of the `onRpc` helper and its variants:

Before: there were 3 shapes:
- `onRpc(route, routeCallback, routeOptions)` (with `routeCallback`
taking the `request` object as sole argument);
- `onRpc(ormCallback)` (with `ormCallback` taking the a string route and
a params dictionnary as arguments);
- `onRpc(method, ormCallback)` (same as above).

Now:
- both ORM versions of `onRpc` have had their parameters merged into a
single dictionary, with the route being a key of this dictionary, as
well as 2 other keys: `request` (original RPC `request` object) and
`parent` (equivalent to "super");
- a 4th shape has been added: `onRpc(model, method, ormCallback)`.

Docstring of all impacted functions, and usage of all impacted tests
have been updated to reflect these changes.

Part-of: #158916
robodoo pushed a commit that referenced this pull request Mar 28, 2024
This commit allows the `:eq` pseudo-class to support negative indexes,
behaving the same as `Array.prototype.at` does.

Part-of: #158916
robodoo pushed a commit that referenced this pull request Mar 28, 2024
This commit removes the `expect.extend` method that could be used to
register new matcher methods.

The reason for this is that it was first implemented because other
test frameworks would also implement an extension system, but this is
not really needed in HOOT because :

- we already have full control over the lib, so generic matchers can
directly be added to the source code;

- more specific helpers can still be added in local test files or other
test helper files as regular functions (which was already done with
QUnit tests).

Also the system was poorly documented in itself and would not provide
autocompletion for newly added matchers, which could easily lead to
misuse for declaration and usage of matchers.

Part-of: #158916
robodoo pushed a commit that referenced this pull request Mar 28, 2024
This commit introduces several helpers:

- a new `toHaveRect` matcher: it checks if the target's DOM rect matches
the given rect;

- 2 new helpers `queryRect` and `queryAllRects` that return the DOM rect
of the target element(s).

Part-of: #158916
robodoo pushed a commit that referenced this pull request Mar 28, 2024
This commit fixes several things in the mock model:

- in `_unityReadRecords`: when reading reference fields, we must read a
related record, whose model and id are encoded in the value of the
reference fields. Before this commit, we read the record on the wrong
model (the main one, not the one of the reference field);

- in `_unityReadRecords`: when specifying the order, the method ordering
the records would not be given the actual record list to sort and would
instead take all available records;

- when parsing a view, an error would be thrown on comment node as the
only ignored node type was the text node. Now, all non-element nodes are
ignored instead;

- it removes a call to `isSameNode`, which use is discouraged;

Part-of: #158916
robodoo pushed a commit that referenced this pull request Mar 28, 2024
This commit fixes a time test in HOOT that failed randomly. The issue
came from an interval whose duration was too short, causing it to
trigger multiple times in some cases.

This commit increases all timers duration in that test to make sure it
does not happen again.

Part-of: #158916
robodoo pushed a commit that referenced this pull request Mar 28, 2024
This commit ensures that a single call to the server `get_definitions`
is performed for all models that will be needed in the current test run
at the start of the run.

It also allows models fetched from the server to ignore inheritance from
models that have not been fetched.

Part-of: #158916
robodoo pushed a commit that referenced this pull request Mar 28, 2024
Before this commit, the callbacks given to the `onError` helper could be
asynchronous and their result would be awaited before processing an
error.

The issue is that dispatching an error event is synchronlous by nature
and the error could be prevented by subscribers registered later on
even before the error can be processed by HOOT.

This commit ensures that the `onError` callbacks are called
synchronlously.

closes #158916

Related: odoo/enterprise#59291
Signed-off-by: Mathieu Duckerts-Antoine (dam) <dam@odoo.com>
@robodoo robodoo closed this Mar 29, 2024
This was referenced Apr 3, 2024
@fw-bot fw-bot deleted the saas-17.2-hoot-jum-2 branch April 12, 2024 01:46
@fw-bot fw-bot mentioned this pull request Apr 24, 2024
@Arcasias Arcasias mentioned this pull request Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RD research & development, internal work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants