Update electron to 16.0.4
This commit is contained in:
parent
ba043c422b
commit
bbc13d058e
28 changed files with 491 additions and 2985 deletions
54
ts/build/test-electron.ts
Normal file
54
ts/build/test-electron.ts
Normal file
|
@ -0,0 +1,54 @@
|
|||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
/* eslint-disable no-console */
|
||||
|
||||
import { execFileSync } from 'child_process';
|
||||
import { join } from 'path';
|
||||
|
||||
const ROOT_DIR = join(__dirname, '..', '..');
|
||||
|
||||
const ELECTRON = join(
|
||||
ROOT_DIR,
|
||||
'node_modules',
|
||||
'.bin',
|
||||
process.platform === 'win32' ? 'electron.cmd' : 'electron'
|
||||
);
|
||||
|
||||
const stdout = execFileSync(ELECTRON, [ROOT_DIR], {
|
||||
cwd: ROOT_DIR,
|
||||
env: {
|
||||
...process.env,
|
||||
NODE_ENV: 'test',
|
||||
},
|
||||
encoding: 'utf8',
|
||||
});
|
||||
|
||||
const match = stdout.match(/ci:test-electron:done=(.*)?\n/);
|
||||
|
||||
if (!match) {
|
||||
throw new Error('No test results were found in stdout');
|
||||
}
|
||||
|
||||
const {
|
||||
passed,
|
||||
failed,
|
||||
}: {
|
||||
passed: Array<string>;
|
||||
failed: Array<{ testName: string; error: string }>;
|
||||
} = JSON.parse(match[1]);
|
||||
|
||||
const total = passed.length + failed.length;
|
||||
|
||||
for (const { testName, error } of failed) {
|
||||
console.error(`- ${testName}`);
|
||||
console.error(error);
|
||||
console.error('');
|
||||
}
|
||||
|
||||
console.log(
|
||||
`Passed ${passed.length} | Failed ${failed.length} | Total ${total}`
|
||||
);
|
||||
|
||||
if (failed.length !== 0) {
|
||||
process.exit(1);
|
||||
}
|
80
ts/build/test-release.ts
Normal file
80
ts/build/test-release.ts
Normal file
|
@ -0,0 +1,80 @@
|
|||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
/* eslint-disable no-console */
|
||||
|
||||
import asar from 'asar';
|
||||
import assert from 'assert';
|
||||
import { join } from 'path';
|
||||
import { _electron as electron } from 'playwright';
|
||||
|
||||
import packageJson from '../../package.json';
|
||||
|
||||
const ENVIRONMENT = 'production';
|
||||
const RELEASE_DIR = join(__dirname, '..', '..', 'release');
|
||||
|
||||
let archive: string;
|
||||
let exe: string;
|
||||
if (process.platform === 'darwin') {
|
||||
archive = join(
|
||||
'mac',
|
||||
`${packageJson.productName}.app`,
|
||||
'Contents',
|
||||
'Resources',
|
||||
'app.asar'
|
||||
);
|
||||
exe = join(
|
||||
'mac',
|
||||
`${packageJson.productName}.app`,
|
||||
'Contents',
|
||||
'MacOS',
|
||||
packageJson.productName
|
||||
);
|
||||
} else if (process.platform === 'win32') {
|
||||
archive = join('win-unpacked', 'resources', 'app.asar');
|
||||
exe = join('win-unpacked', `${packageJson.productName}.exe`);
|
||||
} else if (process.platform === 'linux') {
|
||||
archive = join('linux-unpacked', 'resources', 'app.asar');
|
||||
exe = join('linux-unpacked', packageJson.name);
|
||||
} else {
|
||||
throw new Error(`Unsupported platform: ${process.platform}`);
|
||||
}
|
||||
|
||||
const files = [
|
||||
join('config', 'default.json'),
|
||||
join('config', `${ENVIRONMENT}.json`),
|
||||
join('config', `local-${ENVIRONMENT}.json`),
|
||||
];
|
||||
|
||||
for (const fileName of files) {
|
||||
console.log(`Checking that ${fileName} exists in asar ${archive}`);
|
||||
try {
|
||||
asar.statFile(join(RELEASE_DIR, archive), fileName);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
throw new Error(`Missing file ${fileName}`);
|
||||
}
|
||||
}
|
||||
|
||||
// A simple test to verify a visible window is opened with a title
|
||||
const main = async () => {
|
||||
const executablePath = join(RELEASE_DIR, exe);
|
||||
console.log('Starting path', executablePath);
|
||||
const app = await electron.launch({
|
||||
executablePath,
|
||||
locale: 'en',
|
||||
});
|
||||
|
||||
console.log('Waiting for a first window');
|
||||
const window = await app.firstWindow();
|
||||
await window.waitForLoadState();
|
||||
|
||||
console.log('Checking window title');
|
||||
assert.strictEqual(await window.title(), packageJson.productName);
|
||||
|
||||
await app.close();
|
||||
};
|
||||
|
||||
main().catch(error => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
|
@ -9,7 +9,6 @@ export enum Environment {
|
|||
Production = 'production',
|
||||
Staging = 'staging',
|
||||
Test = 'test',
|
||||
TestLib = 'test-lib',
|
||||
}
|
||||
|
||||
let environment: undefined | Environment;
|
||||
|
@ -41,4 +40,4 @@ export const parseEnvironment = makeEnumParser(
|
|||
);
|
||||
|
||||
export const isTestEnvironment = (env: Environment): boolean =>
|
||||
env === Environment.Test || env === Environment.TestLib;
|
||||
env === Environment.Test;
|
||||
|
|
|
@ -43,9 +43,7 @@ let globalLogger: undefined | pino.Logger;
|
|||
let shouldRestart = false;
|
||||
|
||||
const isRunningFromConsole =
|
||||
Boolean(process.stdout.isTTY) ||
|
||||
getEnvironment() === Environment.Test ||
|
||||
getEnvironment() === Environment.TestLib;
|
||||
Boolean(process.stdout.isTTY) || getEnvironment() === Environment.Test;
|
||||
|
||||
export async function initialize(
|
||||
getMainWindow: () => undefined | BrowserWindow
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
// Copyright 2020-2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { desktopCapturer, ipcRenderer } from 'electron';
|
||||
import type { DesktopCapturerSource } from 'electron';
|
||||
import { ipcRenderer } from 'electron';
|
||||
import type {
|
||||
AudioDevice,
|
||||
CallId,
|
||||
|
@ -1097,11 +1098,8 @@ export class CallingClass {
|
|||
}
|
||||
|
||||
async getPresentingSources(): Promise<Array<PresentableSource>> {
|
||||
const sources = await desktopCapturer.getSources({
|
||||
fetchWindowIcons: true,
|
||||
thumbnailSize: { height: 102, width: 184 },
|
||||
types: ['window', 'screen'],
|
||||
});
|
||||
const sources: ReadonlyArray<DesktopCapturerSource> =
|
||||
await ipcRenderer.invoke('getScreenCaptureSources');
|
||||
|
||||
const presentableSources: Array<PresentableSource> = [];
|
||||
|
||||
|
|
|
@ -37,10 +37,6 @@ describe('environment utilities', () => {
|
|||
it('parses "test" as Environment.Test', () => {
|
||||
assert.equal(parseEnvironment('test'), Environment.Test);
|
||||
});
|
||||
|
||||
it('parses "test-lib" as Environment.TestLib', () => {
|
||||
assert.equal(parseEnvironment('test-lib'), Environment.TestLib);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isTestEnvironment', () => {
|
||||
|
@ -52,7 +48,6 @@ describe('environment utilities', () => {
|
|||
|
||||
it('returns true for test environments', () => {
|
||||
assert.isTrue(isTestEnvironment(Environment.Test));
|
||||
assert.isTrue(isTestEnvironment(Environment.TestLib));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1352,7 +1352,7 @@ describe('calling duck', () => {
|
|||
|
||||
describe('thunk', () => {
|
||||
function noopTest(connectionState: GroupCallConnectionState) {
|
||||
return async function test(this: Mocha.ITestCallbackContext) {
|
||||
return async function test(this: Mocha.Context) {
|
||||
const dispatch = sinon.spy();
|
||||
|
||||
await peekNotConnectedGroupCall({
|
||||
|
|
110
ts/test-electron/textsecure/SendMessage_test.ts
Normal file
110
ts/test-electron/textsecure/SendMessage_test.ts
Normal file
|
@ -0,0 +1,110 @@
|
|||
// Copyright 2019-2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { assert } from 'chai';
|
||||
|
||||
import MessageSender from '../../textsecure/SendMessage';
|
||||
import type { WebAPIType } from '../../textsecure/WebAPI';
|
||||
|
||||
const BUCKET_SIZES = [
|
||||
541, 568, 596, 626, 657, 690, 725, 761, 799, 839, 881, 925, 972, 1020, 1071,
|
||||
1125, 1181, 1240, 1302, 1367, 1436, 1507, 1583, 1662, 1745, 1832, 1924, 2020,
|
||||
2121, 2227, 2339, 2456, 2579, 2708, 2843, 2985, 3134, 3291, 3456, 3629, 3810,
|
||||
4001, 4201, 4411, 4631, 4863, 5106, 5361, 5629, 5911, 6207, 6517, 6843, 7185,
|
||||
7544, 7921, 8318, 8733, 9170, 9629, 10110, 10616, 11146, 11704, 12289, 12903,
|
||||
13549, 14226, 14937, 15684, 16469, 17292, 18157, 19065, 20018, 21019, 22070,
|
||||
23173, 24332, 25549, 26826, 28167, 29576, 31054, 32607, 34238, 35950, 37747,
|
||||
39634, 41616, 43697, 45882, 48176, 50585, 53114, 55770, 58558, 61486, 64561,
|
||||
67789, 71178, 74737, 78474, 82398, 86518, 90843, 95386, 100155, 105163,
|
||||
110421, 115942, 121739, 127826, 134217, 140928, 147975, 155373, 163142,
|
||||
171299, 179864, 188858, 198300, 208215, 218626, 229558, 241036, 253087,
|
||||
265742, 279029, 292980, 307629, 323011, 339161, 356119, 373925, 392622,
|
||||
412253, 432866, 454509, 477234, 501096, 526151, 552458, 580081, 609086,
|
||||
639540, 671517, 705093, 740347, 777365, 816233, 857045, 899897, 944892,
|
||||
992136, 1041743, 1093831, 1148522, 1205948, 1266246, 1329558, 1396036,
|
||||
1465838, 1539130, 1616086, 1696890, 1781735, 1870822, 1964363, 2062581,
|
||||
2165710, 2273996, 2387695, 2507080, 2632434, 2764056, 2902259, 3047372,
|
||||
3199740, 3359727, 3527714, 3704100, 3889305, 4083770, 4287958, 4502356,
|
||||
4727474, 4963848, 5212040, 5472642, 5746274, 6033588, 6335268, 6652031,
|
||||
6984633, 7333864, 7700558, 8085585, 8489865, 8914358, 9360076, 9828080,
|
||||
10319484, 10835458, 11377231, 11946092, 12543397, 13170567, 13829095,
|
||||
14520550, 15246578, 16008907, 16809352, 17649820, 18532311, 19458926,
|
||||
20431872, 21453466, 22526139, 23652446, 24835069, 26076822, 27380663,
|
||||
28749697, 30187181, 31696540, 33281368, 34945436, 36692708, 38527343,
|
||||
40453710, 42476396, 44600216, 46830227, 49171738, 51630325, 54211841,
|
||||
56922433, 59768555, 62756983, 65894832, 69189573, 72649052, 76281505,
|
||||
80095580, 84100359, 88305377, 92720646, 97356678, 102224512, 107335738,
|
||||
];
|
||||
|
||||
describe('SendMessage', () => {
|
||||
let sendMessage: MessageSender;
|
||||
|
||||
before(() => {
|
||||
sendMessage = new MessageSender({} as unknown as WebAPIType);
|
||||
});
|
||||
|
||||
describe('#_getAttachmentSizeBucket', () => {
|
||||
it('properly calculates first bucket', () => {
|
||||
for (let size = 0, max = BUCKET_SIZES[0]; size < max; size += 1) {
|
||||
assert.strictEqual(
|
||||
BUCKET_SIZES[0],
|
||||
sendMessage._getAttachmentSizeBucket(size)
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
it('properly calculates entire table', () => {
|
||||
let count = 0;
|
||||
|
||||
const failures = new Array<string>();
|
||||
for (let i = 0, max = BUCKET_SIZES.length - 1; i < max; i += 1) {
|
||||
// Exact
|
||||
if (
|
||||
BUCKET_SIZES[i] !==
|
||||
sendMessage._getAttachmentSizeBucket(BUCKET_SIZES[i])
|
||||
) {
|
||||
count += 1;
|
||||
failures.push(
|
||||
`${
|
||||
BUCKET_SIZES[i]
|
||||
} does not equal ${sendMessage._getAttachmentSizeBucket(
|
||||
BUCKET_SIZES[i]
|
||||
)}`
|
||||
);
|
||||
}
|
||||
|
||||
// Just under
|
||||
if (
|
||||
BUCKET_SIZES[i] !==
|
||||
sendMessage._getAttachmentSizeBucket(BUCKET_SIZES[i] - 1)
|
||||
) {
|
||||
count += 1;
|
||||
failures.push(
|
||||
`${
|
||||
BUCKET_SIZES[i]
|
||||
} does not equal ${sendMessage._getAttachmentSizeBucket(
|
||||
BUCKET_SIZES[i] - 1
|
||||
)}`
|
||||
);
|
||||
}
|
||||
|
||||
// Just over
|
||||
if (
|
||||
BUCKET_SIZES[i + 1] !==
|
||||
sendMessage._getAttachmentSizeBucket(BUCKET_SIZES[i] + 1)
|
||||
) {
|
||||
count += 1;
|
||||
failures.push(
|
||||
`${
|
||||
BUCKET_SIZES[i + 1]
|
||||
} does not equal ${sendMessage._getAttachmentSizeBucket(
|
||||
BUCKET_SIZES[i] + 1
|
||||
)}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
assert.strictEqual(count, 0, failures.join('\n'));
|
||||
});
|
||||
});
|
||||
});
|
File diff suppressed because it is too large
Load diff
|
@ -105,6 +105,7 @@ const excludedFilesRegexp = RegExp(
|
|||
|
||||
// Modules used only in test/development scenarios
|
||||
'^node_modules/@babel/.+',
|
||||
'^node_modules/@chanzuckerberg/axe-storybook-testing/.+',
|
||||
'^node_modules/@svgr/.+',
|
||||
'^node_modules/@types/.+',
|
||||
'^node_modules/@webassemblyjs/.+',
|
||||
|
@ -116,8 +117,6 @@ const excludedFilesRegexp = RegExp(
|
|||
'^node_modules/ansi-colors/.+',
|
||||
'^node_modules/anymatch/.+',
|
||||
'^node_modules/app-builder-lib/.+',
|
||||
'^node_modules/archiver-utils/.+', // Used by spectron
|
||||
'^node_modules/archiver/.+', // Used by spectron
|
||||
'^node_modules/asn1\\.js/.+',
|
||||
'^node_modules/autoprefixer/.+',
|
||||
'^node_modules/babel.+',
|
||||
|
@ -130,6 +129,7 @@ const excludedFilesRegexp = RegExp(
|
|||
'^node_modules/builder-util/.+',
|
||||
'^node_modules/catharsis/.+',
|
||||
'^node_modules/chai/.+',
|
||||
'^node_modules/chokidar/.+',
|
||||
'^node_modules/clean-css/.+',
|
||||
'^node_modules/cli-table2/.+',
|
||||
'^node_modules/cliui/.+',
|
||||
|
@ -161,10 +161,13 @@ const excludedFilesRegexp = RegExp(
|
|||
'^node_modules/@typescript-eslint.+',
|
||||
'^node_modules/esprima/.+',
|
||||
'^node_modules/express/.+',
|
||||
'^node_modules/fast-glob/.+',
|
||||
'^node_modules/file-loader/.+',
|
||||
'^node_modules/file-system-cache/.+', // Currently only used in storybook
|
||||
'^node_modules/finalhandler/.+',
|
||||
'^node_modules/foreground-chat/.+',
|
||||
'^node_modules/fsevents/.+',
|
||||
'^node_modules/gauge/.+',
|
||||
'^node_modules/global-agent/.+',
|
||||
'^node_modules/globule/.+',
|
||||
'^node_modules/grunt-cli/.+',
|
||||
|
@ -208,6 +211,8 @@ const excludedFilesRegexp = RegExp(
|
|||
'^node_modules/optionator/.+',
|
||||
'^node_modules/plist/.+',
|
||||
'^node_modules/phantomjs-prebuilt/.+',
|
||||
'^node_modules/playwright/.+',
|
||||
'^node_modules/playwright-core/.+',
|
||||
'^node_modules/postcss.+',
|
||||
'^node_modules/preserve/.+',
|
||||
'^node_modules/prettier/.+',
|
||||
|
@ -233,7 +238,6 @@ const excludedFilesRegexp = RegExp(
|
|||
'^node_modules/snapdragon-util/.+',
|
||||
'^node_modules/snapdragon/.+',
|
||||
'^node_modules/sockjs-client/.+',
|
||||
'^node_modules/spectron/.+',
|
||||
'^node_modules/style-loader/.+',
|
||||
'^node_modules/svgo/.+',
|
||||
'^node_modules/terser/.+',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue