mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2026-10-26 06:30:06 -05:00
1) Added browse button to select the binary path in the Preferences. Fixes #1561
2) Added support to set the binary path for the different database server versions. Fixes #5370
This commit is contained in:
1 parent
ac8e8961ce
commit
4bc4ca1ba9
26 files changed
+930
-302
No files matched your search
@@ -68,6 +68,9 @@ describe('BackupDialog', () => {
|
||||
data: {
|
||||
_id: 10,
|
||||
_type: 'server',
|
||||
label: 'some-tree-label',
|
||||
server_type: 'pg',
|
||||
version: 100000,
|
||||
},
|
||||
children: [
|
||||
{
|
||||
@@ -88,14 +91,34 @@ describe('BackupDialog', () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'serverTreeNodeWrongPath',
|
||||
data: {
|
||||
_id: 12,
|
||||
_type: 'server',
|
||||
label: 'some-tree-label',
|
||||
server_type: 'pg',
|
||||
version: 90600,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'ppasServer',
|
||||
data: {
|
||||
_id: 13,
|
||||
_type: 'server',
|
||||
label: 'some-tree-label',
|
||||
server_type: 'ppas',
|
||||
children: [
|
||||
{id: 'someNodeUnderneathPPASServer'},
|
||||
],
|
||||
version: 130000,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'ppasServerTreeNodeWrongPath',
|
||||
data: {
|
||||
_id: 14,
|
||||
_type: 'server',
|
||||
label: 'some-tree-label',
|
||||
server_type: 'ppas',
|
||||
version: 90600,
|
||||
},
|
||||
},
|
||||
],
|
||||
@@ -148,52 +171,42 @@ describe('BackupDialog', () => {
|
||||
pgBrowser.get_preference.and.returnValue(undefined);
|
||||
});
|
||||
|
||||
context('server is a ppas server', () => {
|
||||
it('display an alert with "Backup Error"', () => {
|
||||
backupDialog.draw(null, [{id: 'some_database'}], null);
|
||||
context('server is a PostgreSQL server', () => {
|
||||
it('display an alert with "Preferences Error"', () => {
|
||||
backupDialog.draw(null, [{id: 'serverTreeNode'}], null);
|
||||
expect(alertifySpy.alert).toHaveBeenCalledWith(
|
||||
'Backup Error',
|
||||
'Preferences Error',
|
||||
'Failed to load preference pg_bin_dir of module paths'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
context('server is not a ppas server', () => {
|
||||
it('display an alert with "Backup Error"', () => {
|
||||
context('server is a EPAS server', () => {
|
||||
it('display an alert with "Preferences Error"', () => {
|
||||
backupDialog.draw(null, [{id: 'ppasServer'}], null);
|
||||
expect(alertifySpy.alert).toHaveBeenCalledWith(
|
||||
'Backup Error',
|
||||
'Preferences Error',
|
||||
'Failed to load preference ppas_bin_dir of module paths'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
context('preference can be found', () => {
|
||||
context('preference can be found for PostgreSQL Server', () => {
|
||||
context('binary folder is not configured', () => {
|
||||
beforeEach(() => {
|
||||
pgBrowser.get_preference.and.returnValue({});
|
||||
pgBrowser.get_preference.and.returnValue({value: '[{\"serverType\":\"PostgreSQL 9.6\",\"binaryPath\":null,\"isDefault\":false,\"version\":\"90600\",\"next_major_version\":\"100000\"},{\"serverType\":\"PostgreSQL 10\",\"binaryPath\":\"/Library/PostgreSQL/10/bin\",\"isDefault\":false,\"version\":\"100000\",\"next_major_version\":\"110000\"},{\"serverType\":\"PostgreSQL 11\",\"binaryPath\":\"/Library/PostgreSQL/11/bin\",\"isDefault\":false,\"version\":\"110000\",\"next_major_version\":\"120000\"},{\"serverType\":\"PostgreSQL 12\",\"binaryPath\":\"/Library/PostgreSQL/12/bin\",\"isDefault\":false,\"version\":\"120000\",\"next_major_version\":\"130000\"},{\"serverType\":\"PostgreSQL 13\",\"binaryPath\":null,\"isDefault\":false,\"version\":\"130000\",\"next_major_version\":\"140000\"}]'});
|
||||
});
|
||||
|
||||
context('server is a ppas server', () => {
|
||||
context('server is a PostgreSQL server', () => {
|
||||
it('display an alert with "Configuration required"', () => {
|
||||
backupDialog.draw(null, [{id: 'serverTreeNode'}], null);
|
||||
backupDialog.draw(null, [{id: 'serverTreeNodeWrongPath'}], null);
|
||||
expect(alertifySpy.alert).toHaveBeenCalledWith(
|
||||
'Configuration required',
|
||||
'Please configure the PostgreSQL Binary Path in the Preferences dialog.'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
context('server is not a ppas server', () => {
|
||||
it('display an alert with "Configuration required"', () => {
|
||||
backupDialog.draw(null, [{id: 'ppasServer'}], null);
|
||||
expect(alertifySpy.alert).toHaveBeenCalledWith(
|
||||
'Configuration required',
|
||||
'Please configure the EDB Advanced Server Binary Path in the Preferences dialog.'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
context('binary folder is configured', () => {
|
||||
@@ -202,12 +215,12 @@ describe('BackupDialog', () => {
|
||||
backupDialogResizeToSpy = jasmine.createSpyObj('backupDialogResizeToSpy', ['resizeTo']);
|
||||
alertifySpy['backup_objects'].and
|
||||
.returnValue(backupDialogResizeToSpy);
|
||||
pgBrowser.get_preference.and.returnValue({value: '/some/path'});
|
||||
pgBrowser.get_preference.and.returnValue({value: '[{\"serverType\":\"PostgreSQL 9.6\",\"binaryPath\":null,\"isDefault\":false,\"version\":\"90600\",\"next_major_version\":\"100000\"},{\"serverType\":\"PostgreSQL 10\",\"binaryPath\":\"/Library/PostgreSQL/10/bin\",\"isDefault\":true,\"version\":\"100000\",\"next_major_version\":\"110000\"},{\"serverType\":\"PostgreSQL 11\",\"binaryPath\":\"/Library/PostgreSQL/11/bin\",\"isDefault\":false,\"version\":\"110000\",\"next_major_version\":\"120000\"},{\"serverType\":\"PostgreSQL 12\",\"binaryPath\":\"/Library/PostgreSQL/12/bin\",\"isDefault\":false,\"version\":\"120000\",\"next_major_version\":\"130000\"},{\"serverType\":\"PostgreSQL 13\",\"binaryPath\":null,\"isDefault\":false,\"version\":\"130000\",\"next_major_version\":\"140000\"}]'});
|
||||
spyOn(backupDialog, 'url_for_utility_exists').and.returnValue('/backup/utility_exists/10/objects');
|
||||
networkMock.onGet('/backup/utility_exists/10/objects').reply(200, {'success': 1});
|
||||
});
|
||||
|
||||
it('displays the dialog', (done) => {
|
||||
it('displays the dialog when binary path is for correct server version', (done) => {
|
||||
backupDialog.draw(null, [{id: 'serverTreeNode'}], null, pgBrowser.stdW.md, pgBrowser.stdH.md);
|
||||
setTimeout(() => {
|
||||
expect(alertifySpy['backup_objects']).toHaveBeenCalledWith(true);
|
||||
@@ -216,6 +229,15 @@ describe('BackupDialog', () => {
|
||||
}, 0);
|
||||
});
|
||||
|
||||
it('displays the dialog when default binary path is specified', (done) => {
|
||||
backupDialog.draw(null, [{id: 'serverTreeNodeWrongPath'}], null, pgBrowser.stdW.md, pgBrowser.stdH.md);
|
||||
setTimeout(() => {
|
||||
expect(alertifySpy['backup_objects']).toHaveBeenCalledWith(true);
|
||||
expect(backupDialogResizeToSpy.resizeTo).toHaveBeenCalledWith(pgBrowser.stdW.md, pgBrowser.stdH.md);
|
||||
done();
|
||||
}, 0);
|
||||
});
|
||||
|
||||
context('database label contain "="', () => {
|
||||
it('should create alert dialog with backup error', (done) => {
|
||||
backupDialog.draw(null, [{id: 'database_with_equal_in_name'}], null);
|
||||
@@ -228,6 +250,54 @@ describe('BackupDialog', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
context('preference can be found for EPAS server', () => {
|
||||
context('binary folder is not configured', () => {
|
||||
beforeEach(() => {
|
||||
pgBrowser.get_preference.and.returnValue({value: '[{\"serverType\":\"EDB Advanced Server 9.6\",\"binaryPath\":\"\",\"isDefault\":false,\"version\":\"90600\",\"next_major_version\":\"100000\"},{\"serverType\":\"EDB Advanced Server 10\",\"binaryPath\":null,\"isDefault\":false,\"version\":\"100000\",\"next_major_version\":\"110000\"},{\"serverType\":\"EDB Advanced Server 11\",\"binaryPath\":\"/Library/EPAS/11/bin/\",\"isDefault\":false,\"version\":\"110000\",\"next_major_version\":\"120000\"},{\"serverType\":\"EDB Advanced Server 12\",\"binaryPath\":null,\"isDefault\":false,\"version\":\"120000\",\"next_major_version\":\"130000\"},{\"serverType\":\"EDB Advanced Server 13\",\"binaryPath\":\"/Library/EPAS/13/bin/\",\"isDefault\":false,\"version\":\"130000\",\"next_major_version\":\"140000\"}]'});
|
||||
});
|
||||
|
||||
context('server is a EPAS server', () => {
|
||||
it('display an alert with "Configuration required"', () => {
|
||||
backupDialog.draw(null, [{id: 'ppasServerTreeNodeWrongPath'}], null);
|
||||
expect(alertifySpy.alert).toHaveBeenCalledWith(
|
||||
'Configuration required',
|
||||
'Please configure the EDB Advanced Server Binary Path in the Preferences dialog.'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
context('binary folder is configured', () => {
|
||||
let backupDialogResizeToSpy;
|
||||
beforeEach(() => {
|
||||
backupDialogResizeToSpy = jasmine.createSpyObj('backupDialogResizeToSpy', ['resizeTo']);
|
||||
alertifySpy['backup_objects'].and
|
||||
.returnValue(backupDialogResizeToSpy);
|
||||
pgBrowser.get_preference.and.returnValue({value: '[{\"serverType\":\"EDB Advanced Server 9.6\",\"binaryPath\":\"\",\"isDefault\":false,\"version\":\"90600\",\"next_major_version\":\"100000\"},{\"serverType\":\"EDB Advanced Server 10\",\"binaryPath\":null,\"isDefault\":false,\"version\":\"100000\",\"next_major_version\":\"110000\"},{\"serverType\":\"EDB Advanced Server 11\",\"binaryPath\":\"/Library/EPAS/11/bin/\",\"isDefault\":false,\"version\":\"110000\",\"next_major_version\":\"120000\"},{\"serverType\":\"EDB Advanced Server 12\",\"binaryPath\":null,\"isDefault\":false,\"version\":\"120000\",\"next_major_version\":\"130000\"},{\"serverType\":\"EDB Advanced Server 13\",\"binaryPath\":\"/Library/EPAS/13/bin/\",\"isDefault\":true,\"version\":\"130000\",\"next_major_version\":\"140000\"}]'});
|
||||
spyOn(backupDialog, 'url_for_utility_exists').and.returnValue('/backup/utility_exists/10/objects');
|
||||
networkMock.onGet('/backup/utility_exists/10/objects').reply(200, {'success': 1});
|
||||
});
|
||||
|
||||
it('displays the dialog when binary path is for correct server version', (done) => {
|
||||
backupDialog.draw(null, [{id: 'ppasServer'}], null, pgBrowser.stdW.md, pgBrowser.stdH.md);
|
||||
setTimeout(() => {
|
||||
expect(alertifySpy['backup_objects']).toHaveBeenCalledWith(true);
|
||||
expect(backupDialogResizeToSpy.resizeTo).toHaveBeenCalledWith(pgBrowser.stdW.md, pgBrowser.stdH.md);
|
||||
done();
|
||||
}, 0);
|
||||
});
|
||||
|
||||
it('displays the dialog when default binary path is specified', (done) => {
|
||||
backupDialog.draw(null, [{id: 'ppasServerTreeNodeWrongPath'}], null, pgBrowser.stdW.md, pgBrowser.stdH.md);
|
||||
setTimeout(() => {
|
||||
expect(alertifySpy['backup_objects']).toHaveBeenCalledWith(true);
|
||||
expect(backupDialogResizeToSpy.resizeTo).toHaveBeenCalledWith(pgBrowser.stdW.md, pgBrowser.stdH.md);
|
||||
done();
|
||||
}, 0);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -21,8 +21,8 @@ describe('GlobalServerBackupDialog', () => {
|
||||
let backupModelSpy;
|
||||
|
||||
let rootNode;
|
||||
let serverTreeNode;
|
||||
let ppasServerTreeNode;
|
||||
let serverTreeNode, serverTreeNodeWrongPath;
|
||||
let ppasServerTreeNode, ppasServerTreeNodeWrongPath;
|
||||
|
||||
beforeEach(() => {
|
||||
pgBrowser = {
|
||||
@@ -51,12 +51,26 @@ describe('GlobalServerBackupDialog', () => {
|
||||
serverTreeNode = pgBrowser.treeMenu.addNewNode('level1.1', {
|
||||
_type: 'server',
|
||||
_id: 10,
|
||||
server_type: 'pg',
|
||||
version: 100000,
|
||||
}, undefined, ['level1']);
|
||||
ppasServerTreeNode = pgBrowser.treeMenu.addNewNode('level1.2', {
|
||||
serverTreeNodeWrongPath = pgBrowser.treeMenu.addNewNode('level1.2', {
|
||||
_type: 'server',
|
||||
_id: 11,
|
||||
server_type: 'pg',
|
||||
version: 90600,
|
||||
}, undefined, ['level1']);
|
||||
ppasServerTreeNode = pgBrowser.treeMenu.addNewNode('level1.3', {
|
||||
_type: 'server',
|
||||
server_type: 'ppas',
|
||||
version: 130000,
|
||||
}, undefined, ['level1']);
|
||||
pgBrowser.treeMenu.addNewNode('level3', {}, undefined, ['level1', 'level1.2']);
|
||||
ppasServerTreeNodeWrongPath = pgBrowser.treeMenu.addNewNode('level1.4', {
|
||||
_type: 'server',
|
||||
server_type: 'ppas',
|
||||
version: 90600,
|
||||
}, undefined, ['level1']);
|
||||
pgBrowser.treeMenu.addNewNode('level3', {}, undefined, ['level1', 'level1.2', 'level1.3', 'level1.4']);
|
||||
pgBrowser.treeMenu.addNewNode('level3.1', undefined, undefined, ['level1', 'level1.2', 'level3']);
|
||||
});
|
||||
|
||||
@@ -73,6 +87,7 @@ describe('GlobalServerBackupDialog', () => {
|
||||
alertifySpy,
|
||||
backupModelSpy
|
||||
);
|
||||
|
||||
pgBrowser.get_preference = jasmine.createSpy('get_preferences');
|
||||
});
|
||||
|
||||
@@ -103,46 +118,113 @@ describe('GlobalServerBackupDialog', () => {
|
||||
pgBrowser.get_preference.and.returnValue(undefined);
|
||||
});
|
||||
|
||||
context('server is a ppas server', () => {
|
||||
it('display an alert with "Backup Error"', () => {
|
||||
context('server is a PostgreSQL server', () => {
|
||||
it('display an alert with "Preferences Error"', () => {
|
||||
backupDialog.draw(null, [serverTreeNode], null);
|
||||
expect(alertifySpy.alert).toHaveBeenCalledWith(
|
||||
'Backup Error',
|
||||
'Preferences Error',
|
||||
'Failed to load preference pg_bin_dir of module paths'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
context('server is not a ppas server', () => {
|
||||
it('display an alert with "Backup Error"', () => {
|
||||
context('server is a EPAS server', () => {
|
||||
it('display an alert with "Preferences Error"', () => {
|
||||
backupDialog.draw(null, [ppasServerTreeNode], null);
|
||||
expect(alertifySpy.alert).toHaveBeenCalledWith(
|
||||
'Backup Error',
|
||||
'Preferences Error',
|
||||
'Failed to load preference ppas_bin_dir of module paths'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
context('preference can be found', () => {
|
||||
context('preference can be found for PostgreSQL Server', () => {
|
||||
context('binary folder is not configured', () => {
|
||||
beforeEach(() => {
|
||||
pgBrowser.get_preference.and.returnValue({});
|
||||
pgBrowser.get_preference.and.returnValue({value: '[{\"serverType\":\"PostgreSQL 9.6\",\"binaryPath\":null,\"isDefault\":false,\"version\":\"90600\",\"next_major_version\":\"100000\"},{\"serverType\":\"PostgreSQL 10\",\"binaryPath\":\"/Library/PostgreSQL/10/bin\",\"isDefault\":false,\"version\":\"100000\",\"next_major_version\":\"110000\"},{\"serverType\":\"PostgreSQL 11\",\"binaryPath\":\"/Library/PostgreSQL/11/bin\",\"isDefault\":false,\"version\":\"110000\",\"next_major_version\":\"120000\"},{\"serverType\":\"PostgreSQL 12\",\"binaryPath\":\"/Library/PostgreSQL/12/bin\",\"isDefault\":false,\"version\":\"120000\",\"next_major_version\":\"130000\"},{\"serverType\":\"PostgreSQL 13\",\"binaryPath\":null,\"isDefault\":false,\"version\":\"130000\",\"next_major_version\":\"140000\"}]'});
|
||||
});
|
||||
|
||||
context('server is a ppas server', () => {
|
||||
context('server is a PostgreSQL server', () => {
|
||||
it('display an alert with "Configuration required"', () => {
|
||||
backupDialog.draw(null, [serverTreeNode], null);
|
||||
backupDialog.draw(null, [serverTreeNodeWrongPath], null);
|
||||
expect(alertifySpy.alert).toHaveBeenCalledWith(
|
||||
'Configuration required',
|
||||
'Please configure the PostgreSQL Binary Path in the Preferences dialog.'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
context('server is not a ppas server', () => {
|
||||
context('binary folder is configured', () => {
|
||||
let globalResizeToSpy;
|
||||
let serverResizeToSpy;
|
||||
beforeEach(() => {
|
||||
globalResizeToSpy = jasmine.createSpyObj('globals', ['resizeTo']);
|
||||
alertifySpy['BackupDialog_globals'].and
|
||||
.returnValue(globalResizeToSpy);
|
||||
serverResizeToSpy = jasmine.createSpyObj('server', ['resizeTo']);
|
||||
alertifySpy['BackupDialog_server'].and
|
||||
.returnValue(serverResizeToSpy);
|
||||
pgBrowser.get_preference.and.returnValue({value: '[{\"serverType\":\"PostgreSQL 9.6\",\"binaryPath\":null,\"isDefault\":false,\"version\":\"90600\",\"next_major_version\":\"100000\"},{\"serverType\":\"PostgreSQL 10\",\"binaryPath\":\"/Library/PostgreSQL/10/bin\",\"isDefault\":true,\"version\":\"100000\",\"next_major_version\":\"110000\"},{\"serverType\":\"PostgreSQL 11\",\"binaryPath\":\"/Library/PostgreSQL/11/bin\",\"isDefault\":false,\"version\":\"110000\",\"next_major_version\":\"120000\"},{\"serverType\":\"PostgreSQL 12\",\"binaryPath\":\"/Library/PostgreSQL/12/bin\",\"isDefault\":false,\"version\":\"120000\",\"next_major_version\":\"130000\"},{\"serverType\":\"PostgreSQL 13\",\"binaryPath\":null,\"isDefault\":false,\"version\":\"130000\",\"next_major_version\":\"140000\"}]'});
|
||||
spyOn(backupDialog, 'url_for_utility_exists').and.returnValue('/backup/utility_exists/10/servers');
|
||||
networkMock.onGet('/backup/utility_exists/10/servers').reply(200, {'success': 1});
|
||||
});
|
||||
|
||||
context('dialog for global backup ', () => {
|
||||
it('displays the dialog when binary path is for correct server version', (done) => {
|
||||
backupDialog.draw(null, [serverTreeNode], {globals: true}, pgBrowser.stdW.md, pgBrowser.stdH.md);
|
||||
setTimeout(() => {
|
||||
expect(alertifySpy['BackupDialog_globals']).toHaveBeenCalledWith(true);
|
||||
expect(globalResizeToSpy.resizeTo).toHaveBeenCalledWith(pgBrowser.stdW.md, pgBrowser.stdH.md);
|
||||
done();
|
||||
}, 0);
|
||||
});
|
||||
});
|
||||
|
||||
context('dialog for server backup', () => {
|
||||
it('displays the dialog when binary path is for correct server version', (done) => {
|
||||
backupDialog.draw(null, [serverTreeNode], {server: true}, pgBrowser.stdW.md, pgBrowser.stdH.md);
|
||||
setTimeout(() => {
|
||||
expect(alertifySpy['BackupDialog_server']).toHaveBeenCalledWith(true);
|
||||
expect(serverResizeToSpy.resizeTo).toHaveBeenCalledWith(pgBrowser.stdW.md, pgBrowser.stdH.md);
|
||||
done();
|
||||
}, 0);
|
||||
});
|
||||
});
|
||||
|
||||
context('dialog for global backup ', () => {
|
||||
it('displays the dialog when default binary path is specified', (done) => {
|
||||
backupDialog.draw(null, [serverTreeNodeWrongPath], {globals: true}, pgBrowser.stdW.md, pgBrowser.stdH.md);
|
||||
setTimeout(() => {
|
||||
expect(alertifySpy['BackupDialog_globals']).toHaveBeenCalledWith(true);
|
||||
expect(globalResizeToSpy.resizeTo).toHaveBeenCalledWith(pgBrowser.stdW.md, pgBrowser.stdH.md);
|
||||
done();
|
||||
}, 0);
|
||||
});
|
||||
});
|
||||
|
||||
context('dialog for server backup', () => {
|
||||
it('displays the dialog when default binary path is specified', (done) => {
|
||||
backupDialog.draw(null, [serverTreeNodeWrongPath], {server: true}, pgBrowser.stdW.md, pgBrowser.stdH.md);
|
||||
setTimeout(() => {
|
||||
expect(alertifySpy['BackupDialog_server']).toHaveBeenCalledWith(true);
|
||||
expect(serverResizeToSpy.resizeTo).toHaveBeenCalledWith(pgBrowser.stdW.md, pgBrowser.stdH.md);
|
||||
done();
|
||||
}, 0);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
context('preference can be found for EPAS Server', () => {
|
||||
context('binary folder is not configured', () => {
|
||||
beforeEach(() => {
|
||||
pgBrowser.get_preference.and.returnValue({value: '[{\"serverType\":\"EDB Advanced Server 9.6\",\"binaryPath\":\"\",\"isDefault\":false,\"version\":\"90600\",\"next_major_version\":\"100000\"},{\"serverType\":\"EDB Advanced Server 10\",\"binaryPath\":null,\"isDefault\":false,\"version\":\"100000\",\"next_major_version\":\"110000\"},{\"serverType\":\"EDB Advanced Server 11\",\"binaryPath\":\"/Library/EPAS/11/bin/\",\"isDefault\":false,\"version\":\"110000\",\"next_major_version\":\"120000\"},{\"serverType\":\"EDB Advanced Server 12\",\"binaryPath\":null,\"isDefault\":false,\"version\":\"120000\",\"next_major_version\":\"130000\"},{\"serverType\":\"EDB Advanced Server 13\",\"binaryPath\":\"/Library/EPAS/13/bin/\",\"isDefault\":false,\"version\":\"130000\",\"next_major_version\":\"140000\"}]'});
|
||||
});
|
||||
|
||||
context('server is a EPAS server', () => {
|
||||
it('display an alert with "Configuration required"', () => {
|
||||
backupDialog.draw(null, [ppasServerTreeNode], null);
|
||||
backupDialog.draw(null, [ppasServerTreeNodeWrongPath], null);
|
||||
expect(alertifySpy.alert).toHaveBeenCalledWith(
|
||||
'Configuration required',
|
||||
'Please configure the EDB Advanced Server Binary Path in the Preferences dialog.'
|
||||
@@ -161,14 +243,14 @@ describe('GlobalServerBackupDialog', () => {
|
||||
serverResizeToSpy = jasmine.createSpyObj('server', ['resizeTo']);
|
||||
alertifySpy['BackupDialog_server'].and
|
||||
.returnValue(serverResizeToSpy);
|
||||
pgBrowser.get_preference.and.returnValue({value: '/some/path'});
|
||||
pgBrowser.get_preference.and.returnValue({value: '[{\"serverType\":\"EDB Advanced Server 9.6\",\"binaryPath\":\"\",\"isDefault\":false,\"version\":\"90600\",\"next_major_version\":\"100000\"},{\"serverType\":\"EDB Advanced Server 10\",\"binaryPath\":null,\"isDefault\":false,\"version\":\"100000\",\"next_major_version\":\"110000\"},{\"serverType\":\"EDB Advanced Server 11\",\"binaryPath\":\"/Library/EPAS/11/bin/\",\"isDefault\":false,\"version\":\"110000\",\"next_major_version\":\"120000\"},{\"serverType\":\"EDB Advanced Server 12\",\"binaryPath\":null,\"isDefault\":false,\"version\":\"120000\",\"next_major_version\":\"130000\"},{\"serverType\":\"EDB Advanced Server 13\",\"binaryPath\":\"/Library/EPAS/13/bin/\",\"isDefault\":true,\"version\":\"130000\",\"next_major_version\":\"140000\"}]'});
|
||||
spyOn(backupDialog, 'url_for_utility_exists').and.returnValue('/backup/utility_exists/10/servers');
|
||||
networkMock.onGet('/backup/utility_exists/10/servers').reply(200, {'success': 1});
|
||||
});
|
||||
|
||||
context('dialog for global backup', () => {
|
||||
it('displays the dialog', (done) => {
|
||||
backupDialog.draw(null, [serverTreeNode], {globals: true}, pgBrowser.stdW.md, pgBrowser.stdH.md);
|
||||
context('dialog for global backup ', () => {
|
||||
it('displays the dialog when binary path is for correct server version', (done) => {
|
||||
backupDialog.draw(null, [ppasServerTreeNode], {globals: true}, pgBrowser.stdW.md, pgBrowser.stdH.md);
|
||||
setTimeout(() => {
|
||||
expect(alertifySpy['BackupDialog_globals']).toHaveBeenCalledWith(true);
|
||||
expect(globalResizeToSpy.resizeTo).toHaveBeenCalledWith(pgBrowser.stdW.md, pgBrowser.stdH.md);
|
||||
@@ -178,8 +260,30 @@ describe('GlobalServerBackupDialog', () => {
|
||||
});
|
||||
|
||||
context('dialog for server backup', () => {
|
||||
it('displays the dialog', (done) => {
|
||||
backupDialog.draw(null, [serverTreeNode], {server: true}, pgBrowser.stdW.md, pgBrowser.stdH.md);
|
||||
it('displays the dialog when binary path is for correct server version', (done) => {
|
||||
backupDialog.draw(null, [ppasServerTreeNode], {server: true}, pgBrowser.stdW.md, pgBrowser.stdH.md);
|
||||
setTimeout(() => {
|
||||
expect(alertifySpy['BackupDialog_server']).toHaveBeenCalledWith(true);
|
||||
expect(serverResizeToSpy.resizeTo).toHaveBeenCalledWith(pgBrowser.stdW.md, pgBrowser.stdH.md);
|
||||
done();
|
||||
}, 0);
|
||||
});
|
||||
});
|
||||
|
||||
context('dialog for global backup ', () => {
|
||||
it('displays the dialog when default binary path is specified', (done) => {
|
||||
backupDialog.draw(null, [ppasServerTreeNodeWrongPath], {globals: true}, pgBrowser.stdW.md, pgBrowser.stdH.md);
|
||||
setTimeout(() => {
|
||||
expect(alertifySpy['BackupDialog_globals']).toHaveBeenCalledWith(true);
|
||||
expect(globalResizeToSpy.resizeTo).toHaveBeenCalledWith(pgBrowser.stdW.md, pgBrowser.stdH.md);
|
||||
done();
|
||||
}, 0);
|
||||
});
|
||||
});
|
||||
|
||||
context('dialog for server backup', () => {
|
||||
it('displays the dialog when default binary path is specified', (done) => {
|
||||
backupDialog.draw(null, [ppasServerTreeNodeWrongPath], {server: true}, pgBrowser.stdW.md, pgBrowser.stdH.md);
|
||||
setTimeout(() => {
|
||||
expect(alertifySpy['BackupDialog_server']).toHaveBeenCalledWith(true);
|
||||
expect(serverResizeToSpy.resizeTo).toHaveBeenCalledWith(pgBrowser.stdW.md, pgBrowser.stdH.md);
|
||||
|
||||
@@ -56,6 +56,8 @@ describe('RestoreDialog', () => {
|
||||
_id: 10,
|
||||
_type: 'server',
|
||||
label: 'some-tree-label',
|
||||
server_type: 'pg',
|
||||
version: 100000,
|
||||
},
|
||||
children: [
|
||||
{
|
||||
@@ -76,14 +78,34 @@ describe('RestoreDialog', () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'serverTreeNodeWrongPath',
|
||||
data: {
|
||||
_id: 12,
|
||||
_type: 'server',
|
||||
label: 'some-tree-label',
|
||||
server_type: 'pg',
|
||||
version: 90600,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'ppasServer',
|
||||
data: {
|
||||
_id: 13,
|
||||
_type: 'server',
|
||||
label: 'some-tree-label',
|
||||
server_type: 'ppas',
|
||||
children: [
|
||||
{id: 'someNodeUnderneathPPASServer'},
|
||||
],
|
||||
version: 130000,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'ppasServerTreeNodeWrongPath',
|
||||
data: {
|
||||
_id: 14,
|
||||
_type: 'server',
|
||||
label: 'some-tree-label',
|
||||
server_type: 'ppas',
|
||||
version: 90600,
|
||||
},
|
||||
},
|
||||
],
|
||||
@@ -136,52 +158,42 @@ describe('RestoreDialog', () => {
|
||||
pgBrowser.get_preference.and.returnValue(undefined);
|
||||
});
|
||||
|
||||
context('server is a ppas server', () => {
|
||||
it('display an alert with "Restore Error"', () => {
|
||||
context('server is a PostgreSQL server', () => {
|
||||
it('display an alert with "Preferences Error"', () => {
|
||||
restoreDialog.draw(null, [{id: 'serverTreeNode'}], null);
|
||||
expect(alertifySpy.alert).toHaveBeenCalledWith(
|
||||
'Restore Error',
|
||||
'Preferences Error',
|
||||
'Failed to load preference pg_bin_dir of module paths'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
context('server is not a ppas server', () => {
|
||||
it('display an alert with "Restore Error"', () => {
|
||||
context('server is a EPAS server', () => {
|
||||
it('display an alert with "Preferences Error"', () => {
|
||||
restoreDialog.draw(null, [{id: 'ppasServer'}], null);
|
||||
expect(alertifySpy.alert).toHaveBeenCalledWith(
|
||||
'Restore Error',
|
||||
'Preferences Error',
|
||||
'Failed to load preference ppas_bin_dir of module paths'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
context('preference can be found', () => {
|
||||
context('preference can be found for PostgreSQL Server', () => {
|
||||
context('binary folder is not configured', () => {
|
||||
beforeEach(() => {
|
||||
pgBrowser.get_preference.and.returnValue({});
|
||||
pgBrowser.get_preference.and.returnValue({value: '[{\"serverType\":\"PostgreSQL 9.6\",\"binaryPath\":null,\"isDefault\":false,\"version\":\"90600\",\"next_major_version\":\"100000\"},{\"serverType\":\"PostgreSQL 10\",\"binaryPath\":\"/Library/PostgreSQL/10/bin\",\"isDefault\":false,\"version\":\"100000\",\"next_major_version\":\"110000\"},{\"serverType\":\"PostgreSQL 11\",\"binaryPath\":\"/Library/PostgreSQL/11/bin\",\"isDefault\":false,\"version\":\"110000\",\"next_major_version\":\"120000\"},{\"serverType\":\"PostgreSQL 12\",\"binaryPath\":\"/Library/PostgreSQL/12/bin\",\"isDefault\":false,\"version\":\"120000\",\"next_major_version\":\"130000\"},{\"serverType\":\"PostgreSQL 13\",\"binaryPath\":null,\"isDefault\":false,\"version\":\"130000\",\"next_major_version\":\"140000\"}]'});
|
||||
});
|
||||
|
||||
context('server is a ppas server', () => {
|
||||
context('server is a PostgreSQL server', () => {
|
||||
it('display an alert with "Configuration required"', () => {
|
||||
restoreDialog.draw(null, [{id: 'serverTreeNode'}], null);
|
||||
restoreDialog.draw(null, [{id: 'serverTreeNodeWrongPath'}], null);
|
||||
expect(alertifySpy.alert).toHaveBeenCalledWith(
|
||||
'Configuration required',
|
||||
'Please configure the PostgreSQL Binary Path in the Preferences dialog.'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
context('server is not a ppas server', () => {
|
||||
it('display an alert with "Configuration required"', () => {
|
||||
restoreDialog.draw(null, [{id: 'ppasServer'}], null);
|
||||
expect(alertifySpy.alert).toHaveBeenCalledWith(
|
||||
'Configuration required',
|
||||
'Please configure the EDB Advanced Server Binary Path in the Preferences dialog.'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
context('binary folder is configured', () => {
|
||||
@@ -190,13 +202,13 @@ describe('RestoreDialog', () => {
|
||||
spy = jasmine.createSpyObj('globals', ['resizeTo']);
|
||||
alertifySpy['pg_restore'].and
|
||||
.returnValue(spy);
|
||||
pgBrowser.get_preference.and.returnValue({value: '/some/path'});
|
||||
pgBrowser.Nodes.server.label = 'some-server-label';
|
||||
pgBrowser.get_preference.and.returnValue({value: '[{\"serverType\":\"PostgreSQL 9.6\",\"binaryPath\":null,\"isDefault\":false,\"version\":\"90600\",\"next_major_version\":\"100000\"},{\"serverType\":\"PostgreSQL 10\",\"binaryPath\":\"/Library/PostgreSQL/10/bin\",\"isDefault\":true,\"version\":\"100000\",\"next_major_version\":\"110000\"},{\"serverType\":\"PostgreSQL 11\",\"binaryPath\":\"/Library/PostgreSQL/11/bin\",\"isDefault\":false,\"version\":\"110000\",\"next_major_version\":\"120000\"},{\"serverType\":\"PostgreSQL 12\",\"binaryPath\":\"/Library/PostgreSQL/12/bin\",\"isDefault\":false,\"version\":\"120000\",\"next_major_version\":\"130000\"},{\"serverType\":\"PostgreSQL 13\",\"binaryPath\":null,\"isDefault\":false,\"version\":\"130000\",\"next_major_version\":\"140000\"}]'});
|
||||
spyOn(restoreDialog, 'url_for_utility_exists').and.returnValue('/restore/utility_exists/10/objects');
|
||||
networkMock.onGet('/restore/utility_exists/10/objects').reply(200, {'success': 1});
|
||||
});
|
||||
|
||||
it('displays the dialog', (done) => {
|
||||
it('displays the dialog when binary path is for correct server version', (done) => {
|
||||
restoreDialog.draw(null, [{id: 'serverTreeNode'}], pgBrowser.stdW.md, pgBrowser.stdH.md);
|
||||
setTimeout(() => {
|
||||
expect(alertifySpy['pg_restore']).toHaveBeenCalledWith(
|
||||
@@ -206,6 +218,28 @@ describe('RestoreDialog', () => {
|
||||
_id: 10,
|
||||
_type: 'server',
|
||||
label: 'some-tree-label',
|
||||
server_type: 'pg',
|
||||
version: 100000,
|
||||
},
|
||||
pgBrowser.Nodes.server
|
||||
);
|
||||
expect(spy.resizeTo).toHaveBeenCalledWith(pgBrowser.stdW.md, pgBrowser.stdH.md);
|
||||
done();
|
||||
}, 0);
|
||||
});
|
||||
|
||||
it('displays the dialog when default binary path is specified', (done) => {
|
||||
restoreDialog.draw(null, [{id: 'serverTreeNodeWrongPath'}], pgBrowser.stdW.md, pgBrowser.stdH.md);
|
||||
setTimeout(() => {
|
||||
expect(alertifySpy['pg_restore']).toHaveBeenCalledWith(
|
||||
'Restore (some-server-label: some-tree-label)',
|
||||
[{id: 'serverTreeNodeWrongPath'}],
|
||||
{
|
||||
_id: 12,
|
||||
_type: 'server',
|
||||
label: 'some-tree-label',
|
||||
server_type: 'pg',
|
||||
version: 90600,
|
||||
},
|
||||
pgBrowser.Nodes.server
|
||||
);
|
||||
@@ -226,6 +260,77 @@ describe('RestoreDialog', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
context('preference can be found for EPAS server', () => {
|
||||
context('binary folder is not configured', () => {
|
||||
beforeEach(() => {
|
||||
pgBrowser.get_preference.and.returnValue({value: '[{\"serverType\":\"EDB Advanced Server 9.6\",\"binaryPath\":\"\",\"isDefault\":false,\"version\":\"90600\",\"next_major_version\":\"100000\"},{\"serverType\":\"EDB Advanced Server 10\",\"binaryPath\":null,\"isDefault\":false,\"version\":\"100000\",\"next_major_version\":\"110000\"},{\"serverType\":\"EDB Advanced Server 11\",\"binaryPath\":\"/Library/EPAS/11/bin/\",\"isDefault\":false,\"version\":\"110000\",\"next_major_version\":\"120000\"},{\"serverType\":\"EDB Advanced Server 12\",\"binaryPath\":null,\"isDefault\":false,\"version\":\"120000\",\"next_major_version\":\"130000\"},{\"serverType\":\"EDB Advanced Server 13\",\"binaryPath\":\"/Library/EPAS/13/bin/\",\"isDefault\":false,\"version\":\"130000\",\"next_major_version\":\"140000\"}]'});
|
||||
});
|
||||
|
||||
context('server is a EPAS server', () => {
|
||||
it('display an alert with "Configuration required"', () => {
|
||||
restoreDialog.draw(null, [{id: 'ppasServerTreeNodeWrongPath'}], null);
|
||||
expect(alertifySpy.alert).toHaveBeenCalledWith(
|
||||
'Configuration required',
|
||||
'Please configure the EDB Advanced Server Binary Path in the Preferences dialog.'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
context('binary folder is configured', () => {
|
||||
let spy;
|
||||
beforeEach(() => {
|
||||
spy = jasmine.createSpyObj('globals', ['resizeTo']);
|
||||
alertifySpy['pg_restore'].and
|
||||
.returnValue(spy);
|
||||
pgBrowser.Nodes.server.label = 'some-server-label';
|
||||
pgBrowser.get_preference.and.returnValue({value: '[{\"serverType\":\"EDB Advanced Server 9.6\",\"binaryPath\":\"\",\"isDefault\":false,\"version\":\"90600\",\"next_major_version\":\"100000\"},{\"serverType\":\"EDB Advanced Server 10\",\"binaryPath\":null,\"isDefault\":false,\"version\":\"100000\",\"next_major_version\":\"110000\"},{\"serverType\":\"EDB Advanced Server 11\",\"binaryPath\":\"/Library/EPAS/11/bin/\",\"isDefault\":false,\"version\":\"110000\",\"next_major_version\":\"120000\"},{\"serverType\":\"EDB Advanced Server 12\",\"binaryPath\":null,\"isDefault\":false,\"version\":\"120000\",\"next_major_version\":\"130000\"},{\"serverType\":\"EDB Advanced Server 13\",\"binaryPath\":\"/Library/EPAS/13/bin/\",\"isDefault\":true,\"version\":\"130000\",\"next_major_version\":\"140000\"}]'});
|
||||
spyOn(restoreDialog, 'url_for_utility_exists').and.returnValue('/restore/utility_exists/10/objects');
|
||||
networkMock.onGet('/restore/utility_exists/10/objects').reply(200, {'success': 1});
|
||||
});
|
||||
|
||||
it('displays the dialog when binary path is for correct server version', (done) => {
|
||||
restoreDialog.draw(null, [{id: 'ppasServer'}], pgBrowser.stdW.md, pgBrowser.stdH.md);
|
||||
setTimeout(() => {
|
||||
expect(alertifySpy['pg_restore']).toHaveBeenCalledWith(
|
||||
'Restore (some-server-label: some-tree-label)',
|
||||
[{id: 'ppasServer'}],
|
||||
{
|
||||
_id: 13,
|
||||
_type: 'server',
|
||||
label: 'some-tree-label',
|
||||
server_type: 'ppas',
|
||||
version: 130000,
|
||||
},
|
||||
pgBrowser.Nodes.server
|
||||
);
|
||||
expect(spy.resizeTo).toHaveBeenCalledWith(pgBrowser.stdW.md, pgBrowser.stdH.md);
|
||||
done();
|
||||
}, 0);
|
||||
});
|
||||
|
||||
it('displays the dialog when default binary path is specified', (done) => {
|
||||
restoreDialog.draw(null, [{id: 'ppasServerTreeNodeWrongPath'}], pgBrowser.stdW.md, pgBrowser.stdH.md);
|
||||
setTimeout(() => {
|
||||
expect(alertifySpy['pg_restore']).toHaveBeenCalledWith(
|
||||
'Restore (some-server-label: some-tree-label)',
|
||||
[{id: 'ppasServerTreeNodeWrongPath'}],
|
||||
{
|
||||
_id: 14,
|
||||
_type: 'server',
|
||||
label: 'some-tree-label',
|
||||
server_type: 'ppas',
|
||||
version: 90600,
|
||||
},
|
||||
pgBrowser.Nodes.server
|
||||
);
|
||||
expect(spy.resizeTo).toHaveBeenCalledWith(pgBrowser.stdW.md, pgBrowser.stdH.md);
|
||||
done();
|
||||
}, 0);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -10,6 +10,7 @@ import SearchObjectsDialog from 'tools/search_objects/static/js/search_objects_d
|
||||
import {TreeFake} from '../tree/tree_fake';
|
||||
import MockAdapter from 'axios-mock-adapter';
|
||||
import axios from 'axios/index';
|
||||
import gettext from 'sources/gettext';
|
||||
|
||||
const context = describe;
|
||||
|
||||
@@ -141,11 +142,11 @@ describe('SearchObjectsDialog', () => {
|
||||
expect(alertifySpy['search_objects']).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('display an alert with a Backup Error', () => {
|
||||
it('display an alert with a Search object Error', () => {
|
||||
soDialog.draw(null, [{id: 'serverTreeNode'}], null);
|
||||
expect(alertifySpy.alert).toHaveBeenCalledWith(
|
||||
'Search Objects Error',
|
||||
'Please select a database or its child node from the browser.'
|
||||
gettext('Search Objects Error'),
|
||||
gettext('Please select a database or its child node from the browser.')
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user