[MM-40277][MM-40279][MM-40301][MM-40307][MM-40310][MM-40313] Unit tests and refactors for main module (#1876)

* Refactor autoLauncher and remove unnecessary file

* [MM-40277] Unit tests for main/badge

* [MM-40279] Unit tests for main/certificateStore

* [MM-40301] Unit tests for main/contextMenu, also remove workaround

* [MM-40307] Unit tests for main/CriticalErrorHandler

* [MM-40310] Unit tests for main/utils

* [MM-40313] Unit tests for main/Validator

* Lint fix

* Added globals

* More things that should probably already be merged

* PR feedback
This commit is contained in:
Devin Binnie
2021-11-26 11:14:26 -05:00
committed by GitHub
parent fc06dc99a2
commit 5056ec7ace
14 changed files with 740 additions and 99 deletions

View File

@@ -2,7 +2,7 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import electron, {app, BrowserWindow} from 'electron';
import {app, BrowserWindow} from 'electron';
import path from 'path';
import {Args} from 'types/args';
@@ -49,7 +49,7 @@ export function getLocalURL(urlPath: string, query?: Map<string, string>, isMain
const hostname = '';
const port = '';
if (mode === PRODUCTION) {
pathname = path.join(electron.app.getAppPath(), `${processPath}/${urlPath}`);
pathname = path.join(app.getAppPath(), `${processPath}/${urlPath}`);
} else {
pathname = path.resolve(__dirname, `../../dist/${processPath}/${urlPath}`); // TODO: find a better way to work with webpack on this
}
@@ -66,7 +66,7 @@ export function getLocalURL(urlPath: string, query?: Map<string, string>, isMain
export function getLocalPreload(file: string) {
if (Utils.runMode() === PRODUCTION) {
return path.join(electron.app.getAppPath(), `${file}`);
return path.join(app.getAppPath(), `${file}`);
}
return path.resolve(__dirname, `../../dist/${file}`);
}