Fixed some unit tests and add test step to run on Windows/Mac builds (#2466)
* Fixed some unit tests and add test step to run on Windows/Mac builds * Update failing test * Fix backlash * Fix windows run * Fix Windows again Co-authored-by: Tasos Boulis <tboulis@hotmail.com> Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
This commit is contained in:
@@ -198,6 +198,7 @@ jobs:
|
|||||||
command: nvm off; choco install nodejs-lts -y
|
command: nvm off; choco install nodejs-lts -y
|
||||||
- run: npm i -g node-gyp; node-gyp install; node-gyp install --devdir="$env:USERPROFILE\.electron-gyp" --target=$(jq -r .devDependencies.electron package.json) --dist-url="https://electronjs.org/headers"
|
- run: npm i -g node-gyp; node-gyp install; node-gyp install --devdir="$env:USERPROFILE\.electron-gyp" --target=$(jq -r .devDependencies.electron package.json) --dist-url="https://electronjs.org/headers"
|
||||||
- run: $env:PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = 1; npm ci
|
- run: $env:PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = 1; npm ci
|
||||||
|
- run: $env:ELECTRON_DISABLE_SANDBOX=1; npm run test:unit
|
||||||
- build:
|
- build:
|
||||||
os: windows
|
os: windows
|
||||||
path: ./build/win
|
path: ./build/win
|
||||||
@@ -222,6 +223,7 @@ jobs:
|
|||||||
command: nvm install --lts && nvm use --lts
|
command: nvm install --lts && nvm use --lts
|
||||||
- run: jq '.mac.target=["zip"]' electron-builder.json | jq '.mac.gatekeeperAssess=false' > /tmp/electron-builder.json && cp /tmp/electron-builder.json .
|
- run: jq '.mac.target=["zip"]' electron-builder.json | jq '.mac.gatekeeperAssess=false' > /tmp/electron-builder.json && cp /tmp/electron-builder.json .
|
||||||
- run: PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm ci
|
- run: PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm ci
|
||||||
|
- run: ELECTRON_DISABLE_SANDBOX=1 npm run test:unit-ci
|
||||||
- build:
|
- build:
|
||||||
os: mac
|
os: mac
|
||||||
path: ./build/macos
|
path: ./build/macos
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
const robot = require('robotjs');
|
const robot = require('robotjs');
|
||||||
|
|
||||||
const env = require('../../modules/environment');
|
const env = require('../../modules/environment');
|
||||||
|
@@ -4,8 +4,6 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const robot = require('robotjs');
|
|
||||||
|
|
||||||
const env = require('../../modules/environment');
|
const env = require('../../modules/environment');
|
||||||
const {asyncSleep} = require('../../modules/utils');
|
const {asyncSleep} = require('../../modules/utils');
|
||||||
|
|
||||||
|
@@ -61,11 +61,18 @@ describe('main/diagnostics/loggerHooks', () => {
|
|||||||
|
|
||||||
describe('should mask paths for all OSs', () => {
|
describe('should mask paths for all OSs', () => {
|
||||||
it('darwin', () => {
|
it('darwin', () => {
|
||||||
|
const originalPlatform = process.platform;
|
||||||
|
Object.defineProperty(process, 'platform', {
|
||||||
|
value: 'darwin',
|
||||||
|
});
|
||||||
const message = {
|
const message = {
|
||||||
data: ['/Users/user/Projects/desktop /Users/user/Projects/desktop/file.txt /Users/user/Projects/desktop/folder withSpace/file.txt'],
|
data: ['/Users/user/Projects/desktop /Users/user/Projects/desktop/file.txt /Users/user/Projects/desktop/folder withSpace/file.txt'],
|
||||||
};
|
};
|
||||||
const result = maskMessageDataHook(loggerMock)(message, 'file').data[0];
|
const result = maskMessageDataHook(loggerMock)(message, 'file').data[0];
|
||||||
expect(findOccurrencesInString(MASK_PATH, result)).toBe(4);
|
expect(findOccurrencesInString(MASK_PATH, result)).toBe(4);
|
||||||
|
Object.defineProperty(process, 'platform', {
|
||||||
|
value: originalPlatform,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
it('linux', () => {
|
it('linux', () => {
|
||||||
const originalPlatform = process.platform;
|
const originalPlatform = process.platform;
|
||||||
@@ -87,10 +94,10 @@ describe('main/diagnostics/loggerHooks', () => {
|
|||||||
value: 'win32',
|
value: 'win32',
|
||||||
});
|
});
|
||||||
const message = {
|
const message = {
|
||||||
data: ['C:/Users/user/Desktop/download.pdf C:/Users/user/Desktop/folder withSpace/file.txt'],
|
data: ['C:/Users/user/Desktop/download.pdf C:\\Users\\user\\Desktop\\folder withSpace\\file.txt'],
|
||||||
};
|
};
|
||||||
const result = maskMessageDataHook(loggerMock)(message, 'file').data[0];
|
const result = maskMessageDataHook(loggerMock)(message, 'file').data[0];
|
||||||
expect(findOccurrencesInString(MASK_PATH, result)).toBe(3);
|
expect(findOccurrencesInString(MASK_PATH, result)).toBe(2);
|
||||||
Object.defineProperty(process, 'platform', {
|
Object.defineProperty(process, 'platform', {
|
||||||
value: originalPlatform,
|
value: originalPlatform,
|
||||||
});
|
});
|
||||||
|
@@ -5,10 +5,6 @@ import {MASK_EMAIL, MASK_IPV4, MASK_PATH, MASK_URL, REGEX_EMAIL, REGEX_IPV4, REG
|
|||||||
|
|
||||||
import {truncateString} from './utils';
|
import {truncateString} from './utils';
|
||||||
|
|
||||||
const isDarwin = process.platform === 'darwin';
|
|
||||||
const isLinux = process.platform === 'linux';
|
|
||||||
const isWin = process.platform === 'win32';
|
|
||||||
|
|
||||||
function maskDataInString(str: string): string {
|
function maskDataInString(str: string): string {
|
||||||
let maskedStr = str;
|
let maskedStr = str;
|
||||||
if (!str || typeof str !== 'string') {
|
if (!str || typeof str !== 'string') {
|
||||||
@@ -36,15 +32,15 @@ function maskDataInString(str: string): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Paths
|
// Paths
|
||||||
if (isDarwin) {
|
if (process.platform === 'darwin') {
|
||||||
if (REGEX_PATH_DARWIN.test(str)) {
|
if (REGEX_PATH_DARWIN.test(str)) {
|
||||||
maskedStr = maskedStr.replaceAll(RegExp(REGEX_PATH_DARWIN, 'gi'), MASK_PATH);
|
maskedStr = maskedStr.replaceAll(RegExp(REGEX_PATH_DARWIN, 'gi'), MASK_PATH);
|
||||||
}
|
}
|
||||||
} else if (isLinux) {
|
} else if (process.platform === 'linux') {
|
||||||
if (REGEX_PATH_LINUX.test(str)) {
|
if (REGEX_PATH_LINUX.test(str)) {
|
||||||
maskedStr = maskedStr.replaceAll(RegExp(REGEX_PATH_LINUX, 'gi'), MASK_PATH);
|
maskedStr = maskedStr.replaceAll(RegExp(REGEX_PATH_LINUX, 'gi'), MASK_PATH);
|
||||||
}
|
}
|
||||||
} else if (isWin) {
|
} else if (process.platform === 'win32') {
|
||||||
if (REGEX_PATH_WIN32.test(str)) {
|
if (REGEX_PATH_WIN32.test(str)) {
|
||||||
maskedStr = maskedStr.replaceAll(RegExp(REGEX_PATH_WIN32, 'gi'), MASK_PATH);
|
maskedStr = maskedStr.replaceAll(RegExp(REGEX_PATH_WIN32, 'gi'), MASK_PATH);
|
||||||
}
|
}
|
||||||
|
@@ -262,7 +262,7 @@ describe('main/windows/windowManager', () => {
|
|||||||
loadingScreenState: 3,
|
loadingScreenState: 3,
|
||||||
};
|
};
|
||||||
windowManager.mainWindow = {
|
windowManager.mainWindow = {
|
||||||
getContentBounds: () => ({width: 800, height: 600}),
|
getContentBounds: () => ({width: 1000, height: 900}),
|
||||||
getSize: () => [1000, 900],
|
getSize: () => [1000, 900],
|
||||||
};
|
};
|
||||||
windowManager.teamDropdown = {
|
windowManager.teamDropdown = {
|
||||||
|
Reference in New Issue
Block a user