test: deflake versions with autosave e2e (#11919)

<!--

Thank you for the PR! Please go through the checklist below and make
sure you've completed all the steps.

Please review the
[CONTRIBUTING.md](https://github.com/payloadcms/payload/blob/main/CONTRIBUTING.md)
document in this repository if you haven't already.

The following items will ensure that your PR is handled as smoothly as
possible:

- PR Title must follow conventional commits format. For example, `feat:
my new feature`, `fix(plugin-seo): my fix`.
- Minimal description explained as if explained to someone not
immediately familiar with the code.
- Provide before/after screenshots or code diffs if applicable.
- Link any related issues/discussions from GitHub or Discord.
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Fixes #

-->
### What?
This PR aims to deflake the `test/versions/e2e.spec.ts:925:5 › Versions
› Collections with draft validation › - with autosave - shows a prevent
leave alert when form is submitted but invalid` e2e test.

The issue seems to be that the `fill` call followed by a `page.reload`
sometimes conflicts with autosave which may cause the test to flake.

### Why?
To deflake this test in ci.

### How?
Adds a single `waitForAutoSaveToRunAndComplete` function call prior to
the last call to `page.reload`. In my testing, on my local machine,
adding the `waitForAutoSaveToRunAndComplete` function allows the test to
pass every time. Without this, the tests fails on my machine
consistently.
This commit is contained in:
Said Akhrarov
2025-03-31 08:37:43 -04:00
committed by GitHub
parent af8c7868d6
commit 03d4c5b2ee

View File

@@ -981,6 +981,8 @@ describe('Versions', () => {
// Fill with invalid data again, then reload and accept the warning, should contain previous data // Fill with invalid data again, then reload and accept the warning, should contain previous data
await titleField.fill('') await titleField.fill('')
await waitForAutoSaveToRunAndComplete(page, 'error')
await page.reload() await page.reload()
await expect(titleField).toBeEnabled() await expect(titleField).toBeEnabled()