2017-06-30 09:23:12 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// pgAdmin 4 - PostgreSQL Tools
|
|
|
|
//
|
2019-01-02 10:24:12 +00:00
|
|
|
// Copyright (C) 2013 - 2019, The pgAdmin Development Team
|
2017-06-30 09:23:12 +00:00
|
|
|
// This software is released under the PostgreSQL Licence
|
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
2017-07-31 13:29:44 +00:00
|
|
|
import alertify from 'pgadmin.alertifyjs';
|
2018-05-04 15:56:15 +00:00
|
|
|
import * as $ from 'jquery';
|
|
|
|
import gettext from 'sources/gettext';
|
|
|
|
|
2017-06-30 09:23:12 +00:00
|
|
|
|
|
|
|
describe('alertify_wrapper', function () {
|
|
|
|
describe('success', function () {
|
|
|
|
it('calls the success function from alertify and adds the checkmark to the element', function () {
|
2017-07-31 13:29:44 +00:00
|
|
|
spyOn(alertify, 'orig_success');
|
2017-06-30 09:23:12 +00:00
|
|
|
|
2017-07-31 13:29:44 +00:00
|
|
|
alertify.success('Yay, congrats!', 1);
|
2017-06-30 09:23:12 +00:00
|
|
|
|
2017-07-31 13:29:44 +00:00
|
|
|
var calledWithMessage = alertify.orig_success.calls.mostRecent().args[0];
|
2017-06-30 09:23:12 +00:00
|
|
|
|
|
|
|
expect(calledWithMessage).toContain('Yay, congrats!');
|
Improvement in the look and feel of the whole application
Changed the SCSS/CSS for the below third party libraries to adopt the
new look 'n' feel:
- wcDocker
- Alertify dialogs, and notifications
- AciTree
- Bootstrap Navbar
- Bootstrap Tabs
- Bootstrap Drop-Down menu
- Backgrid
- Select2
Adopated the new the look 'n' feel for the dialogs, wizard, properties,
tab panels, tabs, fieldset, subnode control, spinner control, HTML
table, and other form controls.
- Font is changed to Roboto
- Using SCSS variables to define the look 'n' feel
- Designer background images for the Login, and Forget password pages in
'web' mode
- Improved the look 'n' feel for the key selection in the preferences
dialog
- Table classes consistency changes across the application
- File Open and Save dialog list view changes
Author(s): Aditya Toshniwal & Khushboo Vashi
2018-12-21 11:44:55 +00:00
|
|
|
expect(calledWithMessage).toContain('class="fa fa-check text-success"');
|
2017-06-30 09:23:12 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('error', function () {
|
|
|
|
it('calls the error function from alertify and adds the warning symbol to the element', function () {
|
2017-07-31 13:29:44 +00:00
|
|
|
spyOn(alertify, 'orig_error');
|
2017-06-30 09:23:12 +00:00
|
|
|
|
2017-07-31 13:29:44 +00:00
|
|
|
alertify.error('bad, very bad', 1);
|
2017-06-30 09:23:12 +00:00
|
|
|
|
2017-07-31 13:29:44 +00:00
|
|
|
var calledWithMessage = alertify.orig_error.calls.mostRecent().args[0];
|
2017-06-30 09:23:12 +00:00
|
|
|
|
|
|
|
expect(calledWithMessage).toContain('bad, very bad');
|
Improvement in the look and feel of the whole application
Changed the SCSS/CSS for the below third party libraries to adopt the
new look 'n' feel:
- wcDocker
- Alertify dialogs, and notifications
- AciTree
- Bootstrap Navbar
- Bootstrap Tabs
- Bootstrap Drop-Down menu
- Backgrid
- Select2
Adopated the new the look 'n' feel for the dialogs, wizard, properties,
tab panels, tabs, fieldset, subnode control, spinner control, HTML
table, and other form controls.
- Font is changed to Roboto
- Using SCSS variables to define the look 'n' feel
- Designer background images for the Login, and Forget password pages in
'web' mode
- Improved the look 'n' feel for the key selection in the preferences
dialog
- Table classes consistency changes across the application
- File Open and Save dialog list view changes
Author(s): Aditya Toshniwal & Khushboo Vashi
2018-12-21 11:44:55 +00:00
|
|
|
expect(calledWithMessage).toContain('class="fa fa-exclamation-triangle text-danger"');
|
2017-06-30 09:23:12 +00:00
|
|
|
});
|
|
|
|
});
|
2018-05-04 15:56:15 +00:00
|
|
|
|
|
|
|
describe('pgRespErrorNotify', () => {
|
|
|
|
it('calls error notifier which alertifies response error for ajax calls', () => {
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
url: 'http://some/dummy/url',
|
|
|
|
dataType: 'json',
|
|
|
|
error: function(xhr, status, error) {
|
|
|
|
|
|
|
|
spyOn(alertify, 'orig_error').and.callThrough();
|
|
|
|
spyOn(alertify, 'notify').and.callThrough();
|
|
|
|
|
|
|
|
/*When connection lost*/
|
|
|
|
xhr.status = 0;
|
|
|
|
alertify.pgRespErrorNotify(xhr, error);
|
|
|
|
expect(alertify.orig_error).toHaveBeenCalled();
|
|
|
|
expect(alertify.orig_error.calls.mostRecent().args[0]).toContain(
|
|
|
|
gettext('Connection to the server has been lost.')
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
/*When some exception occurs at back end*/
|
|
|
|
xhr.status = 4;
|
|
|
|
var orig_getResponseHeader = xhr.getResponseHeader;
|
|
|
|
|
|
|
|
/*Exception handled by back end*/
|
|
|
|
xhr.getResponseHeader = (header) => {
|
|
|
|
if(header === 'Content-Type') {
|
|
|
|
return 'application/json';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return orig_getResponseHeader(header);
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
xhr.responseText = '{"errormsg":"Exception XYZ"}';
|
|
|
|
alertify.pgRespErrorNotify(xhr, error);
|
|
|
|
expect(alertify.orig_error).toHaveBeenCalled();
|
|
|
|
expect(alertify.orig_error.calls.mostRecent().args[0]).toContain(
|
|
|
|
gettext('Exception XYZ')
|
|
|
|
);
|
|
|
|
|
|
|
|
/*Exception not handled by back end*/
|
|
|
|
xhr.getResponseHeader = (header) => {
|
|
|
|
if(header === 'Content-Type') {
|
|
|
|
return 'text/html';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return orig_getResponseHeader(header);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
xhr.responseText = '<p>Some Exception Occurred</p>';
|
|
|
|
alertify.pgRespErrorNotify(xhr, error);
|
|
|
|
expect(alertify.notify).toHaveBeenCalled();
|
|
|
|
expect(alertify.notify.calls.mostRecent().args[0]).toContain(
|
|
|
|
gettext('INTERNAL SERVER ERROR')
|
|
|
|
);
|
|
|
|
|
|
|
|
/*With prefixMsg*/
|
|
|
|
xhr.getResponseHeader = (header) => {
|
|
|
|
if(header === 'Content-Type') {
|
|
|
|
return 'application/json';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return orig_getResponseHeader(header);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
xhr.responseText = '{"errormsg":"Exception XYZ"}';
|
|
|
|
alertify.pgRespErrorNotify(xhr, error, gettext('Some prefix message'));
|
|
|
|
expect(alertify.orig_error).toHaveBeenCalled();
|
|
|
|
expect(alertify.orig_error.calls.mostRecent().args[0]).toContain(
|
|
|
|
gettext('Some prefix message')
|
|
|
|
);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2017-06-30 09:23:12 +00:00
|
|
|
});
|