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

[IMP/REF] tests: mount owl App in test mode & mount helper #2045

Closed
wants to merge 1 commit into from

Conversation

hokolomopo
Copy link
Contributor

@hokolomopo hokolomopo commented Feb 3, 2023

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 helper now creates and returns 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.

Description:

description of this task, what is implemented and why it is implemented that way.

Odoo task ID : TASK_ID

review checklist

  • feature is organized in plugin, or UI components
  • support of duplicate sheet (deep copy)
  • in model/core: ranges are Range object, and can be adapted (adaptRanges)
  • in model/UI: ranges are strings (to show the user)
  • undo-able commands (uses this.history.update)
  • multiuser-able commands (has inverse commands and transformations where needed)
  • new/updated/removed commands are documented
  • exportable in excel
  • translations (_lt("qmsdf %s", abc))
  • unit tested
  • clean commented code
  • track breaking changes
  • doc is rebuild (npm run doc)
  • status is correct in Odoo

@robodoo
Copy link
Collaborator

robodoo commented Feb 3, 2023

Copy link
Collaborator

@pro-odoo pro-odoo left a 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

@@ -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 });
Copy link
Collaborator

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, ...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To go one step further (perhaps not in this PR, but...), we could create something like in Odoo, to register a cleanup. So, we will not be forced to take care of destroying the app. See the helper of web

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea !

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't forget fixture ^^

@hokolomopo hokolomopo force-pushed the master-app-test-mode-adrm branch 2 times, most recently from 7ec3d3a to 4bb6239 Compare February 6, 2023 09:26
@hokolomopo hokolomopo changed the title [IMP] tests: mount owl App in test mode [IMP] tests: mount owl App in test mode & mount helper Feb 6, 2023
@hokolomopo hokolomopo changed the title [IMP] tests: mount owl App in test mode & mount helper [IMP/REF] tests: mount owl App in test mode & mount helper Feb 6, 2023
…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.
Copy link
Collaborator

@pro-odoo pro-odoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

robodoo r+

@robodoo robodoo temporarily deployed to merge February 6, 2023 13:07 Inactive
@robodoo robodoo closed this in 6609e98 Feb 6, 2023
@robodoo robodoo added the 16.2 label Feb 6, 2023
@fw-bot fw-bot deleted the master-app-test-mode-adrm branch February 20, 2023 13:47
@rrahir rrahir mentioned this pull request Mar 21, 2023
14 tasks
rrahir pushed a commit that referenced this pull request Mar 21, 2023
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>
robodoo pushed a commit that referenced this pull request Mar 22, 2023
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
@fw-bot fw-bot mentioned this pull request Mar 22, 2023
14 tasks
rrahir pushed a commit that referenced this pull request Mar 22, 2023
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>
robodoo pushed a commit that referenced this pull request Mar 22, 2023
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
This was referenced Mar 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants