diff options
Diffstat (limited to 'addons/web/static/tests/helpers/test_utils_modal.js')
| -rw-r--r-- | addons/web/static/tests/helpers/test_utils_modal.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/addons/web/static/tests/helpers/test_utils_modal.js b/addons/web/static/tests/helpers/test_utils_modal.js new file mode 100644 index 00000000000..d2162aebfa0 --- /dev/null +++ b/addons/web/static/tests/helpers/test_utils_modal.js @@ -0,0 +1,34 @@ +odoo.define('web.test_utils_modal', function (require) { +"use strict"; + +/** + * Modal Test Utils + * + * This module defines various utility functions to help test pivot views. + * + * Note that all methods defined in this module are exported in the main + * testUtils file. + */ + +var core = require('web.core'); + +/** + * Click on a button in the footer of a modal (which contains a given string). + * Note that this method checks the unicity of the button. + * + * @param {string} text (in english: this method will perform the translation) + */ +function clickButton(text) { + var selector = `.modal-footer button:contains(${core._t(text)})`; + var $button = $(selector); + if ($button.length !== 1) { + throw new Error(`Found ${$button.length} button(s) containing '${text}'`); + } + $button.click(); +} + +return { + clickButton: clickButton, +}; + +}); |
