Skip to content

Fix Firefox browser extension end-to-end tests

Warren Gifford requested to merge fix-ff-tests into main

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 var SIMPLE_BROWSER_CONSOLE_LOGS
  • Replaced use of page.bringToFront (unsupported by puppeteer-firefox) with closeInstallPageTab 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 set SIMPLE_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 use puppeteer 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)

Merge request reports

Loading