Update jQuery to 3.3.1. Fixes #3271

Patch by Aditya, with test enhancements from Anthony and Joao at Pivotal.
This commit is contained in:
Aditya Toshniwal 2018-05-25 16:26:37 +01:00 committed by Dave Page
parent 61d8072a8c
commit 9f13865777
32 changed files with 120 additions and 154 deletions

View File

@ -5,7 +5,7 @@ Library Version Licence URL
======= ======= ======= ===
QT 4.6.2+ LGPL v2.1/3 http://www.qt.io/
Bootstrap 3.3.4 MIT http://getbootstrap.com/
jQuery 1.11.1 MIT http://jquery.com/
jQuery 3.3.1 MIT http://jquery.com/
Modernizr 2.6.2 MIT/BSD http://modernizr.com/
AlertifyJS 1.7.1 MIT http://alertifyjs.com/ *** Do not update - changed to GPL3 in 1.8.0 ***
CodeMirror 5.14.2 MIT http://codemirror.net/

View File

@ -69,7 +69,7 @@
"immutability-helper": "^2.2.0",
"imports-loader": "^0.7.1",
"ip-address": "^5.8.9",
"jquery": "^1.12.4",
"jquery": "3.3.1",
"jquery-contextmenu": "^2.6.4",
"jquery-ui": "^1.12.1",
"moment": "^2.20.1",

View File

@ -287,7 +287,7 @@ define('pgadmin.node.column', [
var command = new Backgrid.Command({key: 'Tab', keyCode: 9, which: 9});
self.model.trigger('backgrid:edited', self.model, self.column,
command);
next_cell.focus();
next_cell.trigger('focus');
}
}, 20);
},

View File

@ -381,10 +381,10 @@ define(['sources/gettext', 'underscore', 'jquery', 'backbone', 'backform',
'header': true,
}));
}
self.$el.find('input[type=checkbox]').first().focus();
self.$el.find('input[type=checkbox]').first().trigger('focus');
// Since blur event does not bubble we need to explicitly call parent's blur event.
$(self.$el.find('input[type=checkbox]')).on('blur',function() {
self.$el.blur();
self.$el.trigger('blur');
});
// Make row visible in when entering in edit mode.

View File

@ -395,7 +395,7 @@ define([
// Add button callback
if (!(data.disabled || data.canAdd == false)) {
$gridBody.find('button.add').first().click(function(e) {
$gridBody.find('button.add').first().on('click',(e) => {
e.preventDefault();
var canAddRow = _.isFunction(data.canAddRow) ?
data.canAddRow.apply(self, [self.model]) : true;

View File

@ -1609,7 +1609,7 @@ define('pgadmin.browser', [
jsonResp = (
contentType &&
contentType.indexOf('application/json') == 0 &&
$.parseJSON(xhr.responseText)
JSON.parse(xhr.responseText)
) || {};
if (xhr.status == 410 && jsonResp.success == 0) {

View File

@ -142,18 +142,18 @@ _.extend(pgBrowser.keyboardNavigation, {
bindMainMenuUpDown: function(event, combo) {
// Handle Sub-menus
if (combo === 'up' && $(event.target).parent().prev().prev('.dropdown-submenu').length > 0) {
$(event.target).parent().prev().prev('.dropdown-submenu').find('a:first').focus();
$(event.target).parent().prev().prev('.dropdown-submenu').find('a:first').trigger('focus');
} else {
if ($(event.target).parent().hasClass('dropdown-submenu')) {
$(event.target).parent().parent().parent().find('a:first').dropdown('toggle');
$(event.target).parent().parent().children().eq(2).find('a:first').focus();
$(event.target).parent().parent().children().eq(2).find('a:first').trigger('focus');
}
}
},
bindLeftTree: function() {
const tree = this.getTreeDetails();
$('#tree').focus();
$('#tree').trigger('focus');
tree.t.focus(tree.i);
tree.t.select(tree.i);
},
@ -219,7 +219,7 @@ _.extend(pgBrowser.keyboardNavigation, {
const top = $(event.srcElement).find('.aciTreeEntry').position().top + 70;
tree.t.blur(tree.i);
$('#tree').blur();
$('#tree').trigger('blur');
// Call context menu and set position
tree.i.children().contextMenu({x: left, y: top});
},

View File

@ -95,10 +95,10 @@ define([
element.find('i').addClass('font-white');
element.find('i').removeClass('font-gray-4');
span.mouseover(function() {
span.on('mouseover',() => {
element.addClass('bg-gray-5');
});
span.mouseout(function() {
span.on('mouseout',() => {
element.removeClass('bg-gray-5');
});
},

View File

@ -734,7 +734,7 @@ define('pgadmin.browser.node', [
/* Error from the server */
if (jqx.status == 417 || jqx.status == 410 || jqx.status == 500) {
try {
var data = $.parseJSON(jqx.responseText);
var data = JSON.parse(jqx.responseText);
msg = data.errormsg;
} catch (e) {
console.warn(e.stack || e);
@ -1140,7 +1140,7 @@ define('pgadmin.browser.node', [
icon: 'fa fa-lg fa-pencil-square-o',
disabled: !that.canEdit,
register: function(btn) {
btn.click(function() {
btn.on('click',() => {
onEdit();
});
},
@ -1154,7 +1154,7 @@ define('pgadmin.browser.node', [
icon: 'fa fa-lg fa-info',
disabled: (that.sqlAlterHelp == '' && that.sqlCreateHelp == '') ? true : false,
register: function(btn) {
btn.click(function() {
btn.on('click',() => {
onSqlHelp();
});
},
@ -1359,7 +1359,7 @@ define('pgadmin.browser.node', [
icon: 'fa fa-lg fa-info',
disabled: (that.sqlAlterHelp == '' && that.sqlCreateHelp == '') ? true : false,
register: function(btn) {
btn.click(function() {
btn.on('click',() => {
onSqlHelp();
});
},
@ -1371,7 +1371,7 @@ define('pgadmin.browser.node', [
icon: 'fa fa-lg fa-question',
disabled: (that.dialogHelp == '') ? true : false,
register: function(btn) {
btn.click(function() {
btn.on('click',() => {
onDialogHelp();
});
},
@ -1384,7 +1384,7 @@ define('pgadmin.browser.node', [
disabled: true,
register: function(btn) {
// Save the changes
btn.click(function() {
btn.on('click',() => {
onSave.call(this, view, btn);
});
},
@ -1396,7 +1396,7 @@ define('pgadmin.browser.node', [
icon: 'fa fa-lg fa-close',
disabled: false,
register: function(btn) {
btn.click(function() {
btn.on('click',() => {
// Removing the action-mode
panel.$container.removeAttr('action-mode');
onCancelFunc.call(arguments);
@ -1410,7 +1410,7 @@ define('pgadmin.browser.node', [
icon: 'fa fa-lg fa-recycle',
disabled: true,
register: function(btn) {
btn.click(function() {
btn.on('click',() => {
setTimeout(function() {
editFunc.call();
}, 0);

View File

@ -63,9 +63,9 @@ define('pgadmin.dashboard', [
// This will refresh the grid
var refresh_grid = function() {
if (is_server_dashboard) {
$('#btn_server_activity_refresh').click();
$('#btn_server_activity_refresh').trigger('click');
} else if (is_database_dashboard) {
$('#btn_database_activity_refresh').click();
$('#btn_database_activity_refresh').trigger('click');
}
};
@ -139,7 +139,7 @@ define('pgadmin.dashboard', [
);
this.delegateEvents();
if (this.grabFocus)
this.$el.focus();
this.$el.trigger('focus');
return this;
},
});
@ -969,7 +969,7 @@ define('pgadmin.dashboard', [
});
// Handle button clicks
$('button').click(function() {
$('button').on('click',() => {
switch (this.id) {
case 'btn_server_activity_refresh':
pgAdmin.Dashboard.render_grid_data(div_server_activity);
@ -1290,7 +1290,7 @@ define('pgadmin.dashboard', [
});
// Handle button clicks
$('button').click(function() {
$('button').on('click',() => {
switch (this.id) {
case 'btn_database_activity_refresh':
pgAdmin.Dashboard.render_grid_data(div_database_activity);

View File

@ -574,7 +574,7 @@ define('misc.file_manager', [
$('.file_manager_ok').addClass('disabled');
$('.replace_file, .fm_dimmer').show();
$yesBtn.click(function() {
$yesBtn.on('click',() => {
$('.replace_file, .fm_dimmer').hide();
$yesBtn.off();
$noBtn.off();
@ -586,7 +586,7 @@ define('misc.file_manager', [
$('.file_manager_ok').removeClass('disabled');
});
$noBtn.click(function() {
$noBtn.on('click',() => {
$('.replace_file, .fm_dimmer').hide();
$yesBtn.off();
$noBtn.off();

View File

@ -133,13 +133,13 @@ define([
if (!has_capability(data, 'delete') || pgAdmin.FileUtils.hideButtons()) {
$('.file_manager').find('button.delete').hide();
} else {
$('.file_manager').find('button.delete').click(function() {
$('.file_manager').find('button.delete').on('click',() => {
// hide dimmer
$('.fileinfo .delete_item, .fm_dimmer').show();
});
// take action based on pressed button yes or no
$('.fileinfo .delete_item button.btn_yes').unbind().on('click', function() {
$('.fileinfo .delete_item button.btn_yes').off().on('click', function() {
var path;
if ($('.fileinfo').data('view') == 'grid') {
path = decodeURI($('.fileinfo').find('#contents li.selected .clip span').attr('data-alt'));
@ -168,7 +168,7 @@ define([
if (!has_capability(data, 'download') || pgAdmin.FileUtils.hideButtons()) {
$('.file_manager').find('button.download').hide();
} else {
$('.file_manager').find('button.download').unbind().click(function() {
$('.file_manager').find('button.download').off().on('click',() => {
var path;
if ($('.fileinfo').data('view') == 'grid') {
path = $('.fileinfo li.selected').find('.clip span').attr('data-alt');
@ -266,7 +266,7 @@ define([
data.Filename = newName;
// UnBind toolbar functions.
$('.fileinfo').find('button.rename, button.delete, button.download').unbind();
$('.fileinfo').find('button.rename, button.delete, button.download').off();
Alertify.success(lg.successful_rename);
} else {
@ -443,7 +443,7 @@ define([
}
// navigate to directory or path when clicked on breadcrumbs
$('.file_manager a.breadcrumbs').unbind().on('click', function() {
$('.file_manager a.breadcrumbs').off().on('click', function() {
var curr_path = $(this).attr('data-path'),
current_dir = $(this).html(),
move_to = curr_path.substring(
@ -669,7 +669,7 @@ define([
$('.fileinfo .file_listing').html(result);
// rename file/folder
$('.file_manager button.rename').unbind().on('click', function(e) {
$('.file_manager button.rename').off().on('click', function(e) {
if ($('.fileinfo').data('view') == 'grid') {
e.stopPropagation();
@ -681,11 +681,11 @@ define([
newvalue = decodeURI(orig_value);
}
$this.find('input').toggle().val(newvalue).focus();
$this.find('input').toggle().val(newvalue).trigger('focus');
$this.find('span').toggle();
// Rename folder/file on pressing enter key
$('.file_manager').unbind().on('keyup', function(e) {
$('.file_manager').off().on('keyup', function(e) {
if (e.keyCode == 13) {
e.stopPropagation();
$('.fileinfo #contents li.selected p').find(
@ -705,11 +705,11 @@ define([
newvalue = decodeURI(orig_value);
}
$this.find('input').toggle().val(newvalue).focus();
$this.find('input').toggle().val(newvalue).trigger('focus');
$this.find('span').toggle();
// Rename folder/file on pressing enter key
$('.file_manager').unbind().on('keyup', function(e) {
$('.file_manager').off().on('keyup', function(e) {
if (e.keyCode == 13) {
e.stopPropagation();
$('.fileinfo table#contents tr.selected td p').find(
@ -866,12 +866,12 @@ define([
} else {
var is_valid_file = getFileInfo(path);
if (is_valid_file && check_file_capability(e, data_cap, 'grid')) {
$('.file_manager_ok').click();
$('.file_manager_ok').trigger('click');
}
}
});
$('.fileinfo').find('#contents li').click(function(e) {
$('.fileinfo').find('#contents li').on('click',(e) => {
e.stopPropagation();
var path = decodeURI($(this).find('.clip span').attr('data-alt')),
is_protected = $(this).find(
@ -976,7 +976,7 @@ define([
if (
is_valid_file && check_file_capability(e, data_cap, 'table')
) {
$('.file_manager_ok').click();
$('.file_manager_ok').trigger('click');
}
}
});
@ -1131,7 +1131,7 @@ define([
// If user have preference to show hidden files
if (config.options.show_hidden_files) {
setTimeout(function() {
$('#show_hidden').click();
$('#show_hidden').trigger('click');
}, 10);
}
// handle show hidden files functionality
@ -1199,7 +1199,7 @@ define([
).on(
'click',
function(e) {
$('#uploader .filemanager-btn-group').unbind().on(
$('#uploader .filemanager-btn-group').off().on(
'click',
function() {
$('.fileinfo .delete_item, .fileinfo .replace_file, .fileinfo .fm_dimmer').hide();
@ -1221,7 +1221,7 @@ define([
});
// re-render the home view
$('.file_manager .home').click(function() {
$('.file_manager .home').on('click',() => {
var currentViewMode = $('.fileinfo').data('view');
$('.fileinfo').data('view', currentViewMode);
getFolderInfo('/');
@ -1229,7 +1229,7 @@ define([
});
// Go one directory back
$('.file_manager .level-up').click(function() {
$('.file_manager .level-up').on('click',() => {
var b = $('.currentpath').val();
// Enable/Disable level up button
enab_dis_level_up();
@ -1253,7 +1253,7 @@ define([
});
// set buttons to switch between grid and list views.
$('.file_manager .grid').click(function() {
$('.file_manager .grid').on('click',() => {
setViewButtonsFor('grid');
$('.fileinfo').data('view', 'grid');
enable_disable_btn();
@ -1262,7 +1262,7 @@ define([
});
// Show list mode
$('.file_manager .list').click(function() {
$('.file_manager .list').on('click',() => {
setViewButtonsFor('list');
$('.fileinfo').data('view', 'list');
enable_disable_btn();
@ -1387,7 +1387,7 @@ define([
$('.upload').remove();
$('.create').before('<button value="Upload" type="button" title="Upload File" name="upload" id="upload" class="btn fa fa-upload upload" tabindex="6"><span></span></button> ');
$('#uploader .upload').unbind().click(function() {
$('#uploader .upload').off().on('click',() => {
// we create prompt
var msg = '<div id="dropzone-container">' +
'<button class="fa fa-times dz_cross_btn" tabindex="7"></button>' +
@ -1443,7 +1443,7 @@ define([
acceptedFiles: acceptFiles,
autoProcessQueue: true,
init: function() {
$('.dz_cross_btn').unbind().on('click', function() {
$('.dz_cross_btn').off().on('click', function() {
$('.file_manager .upload_file').toggle();
});
},
@ -1533,7 +1533,7 @@ define([
$('.storage_dialog #uploader .input-path').attr('data-path', path);
// create new folder
$('.create').unbind().click(function() {
$('.create').off().on('click',() => {
var foldername = lg.new_folder;
var $file_element,
$file_element_list,

View File

@ -576,7 +576,7 @@ define('pgadmin.misc.explain', [
// Draw tooltip
var image_data = this.toJSON();
image.mouseover(function() {
image.on('mouseover',() => {
// Empty the tooltip content if it has any and add new data
toolTipContainer.empty();
@ -618,7 +618,7 @@ define('pgadmin.misc.explain', [
});
// Remove tooltip when mouse is out from node's area
image.mouseout(function() {
image.on('mouseout',() => {
toolTipContainer.empty();
toolTipContainer.css({
'opacity': '0',
@ -851,7 +851,7 @@ define('pgadmin.misc.explain', [
'height': h * curr_zoom_factor,
});
planDiv.data('zoom-factor', curr_zoom_factor);
zoomInBtn.blur();
zoomInBtn.trigger('blur');
});
zoomOutBtn.on('click', function() {
@ -867,7 +867,7 @@ define('pgadmin.misc.explain', [
'height': h * curr_zoom_factor,
});
planDiv.data('zoom-factor', curr_zoom_factor);
zoomOutBtn.blur();
zoomOutBtn.trigger('blur');
});
zoomToNormal.on('click', function() {
@ -883,7 +883,7 @@ define('pgadmin.misc.explain', [
'height': h * curr_zoom_factor,
});
planDiv.data('zoom-factor', curr_zoom_factor);
zoomToNormal.blur();
zoomToNormal.trigger('blur');
});
});

View File

@ -96,7 +96,7 @@ define([
if (contentType) {
try {
if (contentType.indexOf('application/json') == 0) {
var resp = $.parseJSON(msg);
var resp = JSON.parse(msg);
if (resp.result != null && (!resp.errormsg || resp.errormsg == '') &&
onJSONResult && typeof(onJSONResult) == 'function') {
@ -253,7 +253,7 @@ define([
var contentType = xhr.getResponseHeader('Content-Type'),
jsonResp = contentType &&
contentType.indexOf('application/json') == 0 &&
$.parseJSON(xhr.responseText);
JSON.parse(xhr.responseText);
if (
jsonResp && (

View File

@ -1081,7 +1081,7 @@ define([
// Add button callback
if (!(data.disabled || data.canAdd == false)) {
$dialog.find('button.add').first().click(function(e) {
$dialog.find('button.add').first().on('click',(e) => {
e.preventDefault();
var canAddRow = _.isFunction(data.canAddRow) ?
data.canAddRow.apply(self, [self.model]) : true;
@ -1361,7 +1361,7 @@ define([
var $dialog = gridBody.append(subNodeGrid);
// Add button callback
$dialog.find('button.add').click(function(e) {
$dialog.find('button.add').on('click',(e) => {
e.preventDefault();
var canAddRow = _.isFunction(data.canAddRow) ?
data.canAddRow.apply(self, [self.model]) : true;
@ -1379,7 +1379,7 @@ define([
grid.insertRow({});
var newRow = $(grid.body.rows[collection.length - 1].$el);
newRow.attr('class', 'new').click(function() {
newRow.attr('class', 'new').on('click',() => {
$(this).attr('class', 'editable');
});
$(newRow).pgMakeVisible('backform-tab');
@ -2367,7 +2367,7 @@ define([
if (widget) {
setTimeout(function() {
picker.toggle();
self.$el.find('input').first().blur();
self.$el.find('input').first().trigger('blur');
}, 10);
} else {
setTimeout(function() {
@ -2380,7 +2380,7 @@ define([
// blur the input
setTimeout(
function() {
self.$el.find('input').first().blur();
self.$el.find('input').first().trigger('blur');
}, 10
);
}
@ -2390,7 +2390,7 @@ define([
var picker = this;
setTimeout(function() {
picker.toggle();
self.$el.find('input').first().blur();
self.$el.find('input').first().trigger('blur');
}, 10);
}
},

View File

@ -348,7 +348,7 @@ define([
this.$el.html('<i class=\'fa fa-pencil-square-o\' title=\'' + _('Edit row') + '\'></i>');
this.delegateEvents();
if (this.grabFocus)
this.$el.focus();
this.$el.trigger('focus');
return this;
},
exitEditMode: function() {
@ -465,7 +465,7 @@ define([
enterEditMode: function() {
this.$el.addClass('editor');
$(this.$el.find('input')).focus();
$(this.$el.find('input')).trigger('focus');
},
exitEditMode: function() {
@ -537,7 +537,7 @@ define([
});
self.model.trigger('backgrid:edited', self.model,
self.column, command);
gotoCell.focus();
gotoCell.trigger('focus');
}
}, 20);
}

View File

@ -84,7 +84,7 @@ function keyboardShortcutsDebugger($el, event, user_defined_shortcuts) {
if(panel_content.length) {
$input = $(panel_content).find('td.editable:first');
if($input.length)
$input.click();
$input.trigger('click');
}
} else if(this.validateShortcutKeys(next_panel_keys, event)) {
this._stopEventPropagation(event);

View File

@ -755,7 +755,7 @@ commonUtils
},
error: function(xhr) {
try {
var err = $.parseJSON(xhr.responseText);
var err = JSON.parse(xhr.responseText);
alertify.alert(
gettext('Backup job failed.'),
err.errormsg
@ -1041,7 +1041,7 @@ commonUtils
},
error: function(xhr) {
try {
var err = $.parseJSON(xhr.responseText);
var err = JSON.parse(xhr.responseText);
alertify.alert(
gettext('Backup job failed.'),
err.errormsg

View File

@ -473,7 +473,7 @@ define('pgadmin.datagrid', [
}
try {
var err = $.parseJSON(xhr.responseText);
var err = JSON.parse(xhr.responseText);
alertify.alert(gettext('Query Tool Initialize Error'),
err.errormsg
);

View File

@ -222,7 +222,7 @@
</div>
<div class="btn-group" role="group" aria-label="">
<button id="btn-flash" type="button" class="btn btn-default" style="width: 40px;"
<button id="btn-flash" data-test-selector="execute-refresh-button" type="button" class="btn btn-default" style="width: 40px;"
title="{{ _('Execute/Refresh') }}{{ _(' ({0})'.format(get_shortcut_text(shortcuts.execute_query))) }}"
tabindex="0">
<i class="fa fa-bolt" aria-hidden="true"></i>

View File

@ -295,7 +295,7 @@ define([
},
error: function(xhr) {
try {
var err = $.parseJSON(xhr.responseText);
var err = JSON.parse(xhr.responseText);
if (err.success == 0) {
Alertify.alert(gettext('Debugger Error'), err.errormsg);
}
@ -415,7 +415,7 @@ define([
},
error: function(xhr) {
try {
var err = $.parseJSON(xhr.responseText);
var err = JSON.parse(xhr.responseText);
if (err.success == 0) {
Alertify.alert(gettext('Debugger Error'), err.errormsg);
}
@ -538,7 +538,7 @@ define([
},
error: function(xhr) {
try {
var err = $.parseJSON(xhr.responseText);
var err = JSON.parse(xhr.responseText);
if (err.success == 0) {
Alertify.alert(gettext('Debugger Error'), err.errormsg);
}

View File

@ -531,7 +531,7 @@ define([
var grid_checkbox = $(grid.el).find('input:checkbox').first();
if (grid_checkbox.length) {
setTimeout(function() {
grid_checkbox.click();
grid_checkbox.trigger('click');
}, 250);
}

View File

@ -690,7 +690,7 @@ define([
},
error: function(xhr) {
try {
var err = $.parseJSON(xhr.responseText);
var err = JSON.parse(xhr.responseText);
if (err.success == 0) {
Alertify.alert(gettext('Debugger Error'), err.errormsg);
}

View File

@ -218,7 +218,6 @@ define([
// Generate wizard main container
var $container = $('<div class=\'wizard_dlg\'></div>');
return {
main: function(title) {
this.set('title', title);
@ -442,7 +441,7 @@ define([
'did': encodeURI(did),
}
),
dataType: 'jsonp',
dataType: 'json',
});
},

View File

@ -549,7 +549,7 @@ Backform, commonUtils
},
error: function(xhr) {
try {
var err = $.parseJSON(xhr.responseText);
var err = JSON.parse(xhr.responseText);
Alertify.alert(
gettext('Import/export job failed.'),
err.errormsg

View File

@ -686,7 +686,7 @@ commonUtils
},
error: function(xhr) {
try {
var err = $.parseJSON(xhr.responseText);
var err = JSON.parse(xhr.responseText);
alertify.alert(
gettext('Restore failed.'),
err.errormsg

View File

@ -812,12 +812,12 @@ define([
userCollection.fetch();
this.$content.find('a.close-error').click(function() {
this.$content.find('a.close-error').on('click',() => {
$statusBar.find('.alert-text').empty();
$statusBar.css('visibility', 'hidden');
});
this.$content.find('button.add').first().click(function(e) {
this.$content.find('button.add').first().on('click',(e) => {
e.preventDefault();
var canAddRow = true;

View File

@ -273,7 +273,7 @@ describe('ColumnSelector', function () {
describe('when the column is not selectable', function () {
it('does not select the column', function () {
$(container.find('.slick-header-column:contains(some-non-selectable-column)')).click();
$(container.find('.slick-header-column:contains(some-non-selectable-column)')).trigger('click');
var selectedRanges = cellSelectionModel.getSelectedRanges();
expect(selectedRanges.length).toEqual(0);

View File

@ -68,7 +68,7 @@ describe('GridSelector', function () {
describe('when the cell for the select/deselect all is clicked', function () {
it('selects the whole grid', function () {
container.find('[title=\'Select/Deselect All\']').parent().click();
container.find('[title=\'Select/Deselect All\']').parent().trigger('click');
var selectedRanges = xCellSelectionModel.getSelectedRanges();
expect(selectedRanges.length).toBe(1);
@ -80,7 +80,7 @@ describe('GridSelector', function () {
});
it('adds selected class', function () {
container.find('[title=\'Select/Deselect All\']').parent().click();
container.find('[title=\'Select/Deselect All\']').parent().trigger('click');
expect($(container.find('[data-id=\'select-all\']')).hasClass('selected')).toBeTruthy();
});
@ -89,7 +89,7 @@ describe('GridSelector', function () {
describe('when the select all button in the corner gets selected', function () {
it('selects all the cells', function () {
container.find('[title=\'Select/Deselect All\']').click();
container.find('[title=\'Select/Deselect All\']').trigger('click');
var selectedRanges = xCellSelectionModel.getSelectedRanges();
expect(selectedRanges.length).toBe(1);
@ -102,11 +102,11 @@ describe('GridSelector', function () {
describe('when the select all button in the corner gets deselected', function () {
beforeEach(function () {
container.find('[title=\'Select/Deselect All\']').click();
container.find('[title=\'Select/Deselect All\']').trigger('click');
});
it('deselects all the cells', function () {
container.find('[title=\'Select/Deselect All\']').click();
container.find('[title=\'Select/Deselect All\']').trigger('click');
var selectedRanges = xCellSelectionModel.getSelectedRanges();
expect(selectedRanges.length).toBe(0);
@ -115,11 +115,11 @@ describe('GridSelector', function () {
describe('and then the underlying selection changes', function () {
beforeEach(function () {
container.find('[title=\'Select/Deselect All\']').click();
container.find('[title=\'Select/Deselect All\']').trigger('click');
});
it('removes the selected class', function () {
container.find('[title=\'Select/Deselect All\']').parent().click();
container.find('[title=\'Select/Deselect All\']').parent().trigger('click');
expect($(container.find('[data-id=\'select-all\']')).hasClass('selected')).toBeFalsy();
});

View File

@ -54,7 +54,7 @@ describe('CellSelector', function () {
describe('when the user clicks or tabs to a cell', function () {
it('sets the selected range to that cell', function () {
var row = 1, column = 0;
$(container.find('.slick-row .slick-cell.l' + column)[row]).click();
$(container.find('.slick-row .slick-cell.l' + column)[row]).trigger('click');
var selectedRanges = cellSelectionModel.getSelectedRanges();
expect(selectedRanges.length).toBe(1);
@ -71,7 +71,7 @@ describe('CellSelector', function () {
cellSelectionModel.setSelectedRanges(ranges);
var row = 4, column = 1;
$(container.find('.slick-row .slick-cell.l' + column)[row]).click();
$(container.find('.slick-row .slick-cell.l' + column)[row]).trigger('click');
expect(RangeSelectionHelper.isRangeSelected(cellSelectionModel.getSelectedRanges(), row2Range))
.toBe(false);

View File

@ -25,7 +25,7 @@ describe('ExecuteQuery', () => {
const startTime = new Date(2018, 1, 29, 12, 15, 52);
beforeEach(() => {
networkMock = new MockAdapter(axios);
jasmine.addMatchers({jQuerytoHaveBeenCalledWith: jQuerytoHaveBeenCalledWith});
// jasmine.addMatchers({jQuerytoHaveBeenCalledWith: jQuerytoHaveBeenCalledWith});
userManagementMock = jasmine.createSpyObj('UserManagement', [
'isPgaLoginRequired',
'pgaLogin',
@ -1074,15 +1074,24 @@ describe('ExecuteQuery', () => {
context('when the SQL statement is not empty', () => {
let pollSpy;
let jqueryPropSpy;
beforeEach(() => {
jqueryPropSpy = spyOn($.fn, 'prop');
sqlEditorMock.gridView = {};
sqlEditorMock.gridView.query_tool_obj = jasmine.createSpyObj(
'QueryToolObject',
['removeLineClass']
);
$('body').append(
'<div id="test-id">' +
'<button id="btn-flash" disabled></button>' +
'<button id="btn-cancel-query"></button>' +
'</div>'
);
});
afterEach(function () {
$('body').remove('#test-id');
});
describe('before the backend request', () => {
@ -1108,15 +1117,15 @@ describe('ExecuteQuery', () => {
});
it('disables the run query button', () => {
const callToProp = findJQueryCallWithSelector(jqueryPropSpy, '#btn-flash');
let buttonFlash = $('#btn-flash');
expect(callToProp).jQuerytoHaveBeenCalledWith('disabled', true);
expect(buttonFlash.prop('disabled')).toEqual(true);
});
it('enable the cancel query button', () => {
const callToProp = findJQueryCallWithSelector(jqueryPropSpy, '#btn-cancel-query');
let buttonFlash = $('#btn-cancel-query');
expect(callToProp).jQuerytoHaveBeenCalledWith('disabled', false);
expect(buttonFlash.prop('disabled')).toEqual(false);
});
it('disable the query tool buttons', () => {
@ -1235,9 +1244,9 @@ describe('ExecuteQuery', () => {
it('disable the cancel query button', (done) => {
setTimeout(() => {
const callToProp = findJQueryCallWithSelector(jqueryPropSpy, '#btn-cancel-query');
let buttonFlash = $('#btn-cancel-query');
expect(callToProp).jQuerytoHaveBeenCalledWith('disabled', true);
expect(buttonFlash.prop('disabled')).toEqual(true);
done();
}, 0);
});
@ -1355,9 +1364,9 @@ describe('ExecuteQuery', () => {
it('should disable the cancel button', (done) => {
setTimeout(
() => {
const callToProp = findJQueryCallWithSelector(jqueryPropSpy, '#btn-cancel-query');
let buttonFlash = $('#btn-cancel-query');
expect(callToProp).jQuerytoHaveBeenCalledWith('disabled', true);
expect(buttonFlash.prop('disabled')).toEqual(true);
done();
}, 0);
});
@ -1413,9 +1422,9 @@ describe('ExecuteQuery', () => {
it('should disable the cancel button', (done) => {
setTimeout(
() => {
const callToProp = findJQueryCallWithSelector(jqueryPropSpy, '#btn-cancel-query');
let buttonFlash = $('#btn-cancel-query');
expect(callToProp).jQuerytoHaveBeenCalledWith('disabled', true);
expect(buttonFlash.prop('disabled')).toEqual(true);
done();
}, 0);
});
@ -1481,9 +1490,9 @@ describe('ExecuteQuery', () => {
it('should disable the cancel button', (done) => {
setTimeout(
() => {
const callToProp = findJQueryCallWithSelector(jqueryPropSpy, '#btn-cancel-query');
let buttonFlash = $('#btn-cancel-query');
expect(callToProp).jQuerytoHaveBeenCalledWith('disabled', true);
expect(buttonFlash.prop('disabled')).toEqual(true);
done();
}, 0);
});
@ -1552,9 +1561,9 @@ describe('ExecuteQuery', () => {
it('should disable the cancel button', (done) => {
setTimeout(
() => {
const callToProp = findJQueryCallWithSelector(jqueryPropSpy, '#btn-cancel-query');
let buttonFlash = $('#btn-cancel-query');
expect(callToProp).jQuerytoHaveBeenCalledWith('disabled', true);
expect(buttonFlash.prop('disabled')).toEqual(true);
done();
}, 0);
});
@ -1626,9 +1635,9 @@ describe('ExecuteQuery', () => {
it('should disable the cancel button', (done) => {
setTimeout(
() => {
const callToProp = findJQueryCallWithSelector(jqueryPropSpy, '#btn-cancel-query');
let buttonFlash = $('#btn-cancel-query');
expect(callToProp).jQuerytoHaveBeenCalledWith('disabled', true);
expect(buttonFlash.prop('disabled')).toEqual(true);
done();
}, 0);
});
@ -1682,43 +1691,5 @@ describe('ExecuteQuery', () => {
});
});
let findJQueryCallWithSelector = (jquerySpy, selector) => {
let result = undefined;
jquerySpy.calls.all().forEach((call) => {
if (call.object.selector === selector) {
result = call;
}
});
return result;
};
});
const jQuerytoHaveBeenCalledWith = function (util) {
return {
compare: function (actual) {
let result = {};
let expectedArgs = jasmine.util.argsToArray(arguments).slice(1);
if (actual.object === undefined || actual.object.selector === undefined) {
throw new Error('Expected a JQuery object, but got ' + jasmine.pp(actual) + '.');
}
result.pass = util.equals(actual.args, expectedArgs, '');
if (result.pass) {
result.message = 'larifo';
} else {
result.message =
'Expected jquery with selector "' +
actual.object.selector +
'" to have been called with ' +
jasmine.pp(expectedArgs) +
' but was called with ' +
jasmine.pp(actual.args);
}
return result;
},
};
};

View File

@ -5327,14 +5327,10 @@ jquery-ui@>=1.8.0, jquery-ui@^1.12.1:
version "1.12.1"
resolved "https://registry.yarnpkg.com/jquery-ui/-/jquery-ui-1.12.1.tgz#bcb4045c8dd0539c134bc1488cdd3e768a7a9e51"
"jquery@>=1.7.1 <4.0.0", jquery@>=1.8.0, "jquery@^1.8.3 || ^2.0 || ^3.0", jquery@^3.3.1:
jquery@3.3.1, "jquery@>=1.7.1 <4.0.0", jquery@>=1.8.0, "jquery@^1.8.3 || ^2.0 || ^3.0", jquery@^3.3.1:
version "3.3.1"
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.3.1.tgz#958ce29e81c9790f31be7792df5d4d95fc57fbca"
jquery@^1.12.4:
version "1.12.4"
resolved "https://registry.yarnpkg.com/jquery/-/jquery-1.12.4.tgz#01e1dfba290fe73deba77ceeacb0f9ba2fec9e0c"
js-base64@^2.1.8, js-base64@^2.1.9:
version "2.4.3"
resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-2.4.3.tgz#2e545ec2b0f2957f41356510205214e98fad6582"