The logic responsible for parsing errors for the mobile editor lacks tests and is spread across both EditorOverlay.js and EditorGateway.js.This ticket encompasses cleaning up the code for all editing error scenarios so that they can be better managed in the future.
=== Developer notes (Here be dragons 🐉)
- 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 🧐).
- 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).
== Acceptance criteria (done)
[x] Fix error handling for edit conflicts
[x] Any errors are displayed inside the editor itself, above the preview like so:
[x] Move all logic relating to error classification inside the error handler for this.gateway.save from EditorOverlay into EditorGateway. EditorOverlay should simply print the error.
[x] There is currently an eslint-ignore-line for no-restricted-properties - this should be removed as part of the changes here.
[x] Add unit tests for error handling
= QA steps (reproduce the following editing error scenarios)
== read only error
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 error
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"
== http error
Open the editor
Disable your internet connection
The error message should be generic.
Try to create a new page on staging as an anonymous user.
Doing so should trigger the display of a captcha:
It should be possible to type in the captcha and save (note: only if you can decipher it! you may need to try several times...)