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:
Devin Binnie 2022-12-14 17:10:20 -04:00 committed by GitHub
parent e63a293b28
commit 29f10f1467
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 16 additions and 12 deletions

View file

@ -198,6 +198,7 @@ jobs:
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: $env:PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = 1; npm ci
- run: $env:ELECTRON_DISABLE_SANDBOX=1; npm run test:unit
- build:
os: windows
path: ./build/win
@ -222,6 +223,7 @@ jobs:
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: PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm ci
- run: ELECTRON_DISABLE_SANDBOX=1 npm run test:unit-ci
- build:
os: mac
path: ./build/macos

View file

@ -3,6 +3,7 @@
'use strict';
const fs = require('fs');
const robot = require('robotjs');
const env = require('../../modules/environment');

View file

@ -4,8 +4,6 @@
'use strict';
const robot = require('robotjs');
const env = require('../../modules/environment');
const {asyncSleep} = require('../../modules/utils');

View file

@ -61,11 +61,18 @@ describe('main/diagnostics/loggerHooks', () => {
describe('should mask paths for all OSs', () => {
it('darwin', () => {
const originalPlatform = process.platform;
Object.defineProperty(process, 'platform', {
value: 'darwin',
});
const message = {
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];
expect(findOccurrencesInString(MASK_PATH, result)).toBe(4);
Object.defineProperty(process, 'platform', {
value: originalPlatform,
});
});
it('linux', () => {
const originalPlatform = process.platform;
@ -87,10 +94,10 @@ describe('main/diagnostics/loggerHooks', () => {
value: 'win32',
});
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];
expect(findOccurrencesInString(MASK_PATH, result)).toBe(3);
expect(findOccurrencesInString(MASK_PATH, result)).toBe(2);
Object.defineProperty(process, 'platform', {
value: originalPlatform,
});

View file

@ -5,10 +5,6 @@ import {MASK_EMAIL, MASK_IPV4, MASK_PATH, MASK_URL, REGEX_EMAIL, REGEX_IPV4, REG
import {truncateString} from './utils';
const isDarwin = process.platform === 'darwin';
const isLinux = process.platform === 'linux';
const isWin = process.platform === 'win32';
function maskDataInString(str: string): string {
let maskedStr = str;
if (!str || typeof str !== 'string') {
@ -36,15 +32,15 @@ function maskDataInString(str: string): string {
}
// Paths
if (isDarwin) {
if (process.platform === 'darwin') {
if (REGEX_PATH_DARWIN.test(str)) {
maskedStr = maskedStr.replaceAll(RegExp(REGEX_PATH_DARWIN, 'gi'), MASK_PATH);
}
} else if (isLinux) {
} else if (process.platform === 'linux') {
if (REGEX_PATH_LINUX.test(str)) {
maskedStr = maskedStr.replaceAll(RegExp(REGEX_PATH_LINUX, 'gi'), MASK_PATH);
}
} else if (isWin) {
} else if (process.platform === 'win32') {
if (REGEX_PATH_WIN32.test(str)) {
maskedStr = maskedStr.replaceAll(RegExp(REGEX_PATH_WIN32, 'gi'), MASK_PATH);
}

View file

@ -262,7 +262,7 @@ describe('main/windows/windowManager', () => {
loadingScreenState: 3,
};
windowManager.mainWindow = {
getContentBounds: () => ({width: 800, height: 600}),
getContentBounds: () => ({width: 1000, height: 900}),
getSize: () => [1000, 900],
};
windowManager.teamDropdown = {