summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/helpers/test_utils.js
AgeCommit message (Collapse)Author
2020-08-13[FIX] mail: fix full composer opening with attachmentsXavier Dubuc
task-2307201 closes odoo/odoo#55678 X-original-commit: 9c47bb0b0034a3419a0c6e3267d90cb520a59535 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com> Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2020-07-23[IMP] web: TestUtils findItemJulien Mougenot
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
2020-06-12[IMP] web: tests: rework mock helpersAaron Bohy
This commit reworks the test helpers, following recent changes on services deployed in the Owl env.
2020-06-10[IMP] web: add 'Create and edit' test helperJulien Mougenot
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");`
2020-06-04[IMP] web: adapt test_utils_control_panelMathieu Duckerts-Antoine
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 <dam@odoo.com> Co-authored-by: Julien Mougenot <jum@odoo.com>
2020-03-13[IMP] web,*: Enhance test helpersJulien Mougenot
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 <dam@odoo.com>
2020-03-13[REF] web: Update generic filesJulien Mougenot
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.
2020-03-13[REF] web: Indent and reorganize generic filesJulien Mougenot
The purpose of this commit is to correctly indent and order some generic files. There is strictly no change in the code logic.
2020-01-21[IMP] web: Owl compatibility: add ComponentAdapterAaron Bohy
This commit adds the ComponentAdapter, an Owl component meant to be used as universal adapter for Owl components that embed Odoo legacy widgets. This component will be a precious tool during the transition phase of converting our JS codebase from the legacy (widget) framework to Owl.
2019-12-09[FIX] web,*: fix all tests and test utils to use native eventsVincent Schippefilt
In this commit: - transformed test_utils helpers to always trigger native events - introduced new test_utils_create helper: prepareTarget - updated qunit asserts to support Owl Components - updated all misused helpers that would crash with the updated test_utils Co-authored-by: Julien Mougenot <jum@odoo.com> Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com> Co-authored-by: Pierre Rousseau <pro@odoo.com>
2019-09-09[IMP] web: edit translations in new dialogVincent Schippefilt
Before this commit, translations were edited in a list view with a filter on the field that needed to be translated. After this commit, the translations for each fields are translated in a dedicated dialog. The changes done to the current language are taken into account immediately, both ways, from the dialog to the form and from the form to the dialog. Translating terms is also available in create mode, the user will be prompted to save before editing a translation Task ID: 2028152 closes odoo/odoo#36185 Signed-off-by: VincentSchippefilt <VincentSchippefilt@users.noreply.github.com>
2019-08-26[REF] web,*: native event dispatching in test utilsJulien Mougenot
*: mail,partner_autocomplete: adapted tests Added a new function to trigger the adequate type of event on an element (native JS event to DOM Nodes and jQuery event to jQuery objects), and refactored the generic event-triggering functions to call this new function.
2019-08-08[IMP] web: adds multi file drag and drop supportThanh Dodeur
This commit adds a function to mock multi-file drops. Task: #2002553 closes odoo/odoo#35435 Signed-off-by: Martin Geubelle (mge) <mge@openerp.com>
2019-06-06[FIX] mail, web: directly load async debug.xml during QUnit testsRomain Derie
Before this commit, the test `list: edit view menu item` would sometimes crash as now the debug manager loads its templates with an `xmlDependencies` where it was not the case before (included in base.xml), see 73327db0656bf.
2019-05-14[FIX] web: restore notifications about disconnectionsfja-odoo
The disconnected/connected notifications were broken due to changes in the way the Notification template was loaded. We need it loaded in assets as we cannot load it afterward if the server is disconnected. This was broken by : https://github.com/odoo/odoo/pull/32793 closes odoo/odoo#33252 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2019-04-24[IMP] web, *: share and improve notification systemqsm-odoo
* barcodes, calendar, partner_autocomplete, web_settings_dashboard Make the notification system better, using bootstrap toast component, and make it available in the frontend. The toast component allowed to remove some JS code and made the component customizable by themes but it had to be reviewed/fixed to make it functional (maybe bootstrap will review its work in next versions). This work should still be improved because there are still too many ways (deprecated and not deprecated) to instantiate toasts in the backend. The goal here was however to make the toasts more modern and make them available in the frontend. This work is needed for some tasks. @kig-odoo and @fja-odoo made a pre-work to instantiate toasts in the frontend for their respective tasks. This commit unifies the system. Part of https://github.com/odoo/odoo/pull/32793 task-1970731 closes odoo/odoo#32793 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2019-03-06[REF] web: adapt code after jQuery updateVincent Schippefilt
Part of task 1896658 Co-authored-by: Aaron Bohy <aab@odoo.com> Co-authored-by: Christophe Matthieu <chm@odoo.com> Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com> Co-authored-by: David Monjoie <dmo@odoo.com> Co-authored-by: Martin Geubelle <mge@odoo.com> Co-authored-by: svs-odoo <svs@odoo.com> Co-authored-by: Vincent Schippefilt <vsc@odoo.com>
2018-12-07[REF] web: move ControlPanel inside controllers/actionsGéry Debongnie
This branch introduces a large-scale reorganization of the component tree generated by the web client. The short version is that now, the control panel is a child of the view controller and no longer a sibling. Graphically (and simplified), we go from this: webClient / | \ ... ... actionManager / \ controlPanel viewController / \ to this: webClient / | \ ... ... actionManager | viewController / | \ ControlPanelController / \ CPRenderer CPModel The motivation is that this work moves the code where it should be. Before this commit, it was kind of weird to have code in the controllers to render buttons outside of their root node (in renderButtons). Also, the action manager had to take care of coordinating search view states between view transitions. So, this work simplifies the code. It also makes it easier to extend. We see day after day that Odoo needs to take care of more complex UI needs, and in many cases, these needs were quite difficult to implement (we prefer spaghettis in our plates, not in our code). The changes in this branch should open the way to implement these features. For example, - it will now be easy to add the possibility of views (for example, the search view or a new ControlPanel view) to add custom buttons (of type action or object) in the control panel. - Another need will be to serialize/ restore the state of the search view across action boundaries (needed by the dashboard). - Another example is the possibility for views to customize easily the presence/absence of sub menus (filters/groupbys/favorites/ time range/...) - Another need is an easier way for views/client action to customize their control panel. This commit also contains a large rewrite of the search view (so it is more inline with our architecture and easier to maintain). Part of task 1893568 Co-authored-by: Aaron Bohy <aab@odoo.com> Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com> Co-authored-by: Martin Geubelle <mge@odoo.com>
2018-11-26[ADD] web:tests: test utils for drag/drop filesAlexandre Kühn
This commit adds test helper functions to drag and drop files: - `createFile`: create a file that can be used for drag and drop in tests. - `dragoverFile`: to drag a file created from `createFile` over a DOM element. - `dropFile`: to drop a file created from `createFile` on a DOM element. These utility functions are available from `testUtils.file`. Example of usage: ```js var testUtils = require('web.test_utils'); testUtils.file.createFile({ name: 'text.txt', content: 'hello, world', contentType: 'text/plain', }).then(function (file) { testUtils.file.dragoverFile($el, file); testUtils.file.dropFile($el, file); }); ```
2018-11-23[MERGE] forward port branch 12.0 up to b3052b690faChristophe Simonis
2018-11-20[IMP] web: tests: backport of new helpersAaron Bohy
This rev. is a partial backport of abf32b8b, so that the newly introduced helpers are already available in 12.0. closes odoo/odoo#28827
2018-11-20[IMP] web: testUtils: ensure backward compatibilityAaron Bohy
Rev. 7c3d5dc0 recently added new helpers to use in the tests, and moved some existing helpers to testUtils sub groups (like .dom or .mock). This rev. adds a compatibility layer to ease forwardports. closes odoo/odoo#28824
2018-11-19[REF] *: update js test suite to use helpersGéry Debongnie
This rev. introduces robust helpers to use in the JS tests suite to interact with DOM and components, and starts using them (almost) everywhere. All the helpers are exposed though testUtils.js. There are 2 kinds of helpers: 1. Assertions ------------- * assert.containsNone, containsN, containsOnce check that the DOM (or a specific part of the DOM) contains a `selector`. It generates a correct error message automatically. ex: assert.strictEqual(form.$('.o_form_editable'), 1, "msg"); -> assert.containsOnce(form, '.o_form_editable'); * assert.isVisible, isNotVisible check that the DOM has an element visible or not. They also check that the element is actually in the DOM (before most tests didn't verify this). * assert.hasClass, doesNotHaveClass, hasAttrVAlue, check specific properties of a DOM element, and also validate that it is applied on a single existing DOM element (before most tests didn't verify this). ex: assert.notOk(form.$('button').hasClass('btn-primary')); -> assert.doesNotHaveClass(form.$('button'), 'btn-primary'); 2. Utilities ------------ The goal of the utilities is to centralize the definition of many standard components and interactions, ensuring that when we refactor the JS framework, we do not need to change all the tests. Existing mock utilities (addMockEnvironment, intercept, path, patchDate, unpatch and fieldsViewGet) are moved to 'testUtils.mock.*'. Existing DOM utilities are moved to 'testUtils.dom.*'. New dom utilities are created for opendDatePicker, click, clickFirst and clickLast. Helper `click` verifies that there is exactly 1 element visible in the DOM you click on, `clickFirst` and `clickLast` verify that there are more than one element on the DOM. ex: form.$('button').click(); -> testUtils.dom.click(form.$('button')); New Form utilities: (testUtils.form.*) clickEdit, clickSave, clickCreate, clickDiscard, all clicks on the control panel buttons of the form. `reload` reloads the form data. New modal, graph, kanban and pivot utils (testUtils.pivot.*, testUtils.kanban.*, etc.). New fields utils: (testUtils.fields.*) * editInput, editSelect: allow to change the value of a field, using a selector to identify it. They validate that the input exists and trigger the change event automatically. * editAndTrigger: allow to modify a field and trigger specific events after the value change * many2one (testUtils.fields.many2one.*) clickOpenDropdown, clickHighlightedItem, clickItem, searchAndClickItem: use a field name instead of a selector and do all the complex mechanism to open, filter and highlight many2one fields. Joint work with aab, dam, ged, mge, svs and vsc.
2018-11-06[MERGE] forward port branch 12.0 up to dd70c684268Christophe Simonis
2018-10-29[MOV] web, base_import: mobile tests should be in mobile suiteAdrien Dieudonne
This fix some inconsistent error on runbot. In mobile, some views* depend on 'jquery.touchSwipe' library which is lazy loaded. As a result, the views become asynchronous... It's why this library is already loaded before running tests in the mobile test suite. So we can continue to use synchronous views whether in mobile tests or not. But some mobile tests weren't in mobile suite... In desktop, 'jquery.touchSwipe' is lazy loaded and the first test will load it for others. It's why the first one has to be asynchronous: https://github.com/odoo/odoo/commit/da7b59045d246c159f93bc75e3f19c6b1221d31c The inconsistency comes from the fact that all tests are sequential but we can't garantee the execution order. So, if the test mentionned is not the first executed one, an error will occur because the view is not asynchronous. Now, all mobile tests are moved in mobile suite to be sure that 'jquery.touchSwipe' is loaded. We also set the default value for size_class because we want a coherent environment. It is very rare to find mobile devices with more than 474px wide. *: form_view, kanban_view, res_config_settings closes odoo/odoo#28195
2018-10-22[MERGE] forward port branch saas-11.4 up to 3c108977c1eChristophe Simonis
2018-10-17[MERGE] forward port branch saas-11.3 up to 0de06a41326Christophe Simonis
2018-10-16[MERGE] forward port branch 11.0 up to b29b545fe84Christophe Simonis
2018-10-22[MERGE] forward port branch 12.0 up to b81c2bce846Christophe Simonis
2018-10-19[IMP] web: remove es5 shimVincent Schippefilt
The library es5 shim was usefull for older browsers that do not implement completely the es5 specifications, like IE9. As we do not support browsers older than IE11, that fully supports all the features of es5, the library has become useless. Removing this library will remove a little bit of noise in the callstack when debugging. closes odoo/odoo#27877
2018-10-12[FIX] board: translate custom views according to current userLucas Perais (lpe)
Have a user in English, put a sale report as "favorite" (pinned to dashboard app) Change the user's language Before this commit, the pinned view was in English (because it was recorded that way) After this commit, the pinned view is in the user's language. OPW 1890664 closes odoo/odoo#27574
2018-10-01[MERGE] forward port branch saas-11.4 up to 57e387b6452Christophe Simonis
2018-09-20[FIX] web: add mouseenter when triggering a dra&drop in testsVincent Schippefilt
2018-09-17[FIX] web: datepicker: correctly use libAaron Bohy
The datepicker lib has been updated to tempus dominus (BS4) recently, but our code hasn't been adapted correctly to the requirements of the new version of the lib. As a consequence, the datepicker didn't close itself when the input was focused out anymore. This required a slight change in the DomainSelector widget as it produced a crash when a focused datepicker widget is removed from the DOM (before the datepicker is destroyed), e.g. by a call to html() on one of its parent. Task 1878254
2018-09-14[FIX] web:tests: correctly handle parameter 'services'Alexandre Kühn
This commit fixes the handling of the service parameter in a mocked environment: - updated docstring: now an object (previously an array) - no longer used by mocked server (unused parameter) - enforces default value for this parameter (empty object)
2018-09-14[FIX] web: tests: adapt JS tests from forward-port ↵Alexandre Kühn
9c77066f345360429a0920ca4d17af1f84a7ebea The test was failing because it was using an old approach to mock services in JS tests. Also, it provides ajax service in the list of services, which was not supported in a mocked environment. With this commit, when an ajax service is provided in the test, it will use this service instead of using mocked RPCs from the mocked server.
2018-09-14[MERGE] forward port branch saas-11.4 up to 6c103589c15Christophe Simonis
2018-09-13[IMP] mail, web: attachments & messages in debug actions.ThanhDodeurOdoo
- added two new actions to the form view debug action list, both opens list (+ form) views of messages and attachments respectively for which the domain is restricted to the current record. task: 1860031
2018-09-10[FIX] web: ajax must return a promise with abort methodChristophe Matthieu
Remove part in service_mixins who hide this error. Queries must be able to be canceled for better performance. Also in the case of longpolling, if the request is not canceled, wait for a server message or the maximum time (30 sec) to add or delete channels.
2018-08-23[FIX] web: view list grouped renders nicelyVincent Schippefilt
Before this fix, the list grouped did not render correctly when the list was not selectable and there was 1 or 2 fields (the sum in the footer was not aligned on the correct column) Also fixed the fact that the group pager was not displayed if the list had only 1 field and it was grouped
2018-08-17[FIX] web: tests: correctly unpatch classesAlexandre Kühn
Before this commit, `testUtils.unpatch` was incorrectly unpatching a class' properties. That is caused by restoring the properties on the class function itself, instead of the prototype of the class function. This commit fixes this issue by restoring properties on the prototype function of the class on `testUtils.unpatch`.
2018-08-17[DOC] web:tests: add docstring for `testUtils.patchDate`Alexandre Kühn
2018-08-14[IMP] web: add a patchDate function in testUtilsMathieu Duckerts-Antoine
This function allows to properly mock Dates in js Tests
2018-08-13[IMP] web: add options to `dragAndDrop` test util functionChristophe Matthieu
There is now an option `continueMove` that can be used to extend a previous drag done in this function. The option `position` has also been extended to take an object (to precise the move position).
2018-08-13[IMP] web: avoid failed tests affecting the next onesChristophe Matthieu
When using positional clicks (among other examples) in tests, a previous failed test might affect a next one because the assert failures are displayed on the top of tests.
2018-08-13[IMP] web, web_tour: handle iframe in tests and tourMartin Geubelle
In both test util functions (`dragAndDrop`) and tours, using elements in iframe was not supported. As a jQuery selector won't work with an iframe, when using a selector like `div.o_my_class iframe p:first` the tour manager will split the selector, which will result to `$('div.o_my_class iframe').contents().find('p:first')`.
2018-08-09[FIX] web: in the test the mocked services use the tests featuresChristophe Matthieu
Must move the service construction to intercept the request with the test parameters
2018-08-09[IMP] web: remove useless service nameChristophe Matthieu
We use the registry keys as name for the services.
2018-08-01[MERGE] forward port branch saas-11.4 up to 8d9366197e1Christophe Simonis
2018-08-01[MERGE] forward port branch saas-11.3 up to 691dd65e0ecChristophe Simonis