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).
= QA steps
== read only
Open the mobile editor.
While open, ask a developer to enable
$wgReadOnly = 'This wiki is currently being upgraded to a newer software version.';
 Does the read only message show when you try to save your edit?
== edit conflict
Open the editor in 2 tabs
In the 2nd tab make an edit and save.
In the 1st tab made an edit and save
In the 1st tab an error should show. It should make clear there has been an "edit conflict"
Open the editor
Disable your internet connection
The error message should be generic.
Instructions to follow
Instructions to follow