Skip to content

Commit

Permalink
chore(e2e): get the chrome version from electron and pass that to rem…
Browse files Browse the repository at this point in the history
…ote() COMPASS-7639 (#5539)

get the chrome version from electron and pass that to remote()
  • Loading branch information
lerouxb committed Mar 5, 2024
1 parent 5444b83 commit 2a59e5c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/compass-e2e-tests/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.log
fixtures/*.csv
fixtures/*.json
electron-versions.json
2 changes: 1 addition & 1 deletion packages/compass-e2e-tests/helpers/compass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ async function startCompassElectron(
automationProtocol: 'webdriver' as const,
capabilities: {
browserName: 'chromium',
browserVersion: '120.0.6099.227', // TODO(COMPASS-7639): this must always be the corresponding chromium version for the electron version
browserVersion: process.env.CHROME_VERSION,
// https://chromedriver.chromium.org/capabilities#h.p_ID_106
'goog:chromeOptions': {
binary: maybeWrappedBinary,
Expand Down
21 changes: 21 additions & 0 deletions packages/compass-e2e-tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ async function setup() {
};
compassWeb.stdout.setEncoding('utf8').on('data', listener);
});
} else {
debug('Writing electron-versions.json');
crossSpawn.sync('scripts/write-electron-versions.sh', [], {
stdio: 'inherit',
});
}
}

Expand Down Expand Up @@ -151,6 +156,22 @@ async function main() {

const shouldTestCompassWeb = process.argv.includes('--test-compass-web');

if (!shouldTestCompassWeb) {
if (!process.env.CHROME_VERSION) {
// written during setup() if disableStartStop is false
const versionsJSON = await fs.promises.readFile(
'electron-versions.json',
'utf8'
);
const versions = JSON.parse(versionsJSON);
process.env.CHROME_VERSION = versions.chrome;
}
debug(
'Chrome version corresponding to Electron:',
process.env.CHROME_VERSION
);
}

// These are mutually exclusive since compass-web is always going to browse to
// the running webserver.
const shouldTestPackagedApp =
Expand Down
3 changes: 3 additions & 0 deletions packages/compass-e2e-tests/scripts/write-electron-versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

echo "const fs = require('fs'); fs.writeFileSync('electron-versions.json', JSON.stringify(process.versions), 'utf8');" | npx electron -i

0 comments on commit 2a59e5c

Please sign in to comment.