summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js
diff options
context:
space:
mode:
authorJulien Mougenot <jum@odoo.com>2020-03-11 09:38:27 +0000
committerJulien Mougenot <jum@odoo.com>2020-03-13 11:39:53 +0000
commit0a129284e4856b6485c48a194fd86c3ab5c736e7 (patch)
treedc0adb0c9528605019af5c915ad2c877f9aa1c57 /addons/web/static/src/js
parent72f1633532a586e1ccee4d2a961d745553b9d8b8 (diff)
[IMP] web,*: Enhance test helpers
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>
Diffstat (limited to 'addons/web/static/src/js')
-rw-r--r--addons/web/static/src/js/core/utils.js22
-rw-r--r--addons/web/static/src/js/tools/test_menus.js4
2 files changed, 24 insertions, 2 deletions
diff --git a/addons/web/static/src/js/core/utils.js b/addons/web/static/src/js/core/utils.js
index 243f3f51cd0..699a912ccc3 100644
--- a/addons/web/static/src/js/core/utils.js
+++ b/addons/web/static/src/js/core/utils.js
@@ -629,6 +629,28 @@ var utils = {
].join(';');
},
/**
+ * Returns a string formatted using given values.
+ * If the value is an object, its keys will replace `%(key)s` expressions.
+ * If the values are a set of strings, they will replace `%s` expressions.
+ * If no value is given, the string will not be formatted.
+ *
+ * @param {string} string
+ * @param {(Object|...string)} values
+ */
+ sprintf: function (string, ...values) {
+ if (values.length === 1 && typeof values[0] === 'object') {
+ const valuesDict = values[0];
+ for (const value in valuesDict) {
+ string = string.replace(`%(${value})s`, valuesDict[value]);
+ }
+ } else {
+ for (const value of values) {
+ string = string.replace(/%s/, value);
+ }
+ }
+ return string;
+ },
+ /**
* Sort an array in place, keeping the initial order for identical values.
*
* @param {Array} array
diff --git a/addons/web/static/src/js/tools/test_menus.js b/addons/web/static/src/js/tools/test_menus.js
index 9767aa29fed..0f91cab4c60 100644
--- a/addons/web/static/src/js/tools/test_menus.js
+++ b/addons/web/static/src/js/tools/test_menus.js
@@ -216,8 +216,8 @@
function testFilters() {
if (appsMenusOnly === true) return Promise.resolve();
var filterProm = Promise.resolve();
- // var $filters = $('div.o_control_panel div.btn-group.o_dropdown > ul.o_filters_menu > li:not(.o_add_custom_filter)');
- var $filters = $('.o_filters_menu > .o_menu_item:not(.d-none)');
+ // var $filters = $('div.o_control_panel div.btn-group.o_dropdown > ul.o_filter_menu > li:not(.o_add_custom_filter)');
+ var $filters = $('.o_filter_menu > .o_menu_item:not(.d-none)');
console.log("Testing " + $filters.length + " filters");
var filter_ids = _.compact(_.map($filters, function(f) { return f.dataset.id}));
filter_ids.forEach(function(filter_id){