diff --git a/ui/desktop/tests/end2end/authentication.spec.js b/ui/desktop/tests/end2end/authentication.spec.js index c7a02fbcd..71667b0de 100644 --- a/ui/desktop/tests/end2end/authentication.spec.js +++ b/ui/desktop/tests/end2end/authentication.spec.js @@ -1,33 +1,13 @@ /* eslint-disable no-undef */ const { test, expect } = require('@playwright/test'); const { _electron: electron } = require('playwright'); -const { generateScreenshotPath } = require('./test-helpers'); +const { + generateScreenshotPath, + returnExecutablePath, +} = require('./test-helpers'); let electronApp = null; const screenshotsDirectory = 'authentication/'; - -// TODO: move this function to a test helpers file so it could be used by other tests. -// Returns the executable path for the Boundary binary the test suite will run. -const returnExecutablePath = (platform, arch) => { - try { - // Just mac - if (platform === 'darwin') { - if (arch === 'x64') { - // Intel chips - return 'electron-app/out/Boundary-darwin-x64/Boundary.app/Contents/MacOS/Boundary'; - } else if (arch === 'arm64') { - // M1 chips - return 'electron-app/out/Boundary-darwin-arm64/Boundary.app/Contents/MacOS/Boundary'; - } else { - throw new Error('The test suite is not compatible with your arch.'); - } - } else { - throw new Error('The test suite is not compatible with your Platform.'); - } - } catch (error) { - console.error(error); - } -}; const executablePath = returnExecutablePath(process.platform, process.arch); test.beforeEach(async () => { diff --git a/ui/desktop/tests/end2end/targets.spec.js b/ui/desktop/tests/end2end/targets.spec.js index d30084031..2ee467d17 100644 --- a/ui/desktop/tests/end2end/targets.spec.js +++ b/ui/desktop/tests/end2end/targets.spec.js @@ -1,15 +1,18 @@ /* eslint-disable no-undef */ const { test, expect } = require('@playwright/test'); const { _electron: electron } = require('playwright'); -const { generateScreenshotPath } = require('./test-helpers'); +const { + generateScreenshotPath, + returnExecutablePath, +} = require('./test-helpers'); let electronApp = null; const screenshotsDirectory = 'targets/'; +const executablePath = returnExecutablePath(process.platform, process.arch); test.beforeEach(async () => { electronApp = await electron.launch({ - executablePath: - 'electron-app/out/Boundary-darwin-arm64/Boundary.app/Contents/MacOS/Boundary', + executablePath: executablePath, env: { NODE_ENV: 'test', BYPASS_APP_UPDATER: true, diff --git a/ui/desktop/tests/end2end/test-helpers.js b/ui/desktop/tests/end2end/test-helpers.js index 8c43b84f4..ff6902143 100644 --- a/ui/desktop/tests/end2end/test-helpers.js +++ b/ui/desktop/tests/end2end/test-helpers.js @@ -16,3 +16,29 @@ exports.generateScreenshotPath = (screenshotTestDirectory, fileName) => { ); return path.join(screenshotPath, fileName).concat(screenshotFormat); }; + +/** + * + * @param {string} platform The operating system. + * @param {string} arch The CPU architecture. + * @returns A full path where the Desktop Client executable is located. + */ +exports.returnExecutablePath = (platform, arch) => { + try { + switch (platform) { + case 'darwin': + switch (arch) { + case 'x64': // Intel chips + return 'electron-app/out/Boundary-darwin-x64/Boundary.app/Contents/MacOS/Boundary'; + case 'arm64': // M1 chips + return 'electron-app/out/Boundary-darwin-arm64/Boundary.app/Contents/MacOS/Boundary'; + default: + throw new Error('The test suite is not compatible with your arch.'); + } + default: + throw new Error('The test suite is not compatible with your platform.'); + } + } catch (error) { + console.error(error); + } +};