[MM-43040] Copy entire config directory over for MAS (#2046)

* [MM-43040] Copy entire config directory over for MAS

* Fix package version
This commit is contained in:
Devin Binnie
2022-04-13 09:25:03 -04:00
committed by GitHub
parent fdbb468e7f
commit 4d46762584
4 changed files with 410 additions and 530 deletions

View File

@@ -1,7 +1,7 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import fs from 'fs';
import fs from 'fs-extra';
import {dialog} from 'electron';
@@ -15,10 +15,11 @@ import {ServerInfo} from 'main/server/serverInfo';
import {getDeeplinkingURL, updateServerInfos, resizeScreen, migrateMacAppStore} from './utils';
jest.mock('fs', () => ({
jest.mock('fs-extra', () => ({
readFileSync: jest.fn(),
writeFileSync: jest.fn(),
existsSync: jest.fn(),
copySync: jest.fn(),
}));
jest.mock('electron', () => ({
@@ -270,19 +271,11 @@ describe('main/app/utils', () => {
};
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`));
});
fs.existsSync.mockReturnValue(true);
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(fs.copySync).toHaveBeenCalledWith('/old/data/path', '/path/to/data');
expect(updatePaths).toHaveBeenCalled();
expect(migrationPrefs.setValue).toHaveBeenCalledWith('masConfigs', true);
});