Remove use of mocks in Navigation Editor e2e tests and instead use REST API utilities #34765
Labels
[Type] Automated Testing
Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests.
[Type] Enhancement
A suggestion for improvement.
What problem does this address?
Currently the navigation editor end-to-end tests use response mocking to build up and tear down state for the editor. Example here -
gutenberg/packages/e2e-tests/specs/experiments/navigation-editor.test.js
Lines 168 to 181 in f74bbde
There's some background around why this was done. Most other end-to-end tests clean up any created state through the UI during a test run. For example, the post editor tests delete all posts at the start of a test run. But in the navigation editor, deleting all menus, menu items and pages would be slow and laborious.
Similarly, some of the tests rely on existing pages or menus being present, ideally these pages and menus are nested structures, and creating these in a test would a very slow process.
Response mocking was an easy way to get around this issue, but was never intended as a final solution. The problem is that mocking REST API responses doesn't represent true end-to-end testing because the REST API's functionality isn't being tested.
What is your proposed solution?
#33414 introduced a REST API utility for e2e tests. Tests can now make REST requests to build up and tear down menus and pages, and this is a good opportunity for the navigation editor to move away from request mocking.
The text was updated successfully, but these errors were encountered: