Fix Firefox browser extension end-to-end tests
Created by: marekweb
This is an attempt to fix the Firefox browser extension end-to-end tests.
Here's how to run these tests locally (note that BROWSER=firefox
targets Firefox and it uses puppeteer-firefox
under the hood).
cd client/browser
# clear the cache of bundled code-intel-extensions (to cause them to re-fetch)
rm -rf code-intel-extensions
# build browser extension for testing
EXTENSION_PERMISSIONS_ALL_URLS=1 yarn run build
# run the tests
BROWSER=firefox SOURCEGRAPH_BASE_URL="https://sourcegraph.com" SIMPLE_BROWSER_CONSOLE_LOGS=1 yarn run mocha ./src/end-to-end/github.test.ts ./src/end-to-end/gitlab.test.ts
Fixed in this PR:
- On
puppeteer-firefox
, formatting the browser console logs in stdout is broken. Added an simpler log formatter, as a fallback to the pretty formatter, controlled by env varSIMPLE_BROWSER_CONSOLE_LOGS
- Replaced use of
page.bringToFront
(unsupported bypuppeteer-firefox
) withcloseInstallPageTab
which what we want to do anyway: get the browser extension after-install page out of the way. Note that it's possible that the install page is only a problem in non-headless mode, because in headless mode the idea of an active tab might be meaningless anyway.
Todo:
-
When running the test on FF ( BROWSER=firefox
) automatically setSIMPLE_BROWSER_CONSOLE_LOGS
, so that we don't have to modify the CI env vars to add that value. -
When opening a link to Sourcegraph, in the Firefox browser extension end-to-end test, on the Sourcegraph web app page the javascript bundle crashes: "SyntaxError: invalid regexp group" {file: "https://sourcegraph.com/.assets/scripts/app.bundle.js?dab5568d28df2a6013aed6908ddd0383" line: 2 column: 75629 source: "\btype:(?<type>diff|commit|symbol|repo|path)\b"}
Remaining problems, outside of this PR scope:
-
puppeteer-firefox
has been deprecated for months and it ships with a very old version of Firefox (v65). The recommended for Firefox support in puppeteer is to usepuppeteer
which now has experimental Firefox support, but we haven't yet verified if the migration might break more things than it fixes.
Closes #15713 (closed)