refactor: 💡 Move returnExecutablePath to e2e test helpers
Move returnExecutablePath to end to end test helpers file. Now the two test files are importing the function from the test helpers file.
This commit is contained in:
1 parent
3600222178
commit
5dd59a6c14
3 files changed
+39
-27
No files matched your search
@@ -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 () => {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -20,3 +20,32 @@ 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 {
|
||||
// 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 or Architecture.'
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user