openverse-frontend icon indicating copy to clipboard operation
openverse-frontend copied to clipboard

Mock provider media requests for the e2e tests

Open obulat opened this issue 3 years ago • 0 comments

Blocked until #881 is merged

Problem

When running e2e tests, we make network requests for media files. This can make the tests non-deterministic and slower than necessary. Currently, in e2e tests we block the requests for images based on their extensions, and all the requests with to jamendo: https://github.com/WordPress/openverse-frontend/blob/99a803542c46b20b7cac36bc7d421ffcaa8398af/test/e2e/utils.js#L64-L66 Audio requests for jamendo files don't have an extension that we could use, so we block all the requests with jamendo in the domain: https://github.com/WordPress/openverse-frontend/blob/99a803542c46b20b7cac36bc7d421ffcaa8398af/test/e2e/search-query-server.spec.js#L19 We are probably missing some network requests that also need to be blocked.

Description

We need to audit what requests are being made and block them. This does not include requests to the Openverse API, which are handled by a proxy that already stops network requests and uses the pre-recorded responses in the repository in test/tapes folder.

Alternatives

We could also set up proxies for all providers, but I suspect that it would be untenable.

Additional context

It would be nice to have a way to monitor the network requests made during the e2e tests in the CI, and fail the PRs that add new un-handled network requests.

Implementation

  • [ ] 🙋 I would be interested in implementing this feature.

obulat avatar Feb 20 '22 04:02 obulat