-
Notifications
You must be signed in to change notification settings - Fork 37
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
[IMP/REF] tests: mount owl App in test mode & mount helper #2045
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can merge as it, my comment is only a proposition
tests/components/bottom_bar.test.ts
Outdated
@@ -38,7 +38,7 @@ async function mountBottomBar( | |||
env: Partial<SpreadsheetChildEnv> = {} | |||
): Promise<{ parent: Parent; app: App; model: Model }> { | |||
const mockEnv = makeTestEnv({ ...env, model }); | |||
const app = new App(Parent, { props: { model }, env: mockEnv }); | |||
const app = new App(Parent, { props: { model }, env: mockEnv, test: true }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about creating a helper to mount a component ?
async function mount(component, target, props={}, env={}) {
const app = new App(component, { props, env, test: true });
app.addTemplates(OWL_TEMPLATES);
const parent = await app.mount(target);
return { app, parent }
}
With that, we could avoid thinking of adding test: true
, OWL_TEMPLATES, ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't forget fixture ^^
7ec3d3a
to
4bb6239
Compare
4bb6239
to
03de83c
Compare
…elper Change the parameters of the owl `App` in the test. The `App` will now be mounted in test mode. The main purpose is to enable props validation, which ensure that the test is close to the reality, and avoid tests failing for unclear reasons because a props was missing (d466315). The Owl test mode is equivalent to dev mode, but without warning that the app is unsuited for production. Documentation here : https://github.com/odoo/owl/blob/master/doc/reference/app.md#dev-mode Also added an helper `mountComponent` and modified the existing helper `mountSpreadsheet`. The helpers now create and return the fixture in which the component is mounted. They also register cleanup functions to remove the fixture and destroy the app, so we don't have to do it manually.
03de83c
to
0ef6bdb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
robodoo r+
This commit is a backport of original merged in PR #2045, it was introduced as it diminishes drastically the sources of errors when mounting OWL components. Change the parameters of the owl `App` in the test. The `App` will now be mounted in test mode. The main purpose is to enable props validation, which ensure that the test is close to the reality, and avoid tests failing for unclear reasons because a props was missing (d466315). The Owl test mode is equivalent to dev mode, but without warning that the app is unsuited for production. Documentation here : https://github.com/odoo/owl/blob/master/doc/reference/app.md#dev-mode Also added an helper `mountComponent` and modified the existing helper `mountSpreadsheet`. The helpers now create and return the fixture in which the component is mounted. They also register cleanup functions to remove the fixture and destroy the app, so we don't have to do it manually. closes #2045 Signed-off-by: Pierre Rousseau (pro) <pro@odoo.com>
This commit is a backport of original merged in PR #2045, it was introduced as it diminishes drastically the sources of errors when mounting OWL components. Change the parameters of the owl `App` in the test. The `App` will now be mounted in test mode. The main purpose is to enable props validation, which ensure that the test is close to the reality, and avoid tests failing for unclear reasons because a props was missing (d466315). The Owl test mode is equivalent to dev mode, but without warning that the app is unsuited for production. Documentation here : https://github.com/odoo/owl/blob/master/doc/reference/app.md#dev-mode Also added an helper `mountComponent` and modified the existing helper `mountSpreadsheet`. The helpers now create and return the fixture in which the component is mounted. They also register cleanup functions to remove the fixture and destroy the app, so we don't have to do it manually. closes #2045 Signed-off-by: Pierre Rousseau (pro) <pro@odoo.com> Part-of: #2252
This commit is a backport of original merged in PR #2045, it was introduced as it diminishes drastically the sources of errors when mounting OWL components. Change the parameters of the owl `App` in the test. The `App` will now be mounted in test mode. The main purpose is to enable props validation, which ensure that the test is close to the reality, and avoid tests failing for unclear reasons because a props was missing (d466315). The Owl test mode is equivalent to dev mode, but without warning that the app is unsuited for production. Documentation here : https://github.com/odoo/owl/blob/master/doc/reference/app.md#dev-mode Also added an helper `mountComponent` and modified the existing helper `mountSpreadsheet`. The helpers now create and return the fixture in which the component is mounted. They also register cleanup functions to remove the fixture and destroy the app, so we don't have to do it manually. closes #2045 Signed-off-by: Pierre Rousseau (pro) <pro@odoo.com>
This commit is a backport of original merged in PR #2045, it was introduced as it diminishes drastically the sources of errors when mounting OWL components. Change the parameters of the owl `App` in the test. The `App` will now be mounted in test mode. The main purpose is to enable props validation, which ensure that the test is close to the reality, and avoid tests failing for unclear reasons because a props was missing (d466315). The Owl test mode is equivalent to dev mode, but without warning that the app is unsuited for production. Documentation here : https://github.com/odoo/owl/blob/master/doc/reference/app.md#dev-mode Also added an helper `mountComponent` and modified the existing helper `mountSpreadsheet`. The helpers now create and return the fixture in which the component is mounted. They also register cleanup functions to remove the fixture and destroy the app, so we don't have to do it manually. closes #2045 Signed-off-by: Pierre Rousseau (pro) <pro@odoo.com> Part-of: #2258
Change the parameters of the owl
App
in the test. TheApp
will nowbe mounted in test mode. The main purpose is to enable props validation,
which ensure that the test is close to the reality, and avoid tests
failing for unclear reasons because a props was missing (d466315).
The Owl test mode is equivalent to dev mode, but without warning that
the app is unsuited for production. Documentation here :
https://github.com/odoo/owl/blob/master/doc/reference/app.md#dev-mode
Also added an helper
mountComponent
and modified the existing helpermountSpreadsheet
. The helper now creates and returns the fixture in whichthe component is mounted. They also register cleanup functions to remove
the fixture and destroy the app, so we don't have to do it manually.
Description:
description of this task, what is implemented and why it is implemented that way.
Odoo task ID : TASK_ID
review checklist