Add UI integration tests backed by Polly
Created by: lguychard
Adds:
- Wrappers over Mocha allowing to describe Puppeteer integration tests in
web/src/integration/helpers.ts
- These wrappers use Polly to record requests to
.har
files when running tests with theRECORD=true
environment variable, and replay responses from those.har
files when running the tests. - Requests to
/.assets/*
(js/css/img assets) are statically served from/ui/assets
when running the tests
- These wrappers use Polly to record requests to
- A README describes intent and usage in
web/src/integration/README.md
- A first set of tests,
web/src/integration/search.test.ts
, ported fromweb/src/end-to-end.test.ts
, and corresponding.har
files.
We may swap out how we record/replay requests for something else -- see this as a starting point. The important part is the API for describing tests, consistent with our other Puppeteer e2e/integration tests, as it's an API that's familiar to developers.
Current tests run in ~20-30s. The vast majority of that is initial page load, not the tests themselves.
There are some unsolved pain points:
- Polly is very chatty when it cannot find requests in its recording. It prints lots of logs like this, with the full content of the request:
Errored ➞ POST http://localhost:8000/.api/graphql?logUserEvent
PollyError: [Polly] [adapter:puppeteer] Recording for the following request is not found and `recordIfMissing` is `false`.
{
"url": "http://localhost:8000/.api/graphql?logUserEvent",
"method": "POST",
...
}
This is most often on logEvent
, logUserEvent
calls, because they include userCookieId
, which is re-regenerated client-side and does not match the value from the recording. A custom handler for these calls, or allowing to set a stable userCookieId
would most likely fix this.
- Some occasional
Error: Protocol error (Network.getResponseBody): No data found for resource with given identifier
errors when recording tests -- this seems to appear when receiving a response after a test succeeded, it's noisy but does not impair recording.