summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/helpers/test_utils_create.js
AgeCommit message (Collapse)Author
2020-10-06[FIX] web: hide action button when no actionPriyanka Kakadiya
Before this commit: the action menu registry items were rendered regardless of their inner state. The problem is that these item components can choose not to render themselves, leading to a blank dropdown menu if no other item was present. To fix this, the "getProps" function of the registry has been altered to act as validation: the item will not be rendered if the return value is falsy. The function has also been made asynchronous to allow RPC calls. This solution is still flawed and hides a bad design choice which is to register components and not items or item getters; this API is too complex for its use case(s) and adds pointless depth to the DOM. The shape of the registry should be simplified in an improvement in master. closes odoo/odoo#59254 Task: 2325587 X-original-commit: 45c7d881a5d130f6b3222749c8c87b6c6b45e910 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com> Co-authored-by: Julien Mougenot <jum@odoo.com> Co-authored-by: Mohammed Shekha <msh@odoo.com>
2020-07-23[IMP] *: adapt tests to Owl search panelJulien Mougenot
Adaptation of the tests to the changes regarding the refactored search panel and model. Part of task 2228968 Co-authored-by: Julien Mougenot <jum@odoo.com> Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
2020-06-25[FIX] web: in search view, use modifiers to determine if filter is invisibleXavier ALT
In search view, the "invisible" attribute can use complex expression, and so we must rely on the "modifiers" attribute set by the ir.ui.view post-processing to determine if a filter should be invisible or not. For example, considering the context {'hide_myfilter': False}, the following view: ```xml <search> ... <filter name="myfilter" string="My Filter" invisible="context.get('hide_myfilter')"/> ... </search> ``` Will be returned as such by the server: ```xml <search> ... <filter name="myfilter" string="My Filter" invisible="context.get('hide_myfilter')" modifiers="{&quot;invisible&quot;: false}"/> ... </search> ``` After this commit, the filter "myfilter" will correctly be shown. OPW-2243639 closes odoo/odoo#53690 X-original-commit: 00969326e24dadd9b3f6e026789a1e575dd1c8dc Signed-off-by: Aaron Bohy (aab) <aab@odoo.com> Signed-off-by: Julien Mougenot (jum) <jum@odoo.com> Signed-off-by: Xavier ALT <xavieralt@users.noreply.github.com>
2020-06-22[IMP] web: add support of "sample" attribute in viewsJérémy Hennecart
With this commit, it is now possible to display sample (fake) data in empty views, in the hope of easing user onboarding. This can be enabled (in list and kanban views) with attribute sample="1" on the arch root element. In this case, if there is no data to display, sample data will be generated based on heuristics (depending on field types and names). This can be used in addition to the no content helper. Task 2232801 X-original-commit: 7c8e627ff5029cb539d702705e5ce53d658c76ed Co-authored-by: Aaron Bohy <aab@odoo.com> Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com> Co-authored-by: Jérémy Hennecart <jeh@odoo.com> Co-authored-by: Julien Mougenot <jum@odoo.com>
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-03-31[REF] calendar,web: update to FullCalendar v4Romeo Fragomeli
This commit updates the FullCalendar library from v3 to v4. The purpose of this update for us is to add a proper support of the drag-and-drop of events on mobile. But also to fix scrolling issues present mainly on smaller screens. In those configurations multi/inner-scrolls were present resulting into either the inability to properly scroll the desired content or even blocking alltogether the scroll. As a nice-to-have feature, the version 4 removes its dependency on the jQuery library, allowing a faster loading of a bigger set of events. Last but not least, this version also reduces its dependency on the Moment.js library (but still keeps a binding to it for compatibility purpose). This commit focus only on the update of the library itself and the adaptation of the related code to keep it working. Further enhancements/fixes will be done later on. To do so it modifies the following points: * Update the library in itself (js, css...). * Convert all FullCalendar's method calls to the new syntax (e.g. `$calendar.fullCalendar('destroy')` becomes `calendar.destroy()`). * Add a utility method to convert v4 events into the old v3 event structure to ease the transition from one version to the other. * Wrap all event's custom fields into a new event's `extendedProps` object (as its the new way of storing them instead of directly as a prop. of the event). * Adapt `slotLabelFormat` and `weekNumberCalculation`. * Use the view's new names: ** `agendaDay` -> `timeGridDay` ** `agendaWeek` -> `timeGridWeek` ** `month` -> `dayGridMonth` * Use the option's new names: ** `viewRender` -> `datesRender` ** `eventMouseover` -> `eventMouseEnter` ** `eventMouseout` -> `eventMouseLeave` ** `isRTL` -> `dir` ** `selectHelper` -> `selectMirror` ** `weekNumberTitle` -> `weekLabel` Ref: https://fullcalendar.io/docs/upgrading-from-v3 Task ID: 2092550
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.
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-10-01[FIX] web: repair keyboard navigation in filter menuMathieu Duckerts-Antoine
Before this commit, invisible filters were rendered by QWeb but hidden in the filter menu. This used to break the keyboard navigation in the filter menu. Now we don't render at all those filters since they were completely useless anyway. This fixes the original problem. Task ID: 2057012 closes odoo/odoo#37567 Signed-off-by: VincentSchippefilt <VincentSchippefilt@users.noreply.github.com>
2019-09-13[MERGE] forward port branch saas-12.4 up to fe59754c520Christophe Simonis
closes odoo/odoo#36721 Signed-off-by: Christophe Simonis <chs@odoo.com>
2019-09-11[MERGE] forward port branch saas-12.3 up to 50e571acf7cChristophe Simonis
closes odoo/odoo#36491 Signed-off-by: Christophe Simonis <chs@odoo.com>
2019-09-05[FIX] web: unpatch test Views earlierChristophe Simonis
We need to unpatch the view as soon as we correcly applied the `groupedBy` attribute to avoid sub views to also be patched. closes odoo/odoo#36486 Signed-off-by: Christophe Simonis <chs@odoo.com>
2019-06-05[IMP] *: add debug manager in frontendRomain Derie
Now that the debug mode is stored in session, we need a clear indication that debug mode is activated. In backend, the 'fa-bug' is doing the trick but in frontend there is no visible clue that debug mode is enabled. This commit separate the debug manager code/feature so we can instanciate it in frontend only with usefull options (such as enable assets, leave debug mode..). Now, in frontend, people having access to the navbar (o_main_navbar) will see the same 'fa-bug' icon with minimal options as mentioned above. Also, in the footer, there will be another 'fa-bug' icon without any options. It will be usefull when the navbar is not shown, typically the case for public user, or for portal (without website installed)). Clicking on it will simply leave debug mode as hinted in tooltip. task-1934445 Comes with https://github.com/odoo/enterprise/pull/4281 Closes #33213
2019-07-19[IMP] base,web*: searchpanel in all multi record viewsLucas Perais (lpe)
Before this rev. the searchpanel could only be activated in kanban views (and it was specified in the kanban arch). From now on, the searchpanel can be activated in any multi record view. It's arch is moved to the search view arch (inside the <searchpanel> tag). Task 1985921 Co-authored-by: Aaron Bohy <aab@odoo.com>
2019-04-05[FIX] web: corrected the order of icons in systrayVincent Schippefilt
Since the merge of JQuery 3, the building of systray icons is non deterministic. After this fix, the menus are loaded correctly in order. Task-ID: 1960741 closes odoo/odoo#32382 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2019-03-27[FIX] web: tests: correct pass `hasSelectors`Martin Geubelle
The attribute is true by default, but when it is set to `false` in a test, it was not correctly passed in the view. Note that it has no impact currently in the tests. closes odoo/odoo#32175 Signed-off-by: Aaron Bohy (aab) <aab@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-11[FIX] web: display action menu in form/list viewGéry Debongnie
The recent refactoring of the control panel moved the sidebar management from the action manager to the view itself. However, the sidebar parameter was forgotten, which resulted in the fact that it was no longer created. This fix was a little tricky, because the sidebar needs to be instantiated in some tests, but not in most of them (in particular, the document application changes its behaviour, which is annoying). closes odoo/odoo#29389
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-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.