Commit Graph
91 Commits
Author SHA1 Message Date
Christophe Monniez 832bac0628 [REM] website: remove useless browser_js test
This test goes to the public homepage and directly logs a 'test
succesful'. It's useless as many other tests use the public homepage and
therefore, those tests will crash if the homepage is unavailable.

Moreover, it happens to trigger random failures due to the fact that
some RPC may occur between the cookies cleaning and the termination of
the browser.

Typically a "GET /web/webclient/locale/en_US" can be triggered right
after the clearing of the browser cookies, cache ...

closes odoo/odoo#46004

X-original-commit: 3aded126e78b18f8bb753f1b57b827667ca99d18
Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
2020-02-22 08:22:10 +00:00
qsm-odoo 6f4c60fe1b [FIX] website, *: lazy load widget assets of the correct website
*: web

Before this commit, when a widget declared assets to lazy load through
the assetLibs key, the asset was loaded through a context-less call to
the server through the base `rpc` function. This caused problems in
website: the website ID was not given to the called route and the loaded
assets were then stripped of their specific-website parts.

This commit solves the problem by allowing the `loadLibs` and
`loadAsset` functions to receive an extra argument: an extra `context`
to use for the actual call to the server. The method is now available
in the ajax service, so that website can add its custom context
automatically, the same way it does it for normal `_rpc` calls.

Part of https://github.com/odoo/odoo/pull/44596

closes odoo/odoo#44596

Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-02-05 10:48:44 +00:00
Yannick Tivisse 05ae347bdd [IMP] website: Adapt tests to work with/without demo data 2019-11-05 16:18:10 +01:00
Christophe Monniez 8d5da6e4be [IMP] tests: log a warning when HttpCase test in at_install
When loading a page on an existing starting database, registry is not
fully loaded causing potential error when trying to access model
existing in database (views, menitem, ...) since model added in last
loaded module does not exist in registry.

Thus, executing browser js test may lead to errors when executed during
an update on a database with other modules installed.

HTTPCase should be executed post_install to ensure that registry is
fully loaded to avoid this problem.

Since HTTPCase are slower than other test, it is also a good idea to
execute them at the end, in order to prioritize fast fail.

With this commit, a warning is isued if such a test class is tagged to
run at install time.

While at it, remove deprecated at_install and post_install helpers and
remove the deprecated phantom_js alias.

closes odoo/odoo#39462

Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
2019-10-30 12:35:23 +00:00
Christophe Monniez 698a68614c [FIX] website: move rte_translator test to post install
When executing test on an existing database with other module installed,
browser_js test tends to crach because not all models are available
in registry. A wip will force all js test to be executed in post_install.

This will also have a side effect that make rte_translator test
fail randomly more often since more module are installed, fix is done
in next commits.
2019-09-16 13:28:30 +00:00
RomainLibert 6aaef4a3d9 [FIX] website: fix ctx argument
In the call to Chart.js we pass a ctx which should be a DOM element,
however we pass `null` as the ctx.

It seems that what happens is that we look for the DOM element inside
the `document` (via getElementById) but this element is not yet inserted
into the document, hence this returns `null`.

Since we already have a reference to the canvas element which should be
used as ctx, we can probably just reuse this reference

closes odoo/odoo#36072

Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
2019-08-28 11:13:18 +00:00
Christophe Simonis f26de445e5 [MERGE] forward port branch saas-12.3 up to 6f55fd65da 2019-08-20 12:17:04 +02:00
Christophe Simonis 168e54d488 [MERGE] forward port branch 12.0 up to 32039b2ab4 2019-08-19 18:57:08 +02:00
Romain Derie 2f361bec36 [FIX] website(_*): better ondelete management on website_id
Before this commit, every model having website_id would have the default
`set null` as ondelete value for that field. Exception for `ir.ui.view` and
`website.redirect` which are set to `cascade`.

This meant that deleting a website would basically transform all its specific
records into generic ones.
That would lead to unwanted behavior, such as multiple `ir.attachment` with
same URL, when 2 websites had been theme-customized. Deleting one of the
website would result in later crashes when trying to open theme customization
in the remaining website(s), since those website would find their specific scss
custom attachment as well as the generic one from the deleted website.

Probably more behavior might be problematic when deleting a website before this
commit.

To summarize the choice of this commit implementation, every model not existing
outside website module are set to `cascade` (website.redirect, website.menu,
product.wishlist..).
The rest should be in restrict, as we don't want to delete a whole forum, blog
or job, which should probably be managed case by case to decide what to do.
Thus, restrict is a good choice to notify user of what should be handled.

Some exception remains, ir.ui.view should be delete on cascade while sale.order
should be set to null.

opw-2038414
opw-2035249

closes odoo/odoo#35398

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2019-08-13 10:02:32 +00:00
Antoine Guenet becfef8f7b [FIX] web_editor: properly start website edit mode as restricted editor
It was impossible to open the website's edit mode as a user with
"restricted editor" permissions. The reason was that wysiwyg_multizone
was trying to manipulate data that is not injected into the html node
when `editable` is false (see `website.layout` template).

closes odoo/odoo#31702

Signed-off-by: Pierre Paridans <pparidans@users.noreply.github.com>
2019-03-18 09:32:14 +00:00
Christophe Monniez fec86404e7 [IMP] tests: replace browser_js success and failure strings
When evaluating js tests using the browser_js method, they are
considered a success when 'ok' is found in the console log and a failure
if 'error' is found instead.

This is not very robust and recently failed with this commit : 7410de111f
It adds a filter named 'Error' in a view, when the 'click_all' test
clicks on this filter, a message with the name of the filter is written
in the console, wrongly leading to a test failure.

With this commit, the browser_js method expects a log message in the
browser console with the explicit text "test successful".
On the other hand, any error in the console log will lead to a test
failure but a test can be forced to fail with the explicit error message
in the browser console "test failed".

As a bonus, the python logger should now also log browser js trace messages.

closes odoo/odoo#31158
2019-02-19 08:06:07 +00:00
qsm-odoo 63e64c5420 [REF] website: restore skipped test
This reverts commit ba0fe3437f, as this
should be ok with recent forward-port.
2019-02-13 12:57:12 +00:00
Christophe Simonis ba0fe3437f [FIX] website: skip broken tests
Theses tests does not works with latests changes.
Skip these to allow other changes to be commited.
2019-02-05 10:34:29 +01:00
Romain Derie 751ea9634a [IMP] website: add tests for scss edition on html editor
As this behavior was recently broken (fixed in #30403), this commit
adds a test tour for that flow.

task-1934279
Fix #30447
2019-01-29 16:06:23 +00:00
Romain Derie 6bd579bd6b [FIX] web_editor: send the html editor writes one after another
With the following view hierarchy:
   A
   |
   B' (oe_structure_ID view)

Before this fix, when saving multiple templates at once from the same hierarchy
the COW views (website) would not be saved correctly as the first call to
`write` would COW the parent view, then the second concurent call to `write`
would create the child specific view under the generic parent view.
Instead, the generic parent should have been cloned to a specific parent view
and then the child view should be COW under the specific parent.

  A    A'
  |    |
  B'   B*' (This one is the old B', without B' changes in the html editor)

Instead of

  A   A'
      |
      B'

Calling the `write` one after another will do the trick. Indeed, when the
second call is fired, the first call has already triggered the COW behavior.
Thus, the second call correctly retrieves the COW view.

Another issue might still appear, if the parent view write is sent first.
Indeed, the parent view will be COW, thus the specific child view (second write
waiting to be fired) will be deleted to be added on the new specific hierarchy.
Thus, that write will then raise an error since the view does not exist anymore.

task-1934279
Fix #30447
2019-01-29 16:06:23 +00:00
Sébastien Theys df7326f0be [IMP] tests, *: add start_tour helper
Before this commit, the syntax to start a tour was extremely verbose.
With this new method, it is possible to start a tour by just giving the
essential parameter: the tour name.
The full set of features from browser_js are kept by using **kwargs.

closes odoo/odoo#32316

Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
2019-04-04 08:44:59 +00:00
Christophe Monniez b356b19033 [IMP] tests: Add the possibility to tag tests
Purpose: When running tests, all the tests for the installed/updated
files are done. This commit adds a 'tagged' decorator that can be used to
tag tests. Combined with a new 'test-tags' CLI option, it adds the ability
to filter which tests are executed. For example, @tagged('slow') will
add a tag 'slow' to the test. The CLI option 'test-tags="slow"' will
only run tests tagged 'slow'.

One can use prefixes to select cases with tags.
'+' or no prefix means that the tests tagged with this tag are selected
for execution. '-' prefix will exclude the tests tagged with this tag.
Exclusion takes precedence over inclusion.

Also, by default, all Odoo tests cases are tagged 'standard' and with
the technical name of the module.
This means that when selecting tests with the 'test-tags'
parameter, if '-standard' is not specified, all tests tags are
going to be executed.
When tagging tests, one can remove such automatic tag by prefixing the
tag name with '-'. E.g. @tagged('-standard') will remove the standard
tag from the test.

Another example, if one wants to test the 'sale' module alone,
even without adding any 'tagged' decorator thos tests can be selected
like that: --test-tags="sale"

Tests are selected or deselected using a TagsSelector. When instanciated,
 a string is passed with comma separated tests selectors like
'+slow,-standard'. When the 'check' method is called  with a test as argument,
it returns True or False if the test has to be executed or not.
2018-01-18 13:20:37 +01:00
qsm-odoo 2972976962 [REF] web_editor, website, *: complete refactoring
* mass_mailing, payment, point_of_sale, portal, survey, web, web_tour,
  website_blog, website_crm_partner_assign, website_event,
  website_event_questions, website_form, website_forum, website_gengo,
  website_hr_recruitment, website_links, website_mail,
  website_mail_channel, website_mass_mailing, website_quote,
  website_sale, website_sale_options, website_slides, website_twitter

This commit reviews the whole "JS side" of the web_editor and website
apps. This is a first step to be able to improve them with new and
better functionnalities; this commit is not supposed to change any
visual behavior.

The main goal was to achieve a structure similar to the backend one.
Now, the frontend side also has a root widget (like the WebClient)
and all other widgets are attached to it one way or another. This allows
the benefits of using the 'trigger_up' functionnality for example.

As RPC are now mainly done with the `this._rpc` functionnality (being
possible thanks to the parent hierarchy), the frontend will also be
possible to test thanks to QUnit in a future update (besides the "text"
editor side which still requires a refactoring to be able to do that).

---

Here are some of the changes:

(-) conventions and documentation

The code has been updated to follow JS conventions and a lot of code has
been commented (around +2000 lines of comment). This also means that
lots of functions have been renamed to use camelCase or simply to make
their name understandable.
See https://github.com/odoo/odoo/wiki/Javascript-coding-guidelines.

(-) deprecated: web_editor.base

The "web_editor.base" module has been split and does not force the
modules which require it to wait for DOM ready anymore. This was indeed
slowing loading times, but also prevented to use some modules in some
contexts (see the LESS editor use in web_studio which is the subject of
another task).
Now the "editor context" can be got thanks to the "web_editor.context"
JS module with its "get" function.
The "web_editor.base" module should probably not be used anymore (see
its code and recent updates).

(-) new: web.dom_ready

If a JS module should wait for the DOM to be ready to be executed, a
new JS module has been created: "web.dom_ready". This should always
be used in a module which only want to instantiate stuff. Do not
extend (or worst, include) classes after DOM ready.

(-) website.website

The "website.website" module has been split. "website.website" does not
return anything useful anymore, it just initialize some miscellaneous
stuff, without waiting for the DOM to be ready. You might want to check
"website.utils", "website.content.compatibility" or `WebsiteRoot`. Also
`website.form` has been deleted (use `this._rpc`), so has been
`website.error`. `website.prompt` will be removed in a future update to
be replaced by `Dialog.prompt`.

(-) widgets are great

Many classes which were not widgets are now widgets. This allows them to
use the 'events', the 'xmlDependencies' and the 'this._rpc' features for
example. Here are some of the main ones:

- Snippet options: these were classes with a `$el` for the menu element
    and `$target` for the customized element. This is still the case
    but following standard `Widget` structure (one exception: using
    `this.$(...)` searches in the `$target` as before this update).

- Snippet animations: instead of class instances with a `$target`
    element which can be `start` and `stop`, these are now standard
    widgets which can be `start` and `destroy`. `this.$target` is
    an alias to `this.$el` for ease of compatibility.

- Snippet editors: instead of class instances in charge of an editor
    overlay, these are now widgets. Each "child" snippet editor is
    properly attached as a "child", which allows editors to communicate
    and to be properly destroyed.

(-) root widgets and website navbar

The frontend is different of the backend. In the backend, the page has
an empty <body/> element and all the components are instantiated from
parent to children (i.e. the `WebClient` is instantiated and is in
charge of instantiating the `ControlPanel`, etc). The frontend cannot
work like that on page loadings as they are way more frequent than in
the backend and we do not want them to flicker. A frontend page is
loaded as a <body/> element which already contains the website navbar
and its menus and the whole content page. JS code has to be "attached"
to these existing elements. This is possible thanks to the `RootWidget`
instances and the specialized `WebsiteRoot`, `IframeRoot` and
`WebsiteNavbar` (see code for details).

(-) lazy loading

No more (or at least a lot less) XML/JS has to be loaded on page
loading, thanks to the use of the `Widget.xmlDependencies` feature.
XML which have to be lazy loaded is loaded only on related Widget
instantiation if necessary, which allows to execute a lot of JS code
before the DOM is ready and to start many widgets on DOM ready (not
later). A visual benefit of this is clicking on the 'edit' button as
soon as it is possible: before this commit, this was sometimes not
doing anything as event handlers were not binded yet.

Still a possible exception: loading the session and locales. This may
be asynchronous stuff which is still required before widget
instantiations but this will be the subject of another task.

(-) deprecated code and code location

More than reviewing code and organizing it, many apparent dead code was
removed. More importantly, mislocated code was put in the right app.
This is the case for snippet animations which is a concept for website
apps but was defined in the web_editor app, or some translation concepts
which were part of website but should have been part of web_editor.

---

There are probably more things to say about this commit but I will let
the comments speak for those.
2017-08-16 11:04:14 +02:00
Christophe Matthieu ea1c061e11 [IMP] website: convert tours to use web_tour.tour 2016-08-30 13:54:28 +02:00
qsm-odoo f9a84b5ebc [IMP] web_tour, *: allow to properly extend tours
* crm, project, website, website_event, website_blog, website_forum,
website_sale

Eg: the tour 'shop_buy_product' is extended by the website_sale_options
addons to add a step to close a modal.

The current solution was requiring the module that defines the tour
to extend, then add/remove steps in the "step" key of the tour
definition.
Some of the problems with this method were:
* The "register" method calls the "update" method to immediately
search for tip to place once registered (as register may be called
after the DOM is ready). So extensions of tours were happening after
the tours were started (and the tours were not restarted).
* The addition/removal of steps was happening after they were filtered
according to the "edition" key.

To allow extension, the system is changed as follow:
* The "register" method now only saves the steps and options without
modifying them and does not call the "update" method.
* Once the DOM was ready, the tour service started listening to DOM
mutations and called the "update" tour method. Now, this "update" call
is replaced by a "_register_all" call, on DOM ready and at the end of
the current call stack (which makes sure all modules are loaded). This
"_register_all" method marks the registered tours as ready after having
filtered the steps according to the "edition" key and initialized the
current step to trigger.
* Also, tours can now define a "wait_for" option which allow them to
be marked as ready for run and update after the given deferred. Those
tours can now also be extended without having to wait for the deferred.
PhamtomJS must wait for the "ready" key to be true to run the tour.
2016-08-26 13:39:55 +02:00
Jérome Maes 8a399930f3 [REF] website_*: remove render method on website
Since saas-3, website controllers use `request.website.render`
to render the template of a web page. This was kept for retro
compatibility. It's time to stop using deprecated stuff.
Same for `_render` method on website.

'json' route don't use `request.render` since
`JsonRequest` has no `render` method.
2016-08-04 12:02:14 +02:00
Ravi Gadhia fd09ddb6f3 [MIG] website: migration to new api
Migration of website module to new API.
The tricky phase is ir_http.py : we need to use `request.env`
only when the authenfication phase is done. Normally by
calling `super` of `_dispatch` method, but website module
required it to be done before. This is important since
`env`is a lazy property of `request` object.

Some hack were kept since this commit is a migration ('RequestUID'
in ir.http, ...)

Some docstrings were added.
2016-08-04 12:02:14 +02:00
qsm-odoo eaf8e82efb [IMP] *: activate automatic tour tests
* project, crm, point_of_sale, website, website_sale, website_blog,
website_event, website_forum
2016-07-18 14:22:29 +02:00
Christophe Matthieu 087fd6942b [IMP] web_editor: add test translator 2015-07-10 17:00:15 +02:00
Christophe Matthieu 8c559044a5 [IMP] web_editor: split website into web_editor (to use editor in backend for html field) and website 2015-07-10 17:00:11 +02:00
Géry Debongnie ebc39b8788 [FIX] update tests to new module system
Various tests (mostly tours) were broken with the large changes in the
way the js code works.
2015-03-18 09:23:37 +01:00
Christophe Matthieu 9069d0127c [IMP] website: use the new summernote editor 2015-01-05 10:59:42 +01:00
Leonardo Donelli 4a0b13ed92 [REF] remove vim modelines and resulting trailing blank lines
Let 2015 be a year without modelines!
cf #4174
2014-12-31 15:52:13 +01:00
Simon Lejeune 195fa93168 [MERGE] backend front end integration
Render the top-menu (backend menu or frontend editbar) server-side.
Use Fontawesome icons (mail, timezone, chat).
Refactor website widgets, split Website.editorBarin editorbar, ace, editorbar- content, editorbarCustomize.
2014-06-27 11:03:34 +02:00
Christophe Matthieu bc3fc54fac [IMP] Tour: add tour in web module; tour became available in backend. 2014-06-18 12:25:13 +02:00
chm@openerp.com 62814f9c23 [FIX] website: activate new tour tests
bzr revid: chm@openerp.com-20140324081112-15n58puu29weydme
2014-03-24 09:11:12 +01:00
Antony Lesuisse 0772c99bcb [FIX] website test, remove useless test, waitfor banner fix
bzr revid: al@openerp.com-20140316144546-agpgmlwxa532xxmb
2014-03-16 15:45:46 +01:00
Xavier Morel 55a9e5af27 [FIX] re-enable website_sale tests because they pass so whatever
bzr revid: xmo@openerp.com-20140219144754-52dz24qmnjq72zor
2014-02-19 15:47:54 +01:00
Xavier Morel a77097ce60 [REM] broken and PITA test_02_public_login_logout
* / fails to load, it turns out Tour is undefined because unlogged home does
  not load bootstrap-tour

* after injecting bootstrap-tour, redirects to /login (to log in), tries to
  inject tour again except this time ``openerp.website`` is completely empty
  (although it is present on the page), no idea why.

removed test because whatever, if enable-test-fix-tour is ever rewritten and
fixed it may reappear.

bzr revid: xmo@openerp.com-20140219142115-5kpu5uvzpkwnt1ef
2014-02-19 15:21:15 +01:00
Xavier Morel 86a537e6a7 [FIX] typo method name
bzr revid: xmo@openerp.com-20140219140241-5p6u4t818mkuo74w
2014-02-19 15:02:41 +01:00
Xavier Morel 61c82f28a4 [FIX] imports, use @expectedFailure, simplify some inject specs
bzr revid: xmo@openerp.com-20140218160339-2r34z4ks2o4lriu5
2014-02-18 17:03:39 +01:00
Xavier Morel c42f9553ec [IMP] remove pointless semicolons, use @expectedFailure instead of commenting broken test
bzr revid: xmo@openerp.com-20140218140610-t4amo9b2jjkk2r0h
2014-02-18 15:06:10 +01:00
Antony Lesuisse 2112eb6448 [FIX] website_sale enable some tests
bzr revid: al@openerp.com-20140217012827-3rb4mrkgx3ubp0dx
2014-02-17 02:28:27 +01:00
Antony Lesuisse e54758988a [FIX] website tests
bzr revid: al@openerp.com-20140217001148-2ub37hxyz8tbxrwe
2014-02-17 01:11:48 +01:00
Christophe Simonis f6422470dd ಠ_ಠ
bzr revid: chs@openerp.com-20140213152348-alye3ovcn2y53xp3
2014-02-13 16:23:48 +01:00
Antony Lesuisse 9c7f132a7a [IMP] website test_ui simplification
bzr revid: al@openerp.com-20140210005926-03hhcm56gpplgbt2
2014-02-10 01:59:26 +01:00
Antony Lesuisse bf2198e4c8 [IMP] website test shorter code
bzr revid: al@openerp.com-20140209234531-0i2xgr94yjaqzen8
2014-02-10 00:45:31 +01:00
Antony Lesuisse a21b1c4f8c [IMP] test_ui conversion, needs validation from chm
bzr revid: al@openerp.com-20140209232040-12uq85pseheth8z0
2014-02-10 00:20:40 +01:00
Christophe Matthieu efe1e4a183 [FIX] website test: remove hack for runbot
bzr revid: chm@openerp.com-20140207155454-jf3pwp3hl9nvay6m
2014-02-07 16:54:54 +01:00
Christophe Matthieu d432e56661 [FIX] website: for activate test on runbot
bzr revid: chm@openerp.com-20140207143241-e4u7ikvgbl0f980d
2014-02-07 15:32:41 +01:00
Christophe Matthieu 6cb5b1e556 [FIX] website: test tour: use admin insead of tools.config['admin_passwd']
bzr revid: chm@openerp.com-20140207130104-nuwurzlsvt4cu1jr
2014-02-07 14:01:04 +01:00
Christophe Matthieu b21bb08c22 [ADD] website: test login, backend, go back, branding, edit, logout
bzr revid: chm@openerp.com-20140207125231-3zd0i1axdwuht5g4
2014-02-07 13:52:31 +01:00
Christophe Matthieu 4663f5b10c [IMP] website test: add a timeout in phantom js to raise a better error and improve log error
bzr revid: chm@openerp.com-20140207074745-ffrcoi2aj5m67i8m
2014-02-07 08:47:45 +01:00
Christophe Matthieu e8964f896c [FIX] website: tour, test and test_runner
bzr revid: chm@openerp.com-20140206140746-jmeyx8q9qxv7sz1j
2014-02-06 15:07:46 +01:00
Antony Lesuisse 1c283ddf24 phantomjs segfaults
bzr revid: al@openerp.com-20140131002019-tbvgpunj6kj6675v
2014-01-31 01:20:19 +01:00