Autosave: Improve E2E test reliability by consuming synchronous data and bailing on save failure#17679
Conversation
|
Travis isn't flattered with the proposed changes: It's surprising that there are no notices found. |
|
|
||
| await page.reload(); | ||
| await page.reload( { waitUntil: [ 'domcontentloaded', 'networkidle2' ] } ); | ||
| await sleep( 2 ); |
There was a problem hiding this comment.
Why does it need to wait 2 seconds after reload?
There was a problem hiding this comment.
Was playing with reliability, expecting the failures to be related to a longer-than-expected data resolution for remote autosaves after the page has loaded.
With that in mind I just pushed 307f95a, which I'm more hopeful about. However, as I was waiting for Travis I just saw a test failing locally. (ノ°Д°)ノ︵ ┻━┻.
|
Can you describe what the issue is and how you think it could be solved? Do you know why does this particular test fail? I can help debugging tomorrow. |
Sure, and thanks for offering help. From the logs, it seems that autosaving on the server occasionally just fails… because So this last change was a desperate attempt at retrying autosaving on the server. |
* Until now, although we were requesting the entire autosave entity inside `LocalAutosaveMonitor`'s `useAutosaveNotice`, we only care about the existence or absence of an autosave for the current post. * `useAutosaveNotice` was requesting the entire entity because there were plans in #17501 to compare local and remote autosave objects, a requirement which was later dropped. * In contrast, the editor setting `autosave` is immediately available upon editor initialisation. * Later on, _if_ we choose to reconcile remote and local autosaves with more sophistication, this could possibly be done based on recency of autosave -- in which case we could might still get away with editor settings if the server provides this information inside the `autosave` object. * This change should hopefully provide a more reliable page-loading experience for autosave's E2E tests.
| // autosaved. The reasons for this are still unknown. Since this is | ||
| // unrelated to *local* autosave, until we can understand them, we'll | ||
| // drop this test's expectations if we don't have an autosave object | ||
| // available. |
There was a problem hiding this comment.
For me, we should just skip the test in this case instead of making it inconsistent.
There was a problem hiding this comment.
ideally, we find the real issue though :) @jasmussen had the issue while working on some PRs.
There was a problem hiding this comment.
Was this worked on?
Still see the code:
gutenberg/packages/e2e-tests/specs/editor/various/autosave.test.js
Lines 333 to 346 in 5a5564b
Could we track it in an issue?
There was a problem hiding this comment.
It wasn't, and it still feels nebulous.
gziolo
left a comment
There was a problem hiding this comment.
It looks like a ton of work to improve the stability of this test. Major props for investing so much time to fully understand what the underlaying issue is.
I re-triggered Travis 3 times and it confirms that this fix is solid.
I don't want to block this PR with my own testing. Let's get this in and I will do my own experiments of the stable master branch. The reliability of the tests is the most important as it increases the confidence that Travis is useful :)
|
My further explorations performed in #17749 didn't help so far. We probably need to investigate whether autosave works properly in all cases. We might replicate what's used in one of the test where we intercept requests to gather more data where the issues might originate. See my related comment: #17749 (comment). |
|
I agree, and thanks for digging!
|
Description
Recently-merged #17501 and #17503 greatly expanded the reach of autosaving and its E2E test coverage. These tests have been remarkably unreliable, especially on Travis, something which this PR sought to fix, and does fix in two main ways.
Terminology preamble
A local autosave is an action — or its resulting object — performed on the client, the object then residing in
window.sessionStorage. A remote autosave is a special kind of WordPress post revision saved on the WordPress site itself. Local autosaves are cheaper but more volatile, and can be performed more frequently, whereas remote autosaves are persisted across clients for a given WordPress user. Currently, per #17500, remote autosaves should take precedence over local ones._Fixes
LocalAutosaveMonitorwaits for remote autosave data.Until now, although we were requesting the entire remote autosave entity inside
LocalAutosaveMonitor'suseAutosaveNotice, we only cared about the existence or absence of a remote autosave for the current post.useAutosaveNoticewas requesting the entire remote entity because there were plans in Autosave: fix conflict between remote and local autosaves #17501 to inspect and compare local and remote autosave objects, a requirement which was later dropped. This data needs to be resolved through thecoredata store.In contrast, the editor setting
autosaveis immediately available upon editor initialisation. It only contains aneditLinkproperty that links to a remote autosave's revision page, but most importantly it's an indication of whether there is a remote autosave available for the current post.Later on, if we choose to reconcile remote and local autosaves with more sophistication, this could possibly be done based on recency of autosave — in which case we could might still get away with editor settings if the server provides this information (e.g. timestamp) inside the
autosaveobject.This change should hopefully provide a more reliable page-loading experience for autosave's E2E tests.
shouldn't conflict with server-side autosavetest bails under unexpected circumstances.Despite the changes described in 1., a particular test would still frequently fail. Debugging led to the conclusion that the test's forced remote autosaves might be failing for unknown reasons.
This remote autosave failure is independent from the test's scope, which is to make sure that, concurrent remote and local autosaves for the current post, the editor will only show a notice to recover from the remote one.
Thus, the temporary solution here is to let the test bail if, upon editor reload, it looks like there is no remote autosave available.
How has this been tested?
E2E tests have been run extensively, and Travis should reliably green-light this branch.
Screenshots
Types of changes
Checklist: