Opened 2 days ago
Last modified 2 days ago
#66227 new defect (bug)
Make the Core E2E tests preserve the development environment state
| Reported by: | afercia | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Build/Test Tools | Version: | |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: | tests |
Description
Related: #63532.
The Core E2E setup makes the test run on the development database. This is inconsistent with the PHPUnit tests which run on the tests database, when properly configured.
Also, some methods provided by the e2e-test-utils-playwright package, like deleteAllMedia() are inherently dangerous because they literally delete all attachments, including the existing ones. This is inconsistent with the PHPUnit tests setup which makes its best to preserve the contents of the uploads directory.
This issue should be reported upstream in the Gutenberg repository to be considered for the packages provided there. However, it also affects the Core E2E setup, which is existing code in Core and should be tested in Core.
To reproduce:
- Make sure your development environment does have a few posts and comments.
- Make sure it also has some uploaded attachments.
- Set some user preferences, for example go to the Media Library and click the 'Grid view' link. Your choice will be saved in the persisted user preferences.
- From the terminal, run
npm run test:e2e. - Once the tests complete, observe that:
- All your posts have been deleted.
- All the commeents have been deleted.
- All your blocks (post type = wp_block), if any, have been deleted.
- Your preferences have been reset. E.g. the Media Library will default to the 'List' view.
The E2E tests global setup, and also some specific tests, use the following methods that are responsible for the deletions:
requestUtils.deleteAllPosts(): Deletes all posts of typepost. As such, Core deletes all the related comments as well.requestUtils.deleteAllBlocks(): Deletes all blocks (post type = wp_block).requestUtils.resetPreferences(): Resets all user persisted preferences.
Additionally, there are a few more 'dangerous' methods provided by the E@E test utils. For example: requestUtils.deleteAllMedia() is not currently used in the tests but it's dangerous as it literally delets all attachments, even the pre-existing ones in your development environment.
Ideally:
- The tests should run on the tests database.
- Any file operation for the attachments should use its own uploads directory, not the default 'uploads' one, as proposed for the PHPUnit tests in #63532.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)