diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/web/static/tests/helpers/test_utils_form.js | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/web/static/tests/helpers/test_utils_form.js')
| -rw-r--r-- | addons/web/static/tests/helpers/test_utils_form.js | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/addons/web/static/tests/helpers/test_utils_form.js b/addons/web/static/tests/helpers/test_utils_form.js new file mode 100644 index 00000000..b4bff154 --- /dev/null +++ b/addons/web/static/tests/helpers/test_utils_form.js @@ -0,0 +1,74 @@ +odoo.define('web.test_utils_form', function (require) { +"use strict"; + +/** + * Form Test Utils + * + * This module defines various utility functions to help test form views. + * + * Note that all methods defined in this module are exported in the main + * testUtils file. + */ + +var testUtilsDom = require('web.test_utils_dom'); + +/** + * Clicks on the Edit button in a form view, to set it to edit mode. Note that + * it checks that the button is visible, so calling this method in edit mode + * will fail. + * + * @param {FormController} form + */ +function clickEdit(form) { + return testUtilsDom.click(form.$buttons.find('.o_form_button_edit')); +} + +/** + * Clicks on the Save button in a form view. Note that this method checks that + * the Save button is visible. + * + * @param {FormController} form + */ +function clickSave(form) { + return testUtilsDom.click(form.$buttons.find('.o_form_button_save')); +} + +/** + * Clicks on the Create button in a form view. Note that this method checks that + * the Create button is visible. + * + * @param {FormController} form + */ +function clickCreate(form) { + return testUtilsDom.click(form.$buttons.find('.o_form_button_create')); +} + +/** + * Clicks on the Discard button in a form view. Note that this method checks that + * the Discard button is visible. + * + * @param {FormController} form + */ +function clickDiscard(form) { + return testUtilsDom.click(form.$buttons.find('.o_form_button_cancel')); +} + +/** + * Reloads a form view. + * + * @param {FormController} form + * @param {[Object]} params given to the controller reload method + */ +function reload(form, params) { + return form.reload(params); +} + +return { + clickEdit: clickEdit, + clickSave: clickSave, + clickCreate: clickCreate, + clickDiscard: clickDiscard, + reload: reload, +}; + +}); |
