[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
This commit is contained in:
Xavier Morel
2022-08-04 09:14:09 +02:00
parent d22cd89a60
commit a52789a8b5
@@ -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,
}];
}
});
});