[MM-42538] Submit nightly builds to TestFlight for macOS (#2023)
* Initial MAS build, working on TestFlight * Migration of old configs to MAS * Ignore fastlane files * Add mac app store build to nightly build * Revert Me - For testing in PR * Don't need to install fastlane * BIG D * Fix patch updater script to allow for no yml * Nevermind, do this instead * Update xcode * Let's try a fake version that works * Revert version and rename for test flight * Use Xcode 13.0.0 * Use CircleCI build number when available * Revert testing changes * Remove notarize for MAS * Change vars to MACOS instead of IOS * Revert electron-builder to v22 * Revert package-lock.json Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
This commit is contained in:
@@ -1,27 +1,58 @@
|
||||
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import fs from 'fs';
|
||||
|
||||
import {dialog} from 'electron';
|
||||
|
||||
import Config from 'common/config';
|
||||
import JsonFileManager from 'common/JsonFileManager';
|
||||
import {TAB_MESSAGING, TAB_FOCALBOARD, TAB_PLAYBOOKS} from 'common/tabs/TabView';
|
||||
import Utils from 'common/utils/util';
|
||||
|
||||
import {updatePaths} from 'main/constants';
|
||||
import {ServerInfo} from 'main/server/serverInfo';
|
||||
|
||||
import {getDeeplinkingURL, updateServerInfos, resizeScreen} from './utils';
|
||||
import {getDeeplinkingURL, updateServerInfos, resizeScreen, migrateMacAppStore} from './utils';
|
||||
|
||||
jest.mock('fs', () => ({
|
||||
readFileSync: jest.fn(),
|
||||
writeFileSync: jest.fn(),
|
||||
existsSync: jest.fn(),
|
||||
}));
|
||||
|
||||
jest.mock('electron', () => ({
|
||||
app: {
|
||||
getPath: () => '/path/to/data',
|
||||
getAppPath: () => '/path/to/app',
|
||||
},
|
||||
nativeImage: {
|
||||
createFromPath: jest.fn(),
|
||||
},
|
||||
dialog: {
|
||||
showOpenDialogSync: jest.fn(),
|
||||
showMessageBoxSync: jest.fn(),
|
||||
},
|
||||
}));
|
||||
|
||||
jest.mock('electron-log', () => ({
|
||||
info: jest.fn(),
|
||||
error: jest.fn(),
|
||||
}));
|
||||
|
||||
jest.mock('common/config', () => ({
|
||||
set: jest.fn(),
|
||||
}));
|
||||
jest.mock('common/JsonFileManager');
|
||||
jest.mock('common/utils/util', () => ({
|
||||
isVersionGreaterThanOrEqualTo: jest.fn(),
|
||||
getDisplayBoundaries: jest.fn(),
|
||||
}));
|
||||
|
||||
jest.mock('main/autoUpdater', () => ({}));
|
||||
jest.mock('main/constants', () => ({
|
||||
updatePaths: jest.fn(),
|
||||
}));
|
||||
jest.mock('main/menus/app', () => ({}));
|
||||
jest.mock('main/menus/tray', () => ({}));
|
||||
jest.mock('main/server/serverInfo', () => ({
|
||||
@@ -190,4 +221,73 @@ describe('main/app/utils', () => {
|
||||
expect(browserWindow.center).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('migrateMacAppStore', () => {
|
||||
it('should skip migration if already migrated', () => {
|
||||
JsonFileManager.mockImplementation(() => ({
|
||||
getValue: () => true,
|
||||
}));
|
||||
migrateMacAppStore();
|
||||
expect(dialog.showMessageBoxSync).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should skip migration if folder does not exist', () => {
|
||||
JsonFileManager.mockImplementation(() => ({
|
||||
getValue: () => false,
|
||||
}));
|
||||
fs.existsSync.mockReturnValue(false);
|
||||
migrateMacAppStore();
|
||||
expect(fs.existsSync).toHaveBeenCalled();
|
||||
expect(dialog.showMessageBoxSync).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should skip migration and set value if the user rejects import', () => {
|
||||
const migrationPrefs = {
|
||||
getValue: () => false,
|
||||
setValue: jest.fn(),
|
||||
};
|
||||
JsonFileManager.mockImplementation(() => migrationPrefs);
|
||||
fs.existsSync.mockReturnValue(true);
|
||||
dialog.showMessageBoxSync.mockReturnValue(1);
|
||||
migrateMacAppStore();
|
||||
expect(migrationPrefs.setValue).toHaveBeenCalledWith('masConfigs', true);
|
||||
expect(dialog.showOpenDialogSync).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should do nothing if no directory is chosen, or if the dialog is closed', () => {
|
||||
JsonFileManager.mockImplementation(() => ({
|
||||
getValue: () => false,
|
||||
}));
|
||||
fs.existsSync.mockReturnValue(true);
|
||||
dialog.showMessageBoxSync.mockReturnValue(0);
|
||||
dialog.showOpenDialogSync.mockReturnValue([]);
|
||||
migrateMacAppStore();
|
||||
expect(dialog.showOpenDialogSync).toHaveBeenCalled();
|
||||
expect(updatePaths).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should copy all of the configs when they exist to the new directory', () => {
|
||||
const migrationPrefs = {
|
||||
getValue: () => false,
|
||||
setValue: jest.fn(),
|
||||
};
|
||||
JsonFileManager.mockImplementation(() => migrationPrefs);
|
||||
fs.readFileSync.mockReturnValue('config-data');
|
||||
fs.existsSync.mockImplementation((path) => {
|
||||
if (path === '/Library/Application Support/Mattermost') {
|
||||
return true;
|
||||
}
|
||||
return ['config', 'app-state', 'bounds-info', 'migration-info'].some((filename) => path.endsWith(`${filename}.json`));
|
||||
});
|
||||
dialog.showMessageBoxSync.mockReturnValue(0);
|
||||
dialog.showOpenDialogSync.mockReturnValue(['/old/data/path']);
|
||||
migrateMacAppStore();
|
||||
expect(fs.readFileSync).toHaveBeenCalledWith('/old/data/path/config.json');
|
||||
expect(fs.writeFileSync).toHaveBeenCalledWith('/path/to/data/config.json', 'config-data');
|
||||
expect(fs.readFileSync).not.toHaveBeenCalledWith('/old/data/path/allowedProtocols.json');
|
||||
expect(fs.writeFileSync).not.toHaveBeenCalledWith('/path/to/data/allowedProtocols.json', 'config-data');
|
||||
expect(updatePaths).toHaveBeenCalled();
|
||||
expect(migrationPrefs.setValue).toHaveBeenCalledWith('masConfigs', true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user