From a52789a8b5d136902f7cbcde17f8e6a4b003b885 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 25 Jul 2022 05:51:16 +0000 Subject: [PATCH] [ADD] web_tour: utility steps to finish form edition A tour finishing while a form is in edition mode is an issue, as it then triggers an `urgentSave` which generates network traffic (and promise handlers) during browser cleanup, at a time when the state of the browser may not be entirely coherent. Two methods seem to be the most common here: - drop form during creation, aka the tour mostly wants to mess around with onchange & ui & error reporting, in those cases the tour just stops using the form, the "proper" way to handle this is to cancel the creation and wait until back to the list view (note: the utility step does not currently handle situation where the creation was triggered from an other form view, or canceling an edition) - save form during creation or edition, aka the tour wanted to create an object, did trigger a save, but didn't wait for the save to complete, leading to the tour finishing mid-save (which in theory should allow the save to complete but may still trigger odd effects) Part-of: odoo/odoo#96517 --- .../web_tour/static/src/js/tour_step_utils.js | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/addons/web_tour/static/src/js/tour_step_utils.js b/addons/web_tour/static/src/js/tour_step_utils.js index 866c804cf94..83adb1f842b 100644 --- a/addons/web_tour/static/src/js/tour_step_utils.js +++ b/addons/web_tour/static/src/js/tour_step_utils.js @@ -157,5 +157,43 @@ return Class.extend({ }, ].map(this.addDebugHelp(this._getHelpMessage('mobileKanbanSearchMany2X', modalTitle, valueSearched))); }, + /** + * Utility steps to save a form and wait for the save to complete + * + * @param extra_trigger additional save-condition selector + */ + saveForm(extra_trigger) { + return [{ + content: "save form", + trigger: '.o_form_button_save:contains("Save")', + extra_trigger, + run: 'click', + auto: true, + }, { + content: "wait for save completion", + trigger: '.o_form_readonly', + run() {}, + auto: true, + }]; + }, + /** + * Utility steps to cancel a form creation or edition. + * + * Supports creation/edition from either a form or a list view (so checks + * for both states). + */ + discardForm() { + return [{ + content: "exit the form", + trigger: ".o_form_button_cancel", + run: 'click', + auto: true, + }, { + content: "wait for cancellation to complete", + trigger: ".o_list_renderer, .o_form_readonly", + run() {}, + auto: true, + }]; + } }); });