mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fixed Security Hotspot reported by SonarQube.
This commit is contained in:
committed by
Akshay Joshi
parent
084203debc
commit
7bd0d55c83
@@ -13,7 +13,7 @@ describe('generate_url', () => {
|
||||
describe('in collection', () => {
|
||||
let baseUrl, treeInfo, actionType, nodeType, pickFunction;
|
||||
beforeEach(() => {
|
||||
baseUrl = 'http://base/and-extension/';
|
||||
baseUrl = 'https://base/and-extension/';
|
||||
treeInfo = {
|
||||
treeNode1: {
|
||||
_id: 'an_id',
|
||||
@@ -29,7 +29,7 @@ describe('generate_url', () => {
|
||||
it('returns a correctly formatted URL', () => {
|
||||
let formattedUrl = generate_url(baseUrl, treeInfo, actionType, nodeType, pickFunction);
|
||||
|
||||
expect(formattedUrl).toEqual('http://base/and-extension/nodeType/actionType/an_id/');
|
||||
expect(formattedUrl).toEqual('https://base/and-extension/nodeType/actionType/an_id/');
|
||||
});
|
||||
|
||||
describe('given there are multiple treeInfoItems', () => {
|
||||
@@ -51,14 +51,14 @@ describe('generate_url', () => {
|
||||
it('chooses the correct treeInfo', () => {
|
||||
let formattedUrl = generate_url(baseUrl, treeInfo, actionType, nodeType, pickFunction);
|
||||
|
||||
expect(formattedUrl).toEqual('http://base/and-extension/nodeType/actionType/a_third_id/an_id/');
|
||||
expect(formattedUrl).toEqual('https://base/and-extension/nodeType/actionType/a_third_id/an_id/');
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('in node', () => {
|
||||
let baseUrl, treeInfo, actionType, nodeType, pickFunction, itemDataID;
|
||||
beforeEach(() => {
|
||||
baseUrl = 'http://base/and-extension/';
|
||||
baseUrl = 'https://base/and-extension/';
|
||||
treeInfo = {
|
||||
treeNode1: {
|
||||
_id: 'an_id',
|
||||
@@ -75,7 +75,7 @@ describe('generate_url', () => {
|
||||
it('returns a correctly formatted URL', () => {
|
||||
let formattedUrl = generate_url(baseUrl, treeInfo, actionType, nodeType, pickFunction, itemDataID);
|
||||
|
||||
expect(formattedUrl).toEqual('http://base/and-extension/nodeType/actionType/an_id/item1');
|
||||
expect(formattedUrl).toEqual('https://base/and-extension/nodeType/actionType/an_id/item1');
|
||||
});
|
||||
|
||||
describe('given there are multiple treeInfoItems', () => {
|
||||
@@ -97,7 +97,7 @@ describe('generate_url', () => {
|
||||
it('chooses the correct treeInfo', () => {
|
||||
let formattedUrl = generate_url(baseUrl, treeInfo, actionType, nodeType, pickFunction, itemDataID);
|
||||
|
||||
expect(formattedUrl).toEqual('http://base/and-extension/nodeType/actionType/another_id/an_id/item1');
|
||||
expect(formattedUrl).toEqual('https://base/and-extension/nodeType/actionType/another_id/an_id/item1');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,106 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgAdmin 4 - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2013 - 2022, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
import StatisticsModel from '../../../../pgadmin/misc/static/explain/js/explain_statistics';
|
||||
import $ from 'jquery';
|
||||
|
||||
describe('ExplainStatistics', () => {
|
||||
let statsModel;
|
||||
let statsDiv;
|
||||
let tooltipContainer;
|
||||
|
||||
beforeEach(function() {
|
||||
statsModel = new StatisticsModel();
|
||||
statsDiv = '<div class="pg-explain-stats-area btn-group d-none"></div>';
|
||||
tooltipContainer = $(
|
||||
`<div class="pgadmin-explain-details d-none">
|
||||
<div class="details-header">
|
||||
<div class="details-title"></div>
|
||||
</div>
|
||||
<div class="details-body"></div>
|
||||
</div>`
|
||||
);
|
||||
});
|
||||
|
||||
describe('No Statistics', () => {
|
||||
it('Statistics button should be hidden', () => {
|
||||
$('body').append(statsDiv);
|
||||
|
||||
statsModel.set('JIT', []);
|
||||
statsModel.set('Triggers', []);
|
||||
statsModel.set('Summary', {});
|
||||
statsModel.set_statistics(tooltipContainer);
|
||||
|
||||
expect($('.pg-explain-stats-area').hasClass('d-none')).toEqual(true);
|
||||
});
|
||||
});
|
||||
|
||||
let mouseClickAction = ()=> {
|
||||
// Trigger mouse over event
|
||||
var clickEvent = new $.Event('click');
|
||||
$('.pg-explain-stats-area').trigger(clickEvent);
|
||||
|
||||
expect(tooltipContainer.hasClass('d-none')).toBe(false);
|
||||
};
|
||||
|
||||
describe('JIT Statistics', () => {
|
||||
beforeEach(function() {
|
||||
$('body').append(statsDiv);
|
||||
statsModel.set('JIT', [{'cost': '100'}]);
|
||||
statsModel.set('Triggers', []);
|
||||
statsModel.set_statistics(tooltipContainer);
|
||||
});
|
||||
|
||||
it('Statistics button should be visible', () => {
|
||||
expect($('.pg-explain-stats-area').hasClass('d-none')).toEqual(false);
|
||||
});
|
||||
|
||||
it('Mouse click event should be trigger', () => {
|
||||
mouseClickAction();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Triggers Statistics', () => {
|
||||
beforeEach(function() {
|
||||
$('body').append(statsDiv);
|
||||
statsModel.set('JIT', []);
|
||||
statsModel.set('Triggers', [{'name': 'test_trigger'}]);
|
||||
statsModel.set_statistics(tooltipContainer);
|
||||
});
|
||||
|
||||
it('Statistics button should be visible', () => {
|
||||
expect($('.pg-explain-stats-area').hasClass('d-none')).toEqual(false);
|
||||
});
|
||||
|
||||
it('Mouse click event should be trigger', () => {
|
||||
mouseClickAction();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Summary', () => {
|
||||
beforeEach(function() {
|
||||
$('body').append(statsDiv);
|
||||
statsModel.set('JIT', []);
|
||||
statsModel.set('Triggers', []);
|
||||
statsModel.set('Summary', {
|
||||
'Planning Time': 0.12,
|
||||
'Execution Time': 2.34,
|
||||
});
|
||||
statsModel.set_statistics(tooltipContainer);
|
||||
});
|
||||
|
||||
it('Statistics button should be visible', () => {
|
||||
expect($('.pg-explain-stats-area').hasClass('d-none')).toEqual(false);
|
||||
});
|
||||
|
||||
it('Mouse click event should be trigger', () => {
|
||||
mouseClickAction();
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user