Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove use of mocks in Navigation Editor e2e tests and instead use REST API utilities #34765

Closed
talldan opened this issue Sep 13, 2021 · 0 comments · Fixed by #34869
Closed
Assignees
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.

Comments

@talldan
Copy link
Contributor

talldan commented Sep 13, 2021

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 -

const menuPostResponse = {
id: 4,
description: '',
name: 'Main Menu',
slug: 'main-menu',
meta: [],
auto_add: false,
};
// Initially return nothing from the menu and menuItem endpoints
await setUpResponseMocking( [
...getMenuMocks( { GET: [] } ),
...getMenuItemMocks( { GET: [] } ),
] );

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.

@talldan talldan added [Type] Enhancement A suggestion for improvement. [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. [Feature] Navigation Screen labels Sep 13, 2021
@talldan talldan changed the title Remove use of mocks in Navigation Editor e2e tests and instead use Remove use of mocks in Navigation Editor e2e tests and instead use REST API utilities Sep 13, 2021
@talldan talldan self-assigned this Sep 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant