Discovered [[ https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/MobileFrontend/+/453131/3/resources/mobile.editor.overlay/EditorOverlay.js@626 | in code-review ]] for T197499, the error handling for the mobile wikitext editor does not produce the correct error messages when an edit conflict occurs. Instead it produces a generic error message "Error, edit was not saved".
//This ticket also encompasses cleaning up the code for the remaining error scenarios so that they can be better managed in the future. //
=== Steps to Reproduce
(i.e. create an edit conflict)
# Open a mobile test page, such as [[ https://en.m.wikipedia.beta.wmflabs.org/wiki/Math | betawiki Math ]] in two tabs
# In both tabs, open the mobile editor
# In one tab, save an edit
# In the other tab, try to save the edit.
=== Expected Results
- The first edit should save successfully (which it does).
- The second edit should produce an edit conflict (which it does), and warn the user with the `mobile-frontend-editor-error-conflict` message. (i.e. "Error, another user has edited this page."), which it doesn't.
=== Actual Results
- The first edit saves successfully
- The second edit produces the generic HTTP error message instead of the error-conflict message.
- NOTE: currently, NO message is visible because the toast-message fail to render properly in the overlay, after T197499, a red error box should be seen.
=== Environments Observed
- Local, beta-wiki
=== Testing Environment for QA
- beta cluster
=== Developer notes
- The edit-conflict scenario falls through to the `fail` handler in [[ https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/MobileFrontend/+/refs/heads/master/resources/mobile.editor.api/EditorGateway.js#252 | EditorGateway.js#252 ]] even though it produces a 200 response.
- That failure is passed to the fail handler in [[ https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/MobileFrontend/+/refs/heads/master/resources/mobile.editor.overlay/EditorOverlay.js?autodive=0%2F#590 | EditorOverlay.js#590 ]] (which expects three parameters, but is only given one 馃).
=== Here be dragons 馃悏
- there are many nested conditionals in the error handling, across both EditorGateway.js and EditorOverlay.js
- The responsibilities between which errors are handled in EditorGateway.js and EditorOverlay.js are mixed.
- there are no tests for the edit-conflict scenario.
- The Deferred's `.fail`s should be switched to Promise compliant `.catch`s. (in the code as well as in tests).